/* Host editor: Lamplight day palette (fog, ink, spruce, lamp text) and the night palette of the guest guide
   (dusk, candle ink, moss, lamp). js/mode.js sets <html data-theme> from the System / Light / Dark choice in the
   header; without a choice the system setting decides. The preview follows the same choice unless the host
   flips it above the phone. */
:root {
  --bg: #EEF0EC; --card: #fff; --ink: #16201D; --muted: #56625D; --line: #D9DED9; --line2: #C3CCC6; --field: #fff;
  --accent: #23463C; --primary: #23463C; --primary-hover: #1A372F; --on-primary: #fff; --on-ink: #fff;
  --lamp: #9A5B00; --lamp-bright: #F0B45A; --soft: #E3ECE6; --ok: #2D6A4F; --danger: #B3261E;
  --track: #D5DBD6; --ph: #68736E; --ring: rgba(35, 70, 60, .18); --warn-bg: #FBF0DC; --warn-ink: #5E4310;
  --up-a: #FBF1DE; --up-b: #F6F2EA; --up-line: #EAD9B8; --pro-line: #C9DBD0;
  --shadow: 0 6px 18px -12px rgba(35, 70, 60, .35); --lift: 0 8px 18px -10px rgba(22, 32, 29, .45);
  --r: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121715; --card: #1B2220; --ink: #F1EDE4; --muted: #A9B2AD; --line: #2E3A36; --line2: #3F4E48; --field: #151B19;
    --accent: #8FB79B; --primary: #F0B45A; --primary-hover: #F5C176; --on-primary: #1E1508; --on-ink: #121715;
    --lamp: #F0B45A; --lamp-bright: #F0B45A; --soft: #232C29; --ok: #8FB79B; --danger: #FF9A90;
    --track: #2E3A36; --ph: #87918C; --ring: rgba(143, 183, 155, .28); --warn-bg: #3A2E17; --warn-ink: #F3D9A4;
    --up-a: #2B261B; --up-b: #1E2422; --up-line: #4A3F28; --pro-line: #3A5A4C;
    --shadow: 0 10px 24px -16px rgba(0, 0, 0, .7); --lift: 0 10px 22px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #121715; --card: #1B2220; --ink: #F1EDE4; --muted: #A9B2AD; --line: #2E3A36; --line2: #3F4E48; --field: #151B19;
    --accent: #8FB79B; --primary: #F0B45A; --primary-hover: #F5C176; --on-primary: #1E1508; --on-ink: #121715;
    --lamp: #F0B45A; --lamp-bright: #F0B45A; --soft: #232C29; --ok: #8FB79B; --danger: #FF9A90;
    --track: #2E3A36; --ph: #87918C; --ring: rgba(143, 183, 155, .28); --warn-bg: #3A2E17; --warn-ink: #F3D9A4;
    --up-a: #2B261B; --up-b: #1E2422; --up-line: #4A3F28; --pro-line: #3A5A4C;
    --shadow: 0 10px 24px -16px rgba(0, 0, 0, .7); --lift: 0 10px 22px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
.i { width: 18px; height: 18px; flex: none; }
code { background: var(--soft); color: var(--accent); padding: 1px 6px; border-radius: 6px; font-size: 13px; font-weight: 700; }
button { font: inherit; }

.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); min-height: 44px; min-width: 44px; }
.mark { width: 28px; height: 28px; flex: none; }
.wm { font: 400 25px/1 var(--serif); letter-spacing: -.01em; }
.wm em { color: var(--lamp); }
.guide-pick { flex: 1; min-width: 0; display: flex; }
.pick-btn {
  display: flex; align-items: center; gap: 8px; max-width: 100%; border: 1px solid var(--line); background: var(--card);
  padding: 7px 12px; border-radius: 14px; cursor: pointer; color: var(--ink); font-weight: 800; min-height: 44px;
}
.pick-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-btn .i { color: var(--muted); }
.top-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border-radius: 14px; border: 1.5px solid transparent; background: var(--ink); color: var(--on-ink); cursor: pointer;
  font-weight: 800; text-decoration: none; font-size: 14.5px; white-space: nowrap;
  transition: transform .12s cubic-bezier(.2, .8, .2, 1), box-shadow .12s, background .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--lift); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--line2); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 13.5px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--danger); }
.btn:disabled, .btn[aria-disabled=true] { opacity: .45; pointer-events: none; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 800; display: inline-flex; align-items: center; gap: 4px; text-decoration: underline; text-underline-offset: 3px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 28px; max-width: 1180px; margin: 0 auto; padding: 20px 18px 60px; }
.form { min-width: 0; }
.pane { position: sticky; top: 76px; align-self: start; }
.phone {
  width: 390px; height: min(800px, calc(100vh - 190px)); margin: 0 auto; border-radius: 46px; padding: 10px;
  background: #0E1110; box-shadow: 0 34px 60px -26px rgba(10, 20, 15, .55), inset 0 0 0 1.5px #2C302E;
}
.phone iframe { width: 100%; height: 100%; border: 0; border-radius: 36px; background: #121715; display: block; }
.pane-note { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.only-mobile { display: none; }

/* Progress line: how complete the guide is */
.prog { display: flex; align-items: center; gap: 12px; margin: 0 4px 14px; font-size: 13px; color: var(--muted); }
.prog-t { white-space: nowrap; }
.prog-t strong { color: var(--ink); font-weight: 900; }
.prog-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.prog-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px 22px; margin-bottom: 14px; box-shadow: var(--shadow); }
.panel h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font: 400 27px/1.05 var(--serif); letter-spacing: -.005em; }
.panel h2 .i { color: var(--lamp); width: 20px; height: 20px; }
.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.fld:last-child { margin-bottom: 0; }
.lbl { font-weight: 800; font-size: 13px; color: var(--muted); }
.opt { font-style: normal; font-weight: 600; color: var(--muted); }
.lbl .opt { margin-left: 4px; }
.hint { color: var(--muted); font-size: 13px; }
.hint.lead { margin: -6px 0 14px; display: block; }
input, textarea, select {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--field); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 10px 12px; width: 100%; min-width: 0; min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--ph); font-weight: 500; }
textarea { resize: vertical; line-height: 1.5; min-height: 76px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid2 .fld:last-child { margin-bottom: 14px; }
.panel .grid2:last-child .fld { margin-bottom: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 2px; }
.sw {
  width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; position: relative;
  background: linear-gradient(135deg, var(--sw-eve) 0 50%, var(--sw-day) 50% 100%);
  box-shadow: inset 0 0 0 1px rgba(22, 32, 29, .12); outline-offset: 3px;
}
.sw.on { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ink); }
.sw.on::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 14px; margin: -9px 0 0 -4px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, .7)); }
.cover-thumb { width: 96px; height: 60px; object-fit: cover; border-radius: 10px; }

.sec { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 12px; margin-bottom: 10px; background: var(--card); }
.sec-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sec-ic { width: 36px; height: 36px; border-radius: 50%; background: var(--soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.sec-title { border: 0; background: transparent; font: 400 22px/1.1 var(--serif); padding: 6px 4px; min-height: 40px; }
.sec-title::placeholder { color: var(--ink); opacity: 1; font-weight: 400; }
.sec-title:focus { background: var(--bg); box-shadow: none; }
.sec-tools { display: flex; gap: 0; }
.ib { width: 44px; height: 44px; border: 0; background: none; border-radius: 12px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.ib:hover:not(:disabled) { background: var(--bg); color: var(--ink); }
.ib:disabled { opacity: .3; }
.sec textarea { min-height: 84px; }

.meter-row { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.meter-row > .i { color: var(--accent); margin-top: 2px; }
.bar { height: 6px; border-radius: 6px; background: var(--bg); overflow: hidden; margin: 4px 0 10px; }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--ok); transition: width .3s; }
.bar i.lv-large { background: #B7861F; }
.bar i.lv-tight, .bar i.lv-too-big { background: var(--danger); }
.foot-note { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; justify-content: center; }
.foot-note a { color: var(--accent); padding: 12px 0; }
.foot-note .i { width: 14px; height: 14px; }
.q-madeby { display: inline-flex; align-items: center; gap: .45em; font-weight: 700; color: var(--muted) !important; text-decoration: none; }
.q-madeby svg { height: .8em; width: auto; }

/* onboarding */
body.empty .pane { display: none; }
body.empty .layout { grid-template-columns: 1fr; }
.onb { max-width: 640px; margin: 6vh auto 0; text-align: center; }
.onb-ic { width: 72px; height: 72px; margin: 0 auto 18px; }
.onb-ic svg { width: 100%; height: 100%; display: block; }
.onb h1 { font: 400 clamp(40px, 7vw, 60px)/1 var(--serif); letter-spacing: -.02em; margin: 0 0 16px; }
.onb h1 em { color: var(--lamp); }
.onb > p { color: var(--muted); font-size: 17px; margin: 0 auto 26px; max-width: 34em; }
.onb-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.card-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 18px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); transition: .15s; box-shadow: var(--shadow);
}
.card-btn:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--lift); }
.card-btn .i { color: var(--lamp); width: 24px; height: 24px; margin-bottom: 6px; }
.card-btn strong { font: 400 23px/1.1 var(--serif); }
.card-btn span { color: var(--muted); font-size: 14px; }
.note { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; justify-content: center; }
.note .i { width: 15px; height: 15px; }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 12px; border-radius: 12px; justify-content: flex-start; }

/* dialog */
dialog { border: 0; padding: 0; border-radius: 28px; width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 40px); max-height: calc(100dvh - 32px); background: var(--card); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(10, 20, 15, .45); }
dialog::backdrop { background: rgba(18, 23, 21, .5); backdrop-filter: blur(2px); }
.dlg-in { padding: 24px; position: relative; }
.dlg-in h2 { margin: 0 0 14px; font: 400 30px/1.05 var(--serif); letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; padding-right: 40px; }
.dlg-in h2 .i { color: var(--lamp); width: 22px; height: 22px; }
.dlg-x { position: absolute; right: 12px; top: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--bg); cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.dlg-in .onb { margin: 0 auto; }
.glist { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.glist button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 14px; min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-align: left; color: var(--ink); }
.glist button.on { border-color: var(--accent); background: var(--soft); }
.glist span { flex: 1; font-weight: 800; }
.pro-badge { font-style: normal; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; background: #F2B632; color: #3A2A00; padding: 2px 9px; border-radius: 99px; }
.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kind { display: flex; align-items: center; gap: 9px; padding: 11px 12px; min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-align: left; color: var(--ink); font-weight: 700; font-size: 14px; }
.kind .i { color: var(--accent); }
.kind:hover { border-color: var(--accent); }
.kind.used { opacity: .5; }

.share { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: start; }
.share-qr { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 10px; }
.share-qr svg { display: block; width: 100%; height: auto; }
.share-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.share-side .hint { display: flex; gap: 6px; align-items: flex-start; margin: 0; }
.share-side .hint .i { width: 15px; height: 15px; margin-top: 2px; }
.share-side input { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; font-weight: 500; }
.toobig { aspect-ratio: 1; display: grid; place-content: center; text-align: center; color: var(--danger); padding: 10px; }
.toobig .i { width: 40px; height: 40px; margin: 0 auto; }
.share-pro { margin-top: 20px; }
.upsell { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 18px; background: linear-gradient(160deg, var(--up-a), var(--up-b)); border: 1px solid var(--up-line); }
.upsell > .i { color: var(--lamp); width: 24px; height: 24px; }
.upsell div { flex: 1; display: flex; flex-direction: column; font-size: 13.5px; color: var(--muted); }
.upsell strong { color: var(--ink); font-size: 14.5px; }
.upsell.pro { background: var(--soft); border-color: var(--pro-line); }
.upsell.pro > .i { color: var(--accent); }
.ok-line { display: flex; gap: 8px; align-items: center; color: var(--ok); font-weight: 800; margin: -4px 0 14px; }
.price { font-size: 16px; }
.price strong { font: 400 34px/1 var(--serif); color: var(--ink); }
.ticks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.ticks li { display: flex; gap: 10px; align-items: flex-start; }
.ticks .i { color: var(--ok); margin-top: 2px; }
.center { text-align: center; padding: 30px; color: var(--muted); }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--on-ink); padding: 11px 18px; border-radius: 14px; font-weight: 700; font-size: 14px;
  transition: .25s; z-index: 100; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 14px 12px 80px; }
  .pane { display: none; }
  .only-mobile { display: inline-flex; }
  body.show-preview .pane { display: block; position: fixed; inset: 0; z-index: 50; background: var(--bg); padding: 12px; overflow: auto; }
  body.show-preview .phone { width: 100%; max-width: 420px; height: calc(100vh - 92px); height: calc(100dvh - 92px); border-radius: 28px; padding: 6px; }
  body.show-preview .phone iframe { border-radius: 23px; }
  .close-preview { display: flex; }
  body.show-preview .pane-note { display: none; }
}
/* Phones: preview and share/print sit in a bar at the bottom, within thumb reach. */
@media (max-width: 620px) {
  .top { padding: 8px 12px; gap: 10px; backdrop-filter: none; background: var(--bg); } /* a filter would trap the fixed action bar */
  .wm { font-size: 22px; }
  body:not(.empty) .logo .wm { display: none; }
  .top-actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  }
  .top-actions .btn { min-height: 48px; font-size: 15px; }
  body.empty .top-actions { display: none; }
  .layout { padding-bottom: 96px; }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .grid2, .onb-btns, .share { grid-template-columns: 1fr; }
  .grid2 .fld { margin-bottom: 14px !important; }
  .share-qr { max-width: 260px; margin: 0 auto; width: 100%; }
  .kinds { grid-template-columns: 1fr 1fr; }
  .panel { padding: 16px; }
  .btn { padding: 8px 12px; }
  .upsell { flex-wrap: wrap; }
  .upsell div { flex-basis: calc(100% - 38px); }
  .upsell .btn { width: 100%; justify-content: center; }
  .dlg-in { padding: 20px 16px; }
  .dlg-in h2 { font-size: 26px; }
}
.langs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin-bottom: 14px; }
.lang { display: flex; gap: 8px; align-items: center; padding: 7px 10px; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 600; }
.lang input { width: auto; min-height: 0; accent-color: var(--accent); }
.panel h2 .pro-badge { margin-left: 4px; font-family: var(--sans); }
.warn-t { color: var(--lamp); }
#shareBtn.dirty { position: relative; }
#shareBtn.dirty::after { content: ""; position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--lamp-bright); border: 2px solid var(--bg); }

/* Focus and motion (Qloovi signature 1.7, 1.8) */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 1.5s linear infinite !important; }
  .btn:active, .btn:hover, .card-btn:hover { transform: none; }
}
.sec-note { margin: 6px 2px 0; }
.sec-note a { color: inherit; }

/* Colour mode: header button with a small menu (js/mode.js fills it), and the preview's light/dark flip */
.mode-menu { position: relative; flex: none; }
.mode-btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.mode-btn:hover:not(:disabled) { background: var(--card); border-color: var(--line2); }
.mode-btn .i { width: 20px; height: 20px; }
.mode-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; padding: 12px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); box-shadow: 0 24px 50px -20px rgba(0, 0, 0, .45);
}
.mode-pop[hidden] { display: none; }
.mode-l { display: block; font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px 4px; }
.mode-seg, .pv-mode { display: inline-flex; gap: 2px; padding: 3px; border-radius: 15px; background: var(--bg); border: 1px solid var(--line); }
.mode-seg button, .pv-mode button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 6px 12px;
  border: 0; border-radius: 12px; background: none; color: var(--muted); font-weight: 800; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.mode-seg button .i, .pv-mode button .i { width: 17px; height: 17px; }
.mode-seg button[aria-checked="true"], .pv-mode button[aria-checked="true"] { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line2), 0 2px 6px -3px rgba(0, 0, 0, .3); }
.mode-seg button[aria-checked="true"] .i, .pv-mode button[aria-checked="true"] .i { color: var(--lamp); }
.pane-bar { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.pv-l { font-size: 13px; font-weight: 800; color: var(--muted); }
.pv-mode button { min-height: 36px; padding: 4px 12px; font-size: 13.5px; }
@media (max-width: 980px) {
  .pane-bar .pv-l { display: none; }
  .pv-mode button { min-height: 44px; }
}
