:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --ink: #1d1a17;
  --muted: #6e675e;
  --line: #e2ddd4;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3da;
  --teal: #0f766e;
  --warn: #b45309;
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 8px 24px rgb(0 0 0 / 0.06);
  --radius: 14px;
  --display: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Faint topographic contour lines behind the whole site. */
  --topo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='560' height='560' viewBox='0 0 560 560' fill='none' stroke='%23ddd4c5' stroke-width='1.1'%3E%3Cpath d='M-20 80C80 40 170 120 280 95S470 40 580 80'/%3E%3Cpath d='M-20 118C90 80 180 158 290 133S470 82 580 118'/%3E%3Cpath d='M-20 156C100 122 190 196 300 171S470 124 580 156'/%3E%3Cellipse cx='400' cy='330' rx='60' ry='38'/%3E%3Cellipse cx='400' cy='330' rx='100' ry='66'/%3E%3Cellipse cx='400' cy='330' rx='140' ry='94'/%3E%3Cellipse cx='120' cy='390' rx='34' ry='24'/%3E%3Cellipse cx='120' cy='390' rx='70' ry='50'/%3E%3Cpath d='M-20 520C100 480 200 556 320 522S480 476 580 520'/%3E%3C/svg%3E");
  /* Home page: dotted flight path from a map pin to a paper plane. */
  --flight: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 520 200' fill='none'%3E%3Cpath d='M30 168C140 30 330 10 480 92' stroke='%23e4572e' stroke-width='2.5' stroke-linecap='round' stroke-dasharray='1 10' opacity='.75'/%3E%3Ccircle cx='30' cy='172' r='9' fill='%23e4572e'/%3E%3Ccircle cx='30' cy='172' r='3.5' fill='%23fff'/%3E%3Cg transform='translate(494 101) rotate(30)'%3E%3Cpath d='M12 0L-14 -10L-8 0L-14 10Z' fill='%23e4572e'/%3E%3Cpath d='M-8 0L-14 10' stroke='%23b8401d' stroke-width='1.2'/%3E%3C/g%3E%3Ccircle cx='260' cy='46' r='3' fill='%230f766e' opacity='.6'/%3E%3Ccircle cx='150' cy='88' r='2.5' fill='%230f766e' opacity='.45'/%3E%3Ccircle cx='390' cy='54' r='2.5' fill='%230f766e' opacity='.45'/%3E%3C/svg%3E");
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131210;
    --surface: #1c1a17;
    --surface-2: #26231f;
    --ink: #f1ede6;
    --muted: #a39b90;
    --line: #34302a;
    --accent: #f06a43;
    --accent-soft: #3a2219;
    --teal: #2dd4bf;
    --warn: #f59e0b;
    --danger: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
    --topo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='560' height='560' viewBox='0 0 560 560' fill='none' stroke='%232b2722' stroke-width='1.1'%3E%3Cpath d='M-20 80C80 40 170 120 280 95S470 40 580 80'/%3E%3Cpath d='M-20 118C90 80 180 158 290 133S470 82 580 118'/%3E%3Cpath d='M-20 156C100 122 190 196 300 171S470 124 580 156'/%3E%3Cellipse cx='400' cy='330' rx='60' ry='38'/%3E%3Cellipse cx='400' cy='330' rx='100' ry='66'/%3E%3Cellipse cx='400' cy='330' rx='140' ry='94'/%3E%3Cellipse cx='120' cy='390' rx='34' ry='24'/%3E%3Cellipse cx='120' cy='390' rx='70' ry='50'/%3E%3Cpath d='M-20 520C100 480 200 556 320 522S480 476 580 520'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--topo) center top / 560px 560px repeat, var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font: 650 1.45rem/1 var(--display);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand::before {
  content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); margin-right: 10px; vertical-align: 0.15em;
}
.owner-nav { display: flex; gap: 8px; }

main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 40px) 64px;
  outline: none;
}

.footer {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 20px clamp(16px, 4vw, 40px);
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.85rem;
}
.footer a { text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer .prompt {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-weight: 600; letter-spacing: 0.05em; padding: 0 4px;
}
.footer .prompt:hover { text-decoration: none; color: var(--accent); }
.prompt .cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .prompt .cursor { animation: none; } }

/* ---------- buttons & forms ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer;
  font-weight: 500; font-size: 0.92rem; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.05); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 0.85rem; }

label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="text"], input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
.hint { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.error { color: var(--danger); font-size: 0.9rem; min-height: 1.4em; }

/* ---------- home ---------- */

.hero { margin-bottom: clamp(28px, 5vw, 48px); position: relative; }
.hero > * { position: relative; z-index: 1; }
.hero::after {
  content: ""; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: min(46vw, 520px); aspect-ratio: 520 / 200;
  background: var(--flight) no-repeat center / contain;
  pointer-events: none;
}
@media (max-width: 700px) {
  .hero::after { width: 70vw; top: auto; bottom: -10px; transform: none; opacity: .35; }
}
.hero h1 {
  font: 650 clamp(2.2rem, 6vw, 4rem)/1.05 var(--display);
  letter-spacing: -0.02em; margin: 0 0 10px;
}
.hero p { color: var(--muted); margin: 0; font-size: 1.05rem; }

.trip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: clamp(16px, 2.5vw, 28px);
}
.trip-card {
  display: block; text-decoration: none;
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.trip-card:hover { transform: translateY(-3px); }
.trip-cover {
  aspect-ratio: 4 / 3; background: var(--surface-2); position: relative; overflow: hidden;
}
.trip-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.trip-cover img.cover-next {
  position: absolute; inset: 0; opacity: 0; transition: opacity 1.2s ease, transform .5s ease;
}
.trip-cover img.cover-next.shown { opacity: 1; }
.trip-card:hover .trip-cover img { transform: scale(1.04); }
.trip-cover .empty-cover {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 0.9rem;
}
.trip-body { padding: 14px 16px 16px; }
.trip-body h2 { font: 600 1.25rem/1.25 var(--display); margin: 0 0 4px; }
.meta { color: var(--muted); font-size: 0.88rem; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 0.78rem; font-weight: 600;
}
.chip-muted { background: var(--surface-2); color: var(--muted); }

.empty {
  text-align: center; padding: 64px 16px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty h2 { font: 600 1.4rem var(--display); color: var(--ink); margin: 0 0 6px; }

/* ---------- trip page ---------- */

.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 18px; font-size: 0.92rem; }
.back:hover { color: var(--ink); }
.trip-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.trip-head h1 { font: 650 clamp(2rem, 5vw, 3.2rem)/1.08 var(--display); letter-spacing: -0.02em; margin: 0 0 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

.gallery { columns: 3 300px; column-gap: 14px; }
.gallery .tile {
  break-inside: avoid; margin: 0 0 14px; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); cursor: zoom-in; position: relative; display: block;
  border: 0; padding: 0; width: 100%;
}
.gallery .tile img { width: 100%; height: auto; transition: opacity .3s; }
.gallery .tile:hover img { opacity: .92; }
.tile .tile-place {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 12px 10px;
  background: linear-gradient(transparent, rgb(0 0 0 / .6)); color: #fff;
  font-size: 0.82rem; text-align: left; opacity: 0; transition: opacity .2s;
}
.tile:hover .tile-place, .tile:focus-visible .tile-place { opacity: 1; }

/* ---------- trip description ---------- */

.trip-desc { max-width: 760px; margin: -12px 0 32px; }
.trip-desc p { font-size: 1.08rem; line-height: 1.7; margin: 0 0 10px; }
.card-desc {
  color: var(--muted); font-size: 0.88rem; margin: 8px 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- map ---------- */

.map-section { margin-bottom: 36px; }
.map-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.map-section h2 { font: 600 1.25rem var(--display); margin: 0; }
.map {
  display: block; width: 100%; border: 0;
  height: clamp(300px, 50vh, 480px); border-radius: var(--radius);
  background: var(--surface-2); box-shadow: var(--shadow);
}
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.seg button {
  border: 0; background: none; cursor: pointer; padding: 5px 14px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 500; color: var(--muted);
}
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.map-info {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
}
.map-info .map-pop-actions { margin-top: 0; }
.map-section > .hint { margin: 14px 0 0; }
.place-row.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.places {
  list-style: none; padding: 0; margin: 14px 0 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px;
}
.place-row {
  width: 100%; display: flex; gap: 12px; align-items: flex-start; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; cursor: pointer;
}
.place-row:hover { border-color: var(--muted); }
.place-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; background: var(--surface-2); }
.place-text { display: grid; gap: 2px; min-width: 0; }
.place-text strong { font-weight: 600; font-size: 0.95rem; }
.place-addr { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.place-meta { color: var(--muted); font-size: 0.78rem; }
.map-pop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.lb-addr { color: #b8b1a7; font-size: 0.85rem; margin-top: 4px; }
.lb-addr a { color: #fff; }

/* ---------- review drafts ---------- */

.review {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 32px;
}
.review-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
.review-head h2 { font: 600 1.25rem var(--display); margin: 0; }
.draft {
  display: grid; grid-template-columns: 180px 1fr; gap: 16px;
  padding: 16px 0; border-top: 1px solid var(--line);
}
.draft img { width: 180px; height: 135px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.draft .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.status { font-size: 0.82rem; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.status.pending { color: var(--muted); }
.status.failed { color: var(--danger); }
.status.done { color: var(--teal); }
.status .conf-low { color: var(--warn); }
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress { color: var(--muted); font-size: 0.9rem; margin: 0 0 16px; }

/* ---------- login ---------- */

.card-narrow {
  max-width: 400px; margin: 4vh auto 0; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px;
}
.card-narrow h1 { font: 650 1.8rem var(--display); margin: 0 0 18px; }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgb(10 9 8 / .94);
  display: grid; grid-template-columns: 64px 1fr 64px; align-items: center;
}
.lb-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 14px; max-height: 100vh; padding: 24px 0; }
.lb-figure img { max-width: 100%; max-height: calc(100vh - 180px); object-fit: contain; border-radius: 6px; }
.lb-figure figcaption { color: #eee; max-width: 720px; text-align: center; padding: 0 12px; }
.lb-figure figcaption .lb-place { font: 600 1.15rem var(--display); color: #fff; }
.lb-figure figcaption p { margin: 6px 0 0; color: #cfc9c0; font-size: 0.95rem; }
.lb-owner { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.lb-owner .btn { background: rgb(255 255 255 / .08); border-color: rgb(255 255 255 / .2); color: #fff; }
.lb-owner textarea, .lb-owner input { background: rgb(255 255 255 / .06); color: #fff; border-color: rgb(255 255 255 / .2); text-align: left; }
.lb-edit { width: min(640px, 92vw); text-align: left; }
.lb-edit label { color: #ddd; }
.lb-nav, .lb-close {
  background: none; border: 0; color: #fff; cursor: pointer; opacity: .75;
}
.lb-nav:hover, .lb-close:hover { opacity: 1; }
.lb-nav { font-size: 3rem; height: 100%; }
.lb-close { position: absolute; top: 8px; right: 14px; font-size: 2.2rem; z-index: 2; }

/* ---------- modal & toasts ---------- */

.modal {
  border: 0; border-radius: var(--radius); padding: 24px;
  width: min(480px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgb(0 0 0 / .45); }
.modal h2 { font: 600 1.4rem var(--display); margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
.toast {
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow); font-size: 0.92rem; max-width: calc(100vw - 32px);
  animation: rise .2s ease;
}
.toast.err { background: var(--danger); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .draft { grid-template-columns: 1fr; }
  .draft img { width: 100%; height: auto; aspect-ratio: 4 / 3; }
  .field-row { grid-template-columns: 1fr; }
  .lightbox { grid-template-columns: 40px 1fr 40px; }
  .lb-nav { font-size: 2.2rem; }
  .owner-nav .btn { padding: 6px 12px; }
}
