/* Webmail: the obsidian workshop. Deep black, hairline white edges, white call to action,
   Inter for words and CommitMono for small labels, cyan for links only. Light variant on
   request. Fonts are served by the webmail itself (strict CSP). */
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-var-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "CommitMono"; src: url("/static/fonts/commit-mono-latin-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #000; --surface: #0f0f10; --surface-2: #161618; --border: #27272a; --border-strong: #3f3f46;
  --text: #fff; --text-2: #abafb4; --text-3: #8b9097; --link: #52e1fe;
  --cta: #fff; --cta-ink: #000; --cta-hover: #e4e4e7; --sel: #18181b; --unread-dot: #52e1fe;
  --ok-bg: rgba(74, 222, 128, .12); --ok: #86efac; --ok-line: rgba(74, 222, 128, .35);
  --bad-bg: rgba(248, 113, 113, .12); --bad: #fca5a5; --bad-line: rgba(248, 113, 113, .4);
  --hair: rgba(255, 255, 255, .1) 0 0 0 1px inset, rgba(255, 255, 255, .15) 0 1px 0 0 inset;
  --hair-soft: rgba(255, 255, 255, .08) 0 0 0 1px inset;
  --glow: radial-gradient(50% 45% at 80% 0%, rgba(37, 174, 186, .12) 0%, rgba(0, 0, 0, 0) 80%);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "CommitMono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6; --surface: #fff; --surface-2: #f8f9fa; --border: #e5e7eb; --border-strong: #d1d5db;
  --text: #0f0f10; --text-2: #364153; --text-3: #5b616b; --link: #0e7490;
  --cta: #0f0f10; --cta-ink: #fff; --cta-hover: #27272a; --sel: #eef0f2; --unread-dot: #0e7490;
  --ok-bg: #dcfce7; --ok: #166534; --ok-line: #86efac; --bad-bg: #fee2e2; --bad: #991b1b; --bad-line: #fca5a5;
  --hair: rgba(15, 15, 16, .1) 0 0 0 1px inset; --hair-soft: rgba(15, 15, 16, .08) 0 0 0 1px inset; --glow: none;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f3f4f6; --surface: #fff; --surface-2: #f8f9fa; --border: #e5e7eb; --border-strong: #d1d5db;
    --text: #0f0f10; --text-2: #364153; --text-3: #5b616b; --link: #0e7490;
    --cta: #0f0f10; --cta-ink: #fff; --cta-hover: #27272a; --sel: #eef0f2; --unread-dot: #0e7490;
    --ok-bg: #dcfce7; --ok: #166534; --ok-line: #86efac; --bad-bg: #fee2e2; --bad: #991b1b; --bad-line: #fca5a5;
    --hair: rgba(15, 15, 16, .1) 0 0 0 1px inset; --hair-soft: rgba(15, 15, 16, .08) 0 0 0 1px inset; --glow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg) var(--glow) no-repeat fixed; color: var(--text); font: 400 14.5px/1.5 var(--font); letter-spacing: -0.008em; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 24px; font-weight: 500; letter-spacing: -0.025em; line-height: 1.2; margin: 0; }
code, pre, kbd, textarea { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* brand */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 550; font-size: 17px; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.mark { width: 26px; height: 26px; border-radius: 8px; background: radial-gradient(circle at 35% 30%, #a5f3fc, #52e1fe 45%, #25aeba); box-shadow: 0 0 12px rgba(82, 225, 254, .35); }
.brand.big { font-size: 20px; margin-bottom: 28px; }
.brand-tag { font: 400 11px/1 var(--mono); padding: 3px 6px; border-radius: 2px; color: var(--text-3); box-shadow: 0 0 0 1px var(--border-strong) inset; }
.bar .brand { white-space: nowrap; }
.brand-logo { flex: none; filter: drop-shadow(0 0 10px rgba(240, 106, 64, .18)); }

/* controls */
button, .btn, .cta { font: 500 14px/1 var(--font); letter-spacing: -0.008em; border: 0; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.cta { background: var(--cta); color: var(--cta-ink); padding: 11px 18px; min-height: 40px; box-shadow: rgba(255, 255, 255, .15) 0 1px 0 0 inset; }
.cta:hover { background: var(--cta-hover); text-decoration: none; }
.ghost, .btn.ghost { background: transparent; color: var(--text); padding: 9px 14px; box-shadow: var(--hair); min-height: 36px; }
.ghost:hover, .btn.ghost:hover { background: var(--sel); text-decoration: none; }
.sm { padding: 6px 11px; min-height: 30px; font-size: 13px; }
.danger { color: var(--bad); }
.wide { width: 100%; }
.ghost-link { font: 400 13px/1 var(--mono); color: var(--text-2); }
.ghost-link:hover { color: var(--text); text-decoration: none; }
input, textarea { font: 400 14.5px/1.4 var(--font); color: var(--text); background: var(--surface-2); border: 0; border-radius: 8px; padding: 10px 12px; box-shadow: var(--hair-soft); width: 100%; }
input:focus, textarea:focus { outline: none; box-shadow: 0 0 0 1px rgba(82, 225, 254, .45) inset, 0 0 0 3px rgba(82, 225, 254, .12); }
input[type="checkbox"] { width: 16px; height: 16px; padding: 0; box-shadow: none; accent-color: var(--link); flex: none; }
textarea { font: 400 14px/1.6 var(--font); resize: vertical; }
label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 500; }
.flash { margin: 0 0 14px; padding: 10px 14px; border-radius: 8px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); box-shadow: 0 0 0 1px var(--ok-line) inset; }
.flash.err { background: var(--bad-bg); color: var(--bad); box-shadow: 0 0 0 1px var(--bad-line) inset; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; background: #27272a; color: #fff; font-weight: 500; font-size: 13px; text-transform: uppercase; box-shadow: rgba(255, 255, 255, .12) 0 0 0 1px inset; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.inline { display: inline-flex; gap: 6px; flex-wrap: wrap; margin: 0; }
.hint, .note { color: var(--text-3); font-size: 12.5px; }

/* sign-in */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { position: relative; width: 100%; max-width: 400px; }
.login .glow { position: absolute; inset: -120px -160px auto auto; width: 360px; height: 360px; background: radial-gradient(rgba(37, 99, 235, .14) 0%, rgba(0, 0, 0, 0) 70%); pointer-events: none; z-index: -1; }
.login h1 { font-size: 30px; letter-spacing: -0.03em; }
.login .sub { color: var(--text-2); margin: 8px 0 24px; }
.stack { display: grid; gap: 14px; }
.stack .cta { margin-top: 6px; width: 100%; }
.settings-hint { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--text-3); font-size: 12.5px; }
.settings-hint code { font-size: 12px; color: var(--text-2); padding: 3px 8px; border-radius: 2px; box-shadow: 0 0 0 1px var(--border-strong) inset; }

/* app shell */
.app { display: flex; flex-direction: column; height: 100vh; }
.bar { display: flex; align-items: center; gap: 16px; height: 60px; padding: 0 20px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); flex: none; }
.bar .brand { width: 208px; }
.search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 8px; background: var(--surface); color: var(--text-3); box-shadow: var(--hair-soft); }
.search input { background: transparent; box-shadow: none; padding: 0; height: 36px; }
.search input:focus { box-shadow: none; }
.bar-right { margin-left: auto; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; color: var(--text-2); font-size: 13.5px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover, .menu[open] > summary { background: var(--sel); color: var(--text); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; z-index: 10; background: var(--surface); border-radius: 12px; padding: 10px; box-shadow: var(--hair), 0 16px 40px rgba(0, 0, 0, .45); display: grid; gap: 8px; }
.menu-meta { font: 400 12px/1.3 var(--mono); color: var(--text-3); padding: 2px 4px; overflow: hidden; text-overflow: ellipsis; }
.theme { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); box-shadow: var(--hair-soft); }
.theme a { flex: 1; text-align: center; padding: 5px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.theme a:hover { color: var(--text); text-decoration: none; }
.theme a[aria-current="true"] { background: #27272a; color: #fff; }
.cols { flex: 1; display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 0; }

/* folders */
.folders { padding: 16px 12px; border-right: 1px solid var(--border); overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.compose-btn { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; padding: 11px 14px; border-radius: 8px; background: var(--cta); color: var(--cta-ink); font-weight: 500; box-shadow: rgba(255, 255, 255, .15) 0 1px 0 0 inset; }
.compose-btn:hover { background: var(--cta-hover); text-decoration: none; }
.folder { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 8px; color: var(--text-2); font-weight: 450; }
.folder:hover { background: var(--sel); color: var(--text); text-decoration: none; }
.folder.cur { background: var(--sel); color: var(--text); box-shadow: var(--hair-soft); }
.f-count { font: 400 11.5px/1.6 var(--mono); padding: 0 7px; border-radius: 2px; color: var(--text); box-shadow: 0 0 0 1px var(--border-strong) inset; }

/* main */
.main { overflow-y: auto; padding: 24px 28px 48px; }
.list-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.meta { font: 400 12.5px/1 var(--mono); color: var(--text-3); }
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 10px; margin-bottom: 8px; border-radius: 12px; background: var(--surface); box-shadow: var(--hair-soft); }
.check-all { display: inline-flex; padding: 0 8px 0 4px; }
.msgs { list-style: none; margin: 0; padding: 0; border-radius: 12px; background: var(--surface); box-shadow: var(--hair-soft); overflow: hidden; }
.msg { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); position: relative; }
.msg:last-child { border-bottom: 0; }
.msg:hover { background: var(--sel); }
.msg-link { flex: 1; min-width: 0; display: grid; grid-template-columns: 28px 200px minmax(0, 1fr) auto 72px; align-items: center; gap: 12px; padding: 12px 0; color: var(--text-2); }
.msg-link:hover { text-decoration: none; }
.msg-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-subject { color: var(--text-2); }
.msg-preview { color: var(--text-3); }
.msg-icons { display: inline-flex; gap: 6px; color: var(--text-3); }
.star { color: #ffb86a; }
.msg-date { font: 400 12px/1 var(--mono); color: var(--text-3); text-align: right; white-space: nowrap; }
.msg.unread .msg-from, .msg.unread .msg-subject { color: var(--text); font-weight: 550; }
.msg.unread::before { content: ""; position: absolute; left: 4px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--unread-dot); }
.pager { display: flex; justify-content: space-between; margin-top: 14px; }
.empty { text-align: center; padding: 80px 16px; color: var(--text-2); display: grid; justify-items: center; gap: 16px; }

/* reading */
.read { max-width: 900px; }
.read-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.read-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.read-subject { font-size: 26px; margin-bottom: 18px; }
.read-head { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.read-who { flex: 1; min-width: 0; }
.read-who strong { font-weight: 550; }
.addr { color: var(--text-3); font-size: 13px; }
.read-date { font: 400 12.5px/1 var(--mono); color: var(--text-3); white-space: nowrap; }
.files { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 16px; }
.files a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; color: var(--text); background: var(--surface); box-shadow: var(--hair-soft); }
.files a:hover { text-decoration: none; box-shadow: var(--hair); }
.files small { color: var(--text-3); font-family: var(--mono); }
.body-frame { width: 100%; min-height: 60vh; border: 0; border-radius: 12px; background: #fff; box-shadow: var(--hair-soft); }
.body-text { white-space: pre-wrap; word-wrap: break-word; font: 400 14.5px/1.65 var(--font); background: var(--surface); padding: 20px 22px; border-radius: 12px; box-shadow: var(--hair-soft); margin: 0; }
.note { margin-top: 8px; }

/* compose */
.compose { display: grid; gap: 10px; max-width: 900px; background: var(--surface); padding: 18px 20px; border-radius: 12px; box-shadow: var(--hair-soft); }
.field { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 10px; }
.field label { color: var(--text-3); font: 400 12.5px/1 var(--mono); }
.more-recipients { display: grid; gap: 10px; }
.more-recipients summary { cursor: pointer; font: 400 12.5px/1 var(--mono); color: var(--text-3); padding-left: 74px; list-style: none; }
.more-recipients summary::-webkit-details-marker { display: none; }
.more-recipients[open] summary { margin-bottom: 10px; }
.compose-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.compose-foot .cta { margin-left: auto; }
.attach { display: inline-flex; grid-auto-flow: column; align-items: center; gap: 8px; cursor: pointer; padding: 8px 12px; border-radius: 8px; box-shadow: var(--hair); color: var(--text); font-size: 13.5px; }
.attach input { width: auto; padding: 0; box-shadow: none; background: none; font-size: 12.5px; color: var(--text-3); }

/* phones */
@media (max-width: 860px) {
  .bar { padding: 0 12px; gap: 10px; }
  .bar .brand { width: auto; }
  .who { display: none; }
  .cols { grid-template-columns: 1fr; }
  .folders { border-right: 0; border-bottom: 1px solid var(--border); display: flex; overflow-x: auto; padding: 10px 12px; gap: 4px; }
  .compose-btn { margin: 0 6px 0 0; padding: 8px 12px; flex: none; }
  .compose-btn span { display: none; }
  .folder { flex: none; padding: 7px 10px; }
  .main { padding: 16px 12px 40px; }
  .msg-link { grid-template-columns: 28px minmax(0, 1fr) auto; grid-template-areas: "av from date" "av text text"; row-gap: 2px; }
  .msg-link .avatar { grid-area: av; }
  .msg-from { grid-area: from; }
  .msg-text { grid-area: text; }
  .msg-icons { display: none; }
  .msg-date { grid-area: date; }
}
