/* ========================================================================
   Cambodia Postal Code Directory
   Design System: Linear-inspired dark-first, bilingual
   See DESIGN.md for full spec
   ======================================================================== */

/* ------------------------------------------------------------------------
   1. Design Tokens
   ------------------------------------------------------------------------ */

:root,
[data-theme="dark"] {
  /* Surfaces */
  --canvas: #08090a;
  --panel: #0f1011;
  --surface: #191a1b;
  --surface-high: #28282c;

  /* Translucent layer backgrounds */
  --bg-subtle: rgba(255, 255, 255, 0.02);
  --bg-soft: rgba(255, 255, 255, 0.04);
  --bg-medium: rgba(255, 255, 255, 0.06);
  --bg-strong: rgba(255, 255, 255, 0.08);

  /* Text */
  --text: #f7f8f8;
  --text-secondary: #d0d6e0;
  --text-tertiary: #8a8f98;
  --text-quaternary: #62666d;
  --text-inverse: #08090a;

  /* Borders (semi-transparent white) */
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --divider: rgba(255, 255, 255, 0.06);

  /* Brand */
  --brand: #5e6ad2;
  --brand-hover: #828fff;
  --accent: #7170ff;
  --accent-tint: rgba(113, 112, 255, 0.10);
  --accent-ring: rgba(113, 112, 255, 0.15);
  --accent-border: rgba(113, 112, 255, 0.55);

  /* Semantic location */
  --province: #a78bfa;
  --district: #22d3ee;
  --commune: #4ade80;
  --province-tint: rgba(167, 139, 250, 0.12);
  --district-tint: rgba(34, 211, 238, 0.12);
  --commune-tint: rgba(74, 222, 128, 0.12);

  /* Status */
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;

  /* Shadows — luminance stepping + multi-layer for popovers */
  --shadow-popover:
    rgba(0, 0, 0, 0.40) 0 2px 4px,
    rgba(0, 0, 0, 0.30) 0 8px 24px,
    rgba(255, 255, 255, 0.08) 0 0 0 1px;
  --shadow-focus:
    0 0 0 3px rgba(113, 112, 255, 0.15),
    0 0 0 1px rgba(113, 112, 255, 0.55);
  --shadow-inset: rgba(0, 0, 0, 0.2) 0 0 12px 0 inset;

  /* Radius */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  /* Typography */
  --font-sans: 'Inter', 'Noto Sans Khmer', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  --font-khmer: 'Noto Sans Khmer', 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;

  /* Layout */
  --container-width: 720px;
  --container-wide: 1120px;
  --container-padding: 24px;
}

[data-theme="light"] {
  --canvas: #f7f8f8;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-high: #f3f4f5;

  --bg-subtle: rgba(8, 9, 10, 0.02);
  --bg-soft: rgba(8, 9, 10, 0.04);
  --bg-medium: rgba(8, 9, 10, 0.06);
  --bg-strong: rgba(8, 9, 10, 0.08);

  --text: #08090a;
  --text-secondary: #3c4149;
  --text-tertiary: #6b7280;
  --text-quaternary: #9ca3af;
  --text-inverse: #ffffff;

  --border-subtle: rgba(8, 9, 10, 0.06);
  --border: rgba(8, 9, 10, 0.10);
  --border-strong: rgba(8, 9, 10, 0.14);
  --divider: rgba(8, 9, 10, 0.08);

  --province: #7c3aed;
  --district: #0891b2;
  --commune: #16a34a;
  --province-tint: rgba(124, 58, 237, 0.10);
  --district-tint: rgba(8, 145, 178, 0.10);
  --commune-tint: rgba(22, 163, 74, 0.10);

  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;

  --shadow-popover:
    rgba(8, 9, 10, 0.08) 0 2px 4px,
    rgba(8, 9, 10, 0.10) 0 8px 24px,
    rgba(8, 9, 10, 0.06) 0 0 0 1px;
}

/* ------------------------------------------------------------------------
   2. Base / Reset
   ------------------------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: -0.006em;
  color: var(--text);
  background: var(--canvas);
  min-height: 100vh;
  /* Linear signature: geometric alternates */
  font-feature-settings: "cv01", "ss03";
  font-synthesis: none;
  transition: background 0.2s ease, color 0.2s ease;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  font-feature-settings: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  font-feature-settings: inherit;
  color: inherit;
}

mark {
  background: rgba(113, 112, 255, 0.22);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius);
}

/* Khmer-specific */
[lang="km"],
.name-km,
.title-km,
.province-name-km,
.district-name-km,
.commune-name-km,
.hierarchy-name-km,
.location-name-km,
.map-item-name-km,
.map-province-link-km {
  font-family: var(--font-khmer);
  line-height: 1.60;
  letter-spacing: 0;
}

::selection {
  background: var(--accent-ring);
  color: var(--text);
}

/* ------------------------------------------------------------------------
   3. Layout — Container & Structure
   ------------------------------------------------------------------------ */

.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  padding: 32px 0 80px;
}

/* ------------------------------------------------------------------------
   4. Header & Logo
   ------------------------------------------------------------------------ */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
}

.logo-text {
  font-size: 15px;
  font-weight: 590;
  letter-spacing: -0.012em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Icon buttons */
.theme-toggle,
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover,
.share-btn:hover {
  background: var(--bg-medium);
  color: var(--text);
  border-color: var(--border-strong);
}

/* Install button — brand CTA */
.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 510;
  background: var(--brand);
  color: #ffffff;
  border-radius: var(--radius);
  transition: background 0.15s ease, transform 0.15s ease;
}

.install-btn:hover {
  background: var(--brand-hover);
}

.install-btn:active {
  transform: scale(0.97);
}

.install-btn svg {
  flex-shrink: 0;
}

/* ------------------------------------------------------------------------
   5. Language Switcher
   ------------------------------------------------------------------------ */

.language-switcher {
  position: relative;
}

.language-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 510;
  transition: background 0.15s ease, color 0.15s ease;
}

.language-btn:hover {
  background: var(--bg-medium);
  color: var(--text);
}

.language-btn svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.current-lang {
  letter-spacing: 0;
}

.language-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 4px;
  z-index: 100;
  box-shadow: var(--shadow-popover);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 510;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-option:hover {
  background: var(--bg-medium);
  color: var(--text);
}

.lang-option.active {
  background: var(--accent-tint);
  color: var(--text);
}

.lang-option.active::after {
  content: "✓";
  margin-left: auto;
  color: var(--accent);
  font-weight: 590;
}

.lang-flag {
  font-size: 16px;
}

.lang-name {
  font-family: var(--font-sans);
}

/* ------------------------------------------------------------------------
   6. Search Section (Hero)
   ------------------------------------------------------------------------ */

.search-section {
  padding: 56px 0 40px;
  text-align: center;
}

.title {
  font-size: 56px;
  font-weight: 510;
  line-height: 1.05;
  letter-spacing: -0.022em;
  color: var(--text);
  margin-bottom: 12px;
}

.title-km {
  font-family: var(--font-khmer);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-tertiary);
  margin-bottom: 40px;
}

.search-box {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto 16px;
}

.search-input {
  flex: 1;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  letter-spacing: -0.006em;
}

.search-input:hover {
  background: var(--bg-medium);
  border-color: var(--border-strong);
}

.search-input:focus {
  background: var(--bg-soft);
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.search-input::placeholder {
  color: var(--text-quaternary);
}

.search-btn {
  padding: 14px 22px;
  font-size: 14px;
  font-weight: 510;
  background: var(--brand);
  color: #ffffff;
  border-radius: var(--radius-md);
  transition: background 0.15s ease, transform 0.15s ease;
  letter-spacing: -0.006em;
}

.search-btn:hover {
  background: var(--brand-hover);
}

.search-btn:active {
  transform: scale(0.98);
}

.search-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
}

/* Location row */
.location-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.location-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 510;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.location-btn:hover {
  background: var(--bg-medium);
  color: var(--text);
  border-color: var(--border-strong);
}

.location-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.location-btn.surprise-link {
  background: var(--accent-tint);
  color: var(--accent);
  border-color: var(--accent-border);
}

.location-btn.surprise-link:hover {
  background: rgba(113, 112, 255, 0.18);
  color: var(--brand-hover);
}

.location-btn svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.location-status {
  font-size: 13px;
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.location-status.visible {
  opacity: 1;
}

/* ------------------------------------------------------------------------
   7. Homepage Sections
   ------------------------------------------------------------------------ */

.homepage-content {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.homepage-section {
  padding: 32px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.homepage-section-header {
  margin-bottom: 20px;
}

.homepage-section h2 {
  font-size: 22px;
  font-weight: 510;
  line-height: 1.25;
  letter-spacing: -0.012em;
  color: var(--text);
  margin-bottom: 6px;
}

.homepage-intro p,
.homepage-how-it-works p {
  font-size: 15px;
  color: var(--text-tertiary);
  line-height: 1.60;
  letter-spacing: -0.009em;
}

.homepage-province-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.homepage-province-grid::-webkit-scrollbar {
  width: 6px;
}

.homepage-province-grid::-webkit-scrollbar-track {
  background: transparent;
}

.homepage-province-grid::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}

.homepage-province-grid::-webkit-scrollbar-thumb:hover {
  background: var(--bg-strong);
}

.homepage-province-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.homepage-province-card:hover {
  background: var(--bg-medium);
  border-color: var(--border);
  color: var(--text);
}

.homepage-province-card .province-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 6px;
  background: var(--province-tint);
  color: var(--province);
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  letter-spacing: 0;
}

.homepage-province-card .province-info {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.homepage-province-card .province-name {
  font-size: 13px;
  font-weight: 510;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.006em;
}

.homepage-province-card .province-name-km {
  font-family: var(--font-khmer);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.homepage-province-card .province-arrow {
  display: none;
}

.how-it-works-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.how-it-works-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 11px;
  font-weight: 590;
  flex-shrink: 0;
}

.step-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.55;
  letter-spacing: -0.009em;
}

.how-it-works-total {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-tertiary);
}

@media (min-width: 768px) {
  .homepage-province-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ------------------------------------------------------------------------
   8. Results Section
   ------------------------------------------------------------------------ */

.results-section {
  margin-top: 32px;
}

.results-count {
  font-size: 12px;
  font-weight: 510;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  padding: 0 4px;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.result-card:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

.result-card:active {
  transform: scale(0.998);
}

.result-card.copied {
  background: var(--bg-soft);
  border-color: var(--accent-border);
}

.result-card.copied::after {
  content: "Copied";
  position: absolute;
  top: 50%;
  right: 56px;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 590;
  color: var(--success);
  background: var(--bg-strong);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

.copy-hint {
  font-size: 10px;
  font-weight: 510;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.result-card:hover .copy-hint {
  opacity: 1;
}

.result-card.copied .copy-hint {
  opacity: 0;
}

.arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.arrow-btn:hover {
  background: var(--accent-tint);
  color: var(--accent);
  border-color: var(--accent-border);
  transform: translateX(2px);
}

.result-card.copied .arrow-btn {
  background: rgba(74, 222, 128, 0.12);
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.35);
}

/* Type-specific left accent — 2px inset line */
.result-card.province {
  box-shadow: inset 2px 0 0 var(--province);
}

.result-card.district {
  box-shadow: inset 2px 0 0 var(--district);
}

.result-card.commune {
  box-shadow: inset 2px 0 0 var(--commune);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.postal-code {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0;
}

.location-type {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.location-type.province {
  background: var(--province-tint);
  color: var(--province);
  border-color: rgba(167, 139, 250, 0.22);
}

.location-type.district {
  background: var(--district-tint);
  color: var(--district);
  border-color: rgba(34, 211, 238, 0.22);
}

.location-type.commune {
  background: var(--commune-tint);
  color: var(--commune);
  border-color: rgba(74, 222, 128, 0.22);
}

.result-body {
  flex: 1;
  min-width: 0;
}

.result-body .name-en {
  font-size: 16px;
  font-weight: 510;
  color: var(--text);
  line-height: 1.35;
  letter-spacing: -0.009em;
  margin-bottom: 2px;
}

.result-body .name-en mark {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 590;
  padding: 0 2px;
  border-radius: 2px;
}

.result-body .name-km {
  font-family: var(--font-khmer);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-tertiary);
  line-height: 1.55;
}

.result-body .parent-location {
  font-size: 12px;
  color: var(--text-quaternary);
  margin-top: 4px;
  font-weight: 510;
}

/* ------------------------------------------------------------------------
   9. No Results / Welcome / Browse
   ------------------------------------------------------------------------ */

.no-results,
.welcome-message {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
}

.no-results p:first-child,
.welcome-message p:first-child {
  font-size: 22px;
  font-weight: 510;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.012em;
}

.no-results-km,
.welcome-km {
  font-family: var(--font-khmer);
  font-size: 14px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.browse-hint {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-tertiary);
}

.browse-hint a {
  color: var(--accent);
  font-weight: 510;
}

.browse-hint a:hover {
  color: var(--brand-hover);
}

/* Recent searches */
.recent-searches {
  margin-top: 40px;
  text-align: center;
}

.recent-title {
  font-size: 11px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.recent-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 510;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.recent-item:hover {
  background: var(--bg-medium);
  color: var(--text);
  border-color: var(--border-strong);
}

.recent-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}

/* Slogan */
.unity-slogan {
  margin-top: 64px;
  text-align: center;
  padding: 24px;
}

.unity-slogan .slogan-km {
  font-family: var(--font-khmer);
  font-size: 15px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.unity-slogan .slogan-en {
  font-size: 12px;
  color: var(--text-quaternary);
  font-style: italic;
}

/* Ad space */
.ad-space {
  margin: 32px 0;
}

.ad-placeholder {
  padding: 32px;
  text-align: center;
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-quaternary);
  font-size: 13px;
}

/* ------------------------------------------------------------------------
   10. Footer
   ------------------------------------------------------------------------ */

.footer {
  padding: 48px 0 32px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 64px;
}

.footer a {
  color: var(--text-secondary);
  font-weight: 510;
}

.footer a:hover {
  color: var(--text);
}

.footer .stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.footer .stats span {
  font-size: 12px;
  color: var(--text-tertiary);
}

.footer .footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 12px;
}

.footer .footer-nav a {
  color: var(--text-tertiary);
}

.footer .footer-nav a:hover {
  color: var(--text);
}

.footer-nav {
  margin-bottom: 12px;
}

.footer .legal-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.footer .legal-links a {
  color: var(--text-tertiary);
  font-size: 12px;
}

.footer .legal-links a:hover {
  color: var(--text);
}

/* ------------------------------------------------------------------------
   11. Legal / Content Pages
   ------------------------------------------------------------------------ */

.legal-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 40px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.legal-page h1 {
  font-size: 36px;
  font-weight: 510;
  line-height: 1.15;
  letter-spacing: -0.022em;
  color: var(--text);
  margin-bottom: 8px;
}

.legal-page .last-updated {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 32px;
}

.legal-page section {
  margin-bottom: 32px;
}

.legal-page h2 {
  font-size: 22px;
  font-weight: 510;
  color: var(--text);
  margin: 24px 0 12px;
  letter-spacing: -0.012em;
}

.legal-page h3 {
  font-size: 16px;
  font-weight: 590;
  color: var(--text);
  margin: 16px 0 8px;
  letter-spacing: -0.006em;
}

.legal-page p {
  font-size: 15px;
  line-height: 1.70;
  color: var(--text-secondary);
  margin-bottom: 12px;
  letter-spacing: -0.009em;
}

.legal-page ul {
  margin: 12px 0 12px 24px;
}

.legal-page li {
  font-size: 15px;
  line-height: 1.70;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.legal-page a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-border);
}

.legal-page a:hover {
  color: var(--brand-hover);
  border-bottom-color: var(--brand-hover);
}

.legal-page .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
  font-size: 13px;
  font-weight: 510;
  color: var(--text-tertiary);
}

.legal-page .back-link:hover {
  color: var(--text);
}

/* ------------------------------------------------------------------------
   12. Usage Stats
   ------------------------------------------------------------------------ */

.usage-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.usage-stats .stat {
  padding: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.usage-stats .stat-value {
  font-size: 32px;
  font-weight: 510;
  color: var(--text);
  line-height: 1.0;
  margin-bottom: 6px;
  letter-spacing: -0.022em;
}

.usage-stats .stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 590;
}

.top-searches {
  margin-top: 32px;
}

.search-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  margin: 3px;
  font-size: 12px;
  font-weight: 510;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
}

/* ------------------------------------------------------------------------
   13. Show Page (Individual Postal Code)
   ------------------------------------------------------------------------ */

.show-page {
  padding: 24px 0;
}

.show-page .back-link {
  display: inline-flex;
  margin-bottom: 20px;
}

.show-page .back-link a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 510;
  color: var(--text-tertiary);
}

.show-page .back-link a:hover {
  color: var(--text);
}

.show-page .back-link svg {
  flex-shrink: 0;
}

.show-page .result-card {
  padding: 32px;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
}

.show-page .result-body h1.name-en {
  font-size: 36px;
  font-weight: 510;
  line-height: 1.15;
  letter-spacing: -0.022em;
  margin-bottom: 6px;
  color: var(--text);
}

/* Turbo progress bar */
.turbo-progress-bar {
  height: 2px;
  background: var(--accent);
}

/* ------------------------------------------------------------------------
   14. Breadcrumbs
   ------------------------------------------------------------------------ */

.breadcrumb {
  padding: 16px 0;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  font-size: 13px;
  font-weight: 510;
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  color: var(--text-tertiary);
}

.breadcrumb li:not(:last-child)::after {
  content: "/";
  margin: 0 8px;
  color: var(--text-quaternary);
}

.breadcrumb a {
  color: var(--text-tertiary);
}

.breadcrumb a:hover {
  color: var(--text);
}

.breadcrumb li[aria-current="page"] {
  color: var(--text);
}

/* ------------------------------------------------------------------------
   15. Location Pages (Province / District / City)
   ------------------------------------------------------------------------ */

.location-page {
  padding: 16px 0 48px;
}

.location-header {
  margin-bottom: 32px;
  padding: 32px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.location-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.location-header h1 {
  font-size: 40px;
  font-weight: 510;
  line-height: 1.10;
  letter-spacing: -0.022em;
  color: var(--text);
  margin-bottom: 6px;
}

.location-name-km {
  font-family: var(--font-khmer);
  font-size: 20px;
  font-weight: 400;
  color: var(--text-tertiary);
  line-height: 1.55;
}

.location-parent {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 8px;
  font-weight: 510;
}

.location-subtitle {
  font-size: 15px;
  color: var(--text-tertiary);
  margin-top: 12px;
  line-height: 1.60;
  letter-spacing: -0.009em;
}

.location-code-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.code-label {
  font-size: 10px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.code-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Location grids */
.provinces-grid,
.districts-grid,
.communes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.province-card,
.district-card,
.commune-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.province-card:hover,
.district-card:hover,
.commune-card:hover {
  background: var(--bg-medium);
  border-color: var(--border-strong);
  color: var(--text);
}

.province-code,
.district-code,
.commune-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  letter-spacing: 0;
}

.province-card .province-code {
  background: var(--province-tint);
  color: var(--province);
}

.district-card .district-code {
  background: var(--district-tint);
  color: var(--district);
}

.commune-card .commune-code {
  background: var(--commune-tint);
  color: var(--commune);
}

.province-info,
.district-info,
.commune-info {
  min-width: 0;
  flex: 1;
}

.province-name,
.district-name,
.commune-name {
  font-size: 14px;
  font-weight: 510;
  color: var(--text);
  line-height: 1.35;
  letter-spacing: -0.006em;
  margin-bottom: 2px;
}

.province-name-km,
.district-name-km,
.commune-name-km {
  font-family: var(--font-khmer);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
  line-height: 1.55;
}

.province-arrow,
.district-arrow {
  color: var(--text-quaternary);
  flex-shrink: 0;
}

.province-description {
  margin: 24px 0;
  padding: 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.province-description p {
  font-size: 15px;
  line-height: 1.70;
  color: var(--text-secondary);
  letter-spacing: -0.009em;
}

/* City / Quick Answer */
.city-quick-answer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.quick-answer-main,
.quick-answer-range {
  padding: 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.quick-answer-main {
  background: var(--accent-tint);
  border-color: var(--accent-border);
}

.quick-answer-label {
  font-size: 10px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.quick-answer-main .quick-answer-label {
  color: var(--accent);
}

.quick-answer-code {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: color 0.15s ease;
}

.quick-answer-code:hover {
  color: var(--accent);
}

.quick-answer-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.city-districts-section,
.city-address-tip,
.city-faq-section {
  margin-top: 40px;
}

.city-districts-section h2,
.city-address-tip h2,
.city-faq-section h2 {
  font-size: 22px;
  font-weight: 510;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.012em;
}

.city-address-tip {
  padding: 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.address-format {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 16px;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
  color: var(--text);
}

.city-faq-section .faq-list details {
  margin-bottom: 6px;
  padding: 16px 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.city-faq-section .faq-list summary {
  font-size: 15px;
  font-weight: 510;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  letter-spacing: -0.006em;
}

.city-faq-section .faq-list details p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.60;
  margin-top: 10px;
}

.browse-all-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 510;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease;
}

.browse-all-link:hover {
  background: var(--bg-medium);
  color: var(--text);
}

.location-footer {
  margin-top: 48px;
  padding-top: 32px;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
}

.location-footer p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.location-footer .footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.location-footer a {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 510;
}

.location-footer a:hover {
  color: var(--text);
}

/* Empty state */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.empty-state p {
  font-size: 15px;
  color: var(--text-tertiary);
}

/* District-only card */
.district-only-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.district-only-card:hover {
  background: var(--bg-medium);
  border-color: var(--border-strong);
}

.district-only-card .postal-code {
  font-size: 20px;
}

.district-only-card .copy-hint {
  font-size: 10px;
  color: var(--text-quaternary);
}

/* Related */
.related-section {
  margin-top: 40px;
  padding: 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.related-section h2 {
  font-size: 18px;
  font-weight: 510;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.012em;
}

.related-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}

.related-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.related-link:hover {
  background: var(--bg-medium);
  border-color: var(--border);
  color: var(--text);
}

.related-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-quaternary);
}

.related-name {
  font-weight: 510;
  color: var(--text);
}

.view-all-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  font-size: 13px;
  font-weight: 510;
  color: var(--text-tertiary);
}

.view-all-link:hover {
  color: var(--accent);
}

/* ------------------------------------------------------------------------
   16. FAQ Page
   ------------------------------------------------------------------------ */

.faq-page {
  padding: 24px 0 48px;
}

.faq-header {
  margin-bottom: 32px;
  text-align: center;
  padding: 48px 16px 32px;
}

.faq-header h1 {
  font-size: 48px;
  font-weight: 510;
  line-height: 1.05;
  letter-spacing: -0.022em;
  color: var(--text);
  margin-bottom: 12px;
}

.faq-subtitle {
  font-size: 17px;
  color: var(--text-tertiary);
  line-height: 1.60;
  letter-spacing: -0.009em;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.faq-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.faq-item:hover {
  border-color: var(--border-strong);
}

.faq-item[open] {
  background: var(--bg-soft);
}

.faq-question {
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question h2 {
  font-size: 15px;
  font-weight: 510;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.006em;
}

.faq-question::after {
  content: "";
  width: 10px;
  height: 10px;
  border-right: 1.5px solid var(--text-tertiary);
  border-bottom: 1.5px solid var(--text-tertiary);
  transform: rotate(45deg);
  transition: transform 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
  margin-right: 4px;
  margin-top: -3px;
}

.faq-item[open] .faq-question::after {
  transform: rotate(-135deg);
  margin-top: 3px;
  border-color: var(--text);
}

.faq-answer {
  padding: 0 22px 18px;
}

.faq-answer p {
  font-size: 14px;
  line-height: 1.70;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: -0.006em;
}

.faq-answer ul,
.faq-answer ol {
  margin: 10px 0 10px 24px;
}

.faq-answer li {
  font-size: 14px;
  line-height: 1.70;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.faq-answer a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-border);
}

.faq-answer a:hover {
  color: var(--brand-hover);
}

.faq-footer {
  margin-top: 48px;
  padding: 32px;
  text-align: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.faq-footer h3 {
  font-size: 20px;
  font-weight: 510;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.012em;
}

.faq-footer > p {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.faq-footer .footer-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------------
   17. Generic Buttons
   ------------------------------------------------------------------------ */

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 510;
  border-radius: var(--radius);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  letter-spacing: -0.006em;
}

.btn-primary {
  background: var(--brand);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-hover);
}

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

.btn-secondary:hover {
  background: var(--bg-medium);
  color: var(--text);
  border-color: var(--border-strong);
}

/* ------------------------------------------------------------------------
   18. Hierarchy Section
   ------------------------------------------------------------------------ */

.hierarchy-section {
  margin: 32px 0;
  padding: 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.hierarchy-section h2 {
  font-size: 18px;
  font-weight: 510;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.012em;
}

.hierarchy-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hierarchy-level {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  position: relative;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.hierarchy-level.active {
  background: var(--accent-tint);
  border-color: var(--accent-border);
}

.hierarchy-connector {
  display: none;
}

.hierarchy-badge {
  flex-shrink: 0;
}

.hierarchy-code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  background: var(--bg-medium);
  border-radius: var(--radius-sm);
  color: var(--text);
}

.hierarchy-level.active .hierarchy-code {
  background: rgba(113, 112, 255, 0.22);
  color: var(--text);
}

.hierarchy-info {
  flex: 1;
  min-width: 0;
}

.hierarchy-type {
  font-size: 10px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.hierarchy-level.province .hierarchy-type {
  color: var(--province);
}

.hierarchy-level.district .hierarchy-type {
  color: var(--district);
}

.hierarchy-level.commune .hierarchy-type {
  color: var(--commune);
}

.hierarchy-name {
  font-size: 14px;
  font-weight: 510;
  color: var(--text);
  letter-spacing: -0.006em;
}

.hierarchy-name-km {
  font-family: var(--font-khmer);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.hierarchy-current {
  font-size: 10px;
  margin-left: auto;
  padding: 3px 8px;
  background: var(--bg-strong);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  font-weight: 590;
  letter-spacing: 0.06em;
  color: var(--accent);
}

/* ------------------------------------------------------------------------
   19. Error Pages
   ------------------------------------------------------------------------ */

.error-page {
  padding: 64px 24px;
  text-align: center;
  max-width: 520px;
  margin: 0 auto;
}

.error-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.error-icon--warning {
  background: rgba(251, 191, 36, 0.10);
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.25);
}

.error-icon--danger {
  background: rgba(248, 113, 113, 0.10);
  color: var(--error);
  border-color: rgba(248, 113, 113, 0.25);
}

.error-code {
  font-size: 72px;
  font-weight: 510;
  line-height: 1.0;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-bottom: 8px;
}

.error-title {
  font-size: 26px;
  font-weight: 510;
  line-height: 1.20;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.018em;
}

.error-message {
  font-size: 16px;
  line-height: 1.60;
  color: var(--text-tertiary);
  margin-bottom: 32px;
  letter-spacing: -0.006em;
}

.error-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.error-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 510;
  border-radius: var(--radius);
}

.error-actions .btn-primary {
  background: var(--brand);
  color: #ffffff;
}

.error-actions .btn-primary:hover {
  background: var(--brand-hover);
}

.error-actions .btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.error-actions .btn-secondary:hover {
  background: var(--bg-medium);
  color: var(--text);
}

.error-inline {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.20);
  border-radius: var(--radius-md);
  margin: 16px 0;
}

.error-inline-icon {
  color: var(--error);
  flex-shrink: 0;
}

.error-inline-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.50;
}

/* ------------------------------------------------------------------------
   20. Time Capsules
   ------------------------------------------------------------------------ */

.time-capsules-section {
  margin: 40px 0;
}

.capsules-header {
  margin-bottom: 24px;
  text-align: center;
}

.capsules-header h2 {
  font-size: 28px;
  font-weight: 510;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.018em;
}

.capsules-subtitle {
  font-size: 14px;
  color: var(--text-tertiary);
}

.capsules-count-wrapper {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-quaternary);
}

.capsules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.no-capsules {
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
}

.capsule-card {
  display: flex;
  gap: 16px;
  padding: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.capsule-card:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

.capsule-mood {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
}

.capsule-content {
  flex: 1;
  min-width: 0;
}

.capsule-message {
  font-size: 14px;
  line-height: 1.60;
  color: var(--text-secondary);
  margin-bottom: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  letter-spacing: -0.006em;
}

.capsule-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 510;
}

.capsule-age {
  font-weight: 510;
}

.capsule-author {
  color: var(--text-quaternary);
}

.capsule-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.capsule-heart-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 510;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-tertiary);
  transition: all 0.15s ease;
}

.capsule-heart-btn:hover {
  color: var(--error);
  border-color: rgba(248, 113, 113, 0.35);
}

.capsule-heart-btn.hearted {
  color: var(--error);
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.25);
}

.capsule-heart-btn svg {
  flex-shrink: 0;
}

.heart-count {
  font-weight: 590;
}

.capsule-flag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  color: var(--text-quaternary);
  opacity: 0;
  transition: all 0.15s ease;
  border-radius: var(--radius-sm);
}

.capsule-card:hover .capsule-flag-btn {
  opacity: 1;
}

.capsule-flag-btn:hover {
  color: var(--warning);
  background: rgba(251, 191, 36, 0.10);
}

/* Capsule form */
.capsule-form-wrapper {
  margin-top: 32px;
  padding: 32px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.capsule-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.capsule-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.capsule-form label {
  font-size: 12px;
  font-weight: 590;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.capsule-textarea {
  padding: 12px 14px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  resize: vertical;
  min-height: 120px;
  color: var(--text);
  line-height: 1.60;
  letter-spacing: -0.006em;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.capsule-textarea:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.capsule-textarea.field-error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.15);
}

.capsule-input {
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.capsule-input:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.50;
}

.form-hint .warning {
  color: var(--warning);
}

.form-hint .limit {
  font-weight: 510;
}

.form-hint .error-text {
  color: var(--error);
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.mood-group label:first-child {
  margin-bottom: 8px;
}

.mood-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mood-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 22px;
  transition: all 0.15s ease;
  position: relative;
}

.mood-option:hover {
  background: var(--bg-medium);
  border-color: var(--border-strong);
}

.mood-option.selected,
.mood-option:has(input:checked) {
  background: var(--accent-tint);
  border-color: var(--accent-border);
}

.mood-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mood-emoji {
  line-height: 1;
}

.time-lock-details {
  padding: 14px 18px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.time-lock-details summary {
  font-size: 13px;
  font-weight: 510;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.time-lock-details summary:hover {
  color: var(--accent);
}

.time-lock-content {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.time-lock-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.50;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.capsule-submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 510;
  background: var(--brand);
  color: #ffffff;
  border-radius: var(--radius);
  transition: background 0.15s ease, transform 0.15s ease;
}

.capsule-submit-btn:hover {
  background: var(--brand-hover);
}

.capsule-submit-btn:active {
  transform: scale(0.98);
}

.capsule-form-error {
  padding: 12px 16px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.20);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 13px;
}

.capsule-form-error:empty {
  display: none;
}

.capsule-form-success {
  padding: 32px;
  text-align: center;
}

.capsule-form-success .success-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.capsule-form-success h3 {
  font-size: 20px;
  font-weight: 510;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.012em;
}

.capsule-form-success p {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
}

.capsule-another-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 510;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease;
}

.capsule-another-btn:hover {
  background: var(--bg-medium);
  color: var(--text);
}

/* ------------------------------------------------------------------------
   21. Surprise Page
   ------------------------------------------------------------------------ */

.surprise-page {
  padding: 24px 0 48px;
}

.surprise-header {
  text-align: center;
  padding: 48px 16px 32px;
  margin-bottom: 32px;
}

.surprise-header h1 {
  font-size: 48px;
  font-weight: 510;
  line-height: 1.05;
  letter-spacing: -0.022em;
  color: var(--text);
  margin-bottom: 12px;
}

.surprise-subtitle {
  font-size: 17px;
  color: var(--text-tertiary);
  line-height: 1.60;
  letter-spacing: -0.009em;
}

.surprise-main {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
}

.category-filters {
  margin-bottom: 32px;
}

.filter-label {
  display: block;
  font-size: 11px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  text-align: center;
}

.category-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}

.category-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 510;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.category-btn:hover {
  background: var(--bg-medium);
  color: var(--text);
  border-color: var(--border-strong);
}

.category-btn:active {
  transform: scale(0.97);
}

.category-btn.active {
  background: var(--accent-tint);
  color: var(--accent);
  border-color: var(--accent-border);
}

.category-emoji {
  font-size: 22px;
  line-height: 1;
}

.category-label {
  line-height: 1.3;
}

.surprise-action {
  text-align: center;
  margin: 32px 0;
}

.surprise-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 510;
  background: var(--brand);
  color: #ffffff;
  border-radius: var(--radius-pill);
  transition: background 0.15s ease, transform 0.15s ease;
  letter-spacing: -0.009em;
}

.surprise-btn:hover {
  background: var(--brand-hover);
}

.surprise-btn:active {
  transform: scale(0.98);
}

.surprise-btn.spinning {
  pointer-events: none;
}

.surprise-btn.spinning .btn-emoji {
  animation: spin 0.6s ease-in-out infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn-emoji {
  font-size: 18px;
  line-height: 1;
}

.surprise-hint {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Destiny card */
.surprise-result {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.surprise-result.revealed {
  opacity: 1;
  transform: translateY(0);
}

.destiny-card {
  position: relative;
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--accent-border);
  color: var(--text);
  border-radius: var(--radius-lg);
  text-align: center;
  overflow: hidden;
}

.destiny-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(113, 112, 255, 0.10), transparent 60%);
  pointer-events: none;
}

.destiny-header {
  margin-bottom: 20px;
  position: relative;
}

.destiny-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--accent);
  padding: 4px 12px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-pill);
}

.destiny-content {
  position: relative;
}

.destiny-emoji {
  font-size: 48px;
  margin-bottom: 12px;
  line-height: 1;
}

.destiny-name {
  font-size: 32px;
  font-weight: 510;
  line-height: 1.15;
  letter-spacing: -0.022em;
  margin-bottom: 10px;
  color: var(--text);
}

.destiny-code {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 6px 14px;
  background: var(--bg-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: inline-block;
  margin-bottom: 16px;
  color: var(--text);
}

.destiny-tagline {
  font-size: 14px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-bottom: 16px;
  line-height: 1.60;
  letter-spacing: -0.006em;
}

.destiny-location {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  font-weight: 510;
}

.destiny-location-km {
  font-family: var(--font-khmer);
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 24px;
}

.destiny-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 24px;
  position: relative;
}

.share-btn-card,
.youtube-btn,
.tiktok-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 510;
  background: var(--bg-soft);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.share-btn-card:hover,
.youtube-btn:hover,
.tiktok-btn:hover {
  background: var(--bg-medium);
  color: var(--text);
  border-color: var(--border-strong);
}

.share-btn-card:active,
.youtube-btn:active,
.tiktok-btn:active {
  transform: scale(0.97);
}

.share-btn-card.success {
  background: rgba(74, 222, 128, 0.12);
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.35);
}

.destiny-explore-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 510;
  background: var(--brand);
  color: #ffffff;
  border-radius: var(--radius);
  transition: background 0.15s ease, transform 0.15s ease;
  position: relative;
}

.destiny-explore-btn:hover {
  background: var(--brand-hover);
}

.destiny-explore-btn:active {
  transform: scale(0.98);
}

.destiny-footer {
  margin-top: 20px;
  font-size: 10px;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: relative;
  font-weight: 590;
}

.reveal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

.try-again-btn,
.explore-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 510;
  border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.try-again-btn {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.try-again-btn:active {
  transform: scale(0.97);
}

.try-again-btn:hover {
  background: var(--bg-medium);
  color: var(--text);
}

.explore-btn {
  background: var(--brand);
  color: #ffffff;
}

.explore-btn:hover {
  background: var(--brand-hover);
}

.explore-btn:active {
  transform: scale(0.97);
}

/* Surprise History */
.surprise-history {
  margin-top: 48px;
  padding: 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.surprise-history h3 {
  font-size: 16px;
  font-weight: 510;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.012em;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.history-item:hover {
  background: var(--bg-medium);
  border-color: var(--border);
  color: var(--text);
}

.history-item:active {
  transform: scale(0.99);
}

.history-emoji {
  font-size: 18px;
  flex-shrink: 0;
}

.history-name {
  flex: 1;
  font-weight: 510;
}

.history-date {
  font-size: 11px;
  color: var(--text-quaternary);
  font-weight: 510;
}

.history-progress {
  margin-top: 16px;
}

.progress-bar {
  height: 4px;
  background: var(--bg-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.progress-text {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  font-weight: 510;
}

.surprise-footer {
  margin-top: 32px;
  text-align: center;
}

.surprise-footer .back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 510;
  color: var(--text-tertiary);
}

.surprise-footer .back-link:hover {
  color: var(--text);
}

/* ------------------------------------------------------------------------
   22. Map Page
   ------------------------------------------------------------------------ */

.container:has(.map-page) {
  max-width: var(--container-wide);
}

.map-page {
  padding: 24px 0 48px;
}

.map-header {
  margin-bottom: 24px;
  text-align: center;
}

.map-header h1 {
  font-size: 40px;
  font-weight: 510;
  line-height: 1.10;
  letter-spacing: -0.022em;
  color: var(--text);
  margin-bottom: 10px;
}

.map-subtitle {
  font-size: 16px;
  color: var(--text-tertiary);
  line-height: 1.60;
  letter-spacing: -0.006em;
}

.map-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.map-svg-container {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
}

.cambodia-svg {
  width: 100%;
  height: auto;
  display: block;
}

.province-path {
  fill: var(--bg-medium);
  stroke: var(--canvas);
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill 0.15s ease;
}

.province-path:focus-visible {
  outline: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.province-path:hover {
  fill: var(--bg-strong);
}

.province-path.active {
  fill: var(--accent);
}

.province-path.province-capital {
  fill: var(--bg-strong);
}

.province-path.province-capital:hover {
  fill: rgba(255, 255, 255, 0.12);
}

.province-path.province-capital.active {
  fill: var(--accent);
}

.province-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 510;
  fill: var(--text);
  pointer-events: none;
}

.province-label-sm {
  font-size: 9px;
}

/* Map sidebar */
.map-sidebar {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
  font-size: 16px;
  font-weight: 510;
  color: var(--text);
  flex: 1;
  letter-spacing: -0.012em;
}

.sidebar-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-back-btn:hover {
  background: var(--bg-medium);
  color: var(--text);
}

.sidebar-back-btn svg {
  flex-shrink: 0;
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-count {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  font-weight: 590;
}

.map-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  cursor: pointer;
}

.map-list-item:hover {
  background: var(--bg-medium);
  border-color: var(--border);
  color: var(--text);
}

.map-list-item.province-item {
  border-left-color: var(--province);
  box-shadow: inset 2px 0 0 var(--province);
}

.map-list-item.district-item {
  box-shadow: inset 2px 0 0 var(--district);
}

.map-list-item.commune-item {
  box-shadow: inset 2px 0 0 var(--commune);
}

.map-item-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-quaternary);
  flex-shrink: 0;
}

.map-item-info {
  flex: 1;
  min-width: 0;
}

.map-item-name {
  font-size: 13px;
  font-weight: 510;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.006em;
}

.map-item-name-km {
  font-family: var(--font-khmer);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-item-arrow {
  color: var(--text-quaternary);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.map-list-item:hover .map-item-arrow {
  opacity: 1;
}

.map-loading {
  padding: 32px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.map-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-pill);
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

.map-error {
  padding: 24px;
  text-align: center;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.20);
  border-radius: var(--radius-md);
  color: var(--error);
  font-size: 13px;
}

/* Map SEO content */
.map-seo-content {
  margin-top: 48px;
  padding: 32px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.map-seo-content h2 {
  font-size: 24px;
  font-weight: 510;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.018em;
}

.map-seo-content h3 {
  font-size: 17px;
  font-weight: 590;
  color: var(--text);
  margin: 20px 0 10px;
  letter-spacing: -0.006em;
}

.map-seo-content p {
  font-size: 15px;
  line-height: 1.70;
  color: var(--text-secondary);
  margin-bottom: 12px;
  letter-spacing: -0.009em;
}

.map-province-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  margin-top: 16px;
}

.map-province-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.map-province-link:hover {
  background: var(--bg-medium);
  border-color: var(--border);
  color: var(--text);
}

.map-province-link strong {
  font-size: 13px;
  font-weight: 510;
  color: var(--text);
  letter-spacing: -0.006em;
}

.map-province-link-km {
  font-family: var(--font-khmer);
  font-size: 11px;
  color: var(--text-tertiary);
}

.map-faq {
  margin-top: 24px;
}

.map-faq dt {
  font-size: 15px;
  font-weight: 510;
  color: var(--text);
  margin-top: 16px;
  letter-spacing: -0.006em;
}

.map-faq dd {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.60;
  margin-top: 4px;
}

.map-seo-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

/* ------------------------------------------------------------------------
   23. Responsive
   ------------------------------------------------------------------------ */

@media (max-width: 768px) {
  :root {
    --container-padding: 20px;
  }

  .search-section {
    padding: 40px 0 32px;
  }

  .title {
    font-size: 40px;
  }

  .title-km {
    font-size: 16px;
    margin-bottom: 28px;
  }

  .search-box {
    flex-direction: column;
  }

  .search-btn {
    padding: 14px;
  }

  .homepage-section {
    padding: 24px 20px;
  }

  .homepage-section h2 {
    font-size: 20px;
  }

  .legal-page {
    padding: 32px 24px;
  }

  .legal-page h1 {
    font-size: 28px;
  }

  .location-header {
    padding: 24px 20px;
  }

  .location-header h1 {
    font-size: 28px;
  }

  .location-title-row {
    flex-direction: column;
    gap: 16px;
  }

  .faq-header h1 {
    font-size: 36px;
  }

  .surprise-header h1 {
    font-size: 36px;
  }

  .surprise-main {
    padding: 28px 20px;
  }

  .destiny-name {
    font-size: 26px;
  }

  .destiny-code {
    font-size: 18px;
  }

  .error-code {
    font-size: 56px;
  }

  .error-title {
    font-size: 22px;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .map-sidebar {
    position: static;
    max-height: none;
  }

  .map-header h1 {
    font-size: 30px;
  }

  .show-page .result-body h1.name-en {
    font-size: 28px;
  }

  .show-page .result-card {
    padding: 24px 20px;
  }

  .result-card {
    padding: 14px 16px;
  }

  .header {
    padding: 16px 0;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
  }

  .language-btn .current-lang {
    display: none;
  }

  .install-btn {
    padding: 8px 12px;
  }

  .footer {
    padding: 32px 0 24px;
  }

  .quick-answer-code {
    font-size: 24px;
  }

  .usage-stats .stat-value {
    font-size: 26px;
  }
}

@media (max-width: 480px) {
  .title {
    font-size: 34px;
  }

  .search-section {
    padding: 32px 0 24px;
  }

  .category-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ============================================
   Format Authority Page
   ============================================ */

.format-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  color: var(--text);
}

.format-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.format-header h1 {
  font-size: 32px;
  line-height: 1.2;
  margin: 0 0 12px;
  color: var(--text);
}

.format-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  margin: 0;
}

.format-section {
  margin-bottom: 40px;
  color: var(--text);
}

.format-section h2 {
  font-size: 24px;
  margin: 0 0 12px;
  color: var(--text);
}

.format-section h3 {
  font-size: 18px;
  margin: 20px 0 10px;
  color: var(--text);
}

.format-section p {
  color: var(--text);
}

.format-lead {
  font-size: 17px;
  line-height: 1.5;
  margin: 0 0 16px;
  color: var(--text);
}

.format-structure {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 16px 0;
  color: var(--text);
}

.format-structure-label {
  font-weight: 600;
  margin: 0 0 8px;
  font-family: monospace;
  font-size: 16px;
  color: var(--text);
}

.format-structure-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

.format-structure-list li {
  margin: 6px 0;
}

.format-example {
  background: var(--bg-soft);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  padding: 12px 16px;
  margin: 16px 0;
  color: var(--text);
}

.format-example h3 {
  margin: 0 0 6px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.format-example-body {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.format-example-body code {
  font-size: 15px;
  background: transparent;
  padding: 0;
  color: var(--text);
}

.format-source-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 16px 0;
  color: var(--text);
}

.format-source-box p {
  margin: 6px 0;
  color: var(--text);
}

.format-source-box strong {
  color: var(--text);
}

.format-source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0;
}

/* Warning section: amber-tinted, theme-aware */
.format-section-warning {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 20px 24px;
  color: var(--text);
}

[data-theme="light"] .format-section-warning {
  background: #fff7ed;
  border-color: #fed7aa;
  border-left-color: #f59e0b;
}

.format-section-warning h2 {
  color: #f59e0b;
}

[data-theme="light"] .format-section-warning h2 {
  color: #9a3412;
}

.format-section-warning p,
.format-section-warning li {
  color: var(--text);
}

.format-verify-list {
  padding-left: 20px;
  margin: 12px 0;
  color: var(--text);
}

.format-verify-list li {
  margin: 6px 0;
}

.format-anchor-note {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 15px;
  color: var(--text-secondary);
}

.format-table-wrap {
  overflow-x: auto;
  margin: 16px 0;
}

.format-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  color: var(--text);
}

.format-table th,
.format-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.format-table th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--text);
}

.format-table code {
  font-family: monospace;
  font-size: 15px;
  color: var(--text);
}

.format-developer-list {
  padding-left: 20px;
  margin: 12px 0;
  color: var(--text);
}

.format-developer-list li {
  margin: 8px 0;
  line-height: 1.5;
}

.format-developer-list code {
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 14px;
  color: var(--text);
}

.format-cite {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 16px;
}

.format-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.format-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

@media (max-width: 600px) {
  .format-header h1 {
    font-size: 26px;
  }

  .format-section h2 {
    font-size: 20px;
  }

  .format-source-links {
    flex-direction: column;
  }

  .format-source-links a {
    width: 100%;
    text-align: center;
  }
}

/* Source attribution note on postal code pages */
.postal-source-note {
  margin: 32px 0 16px;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.postal-source-note a {
  color: var(--accent);
  text-decoration: none;
}

.postal-source-note a:hover {
  text-decoration: underline;
}
