/* Tiko BYOB Browser — a calm, dense archive reader.
   No web fonts, no CDN, no JS framework: this has to run on any host, offline. */

:root {
    --bg:        #faf9f7;
    --surface:   #ffffff;
    --sunken:    #f2f0ec;
    --line:      #e3dfd8;
    --line-soft: #eeebe5;
    --text:      #1c1a17;
    --muted:     #6f6963;
    --faint:     #9a938a;
    --accent:    #a4551d;
    --accent-bg: #fbf1e8;
    --danger:    #a32f2f;
    --ok:        #2f6b46;
    --radius:    7px;
    --shadow:    0 1px 2px rgba(28, 26, 23, .05), 0 4px 16px -8px rgba(28, 26, 23, .12);
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:        #17181a;
        --surface:   #1e2023;
        --sunken:    #191b1d;
        --line:      #303337;
        --line-soft: #26292c;
        --text:      #e8e6e3;
        --muted:     #9b968f;
        --faint:     #6d6862;
        --accent:    #e0995e;
        --accent-bg: #2b2119;
        --danger:    #e08585;
        --ok:        #7fbf9a;
        --shadow:    0 1px 2px rgba(0,0,0,.3), 0 4px 16px -8px rgba(0,0,0,.5);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font: 14px/1.5 var(--sans);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

.icon { width: 17px; height: 17px; flex: none; }

/* ---------------------------------------------------------------- unlock */

.unlock {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.unlock-card {
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 34px;
}

.unlock-mark {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 620;
    letter-spacing: -.01em;
    margin-bottom: 22px;
}
.unlock-mark .icon { color: var(--accent); width: 20px; height: 20px; }

.unlock h1 { font-size: 19px; font-weight: 600; letter-spacing: -.015em; margin-bottom: 6px; }
.unlock p  { color: var(--muted); margin-bottom: 22px; }

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 560;
    color: var(--muted);
    margin-bottom: 6px;
}
.field input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 13px;
}
.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    background: var(--accent);
    color: #fff;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 560;
    cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn.wide { width: 100%; }
.btn.ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line);
}
.btn.ghost:hover { background: var(--sunken); filter: none; }

.fine {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line-soft);
    font-size: 12px;
    color: var(--faint);
    line-height: 1.6;
}
.fine code { font-family: var(--mono); color: var(--muted); }

.alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid;
}
.alert.error { color: var(--danger); border-color: var(--danger); background: transparent; }
.alert.info  { color: var(--muted); border-color: var(--line); background: var(--sunken); }

/* ------------------------------------------------------------------ shell */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.side {
    background: var(--sunken);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 14px 10px;
    gap: 2px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px 14px;
    font-weight: 620;
    letter-spacing: -.01em;
}
.brand .icon { color: var(--accent); }
.brand small {
    display: block;
    font-size: 11px;
    font-weight: 450;
    color: var(--faint);
    letter-spacing: 0;
}

.nav-label {
    font-size: 10.5px;
    font-weight: 620;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--faint);
    padding: 14px 8px 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 480;
}
.nav-item:hover { background: var(--line-soft); color: var(--text); }
.nav-item.on { background: var(--accent-bg); color: var(--accent); font-weight: 560; }
.nav-item .count { margin-left: auto; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-item.on .count { color: var(--accent); }
.nav-item.depth-1 { padding-left: 26px; }
.nav-item.depth-2 { padding-left: 42px; }
.nav-item span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------- main */

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.searchbox { flex: 1; max-width: 520px; position: relative; display: flex; align-items: center; }
.searchbox .icon { position: absolute; left: 10px; color: var(--faint); }
.searchbox input {
    width: 100%;
    padding: 8px 12px 8px 33px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.searchbox input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.spacer { flex: 1; }

.banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    background: var(--accent-bg);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    color: var(--accent);
}
.banner form { margin-left: auto; }

.content { flex: 1; min-height: 0; overflow: auto; }

.pane-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 18px 22px 12px;
}
.pane-head h1 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
.pane-head .sub { color: var(--faint); font-size: 12.5px; }

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

.list { display: flex; flex-direction: column; }

.row {
    display: grid;
    grid-template-columns: 30px minmax(120px, 190px) 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 22px;
    border-bottom: 1px solid var(--line-soft);
    cursor: pointer;
}
.row:hover { background: var(--sunken); }
.row.unread .who, .row.unread .subject { font-weight: 640; }

.avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 10.5px; font-weight: 620;
    color: #fff;
}

.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject .preview { color: var(--faint); font-weight: 400; }
.when { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.flag { color: var(--accent); }
.pending { color: var(--faint); font-style: italic; }

.empty { padding: 60px 22px; text-align: center; color: var(--faint); }

.pager {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 18px;
}

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

.msg { max-width: 880px; margin: 0 auto; padding: 22px; }
.msg-head { padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.msg-head h1 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 12px; }
.msg-meta { display: flex; align-items: center; gap: 11px; }
.msg-meta .who { font-weight: 560; }
.msg-meta .addr { color: var(--faint); font-size: 12.5px; }
.msg-actions { margin-left: auto; display: flex; gap: 8px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--sunken);
    border: 1px solid var(--line);
    color: var(--muted);
}
.chip.accent { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

.body-text {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Untrusted HTML is rendered in a sandboxed iframe — never inlined into this document. */
.body-html {
    width: 100%;
    min-height: 420px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tab {
    padding: 5px 11px;
    border-radius: 6px;
    font-size: 12.5px;
    color: var(--muted);
    border: 1px solid transparent;
    cursor: pointer;
}
.tab.on { background: var(--surface); border-color: var(--line); color: var(--text); font-weight: 560; }

.attachments { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 7px;
    background: var(--surface);
}
.attachment .size { margin-left: auto; color: var(--faint); font-size: 12px; }

/* ------------------------------------------------------------------ cards */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; padding: 0 22px 22px; }
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.card .meta { color: var(--faint); font-size: 12.5px; }
.card .rows { margin-top: 9px; display: flex; flex-direction: column; gap: 3px; }
.card .rows a, .card .rows span { font-size: 12.5px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--faint);
    padding: 8px 22px;
    border-bottom: 1px solid var(--line);
    font-weight: 620;
}
.table td { padding: 10px 22px; border-bottom: 1px solid var(--line-soft); }
.table tr:hover td { background: var(--sunken); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

pre.code {
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.6;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    overflow-x: auto;
    white-space: pre;
}

.kv { display: grid; grid-template-columns: 190px 1fr; gap: 1px; background: var(--line-soft); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kv dt { background: var(--sunken); padding: 9px 12px; font-size: 12.5px; color: var(--muted); }
.kv dd { background: var(--surface); padding: 9px 12px; font-size: 12.5px; word-break: break-word; }
.kv dd.redacted { color: var(--faint); font-style: italic; }

.section { padding: 0 22px 26px; }
.section h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--faint);
    font-weight: 620;
    margin-bottom: 10px;
}

mark { background: var(--accent-bg); color: var(--accent); padding: 0 2px; border-radius: 2px; }

.hit { display: flex; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line-soft); }
.hit:hover { background: var(--sunken); }
.hit .kind {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--faint);
    padding-top: 2px;
    width: 62px;
    flex: none;
    font-weight: 620;
}
.hit .title { font-weight: 560; }
.hit .snippet { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
