:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #38bdf8;
  --accent-hover: #0284c7;
  --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #334155;
  --radius: 14px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

.light-theme {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App Container */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 1rem;
  width: 100%;
}

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

/* Header */
header.app-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-primary);
}

.header-brand h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-code {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-family: monospace;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--border);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: all 0.25s ease;
}

/* Question List Item */
.q-card {
  display: flex;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.q-card.pinned {
  border-left: 4px solid var(--accent);
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.06) 0%, var(--bg-card) 100%);
}

.q-card.answered {
  opacity: 0.65;
}

.q-card.answered .q-content {
  text-decoration: line-through;
  color: var(--text-muted);
}

.q-vote-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 54px;
}

.vote-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 52px;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.vote-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

.vote-btn.voted {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.vote-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.vote-count {
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 2px;
}

.q-body {
  flex: 1;
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.q-author {
  font-weight: 600;
  color: var(--text-secondary);
}

.q-content {
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text-primary);
  word-break: break-word;
}

.q-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-weight: 600;
}

.q-badge-pin {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
}

.q-badge-answered {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  background-color: var(--bg-secondary);
  border-radius: 12px;
  padding: 0.25rem;
  margin-bottom: 1.2rem;
  gap: 0.25rem;
  border: 1px solid var(--border);
}

.nav-tab {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.nav-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
}

.tab-badge {
  position: absolute;
  top: 4px;
  right: 12px;
  width: 8px;
  height: 8px;
  background-color: var(--danger);
  border-radius: 50%;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* Poll View */
.poll-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.poll-option-item {
  position: relative;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.8rem;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s ease;
}

.poll-option-item:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.poll-option-item.selected {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.15);
}

.poll-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: rgba(56, 189, 248, 0.25);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.poll-option-content {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--border);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 30px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: fadeInOut 2.5s forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(20px); }
  15% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-20px); }
}

/* Projector Wall Styles */
.wall-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2rem 3rem;
  background: radial-gradient(circle at top right, #1e293b 0%, #090d16 100%);
}

.wall-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

.wall-title-area h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.wall-qr-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.75rem 1.25rem;
  border-radius: 16px;
  backdrop-filter: blur(10px);
}

.wall-qr-img {
  width: 90px;
  height: 90px;
  background: #fff;
  padding: 4px;
  border-radius: 8px;
}

.wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1.5rem;
  align-content: start;
}

.wall-q-card {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 160px;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.wall-q-card.pinned {
  border: 2px solid var(--accent);
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.3);
}

.wall-q-card.answered {
  opacity: 0.55;
  background: rgba(15, 23, 42, 0.6);
  border: 1px dashed rgba(16, 185, 129, 0.4);
}

.wall-q-card.answered .wall-q-content {
  color: var(--text-muted);
}

.wall-q-content {
  font-size: 1.45rem;
  line-height: 1.45;
  font-weight: 500;
  margin-bottom: 1rem;
}

.wall-q-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.8rem;
}

.wall-vote-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
  font-weight: 800;
  font-size: 1.2rem;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
}

/* Big QR Code Modal */
.qr-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.qr-modal.active {
  display: flex;
}

.qr-modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.2rem 2rem;
  text-align: center;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  animation: modalSlide 0.2s ease;
}

.qr-modal-img {
  width: 250px;
  height: 250px;
  border-radius: 14px;
  background: #ffffff;
  padding: 10px;
  margin: 1.2rem auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  display: block;
}
