:root {
  --sage: #8a9a7b; --sage-deep: #5f6f52; --moss: #3f4a35; --sage-light: #dde3d3; --sage-mist: #eef1e8;
  --cream: #f7f3ea; --sand: #ebe3d3; --clay: #b5694a; --clay-deep: #96523a;
  --bark: #3d3226; --bark-soft: #6b5d4d; --line: #ddd4c2; --danger: #a33b2b;
  --radius: 12px; --shadow: 0 1px 2px rgba(61,50,38,.06), 0 6px 18px rgba(61,50,38,.08);
  --serif: 'Fraunces', Georgia, serif; --sans: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--bark); font: 400 1.0625rem/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2 { font-family: var(--serif); font-weight: 600; color: var(--moss); line-height: 1.2; }
h1 { font-size: clamp(1.7rem, 5vw, 2.2rem); margin: 0; }
h2 { font-size: 1.3rem; margin: 0 0 4px; }
a { color: var(--sage-deep); }
img { max-width: 100%; display: block; }
code { background: var(--sand); padding: 1px 6px; border-radius: 4px; font-size: .9em; }
:focus-visible { outline: 3px solid var(--clay); outline-offset: 2px; }
.a-wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.narrow-admin { max-width: 680px; }
.hint { color: var(--bark-soft); font-size: .92rem; font-weight: 400; }

.a-header { background: var(--sage-deep); color: var(--cream); }
.a-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.a-brand { display: flex; align-items: center; gap: 10px; color: var(--cream); text-decoration: none; font: 600 1.25rem/1.1 var(--serif); }
.a-brand .mark { width: 28px; height: 28px; color: var(--sage-light); }
.a-brand small { font: 600 .72rem/1 var(--sans); text-transform: uppercase; letter-spacing: .12em; opacity: .75; margin-left: 4px; }
.a-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.a-nav a, .a-nav .linklike { color: var(--cream); text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.a-nav a:hover, .a-nav a[aria-current="page"], .a-nav .linklike:hover { background: rgba(247,243,234,.15); color: #fff; }
.a-nav form { margin: 0; }
.a-main { padding: 28px 0 120px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--sage-deep); color: #fff; border: 2px solid var(--sage-deep);
  padding: 10px 18px; border-radius: 999px; font: 700 1rem/1.2 var(--sans); text-decoration: none; cursor: pointer; min-height: 44px; }
.btn:hover { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn.big { padding: 12px 22px; font-size: 1.05rem; }
.btn.clay { background: var(--clay); border-color: var(--clay); }
.btn.clay:hover { background: var(--clay-deep); border-color: var(--clay-deep); }
.btn.ghost { background: #fff; color: var(--sage-deep); }
.btn.ghost:hover { background: var(--sage-mist); color: var(--moss); }
.btn:disabled { opacity: .6; cursor: progress; }
.linklike { background: none; border: 0; padding: 0; color: var(--sage-deep); font: inherit; text-decoration: underline; cursor: pointer; }
.linklike.danger, .danger { color: var(--danger); }

.flash { padding: 12px 16px; border-radius: var(--radius); margin: 0 0 20px; font-weight: 600; }
.flash.ok { background: var(--sage-mist); color: var(--moss); border: 1px solid var(--sage-light); }
.flash.error { background: #f8e6e1; color: var(--danger); border: 1px solid #ecc7bd; }

input, textarea, select { font: inherit; color: inherit; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; color: var(--moss); }
input:not([type=hidden]):not([type=file]):not([type=checkbox]), textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-weight: 400; color: var(--bark); min-height: 46px; }
input:focus, textarea:focus { border-color: var(--sage); outline: 3px solid var(--sage-light); outline-offset: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.card-form { background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 24px; }
.card-form .btn { align-self: flex-start; }

/* login */
.login-box { max-width: 400px; margin: 8vh auto 0; padding: 0 16px; }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .mark { width: 52px; height: 52px; color: var(--sage-deep); margin: 0 auto 8px; }
.login-brand h1 { font-size: 2.2rem; }
.login-brand p { margin: 2px 0 0; color: var(--bark-soft); text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; font-weight: 700; }
.login-box form { background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); }

/* dashboard */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.back { font-weight: 700; text-decoration: none; }
.storage { background: #fff; border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); margin-bottom: 20px; font-size: .92rem; color: var(--bark-soft); }
.storage-row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-weight: 600; }
.meter { height: 8px; background: var(--sage-mist); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--sage); border-radius: 999px; }
.meter.warn span { background: var(--clay); }
.empty-state { text-align: center; padding: 48px 16px; color: var(--bark-soft); background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-state .mark { width: 56px; height: 56px; color: var(--sage); margin: 0 auto 8px; }
.post-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.post-list li { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: var(--radius); padding: 10px 16px 10px 10px; box-shadow: var(--shadow); }
.pl-main { flex: 1; display: flex; align-items: center; gap: 14px; min-width: 0; text-decoration: none; color: inherit; }
.pl-thumb { flex: none; width: 72px; height: 56px; border-radius: 8px; overflow: hidden; background: var(--sage-light); display: grid; place-items: center; color: var(--sage); }
.pl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pl-thumb .mark { width: 28px; height: 28px; }
.pl-text { display: flex; flex-direction: column; min-width: 0; }
.pl-text strong { font-family: var(--serif); font-size: 1.15rem; color: var(--moss); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-meta { color: var(--bark-soft); font-size: .9rem; }
.pl-actions { display: flex; gap: 14px; font-weight: 700; font-size: .95rem; }
.badge { flex: none; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 10px; border-radius: 999px; }
.badge.published { background: var(--sage-mist); color: var(--sage-deep); }
.badge.draft { background: #f3e6d6; color: var(--clay-deep); }

/* editor */
.editor-wrap { max-width: 860px; }
.title-input { font: 600 clamp(1.5rem, 4.5vw, 2rem)/1.2 var(--serif) !important; color: var(--moss) !important; padding: 14px 16px !important; }
.editor-form { display: flex; flex-direction: column; gap: 18px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.label { font-weight: 700; color: var(--moss); }
.label-row { display: flex; flex-direction: column; gap: 2px; margin-bottom: -10px; }
.cover-field { background: #fff; border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.cover-preview img { max-height: 200px; border-radius: 8px; }
.cover-preview:empty { display: none; }
.cover-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.editor-shell { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.editor-shell .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--line); padding: 8px; position: sticky; top: 0; background: #fff; z-index: 3; border-radius: var(--radius) var(--radius) 0 0; font-family: var(--sans); }
.editor-shell .ql-container.ql-snow { border: 0; font: 400 1.125rem/1.7 var(--sans); }
.editor-shell .ql-editor { min-height: 45vh; padding: 20px 22px 40px; }
.editor-shell .ql-editor.ql-blank::before { color: #a99c8a; font-style: italic; left: 22px; }
.editor-shell .ql-editor h2, .editor-shell .ql-editor h3 { font-family: var(--serif); color: var(--moss); }
.editor-shell .ql-editor img, .editor-shell .ql-editor video { max-width: 100%; border-radius: 8px; margin: 10px 0; }
.editor-shell .ql-editor video { width: 100%; background: #000; }
.editor-shell .ql-editor blockquote { border-left: 4px solid var(--sage); font-style: italic; color: var(--moss); }
.ql-snow .ql-toolbar button, .ql-snow.ql-toolbar button { width: 34px; height: 32px; }
.ql-snow .ql-picker.ql-header { width: 130px; }
.media-btns { display: inline-flex !important; gap: 6px; }
.ql-snow.ql-toolbar button.tb-media { width: auto; height: 34px; padding: 4px 12px; background: var(--sage-mist); color: var(--moss); border-radius: 999px; font: 700 .92rem/1 var(--sans); }
.ql-snow.ql-toolbar button.tb-media:hover { background: var(--sage-light); color: var(--moss); }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--clay); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--clay); }
.ql-snow.ql-toolbar button.ql-active, .ql-snow .ql-picker-label.ql-active { color: var(--clay); }

.uploads { display: flex; flex-direction: column; gap: 8px; }
.editor-form .uploads { position: fixed; right: 16px; bottom: 84px; width: min(440px, calc(100% - 32px)); z-index: 11; max-height: 50vh; overflow: auto; }
.uploads:empty { display: none; }
.up-row { border: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) 140px auto auto; align-items: center; gap: 12px; background: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: .95rem; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { height: 8px; background: var(--sage-mist); border-radius: 999px; overflow: hidden; }
.up-bar span { display: block; height: 100%; width: 0; background: var(--sage); transition: width .3s; }
.up-status { color: var(--bark-soft); font-weight: 600; white-space: nowrap; }
.up-row.ok .up-status { color: var(--sage-deep); }
.up-row.err { grid-template-columns: minmax(0, 1fr) auto; }
.up-row.err .up-bar { display: none; }
.up-row.err .up-status { color: var(--danger); white-space: normal; grid-column: 1 / -1; }

.save-bar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(247,243,234,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); z-index: 10; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
.save-inner { display: flex; justify-content: flex-end; align-items: center; gap: 10px; max-width: 860px; }
.save-msg { margin-right: auto; color: var(--bark-soft); font-weight: 600; }
.danger-zone { margin-top: 40px; text-align: right; }

/* media library */
.media-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.media-grid li { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.mg-thumb { position: relative; aspect-ratio: 1; background: var(--sage-light); display: grid; place-items: center; }
.mg-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mg-thumb .vid { font-size: 2.4rem; }
.mg-thumb .play { position: absolute; width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; font-size: 1rem; }
.mg-info { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; font-size: .88rem; min-width: 0; }
.mg-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.mg-info small { color: var(--bark-soft); }
.mg-info form { margin: 2px 0 0; }

@media (max-width: 680px) {
  .a-header-inner { justify-content: center; }
  .a-nav { justify-content: center; }
  .a-nav a, .a-nav .linklike { padding: 6px 9px; font-size: .9rem; }
  .row { grid-template-columns: 1fr; }
  .post-list li { flex-wrap: wrap; }
  .pl-actions { width: 100%; justify-content: flex-end; }
  .page-head .btn.big { width: 100%; }
  .up-row { grid-template-columns: minmax(0, 1fr) auto; }
  .up-bar { grid-column: 1 / -1; grid-row: 2; }
  .save-inner .btn { padding: 10px 14px; }
  .save-msg { display: none; }
  .editor-shell .ql-editor { padding: 16px 14px 32px; }
}

/* travel map */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.map-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 12px 4px; }
.map-frame { background: var(--sage-mist); border-radius: 10px; padding: 6px; }
.worldmap { display: block; width: 100%; height: auto; }
.worldmap .c { fill: #d9d2c0; stroke: var(--sage-mist); stroke-width: .6; cursor: pointer; transition: fill .12s; }
.worldmap .c:hover, .worldmap .c:focus { fill: #c2b89f; outline: none; }
.worldmap .c.on { fill: var(--sage-deep); }
.worldmap .c.on:hover, .worldmap .c.on:focus { fill: var(--moss); }
.worldmap .dot { fill: #b9ae95; stroke: #fff; stroke-width: 1; cursor: pointer; }
.worldmap .dot.on { fill: var(--sage-deep); }
.worldmap .dot:hover, .worldmap .dot:focus { fill: var(--clay); outline: none; }
.map-tip { margin: 6px 4px 6px; min-height: 1.6em; color: var(--bark-soft); font-weight: 600; }
.picker { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-top: 18px; }
.picker-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.picker-head .search { flex: 1; min-width: 220px; }
.picked { color: var(--bark-soft); font-weight: 600; }
.picked strong { color: var(--sage-deep); font-size: 1.2rem; }
.country-list { list-style: none; margin: 0; padding: 0; columns: 3 200px; column-gap: 18px; }
.country-list li { break-inside: avoid; }
.country-list label { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; color: var(--bark); padding: 6px 8px; border-radius: 8px; cursor: pointer; min-height: 40px; }
.country-list label:hover { background: var(--sage-mist); }
.country-list input { width: 20px; height: 20px; accent-color: var(--sage-deep); flex: none; }
.country-list input:checked + * , .country-list label:has(input:checked) { font-weight: 700; color: var(--moss); }

/* story filter tabs */
.tabs { display: flex; gap: 6px; margin: 0 0 14px; flex-wrap: wrap; }
.tab { text-decoration: none; font-weight: 700; color: var(--bark-soft); padding: 8px 14px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); min-height: 40px; display: inline-flex; align-items: center; gap: 8px; }
.tab .n { font-size: .8rem; background: var(--sage-mist); color: var(--sage-deep); border-radius: 999px; padding: 1px 8px; }
.tab[aria-current="page"] { background: var(--sage-deep); color: #fff; }
.tab[aria-current="page"] .n { background: rgba(255,255,255,.2); color: #fff; }
.pl-edited { font-size: .82rem; font-style: italic; }

/* "Where?" place search */
.place-field { display: flex; flex-direction: column; gap: 6px; }
.place-field > label { margin: 0; }
.place-combo { position: relative; }
.place-combo input { width: 100%; }
.place-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); list-style: none; margin: 0; padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; }
.place-list li[role=option] { padding: 9px 12px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; line-height: 1.3; }
.place-list li[role=option] strong { color: var(--moss); }
.place-list li[role=option] span { color: var(--bark-soft); font-size: .88rem; }
.place-list li[aria-selected="true"], .place-list li[role=option]:hover { background: var(--sage-mist); }
.place-list .powered { font-size: .72rem; color: var(--bark-soft); text-align: right; padding: 4px 10px 2px; }
.place-chip { margin: 0; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; background: var(--sage-mist); color: var(--moss); border-radius: 10px; padding: 8px 12px; font-size: .92rem; }
.place-chip strong { font-weight: 700; }
.place-status { margin: 0; min-height: 0; }
.place-status:empty { display: none; }
.hint.limits { display: block; margin-top: 2px; font-weight: 600; color: var(--sage-deep); }
.up-row.err .up-status { line-height: 1.4; }

/* important places */
.worldmap .landmarks { pointer-events: none; } /* clicks fall through to the country underneath */
.worldmap .lm-pin { fill: #a8323a; stroke: #fff; stroke-width: 1.4; }
.worldmap .lm-star { fill: #ffd36b; }
.worldmap .landmark text { font: 700 13px var(--sans); fill: var(--bark); stroke: #fff; stroke-width: 3.2px; stroke-linejoin: round; paint-order: stroke; }
.ip-section h2 { margin: 0 0 4px; font-size: 1.25rem; color: #a8323a; }
.ip-section > .hint { margin: 0 0 12px; }
.ip-section .place-status { margin-top: 6px; }
.ip-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.ip-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; background: var(--sage-mist); }
.ip-star { color: #a8323a; font-size: 1.2rem; flex: none; }
.ip-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ip-label { font: inherit; font-weight: 700; color: var(--moss); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; margin-left: -6px; min-height: 0; width: 100%; }
.ip-label:hover { border-color: var(--line); background: #fff; }
.ip-label:focus { border-color: var(--sage-deep); background: #fff; outline: none; }
.ip-addr { font-size: .85rem; color: var(--bark-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ip-remove { flex: none; }
