/* Home Ghost V2 — shared styles. Copyright (c) 2026 Marc Cherenson. */
:root {
  --ink: #15212b;
  --ink-2: #2a3946;
  --mist: #eef3f1;
  --paper: #ffffff;
  --sage: #3d8b7b;
  --sage-dark: #2c6b5f;
  --sage-soft: #dcefe9;
  --line: #dbe4e1;
  --muted: #617079;
  --warn: #a8501b;
  --warn-soft: #fbeee4;
  --radius: 16px;
  --display: 'Fraunces', Georgia, serif;
  --body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--body); color: var(--ink); background: var(--mist); -webkit-font-smoothing: antialiased; }
a { color: var(--sage-dark); }
button { font: inherit; cursor: pointer; }

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 600; font-size: 24px; letter-spacing: -0.3px; color: var(--ink); text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }

/* ---------- gate / landing ---------- */
.gate { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 18px 40px;
  background: radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, var(--mist) 55%, #e2ebe8 100%); }
.gate-card { width: 100%; max-width: 460px; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 34px 28px 28px; box-shadow: 0 18px 50px rgba(21,33,43,0.08); }
.gate-card .brand { justify-content: center; font-size: 30px; margin-bottom: 18px; }
.gate-card .brand svg { width: 38px; height: 38px; }
.gate h1 { font-family: var(--display); font-weight: 500; font-size: 25px; line-height: 1.25; text-align: center; letter-spacing: -0.3px; margin-bottom: 12px; }
.gate .lede { color: var(--muted); text-align: center; font-size: 15.5px; line-height: 1.55; margin-bottom: 26px; }
.gate label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.code-input { width: 100%; padding: 15px; border: 2px solid var(--line); border-radius: 12px; font: 600 18px var(--body); text-align: center; letter-spacing: 3px; text-transform: uppercase; color: var(--ink); background: #fbfdfc; }
.code-input:focus { outline: none; border-color: var(--sage); background: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: 12px; padding: 14px 18px; font-weight: 600; font-size: 16px; text-decoration: none; transition: background .15s, transform .1s; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--sage); color: #fff; }
.btn-primary:hover { background: var(--sage-dark); }
.btn-ghost { background: transparent; color: var(--ink-2); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--sage); color: var(--sage-dark); }
.btn-block { width: 100%; margin-top: 14px; }
.alert { background: var(--warn-soft); color: var(--warn); border: 1px solid #f1d2bd; padding: 12px 14px; border-radius: 10px; font-size: 14.5px; line-height: 1.45; margin-bottom: 18px; }
.fine { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.6; color: var(--muted); text-align: center; }
.points { list-style: none; margin: 0 0 26px; display: grid; gap: 10px; }
.points li { display: flex; gap: 10px; font-size: 14.5px; line-height: 1.45; color: var(--ink-2); }
.points li::before { content: ''; flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--sage); }
.legal { max-width: 460px; margin-top: 18px; font-size: 12px; line-height: 1.55; color: var(--muted); text-align: center; }

/* ---------- app ---------- */
.app { height: 100%; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; background: var(--mist); }
.topbar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: rgba(238,243,241,0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .brand { font-size: 21px; }
.topbar .actions { display: flex; gap: 8px; }
.chip-btn { background: var(--paper); border: 1px solid var(--line); color: var(--ink-2); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600; }
.chip-btn:hover { border-color: var(--sage); }

.screen { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.start { padding: 36px 20px 30px; display: flex; flex-direction: column; align-items: stretch; }
.start h2 { font-family: var(--display); font-weight: 500; font-size: 30px; line-height: 1.2; text-align: center; letter-spacing: -0.4px; margin: 8px 0 26px; }
.answer { display: block; width: 100%; text-align: left; background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 18px 18px; margin-bottom: 12px; transition: border-color .15s, box-shadow .15s; }
.answer:hover, .answer:focus-visible { border-color: var(--sage); box-shadow: 0 6px 18px rgba(61,139,123,0.12); outline: none; }
.answer strong { display: block; font-size: 18px; margin-bottom: 4px; color: var(--ink); }
.answer span { font-size: 14.5px; color: var(--muted); line-height: 1.45; }
.answer.yes strong::before { content: '● '; color: var(--sage); }
.start .note { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.55; }

.section-label { font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin: 30px 2px 10px; }
.visit { display: block; width: 100%; text-align: left; background: transparent; border: none; border-top: 1px solid var(--line); padding: 13px 2px; color: var(--ink); }
.visit:hover { background: rgba(255,255,255,0.5); }
.visit .when { font-size: 13px; color: var(--muted); }
.visit .what { font-size: 15px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .4px; padding: 2px 8px; border-radius: 999px; margin-right: 6px; vertical-align: 1px; }
.tag.live { background: var(--sage-soft); color: var(--sage-dark); }
.tag.prep { background: #e7ebf1; color: #475569; }

.modebar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; font-size: 14px; border-bottom: 1px solid var(--line); background: var(--paper); }
.modebar .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--sage); margin-right: 7px; box-shadow: 0 0 0 4px var(--sage-soft); vertical-align: 0; }
.modebar.prep .dot { background: #94a3b8; box-shadow: 0 0 0 4px #e7ebf1; }
.arrived { background: var(--sage); color: #fff; border: none; border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600; }

.thread { padding: 18px 14px 10px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 12px 15px; border-radius: 18px; font-size: 16px; line-height: 1.5; word-wrap: break-word; }
.msg p + p, .msg p + ul, .msg ul + p { margin-top: 8px; }
.msg ul, .msg ol { padding-left: 20px; }
.msg li + li { margin-top: 4px; }
.msg.assistant { align-self: flex-start; background: var(--paper); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.user { align-self: flex-end; background: var(--ink); color: #f3f7f6; border-bottom-right-radius: 6px; }
.msg.gate { align-self: center; background: transparent; border: none; color: var(--muted); font-size: 13.5px; padding: 2px 8px; }
.typing { display: inline-flex; gap: 5px; padding: 16px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9fb1ab; animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.composer { flex: none; display: flex; gap: 10px; align-items: flex-end; padding: 10px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; font: 16px/1.4 var(--body); color: var(--ink); max-height: 160px; min-height: 48px; background: #fbfdfc; }
.composer textarea:focus { outline: none; border-color: var(--sage); background: #fff; }
.send { flex: none; height: 48px; padding: 0 18px; border-radius: 14px; border: none; background: var(--sage); color: #fff; font-weight: 700; font-size: 16px; }
.send:disabled { background: #a9c9c1; cursor: default; }
.toast { margin: 0 14px 10px; padding: 10px 13px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; line-height: 1.45; }

.drawer-bg { position: fixed; inset: 0; background: rgba(21,33,43,0.35); display: none; z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); background: var(--mist); z-index: 21; transform: translateX(105%); transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(21,33,43,0.15); }
.drawer.open { transform: none; } .drawer-bg.open { display: block; }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.drawer header h3 { font-family: var(--display); font-weight: 500; font-size: 21px; }
.drawer .body { flex: 1; overflow-y: auto; padding: 4px 16px 20px; }
.drawer .access { font-size: 13.5px; color: var(--muted); padding: 14px 0 4px; line-height: 1.5; }
.empty { color: var(--muted); font-size: 14.5px; padding: 14px 2px; }
.hidden { display: none !important; }

/* ---------- admin ---------- */
.admin { max-width: 1100px; margin: 0 auto; padding: 22px 18px 60px; }
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.admin nav { display: flex; gap: 8px; flex-wrap: wrap; }
.admin nav a, .admin nav button { background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.admin nav a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 18px; }
.panel h2 { font-family: var(--display); font-weight: 500; font-size: 20px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.row input, .row select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font: 15px var(--body); }
.admin .btn { padding: 10px 14px; font-size: 14.5px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
td form { display: inline; }
.mini { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12.5px; color: var(--ink-2); margin: 0 2px 4px 0; }
.mini:hover { border-color: var(--sage); }
.mini.danger:hover { border-color: var(--warn); color: var(--warn); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; }
.status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.status.active { background: var(--sage-soft); color: var(--sage-dark); }
.status.unused { background: #e7ebf1; color: #475569; }
.status.expired, .status.revoked { background: var(--warn-soft); color: var(--warn); }
.copybox { width: 100%; min-height: 110px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font: 13.5px/1.5 ui-monospace, Menlo, monospace; margin-top: 10px; }
.transcript .msg { max-width: 80%; }
.ok { background: var(--sage-soft); color: var(--sage-dark); border: 1px solid #bfe0d7; padding: 10px 13px; border-radius: 10px; margin-bottom: 16px; font-size: 14.5px; }
.scroll-x { overflow-x: auto; }

/* ---------- V2: finish visit ---------- */
.modebtns { display: flex; gap: 8px; }
.finish { background: var(--paper); color: var(--sage-dark); border: 1.5px solid var(--sage); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; }
.msg.result { align-self: stretch; max-width: 100%; background: var(--sage-soft); border: 1px solid #bfe0d7; color: var(--ink); font-size: 15px; }
.tag.saved { background: #fff3d6; color: #8a5a00; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 720px; margin: 0 auto; max-height: 92vh; overflow-y: auto;
  background: var(--paper); border-radius: 20px 20px 0 0; padding: 20px 18px; padding-bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .22s ease; box-shadow: 0 -10px 40px rgba(21,33,43,0.18); }
.sheet.open { transform: none; }
.sheet h3 { font-family: var(--display); font-weight: 500; font-size: 22px; }
.sheet-sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 14px; }
.fld { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 14px; }
.fld select, .fld input, .fld textarea { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px; font: 16px var(--body); color: var(--ink); background: #fbfdfc; }
.fld select:focus, .fld input:focus, .fld textarea:focus { outline: none; border-color: var(--sage); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips label { cursor: pointer; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-block; padding: 9px 13px; border: 1.5px solid var(--line); border-radius: 999px; font-weight: 500; font-size: 14.5px; background: #fbfdfc; }
.chips input:checked + span { border-color: var(--sage); background: var(--sage-soft); color: var(--sage-dark); font-weight: 600; }
.chips input:focus-visible + span { outline: 2px solid var(--sage); }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat b { display: block; font-family: var(--display); font-weight: 500; font-size: 28px; }
.stat span { font-size: 13px; color: var(--muted); }
td.mono { white-space: nowrap; }
