/* Frank's look: the tokens and type of the Frank landing page and the blind A/B page. */
:root {
  --bg: #f5f0e8;
  --surface: #faf7f2;
  --surface-2: #f0ebe0;
  --text: #2a2218;
  --text-mid: #4a3e30;
  --text-muted: #6a6258;
  --accent: #4d5f78;
  --accent-bg: #e4e9ef;
  --client-bg: #e8e0d0;
  --danger: #8a3b2e;
  --rule: rgba(42,34,24,0.12);
  --rule-strong: rgba(42,34,24,0.22);
  --shadow: 0 2px 24px rgba(42,34,24,0.07);
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141210;
    --surface: #1c1a17;
    --surface-2: #232019;
    --text: #e8e2d6;
    --text-mid: #c8baa8;
    --text-muted: #8a8278;
    --accent: #c0875a;
    --accent-bg: #291c0d;
    --client-bg: #2c2820;
    --danger: #d98a77;
    --rule: rgba(255,255,255,0.07);
    --rule-strong: rgba(255,255,255,0.13);
    --shadow: 0 2px 24px rgba(0,0,0,0.36);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141210;
  --surface: #1c1a17;
  --surface-2: #232019;
  --text: #e8e2d6;
  --text-mid: #c8baa8;
  --text-muted: #8a8278;
  --accent: #c0875a;
  --accent-bg: #291c0d;
  --client-bg: #2c2820;
  --danger: #d98a77;
  --rule: rgba(255,255,255,0.07);
  --rule-strong: rgba(255,255,255,0.13);
  --shadow: 0 2px 24px rgba(0,0,0,0.36);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 'DM Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: 'Cormorant Garamond', serif; font-weight: 500; }
button, input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
}
button { padding: 8px 14px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
button.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; }
button.quiet { background: none; border-color: transparent; color: var(--text-muted); }
button:disabled { opacity: 0.5; cursor: default; }
input, textarea { padding: 10px 12px; width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- Sign-in and notice screens ---- */
.signin, .notice {
  max-width: 440px;
  margin: 0 auto;
  padding: max(48px, env(safe-area-inset-top)) 16px 48px;
}
.signin h1, .notice h1 { font-size: 40px; line-height: 1.1; margin: 0 0 8px; }
.lede { color: var(--text-mid); margin: 0 0 24px; }
.signin-form { display: grid; gap: 10px; margin-bottom: 12px; }
.signin-form label { font-size: 14px; color: var(--text-muted); }
.sent p { color: var(--text-mid); }
.sent details { margin: 16px 0; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius); }
.sent summary { cursor: pointer; color: var(--accent); }
.error { color: var(--danger); min-height: 1.6em; }

/* ---- Chat layout ---- */
.app { display: flex; height: 100%; height: 100dvh; }
.drawer {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  padding-top: env(safe-area-inset-top);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.drawer-head h2 { margin: 0; font-size: 22px; }
.conversations { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 8px; }
.conversations li { display: flex; align-items: center; gap: 4px; border-radius: var(--radius); }
.conversations li.current { background: var(--accent-bg); }
.conversations .open {
  flex: 1; min-width: 0; text-align: left; background: none; border: none; padding: 8px 10px;
}
.conversations .open span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversations .open small { color: var(--text-muted); font-size: 12px; }
.conversations .delete { padding: 4px 8px; font-size: 13px; }
.conversations .empty { color: var(--text-muted); font-style: italic; padding: 8px 10px; }
.drawer-foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); display: grid; gap: 8px; font-size: 14px; color: var(--text-muted); }
.drawer-foot .who { overflow: hidden; text-overflow: ellipsis; }
.drawer-foot a, .drawer-foot button.link { color: var(--accent); justify-self: start; }
.install-hint { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; color: var(--text-mid); }

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--rule);
}
.chat-head h1 { margin: 0; font-size: 28px; line-height: 1.1; flex: 1; }
.menu-button { display: none; }
.log { flex: 1; overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.log-inner { width: 100%; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: var(--radius); overflow-wrap: anywhere; }
.msg p { margin: 0 0 0.7em; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 0 0 0.7em; padding-left: 1.3em; }
.msg.user { align-self: flex-end; background: var(--client-bg); color: var(--text-mid); }
.msg.assistant { align-self: flex-start; background: var(--accent-bg); }
.msg.waiting { color: var(--text-muted); font-style: italic; }
.welcome { margin: auto; text-align: center; max-width: 34ch; color: var(--text-muted); }
.welcome h2 { color: var(--text); font-size: 30px; margin: 0 0 6px; }
.welcome button { margin-top: 14px; }
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  width: 100%; max-width: 752px; margin: 0 auto;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
}
.composer textarea { flex: 1; resize: none; min-height: 48px; max-height: 40vh; line-height: 1.45; }
.composer button { height: 48px; }
.allowance { text-align: center; font-size: 13px; color: var(--text-muted); padding: 0 16px; min-height: 0; }
.scrim { display: none; }

@media (max-width: 760px) {
  .menu-button { display: inline-block; }
  .drawer {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: min(86vw, 320px);
    transform: translateX(-100%); transition: transform 0.2s ease, visibility 0.2s;
    visibility: hidden;
  }
  .app.drawer-open .drawer { transform: none; visibility: visible; box-shadow: var(--shadow); }
  .app.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,0.3); }
  .msg { max-width: 94%; }
  /* 16px keeps iOS from zooming into the text box. */
  .composer textarea { font-size: 16px; }
}

/* ---- Admin ---- */
.admin { max-width: 980px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 16px 48px; }
.admin header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
.admin h1 { font-size: 36px; margin: 0; flex: 1; }
.admin .meta { color: var(--text-muted); font-size: 14px; }
.admin .card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-top: 20px; }
.admin h2 { margin: 0 0 12px; font-size: 24px; }
.invite-form { display: flex; flex-wrap: wrap; gap: 8px; }
.invite-form input { flex: 1 1 200px; width: auto; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th { font-weight: 500; color: var(--text-muted); font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.off td { color: var(--text-muted); }
tfoot td { font-weight: 500; border-bottom: none; }
.privacy-note { color: var(--text-muted); font-size: 14px; margin: 12px 0 0; }
