:root {
  --color-primary: #FF7A1A;
  --color-primary-dark: #E4650A;
  --color-secondary: #2E7D32;
  --color-secondary-light: #66BB6A;
  --color-bg: #FFF9F2;
  --color-surface: #FFFFFF;
  --color-text: #2B2B2B;
  --color-text-muted: #6B6B6B;
  --color-border: #F0DFC8;
  --radius: 20px;
  --shadow-card: 0 4px 16px rgba(43, 43, 43, 0.08);
  --shadow-card-hover: 0 8px 24px rgba(43, 43, 43, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Sarabun', sans-serif;
  background: var(--color-bg);
  background-image:
    linear-gradient(rgba(255, 122, 26, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 122, 26, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--color-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-display {
  font-family: 'Kanit', sans-serif;
  margin: 0;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  padding: 24px 20px 32px;
  animation: fadeIn 0.25s ease;
}

.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: linear-gradient(135deg, var(--color-primary) 0%, #FF9A4D 100%);
  color: white;
}

.app-header img { width: 40px; height: 40px; border-radius: 10px; }
.app-header .title { font-size: 18px; font-weight: 600; line-height: 1.3; }
.app-header .subtitle { font-size: 13px; opacity: 0.9; }
.app-header .credit-line { font-size: 10px; opacity: 0.7; margin-top: 2px; }

.back-button {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  border-radius: 999px;
  color: white;
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 14px;
  margin-right: -4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.back-button:hover { background: rgba(255, 255, 255, 0.28); }

/* ---------- Branch select ---------- */
.branch-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.branch-card {
  background: var(--color-surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.branch-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--color-primary);
}

.branch-name { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 16px; }
.branch-tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--color-secondary-light);
  color: white;
}
.branch-tag.soon { background: #D9D9D9; color: #666; }
.branch-tag.preview { background: #7C4DFF; color: white; }

.branch-card.preview {
  border-color: #7C4DFF;
  border-style: dashed;
}

.page-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { color: var(--color-text-muted); font-size: 14px; margin-bottom: 8px; }

/* ---------- Home ---------- */
.home-hero {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  margin-top: 8px;
  text-align: center;
}

.home-hero .branch-emoji { font-size: 40px; }
.home-hero h2 { font-size: 20px; margin-top: 8px; }
.home-hero p { color: var(--color-text-muted); font-size: 14px; margin-top: 4px; }

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
}

.menu-button {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  text-align: left;
  font-family: 'Sarabun', sans-serif;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.menu-button:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }

.menu-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.menu-icon.orange { background: #FFE7D1; }
.menu-icon.green { background: #DCF2DD; }

.menu-text .menu-title { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 15px; }
.menu-text .menu-desc { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }

.change-branch-link {
  margin-top: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Category list ---------- */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.category-card {
  background: var(--color-surface);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.category-card:hover { transform: translateX(3px); }
.category-card .cat-name { font-size: 14px; font-weight: 500; }
.category-card .cat-count { font-size: 12px; color: var(--color-text-muted); }
.category-card .cat-arrow { color: var(--color-primary); font-size: 18px; }

/* ---------- Question card ---------- */
.progress-bar-track {
  height: 6px;
  background: #EFE2CE;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 20px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  transition: width 0.3s ease;
}

.question-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow-card);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.question-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.question-text {
  font-size: 17px;
  line-height: 1.6;
  font-weight: 500;
  margin-bottom: 20px;
}

.answer-section {
  border-top: 1px dashed var(--color-border);
  padding-top: 16px;
  display: none;
  animation: fadeIn 0.2s ease;
}
.answer-section.visible { display: block; }

.answer-label { font-size: 12px; font-weight: 600; color: var(--color-secondary); margin-bottom: 6px; }
.answer-text { font-size: 15px; line-height: 1.6; font-weight: 500; margin-bottom: 14px; }
.explanation-label { font-size: 12px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 6px; }
.explanation-text { font-size: 14px; line-height: 1.65; color: var(--color-text-muted); }

.spacer { flex: 1; }

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary { background: #EFE2CE; color: var(--color-text); }
.btn-secondary:hover { background: #E6D3B5; }

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-border);
  color: var(--color-text-muted);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}
.empty-state .emoji { font-size: 40px; margin-bottom: 8px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2B2B2B;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}
.toast.show { opacity: 1; }

.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
