:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eceeea;
  --hover: #e2e6e1;
  --ink: #1e2421;
  --ink-soft: #3f4944;
  --muted: #5c6862;
  --accent: #1f6b4f;
  --on-accent: #ffffff;
  --link: #1a5d45;
  --danger: #b42318;
  --line: #dde2dd;
  --line-strong: #b8c1bb;
  --ring: #1f6b4f;
  --header-bg: #1f6b4f;
  --on-header: #ffffff;
  --page: 1180px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121614;
  --surface: #1a1f1c;
  --surface-2: #252b27;
  --hover: #2f3732;
  --ink: #e6ebe8;
  --ink-soft: #c3ccc7;
  --muted: #97a29c;
  --accent: #5fbf98;
  --on-accent: #0c1712;
  --link: #79cfa9;
  --danger: #f29b8f;
  --line: #2d3530;
  --line-strong: #4a5550;
  --ring: #5fbf98;
  --header-bg: #17261f;
  --on-header: #e6ebe8;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body { min-height: 100vh; background: var(--bg); color: var(--ink); font-family: Roboto, 'Segoe UI', Arial, sans-serif; font-size: 15px; line-height: 1.55; }
button, input, textarea, select { font: inherit; border-radius: 0; -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--link); text-underline-offset: 3px; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:where(button, a, input, textarea, select, summary, [tabindex]):focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.ico { width: 18px; height: 18px; flex-shrink: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; border: 0; }
.link-btn { padding: 2px 0; background: none; border: 0; color: var(--link); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--ink); }
.link-btn:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.block-label { margin-bottom: 8px; color: var(--ink-soft); font-size: 14px; font-weight: 700; }

.site-header { background: var(--header-bg); color: var(--on-header); }
.header-inner { max-width: var(--page); margin: 0 auto; padding: 0 24px; min-height: 56px; display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; font-size: 19px; font-weight: 700; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex-shrink: 0; }
.header-tools { display: flex; align-items: center; gap: 24px; margin-left: auto; }
.header-link { display: inline-flex; align-items: center; min-height: 40px; padding: 0; background: none; border: 0; color: inherit; font-size: 14px; text-decoration: none; }
.header-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.site-header :focus-visible { outline-color: currentColor; }
.status-pill { display: flex; align-items: center; gap: 8px; padding: 4px 10px; background: var(--surface); color: var(--danger); font-size: 13px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; background: var(--danger); flex-shrink: 0; }
.server-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; max-width: var(--page); padding: 16px 24px 0; margin: 0 auto; font-size: 14px; }
.server-bar input { flex: 1 1 220px; min-width: 0; padding: 8px 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.server-bar button { min-height: 38px; padding: 6px 14px; background: var(--surface-2); border: 0; }
.server-note { flex-basis: 100%; color: var(--muted); }

.featured-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.featured-photo { position: relative; margin: 0; }
.featured-photo img { display: block; width: 100%; height: 270px; object-fit: cover; }
.featured-photo figcaption { position: absolute; right: 0; bottom: 0; padding: 2px 8px; background: #000000a6; color: #fff; font-size: 12px; }
.featured-text { display: flex; flex-direction: column; justify-content: center; padding: 20px 28px; }
.featured-label { color: var(--accent); font-size: 14px; font-weight: 700; }
.featured-name { margin: 4px 0 0; font-size: 26px; font-weight: 700; line-height: 1.25; }
.featured-district { margin-top: 2px; color: var(--muted); font-size: 14px; }
.featured-fact { margin: 12px 0 18px; color: var(--ink-soft); }
.featured-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.featured-actions .btn-primary { display: inline-flex; align-items: center; text-decoration: none; }
.intro-text { padding: 14px 20px 16px; border-top: 3px solid var(--accent); }
.intro-text h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; line-height: 1.3; }
.intro-text p { margin: 0; color: var(--ink-soft); }
.intro-text b { color: var(--accent); }
.intro-text .link-btn { font-size: inherit; }
.intro-text .place-list { columns: 4 200px; }

.layout { max-width: var(--page); padding: 16px 24px 40px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px #0000000d; }
.panel + .panel { margin-top: 16px; }
.panel-title { margin: 16px 20px 0; padding-left: 10px; border-left: 4px solid var(--accent); font-size: 17px; font-weight: 700; line-height: 1.3; }
.panel-body { padding: 16px 20px 20px; }
.field-label { display: block; margin: 0 0 8px; font-size: 14px; font-weight: 700; }

.ask-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 28px; }
.ask-photo, .ask-question { min-width: 0; }
.ask-question { display: flex; flex-direction: column; }
.ask-question textarea { flex: 1; }
.photo-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.photo-heading .field-label { margin: 0; }
.dropzone { position: relative; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; height: 190px; overflow: hidden; cursor: pointer; background: var(--bg); border: 1px dashed var(--line-strong); transition: border-color .2s, background-color .2s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--surface-2); }
.dropzone img { display: none; width: 100%; height: 100%; object-fit: contain; }
.dropzone.has-image { border-style: solid; border-color: var(--line); background: var(--surface-2); }
.dropzone.has-image img { display: block; }
.dropzone.has-image .drop-hint { display: none; }
.dropzone.is-preparing::after { content: 'Đang chuẩn bị ảnh…'; position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--surface); color: var(--ink-soft); font-size: 14px; }
.drop-hint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; text-align: center; }
.drop-hint svg { width: 26px; height: 26px; margin-bottom: 8px; color: var(--accent); }
.drop-title { font-weight: 500; }
.drop-sub { margin-top: 2px; color: var(--muted); font-size: 13px; }
.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.photo-details { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; font-size: 14px; }
.photo-details:has(.photo-name:empty) { display: none; }
.photo-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.photo-details .link-btn { flex-shrink: 0; }
.photo-status { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.photo-status:empty { display: none; }
.btn-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 14px; background: var(--surface-2); border: 0; color: var(--ink); font-size: 14px; }
.btn-secondary:hover { background: var(--hover); }
textarea { display: block; width: 100%; min-height: 80px; max-height: 220px; resize: vertical; padding: 10px 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); font-size: 15px; line-height: 1.5; }
textarea::placeholder { color: var(--muted); opacity: 1; }
textarea:focus-visible { outline: 0; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.suggest { display: flex; align-items: baseline; gap: 10px; margin-top: 10px; }
.suggest-label { flex-shrink: 0; color: var(--muted); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 32px; padding: 5px 12px; background: var(--surface-2); border: 0; color: var(--ink); font-size: 14px; line-height: 1.4; transition: background-color .15s, color .15s; }
.chip:hover { background: var(--accent); color: var(--on-accent); }
.chip-suggest { color: var(--link); font-weight: 500; }
.ask-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 16px; }
.btn-primary { min-height: 42px; padding: 9px 24px; background: var(--accent); color: var(--on-accent); border: 0; font-size: 15px; font-weight: 500; transition: filter .15s; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-primary:disabled { background: var(--surface-2); color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 14px; }
.hint:empty { display: none; }
.error-box { margin-top: 16px; padding: 12px 14px; background: var(--surface); border-left: 3px solid var(--danger); color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }

.result-panel { position: relative; padding: 16px 20px 20px; scroll-margin-top: 56px; }
.result-panel:focus { outline: 0; }
.empty-text { margin: 0; color: var(--muted); }
.empty-text .link-btn { margin-left: 4px; font-size: inherit; }

.loading-state { color: var(--muted); }
.loading-question { margin: 0 0 12px; color: var(--ink); font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.loading-state::before { content: ''; display: block; height: 3px; margin-bottom: 16px; background: linear-gradient(90deg, transparent, var(--accent), transparent) -40% 0 / 40% 100% no-repeat var(--surface-2); animation: progress 1.4s ease-in-out infinite; }
@keyframes progress { to { background-position: 140% 0; } }
.loading-state .link-btn { margin-left: 12px; }
.elapsed { margin-left: 6px; color: var(--muted); font-size: 13px; }
.dots::after { content: ''; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.result-card { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; }
.result-card:has(.result-side[hidden]) { grid-template-columns: minmax(0, 1fr); }
.result-main { min-width: 0; }
.place-head { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--accent); }
.place-name { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.place-meta { margin-top: 2px; color: var(--muted); font-size: 14px; }
.place-meta:empty { display: none; }
.qa-item { overflow-wrap: anywhere; }
.qa-log > .qa-item:not(:first-child) { display: none; }
.qa-q { margin-bottom: 4px; color: var(--muted); font-size: 14px; font-weight: 500; }
.qa-a { margin: 0; font-size: 16px; line-height: 1.7; white-space: pre-line; }
.qa-a b { font-weight: 700; }
.qa-a.qa-collapsible { max-height: calc(7 * 1.7em); overflow: hidden; }
.qa-a.qa-expanded { max-height: none; }
.qa-pending { color: var(--muted); }
.qa-more { display: block; margin-top: 8px; }
.qa-note { margin-top: 10px; color: var(--muted); font-size: 13px; }
.qa-note + .chips { margin-top: 8px; }
.qa-tip { margin-top: 16px; color: var(--muted); font-size: 14px; }
.place-list { columns: 2 180px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.8; }
.qa-cancel { margin-top: 8px; }
.follow { margin-top: 20px; }

.place-card { align-self: start; padding: 16px; background: var(--bg); border: 1px solid var(--line); }
.place-summary { margin: 0 0 14px; color: var(--ink-soft); font-size: 14px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.place-facts { display: grid; gap: 10px; margin-bottom: 14px; }
.fact { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.fact-label { color: var(--muted); font-size: 13px; }
.fact-value { font-weight: 700; }
.place-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; font-size: 14px; }
.map-link { display: inline-flex; align-items: center; min-height: 38px; padding: 6px 16px; background: var(--accent); color: var(--on-accent); font-weight: 500; text-decoration: none; }
.map-link:hover { filter: brightness(1.12); }
.nearby { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); }

.qa-history { margin-top: 20px; border-top: 1px solid var(--line); }
.qa-history summary { display: flex; align-items: baseline; gap: 6px; list-style: none; cursor: pointer; }
.qa-history summary::-webkit-details-marker { display: none; }
.qa-history summary::after { content: '+'; margin-left: auto; color: var(--accent); font-size: 18px; line-height: 1; }
.qa-history details[open] > summary::after, .qa-history[open] > summary::after { content: '\2212'; }
.qa-history > summary { padding: 10px 0; font-weight: 700; }
#qaHistoryCount { color: var(--muted); font-size: 14px; font-weight: 400; }
#qaHistoryCount::before { content: '('; }
#qaHistoryCount::after { content: ')'; }
.qa-history-entry { border-top: 1px solid var(--line); }
.qa-history-entry > summary { padding: 10px 0; color: var(--ink-soft); font-size: 14px; overflow-wrap: anywhere; }
.qa-history-entry > .qa-item { padding: 0 0 14px; }
.qa-history-entry .qa-q { display: none; }

.samples-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-right: 0; }
.samples-heading h2 { margin: 0; font-size: inherit; scroll-margin-top: 16px; }
.sample-credits { position: relative; flex-shrink: 0; font-weight: 400; }
.sample-credits summary { color: var(--link); font-size: 14px; list-style: none; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.sample-credits summary::-webkit-details-marker { display: none; }
.sample-credits p { position: absolute; top: 100%; right: 0; z-index: 5; width: min(560px, calc(100vw - 32px)); margin: 8px 0 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 6px 20px #0000001f; color: var(--muted); font-size: 13px; line-height: 1.7; }
.sample-credits a { color: var(--ink-soft); }
.samples-deck { display: flex; flex-direction: column; gap: 16px; }
.sample-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.sample { display: block; min-width: 0; padding: 0; background: transparent; border: 0; text-align: left; }
.sample img { display: block; width: 100%; aspect-ratio: 16/10; object-fit: cover; outline: 3px solid transparent; outline-offset: -3px; transition: opacity .2s; }
.sample span { display: block; padding-top: 6px; font-size: 14px; font-weight: 500; }
.sample:hover img { opacity: .85; }
.sample:hover span, .sample.active span { color: var(--accent); }
.sample.active img { outline-color: var(--accent); }

.fb-dock { position: fixed; bottom: 24px; right: 24px; z-index: 50; }
.feedback { width: min(360px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: 0 6px 20px #00000029; }
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fb-head .block-label { margin: 0; }
.fb-close { display: inline-flex; padding: 2px; }
.fb-label { display: block; margin: 14px 0 6px; font-size: 14px; }
.feedback select { width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 14px; }
.feedback textarea { min-height: 80px; font-size: 14px; }
.fb-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.fb-status { color: var(--link); font-size: 14px; }

@media (max-width: 960px) {
  .featured-grid { grid-template-columns: 1fr; }
  .featured-photo img { height: 200px; }
  .ask-grid { grid-template-columns: 1fr; gap: 20px; }
  .result-card { grid-template-columns: minmax(0, 1fr); }
  .place-card { align-self: stretch; }
}
@media (max-width: 760px) {
  .header-inner { padding: 0 16px; }
  .header-tools { gap: 14px; }
  .site-header:has(.status-pill:not([hidden])) .header-inner { flex-wrap: wrap; padding-bottom: 8px; }
  .status-pill { order: 1; width: 100%; white-space: normal; }
  .server-bar { padding: 12px 16px 0; }
  .layout { padding: 12px 12px 32px; }
  .panel-body, .result-panel { padding: 16px; }
  textarea { font-size: 16px; }
  .btn-secondary, .btn-primary { min-height: 44px; }
  .chip { min-height: 38px; }
  .suggest { flex-direction: column; gap: 6px; }
  .result-column:has(.empty-state:not([hidden])) { display: none; }
  .place-name { font-size: 22px; }
  .sample-credits p { right: auto; left: 0; }
  .samples-deck { flex-direction: row; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 8px; }
  .sample-list { display: contents; }
  .sample { flex: 0 0 min(64vw, 240px); scroll-snap-align: start; }
  .fb-dock { right: 16px; bottom: 16px; }
}
@media (hover: none) and (pointer: coarse) {
  .chip, .link-btn, .btn-secondary, .feedback select, .map-link { min-height: 44px; }
  .header-link, .sample-link { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

