/* Franklin — the interface Nolan's firm sees.
   Deliberately plain: this is a working tool for reading mail, not a landing
   page. Density and legibility over decoration. */

:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --line: #e2ded7;
  --ink: #23201c;
  --ink-soft: #6b655d;
  --ink-faint: #98918a;
  --accent: #2f5d50;
  --accent-soft: #eef3f1;
  --warn: #8a5a12;
  --warn-soft: #fdf4e3;
  --bad: #8c2f2f;
  --bad-soft: #fbeded;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(35,32,28,.06), 0 1px 8px rgba(35,32,28,.04);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614;
    --surface: #1f1e1b;
    --line: #35322d;
    --ink: #ece8e1;
    --ink-soft: #a49d94;
    --ink-faint: #786f66;
    --accent: #7fb8a5;
    --accent-soft: #23302c;
    --warn: #d9a44a;
    --warn-soft: #2e2617;
    --bad: #d98a8a;
    --bad-soft: #2e1d1d;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #171614; --surface: #1f1e1b; --line: #35322d;
  --ink: #ece8e1; --ink-soft: #a49d94; --ink-faint: #786f66;
  --accent: #7fb8a5; --accent-soft: #23302c;
  --warn: #d9a44a; --warn-soft: #2e2617;
  --bad: #d98a8a; --bad-soft: #2e1d1d;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--accent); }

/* ---------------------------------------------------------------- chrome */

.bar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 650; letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.bar nav { display: flex; gap: 4px; }
.bar nav a {
  padding: 5px 11px; border-radius: var(--radius); text-decoration: none;
  color: var(--ink-soft); font-size: 14px;
}
.bar nav a:hover { background: var(--accent-soft); color: var(--ink); }
.bar nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { color: var(--ink-faint); font-size: 12.5px; max-width: 26ch; overflow: hidden;
       text-overflow: ellipsis; white-space: nowrap; }
.ghost { color: var(--ink-soft); font-size: 13px; text-decoration: none; }
.ghost:hover { color: var(--ink); text-decoration: underline; }

.foot {
  margin-top: auto; padding: 10px 18px; display: flex; gap: 16px;
  color: var(--ink-faint); font-size: 12px; border-top: 1px solid var(--line);
}

main { padding: 18px; width: 100%; }
main.split { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; align-items: start; }
main.narrow { max-width: 760px; margin: 0 auto; }
@media (max-width: 720px) { main.split { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- pieces */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card h2 { margin: 0; padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--line); }
.card .body { padding: 14px; }

h1 { font-size: 20px; margin: 0 0 14px; letter-spacing: -.01em; text-wrap: balance; }

.alert {
  margin: 0; padding: 10px 18px; background: var(--warn-soft);
  border-bottom: 1px solid var(--line); color: var(--warn); font-size: 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.btn {
  display: inline-block; padding: 7px 13px; border-radius: var(--radius);
  background: var(--accent); color: #fff; border: 0; cursor: pointer;
  font: inherit; font-size: 14px; text-decoration: none;
}
:root[data-theme="dark"] .btn, :root:not([data-theme="light"]) .btn { color: #12201c; }
.btn:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }

select, input[type=text], input[type=search], textarea {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink);
  width: 100%;
}
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-size: 13px; color: var(--ink-soft); margin: 0 0 4px; }
.field + .field { margin-top: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* -------------------------------------------------------------- buckets */

.buckets { list-style: none; margin: 0; padding: 6px; }
.buckets a {
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
  padding: 6px 9px; border-radius: var(--radius); text-decoration: none;
  color: var(--ink); font-size: 14px;
}
.buckets a:hover { background: var(--accent-soft); }
.buckets a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.buckets .n { color: var(--ink-faint); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- messages */

.msgs { list-style: none; margin: 0; padding: 0; }
.msgs li { border-bottom: 1px solid var(--line); }
.msgs li:last-child { border-bottom: 0; }
.msgs a.row {
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 3px 12px;
  padding: 10px 14px; text-decoration: none; color: inherit;
}
.msgs a.row:hover { background: var(--accent-soft); }
.msgs .subject { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgs .from { grid-column: 1; color: var(--ink-soft); font-size: 13px;
              overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgs .when { grid-column: 2; grid-row: 1; color: var(--ink-faint); font-size: 12px;
              white-space: nowrap; font-variant-numeric: tabular-nums; }
.msgs .tags { grid-column: 2; grid-row: 2; display: flex; gap: 6px; justify-content: flex-end; }
.msgs .unread .subject::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-right: 7px; vertical-align: middle;
}

.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad  { background: var(--bad-soft);  color: var(--bad); }
.tag.mute { background: transparent; color: var(--ink-faint); border: 1px solid var(--line); }

.empty { padding: 34px 14px; text-align: center; color: var(--ink-faint); }

.pager { display: flex; gap: 10px; align-items: center; padding: 11px 14px;
         border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-soft); }
.pager .spacer { margin-left: auto; }

/* -------------------------------------------------------------- message */

.meta { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 4px 12px;
        font-size: 13.5px; margin-bottom: 14px; }
.meta dt { color: var(--ink-faint); }
.meta dd { margin: 0; overflow-wrap: anywhere; }

.bodytext {
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px;
  line-height: 1.6; max-height: 60vh; overflow-y: auto;
  border-top: 1px solid var(--line); padding-top: 12px;
}

.refile { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.refile .field { flex: 1 1 190px; margin: 0; }

.note { font-size: 12.5px; color: var(--ink-faint); margin-top: 8px; }

/* ----------------------------------------------------------------- ask */

.answer { white-space: pre-wrap; line-height: 1.65; }
.cites { list-style: none; margin: 14px 0 0; padding: 0; }
.cites li { border-top: 1px solid var(--line); padding: 10px 0; font-size: 13.5px; }
.cites .snippet { color: var(--ink-soft); font-size: 13px; margin-top: 3px;
                  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
                  overflow: hidden; }

.htmx-request .spin { display: inline; }
.spin { display: none; color: var(--ink-faint); font-size: 13px; margin-left: 8px; }

/* --------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
        background: var(--surface); }
.stat .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums;
           letter-spacing: -.02em; }
.stat .k { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.stat.good .v { color: var(--accent); }
.stat.bad .v { color: var(--bad); }

table.plain { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.plain th, table.plain td { text-align: left; padding: 7px 10px;
                                 border-bottom: 1px solid var(--line); }
table.plain th { color: var(--ink-faint); font-weight: 500; font-size: 12px; }
table.plain td.n { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

/* ---------------------------------------------------------------- sign in */

.signin { max-width: 380px; margin: 12vh auto; text-align: center; }
.signin p { color: var(--ink-soft); }
