/* Affordance vocabulary + conventions: docs/WEB-UI-STYLE.md */
* { box-sizing: border-box; }
body { font: 14px/1.4 system-ui, sans-serif; margin: 0; color: #222; background: #f4f4f4; }
.topbar { display: flex; align-items: center; gap: 1rem; background: #1e3a5f; color: #fff; padding: 0.6rem 1rem; }
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 600; }
.sysname { opacity: 0.7; margin-left: 0.4rem; }
.mainnav { display: flex; gap: 0.8rem; flex: 1; }
.mainnav a { padding: 0.2rem 0.4rem; border-radius: 3px; }
.mainnav a.active { background: #2c5a8e; }
.logoutform { display: flex; gap: 0.5rem; align-items: center; }
.userchip { font-size: 0.85rem; opacity: 0.85; text-decoration: none; color: inherit; }
.userchip:hover { opacity: 1; text-decoration: underline; }
button { background: #2c5a8e; color: #fff; border: 0; padding: 0.3rem 0.7rem; border-radius: 3px; cursor: pointer; }
main { padding: 1rem; max-width: 1200px; margin: 0 auto; }
footer { padding: 1rem; text-align: center; color: #777; font-size: 0.85rem; }
.flash { background: #ffe; border-bottom: 1px solid #cc6; padding: 0.5rem 1rem; }
.banner-degraded { background: #fff3e0; border-bottom: 1px solid #e8a33d; color: #7a4a00; padding: 0.5rem 1rem; font-size: 0.9rem; }
h1 { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.card { background: #fff; padding: 1rem; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card h2 { margin: 0 0 0.4rem; font-size: 0.9rem; color: #666; }
.big { font-size: 2rem; margin: 0; }
.card .sub { margin: 0.1rem 0 0; font-size: 0.8rem; color: #888; }
table.rows { width: 100%; border-collapse: collapse; background: #fff; }
table.rows th, table.rows td { padding: 0.4rem 0.6rem; border-bottom: 1px solid #eee; text-align: left; vertical-align: top; }
table.rows th { background: #f9f9f9; font-size: 0.85rem; color: #555; }
/* Sortable column headers: the whole cell reads as a click target, the
   active one is bolded by its arrow. The anchor inherits the header colour
   so a sorted table doesn't sprout a row of blue links. */
table.rows th.sortable { padding: 0; white-space: nowrap; }
table.rows th.sortable a { display: block; padding: 0.4rem 0.6rem; color: inherit; text-decoration: none; }
table.rows th.sortable a:hover { background: #f0f0f0; text-decoration: underline; }
/* Let long unbreakable tokens (proxy URLs, software strings, IPs) wrap
   instead of forcing the table wider than its container. */
table.rows td { overflow-wrap: anywhere; }
/* Opt-out for short atomic values (dates) that must never break. */
table.rows td.nowrap { white-space: nowrap; }
/* Horizontal-scroll fallback for wide tables, so a table that still
   can't fit scrolls within the content column rather than widening the
   whole page (and spawning a body-level scrollbar that breaks the nav). */
.tablescroll { overflow-x: auto; }
.login { max-width: 320px; margin: 4rem auto; background: #fff; padding: 1.5rem; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.login label { display: block; margin-bottom: 0.7rem; font-size: 0.85rem; color: #555; }
.login input { display: block; width: 100%; padding: 0.4rem; border: 1px solid #ccc; border-radius: 3px; font-size: 1rem; }
dl.msghead dt { font-weight: 600; color: #555; }
dl.msghead dd { margin-left: 1rem; margin-bottom: 0.3rem; }
.msgbody { background: #fff; padding: 1rem; border-radius: 4px; white-space: pre-wrap; font-family: monospace; overflow-wrap: anywhere; }
/* Quote-author colour ladder: one hue per distinct author (initials),
   assigned in first-seen order, cycling above 10. Bare ">>" quotes with
   no initials fall back to a 5-wide depth cycle on q1..q5. */
.msgbody .q1  { color: #1d4ed8; }  /* blue    */
.msgbody .q2  { color: #15803d; }  /* green   */
.msgbody .q3  { color: #7e22ce; }  /* purple  */
.msgbody .q4  { color: #0f766e; }  /* teal    */
.msgbody .q5  { color: #92400e; }  /* brown   */
.msgbody .q6  { color: #b91c1c; }  /* red     */
.msgbody .q7  { color: #a16207; }  /* amber   */
.msgbody .q8  { color: #be185d; }  /* magenta */
.msgbody .q9  { color: #4338ca; }  /* indigo  */
.msgbody .q10 { color: #0e7490; }  /* cyan    */
.msgbody .tear, .msgbody .orig { color: #777; }
.msgbody .kludge { color: #999; }
.msgbody .tagline { color: #777; font-style: italic; }
/* ANSI colour/art reader: terminal-like canvas (black bg, monospace,
   whitespace preserved for box-drawing alignment). Colours live inline on
   each decoded SGR run; only blink is a class so the animation can be shared. */
.ansi { white-space: pre; font-family: "Cascadia Mono", Menlo, Consolas, monospace;
        background: #000; color: #aaaaaa; line-height: 1.15; padding: .6em;
        overflow-x: auto; border-radius: 4px; }
.ansi-blink { animation: ansiBlink 1s step-start infinite; }
@keyframes ansiBlink { 50% { opacity: 0; } }
.ansi-toggle { font-size: .85em; }
.tearline, .origin { font-family: monospace; color: #777; margin-top: 0.5rem; }
.pager { margin-top: 1rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.pager .cur { font-weight: 700; }
.pager .gap { color: #999; }
.pager .rowcount { color: #777; margin-left: auto; }

/* Reader navigation bar (GoldED reading loop) */
.readnav { margin: 0.6rem 0; color: #999; }
.readnav .dim { color: #bbb; }
.readnav .pos { color: #555; }
.arealist { list-style: none; padding: 0; }
.arealist li { padding: 0.3rem 0; border-bottom: 1px solid #eee; }
.arealist .net { color: #999; font-size: 0.8rem; margin-left: 0.5rem; }
.arealist .adesc { color: #555; font-size: 0.85rem; margin-left: 0.5rem; }
.error { background: #fff; padding: 1rem; border-left: 4px solid #c33; }

/* Thread tree */
.tlist { list-style: none; padding-left: 1.2rem; margin: 0.2rem 0; border-left: 1px dashed #ccc; }
.tlist.troot { padding-left: 0; border-left: 0; }
.tnode { padding: 0.2rem 0; }
.tlink { display: block; padding: 0.2rem 0.5rem; border-radius: 3px; text-decoration: none; color: #222; background: #fff; }
.tlink:hover { background: #eef4fa; }
.tlink.anchor { background: #fffbe0; border: 1px solid #d8c25c; font-weight: 600; }
.tsubj { display: inline-block; }
.tmeta { color: #888; font-size: 0.8rem; margin-left: 0.4rem; }
.tsummary { color: #555; font-size: 0.9rem; }
.tsummary .warn { color: #b85; margin-left: 0.4rem; }
.vtoggle { font-size: 0.85rem; font-weight: normal; color: #777; }
.thread { background: #fff; padding: 0.5rem 0.8rem; border-radius: 4px; margin-bottom: 0.6rem; box-shadow: 0 1px 1px rgba(0,0,0,.04); }

/* Read-state decoration */
tr.unread td { font-weight: 600; }
tr.unread td:first-child { border-left: 3px solid #2c5a8e; }
/* "Addressed to you" highlight (GoldED's to-you marking); composes
   with the unread bold. */
tr.tome td { background: #f4f9ee; }

/* Echo-level "to you" indicator on /mail/unread: a warm tinted row plus a
   star count badge, marking echoes that hold unread mail addressed to one
   of your tracked names. Distinct hue from tr.tome (the per-message green)
   so the echo-list signal reads as its own thing. */
tr.toyou td { background: #fff8e6; }
.toyoubadge { display: inline-block; background: #c8860a; color: #fff; font-size: 0.7rem; padding: 0.05rem 0.4rem; border-radius: 10px; white-space: nowrap; }
a.toyoubadge:hover { background: #a86d05; }

/* List header: search + jump-to-date forms, year strip */
.listnav { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; background: #fff; padding: 0.5rem 0.8rem; border-radius: 4px; margin-bottom: 0.6rem; }
.listnav form { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.listnav input, .listnav select { padding: 0.25rem 0.4rem; border: 1px solid #ccc; border-radius: 3px; }
.listnav input[name=q] { min-width: 18rem; }
.listnav label { font-size: 0.8rem; color: #555; }
.listnav label.cb input { vertical-align: middle; }
.searchsummary { color: #555; }
.yearstrip { font-size: 0.85rem; color: #777; margin: 0.3rem 0 0.6rem; }
.yearstrip a { margin-right: 0.3rem; }
.unreadbadge { background: #2c5a8e; color: #fff; font-size: 0.7rem; padding: 0.05rem 0.4rem; border-radius: 10px; margin-left: 0.4rem; vertical-align: middle; }
.inlineform { display: inline; margin-left: 0.6rem; }

/* Action affordance — applies identically to <a> and <button>.
   Base = primary blue; .btn-quiet = secondary gray. */
.btn { display: inline-block; background: #2c5a8e; color: #fff;
       border: 0; border-radius: 3px; padding: 0.2rem 0.7rem;
       font-size: 0.85rem; text-decoration: none; cursor: pointer; }
.btn:hover { background: #1e3a5f; }
.btn-quiet { background: #6c757d; }
.btn-quiet:hover { background: #5a6268; }
h1 .btn, .listactions .btn { margin-left: 0.6rem; }
/* One shared small-button size for dense rows; the container classes
   below carry layout only (flex/gap/margins). */
.listnav button, .inlineform button, .readactions button,
.selectbar button, td.actions button, .savesearchform button,
.noteform button { font-size: 0.85rem; padding: 0.2rem 0.6rem; }

/* Sent-netmail direction + delivery-status badges (SENT-NETMAIL-PLAN §3.6) */
.dirfilter { font-size: 0.85rem; margin: 0.3rem 0 0.6rem; color: #555; }
.dirfilter a.active { font-weight: 700; text-decoration: none; }
.badge { display: inline-block; font-size: 0.7rem; padding: 0.05rem 0.4rem; border-radius: 10px; vertical-align: middle; color: #fff; }
.badge-sent-dir { background: #2c5a8e; }
.badge-recv-dir { background: #6c757d; }
.badge-queued { background: #b8860b; }
.badge-sent { background: #2e7d32; }
.badge-failed { background: #b00020; }
.badge-canceled { background: #6c757d; }
/* Session security ("🔒" column on /sessions + link detail). */
.badge-secure { background: #2e7d32; }
.badge-insecure { background: #b8860b; }
/* Rejected (audit-only) echomail — sysop-visible badge + detail banner. */
.badge-rejected { background: #b00020; }
/* Subscription confirmation lifecycle (area/link Sources status). The
   `rejected` state reuses .badge-rejected above. */
.badge-confirmed { background: #2e7d32; }
.badge-unconfirmed { background: #b8860b; }
.rejectbanner { background: #fbeaec; border: 1px solid #e0a3ab; color: #6b1622; padding: 0.4rem 0.6rem; border-radius: 4px; font-size: 0.9rem; margin: 0.4rem 0; }

/* Dashboard header: title + "as of" stamp + Refresh on one baseline. */
.dashhead { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.dashhead h1 { margin: 0; }
.dashhead .btn { margin-left: auto; }

/* Modem line-phase badges (Dashboard). Reuse the .badge base; colour by
   derived phase, NOT raw pool state. */
.phase-idle { background: #6c757d; }
.phase-listening { background: #2c5a8e; }
.phase-dialing { background: #b8860b; }
.phase-in-call { background: #2e7d32; }
.phase-maintenance { background: #6f42c1; }
.phase-fault { background: #b00020; }
.phase-offline { background: #adb5bd; }
.phase-disabled { background: #8d6e63; }
.flash.err { background: #fee; border-bottom: 1px solid #c33; color: #800; padding: 0.5rem 1rem; margin-bottom: 1rem; }
.flash.warn { background: #fff7e6; border-bottom: 1px solid #d49b22; color: #7a4e00; padding: 0.5rem 1rem; margin-bottom: 1rem; }
.composeform { background: #fff; padding: 1rem; border-radius: 4px; }
.composeform label { display: block; margin-bottom: 0.7rem; font-size: 0.85rem; color: #555; }
.composeform input, .composeform select, .composeform textarea { display: block; width: 100%; padding: 0.4rem; border: 1px solid #ccc; border-radius: 3px; font-family: inherit; font-size: 0.95rem; box-sizing: border-box; }
.composeform textarea { font-family: monospace; }
.cancel { color: #666; }
.composeform .cancel { margin-left: 1rem; }
.composeform fieldset { border: 1px solid #ddd; padding: 0.5rem 0.8rem; margin: 0.8rem 0; }
.composeform fieldset legend { padding: 0 0.5rem; color: #555; font-size: 0.85rem; }
.composeform label.cb { display: block; }
.composeform label.cb input { display: inline-block; width: auto; margin-right: 0.4rem; }
/* One-click From-name picker chips. The input's datalist filters its
   dropdown by the current (pre-filled) value, hiding the other
   configured names — the chips are the always-visible alternative. */
.namechips { margin: -0.4rem 0 0.7rem; }
.namechip { background: #e8eef5; color: #2c5a8e; border: 1px solid #b9c9dc; font-size: 0.85rem; padding: 0.15rem 0.6rem; margin-right: 0.35rem; }
.namechip:hover { background: #d8e4f0; }
/* Compose preview pane: the renderBody fragment lands here. */
.previewbar { margin: 0.2rem 0 0.6rem; display: flex; gap: 0.6rem; align-items: center; }
.previewpane { margin-bottom: 0.8rem; }
.previewpane:empty { display: none; }
.previewpane .msgbody { border: 1px dashed #ccc; }

.adminactions { background: #fff; padding: 1rem; margin-top: 1rem; border-radius: 4px; }
.adminactions h2 { font-size: 1rem; margin-top: 0.6rem; color: #444; }
/* Standalone form directly below a table (e.g. /system "Refresh sizes"). */
.refreshform { margin-top: 0.5rem; }
.dangerbtn { background: #c33; }
.dangerbtn:hover { background: #a22; }
.cardlink { display: block; color: inherit; text-decoration: none; }
.cardlink:hover { background: #eef4fa; }
.muted { color: #777; font-size: 0.9rem; }
.warn { color: #b85; font-size: 0.8rem; }

.filterform { background: #fff; padding: 0.6rem 1rem; border-radius: 4px; display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filterform label { font-size: 0.8rem; color: #555; }
.filterform input, .filterform select { padding: 0.3rem; border: 1px solid #ccc; border-radius: 3px; }
.audit-failure td { background: #fff4f4; }
.audit-success td { background: inherit; }
.auditdetail { font-family: monospace; font-size: 0.85rem; color: #555; word-break: break-all; }

details.kludges { margin: 1rem 0; }
details.kludges summary { cursor: pointer; color: #555; font-size: 0.9rem; padding: 0.3rem 0; }
.kludgetable td code { font-size: 0.85rem; }
.vias { list-style: none; padding: 0; }
.vias li { padding: 0.1rem 0; }
/* Captured original control block (transparent-relay fidelity) shown in
   the message detail view; same look as the Via list. */
.rawkludges { list-style: none; padding: 0; }
.rawkludges li { padding: 0.1rem 0; }
.rawkludges li code { font-size: 0.85rem; white-space: pre-wrap; word-break: break-all; }
/* Muted annotations outside .readnav (msghead Charset note, kludges
   block explainer). Scoped so the existing .readnav .dim is untouched. */
.msghead .dim, details.kludges .dim, p.dim { color: #888; font-size: 0.9rem; }

/* /areas inventory + Discover */
/* Areas hub tabs: /areas (Subscribed) ↔ /areas/available (Discover) */
.subnav { display: flex; gap: 0.2rem; margin: 0 0 1rem; border-bottom: 2px solid #d8dee6; }
.subnav a { padding: 0.35rem 1rem; text-decoration: none; color: #555; border-radius: 4px 4px 0 0; }
.subnav a:hover { background: #eef4fa; }
.subnav a.active { background: #fff; color: #1e3a5f; font-weight: 600; border: 1px solid #d8dee6; border-bottom: 2px solid #fff; margin-bottom: -2px; }
tr.inactive td { color: #999; }
/* Discover action cell. A <select>'s intrinsic width is its widest
   option and ignores the td's overflow-wrap, so one long link name
   would widen the whole column — cap it; the opened popup still
   renders options at full width. */
td.actions .actionform { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
td.actions select { max-width: 11rem; }
td.actions .offeraddr { max-width: 14rem; }
td.actions details.switchsrc { flex-basis: 100%; }
td.actions details.switchsrc summary { cursor: pointer; color: #777; font-size: 0.85rem; }
/* The "remove locally only" escape hatch on the area pages' Sources
   table — visually subordinate to the AreaFix/FileFix-correct button. */
td.actions details.localonly { flex-basis: 100%; }
td.actions details.localonly summary { cursor: pointer; color: #777; font-size: 0.85rem; }
td.actions .switchrow { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin-top: 0.2rem; }
ul.subs { list-style: none; padding: 0; margin: 0.2rem 0 0.8rem; }
ul.subs li { padding: 0.1rem 0; }

/* Explicit read-state actions on the reader + lists */
.readactions { display: flex; gap: 0.5rem; margin: 0.6rem 0; flex-wrap: wrap; align-items: center; }
.readactions form { display: inline; }
.selectbar { display: flex; gap: 0.5rem; margin: 0.5rem 0; align-items: center; flex-wrap: wrap; }
td.selcell { width: 1.5rem; }
td.selcell input[type=checkbox] { vertical-align: middle; }
.inboxhead { font-size: 1.05rem; margin: 1.2rem 0 0.5rem; }

/* Reader in-thread navigation + collapsible thread tree */
.threadnav .navlabel { color: #777; font-size: 0.85rem; }
details.tfold > summary { cursor: pointer; list-style-position: outside; }
details.tfold > summary .tlink { display: inline-block; }
details.tfold > summary .tcount { color: #999; font-size: 0.75rem; margin-left: 0.4rem; }

/* Personal triage: stars, watch marks, muted rows, saved searches */
.starbtn { background: transparent; color: #b8860b; border: 0; font-size: 1rem; padding: 0 0.2rem; line-height: 1; }
.starbtn:hover { background: transparent; color: #8a6508; }
.starbtn.starred { color: #d4a017; }
/* Filled pill only for the standalone "★ Bookmarked" buttons on detail pages;
   the inline .starbtn toggles stay transparent (just the gold glyph). */
button.starred:not(.starbtn) { background: #b8860b; }
.watchmark { font-size: 0.85rem; }
tr.mutedrow td { opacity: 0.55; }
.mutedline { color: #777; font-size: 0.85rem; }
.savesearchform { display: flex; gap: 0.4rem; align-items: center; margin: 0.3rem 0 0.6rem; }
.savesearchform input[type=text] { padding: 0.25rem 0.4rem; border: 1px solid #ccc; border-radius: 3px; }
.triagenav { color: #777; }
.noteform { display: flex; gap: 0.3rem; align-items: center; }
.noteform input[type=text] { padding: 0.2rem 0.4rem; border: 1px solid #ccc; border-radius: 3px; }

/* Composer ergonomics: 72-column body, draft banner, folded quotes */
.composeform textarea[name=body] { width: min(100%, 76ch); }
.draftbanner { display: flex; gap: 0.8rem; align-items: center; }
.previewbar #draftstatus { margin-left: auto; font-size: 0.85rem; }
.previewpane details.qfold { margin: 0.1rem 0; }
.previewpane details.qfold > summary { cursor: pointer; color: #777; font-size: 0.85rem; }
.qwarn { border-radius: 4px; margin-bottom: 0.4rem; }

/* Collapsed muted-row stub (mute never removes a row from the page —
   pagination and totals stay truthful). */
td.mutedstub { color: #999; font-size: 0.85rem; }
td.mutedstub a { color: #999; }

/* API docs page (api_docs.html): readable reference styling — code
   blocks, inline code, status pills, the per-endpoint "token" tag. */
.apidocs { max-width: 920px; }
.apidocs h2 { margin-top: 1.6rem; border-bottom: 1px solid #ddd; padding-bottom: 0.2rem; }
.apidocs p, .apidocs li { line-height: 1.5; }
.apidocs code { background: #eef1f4; padding: 0.05rem 0.3rem; border-radius: 3px; font-size: 0.85rem; }
.apidocs pre { background: #1e2733; color: #e6edf3; padding: 0.8rem 1rem; border-radius: 4px; overflow-x: auto; font-size: 0.82rem; line-height: 1.45; }
.apidocs pre code { background: transparent; padding: 0; color: inherit; }
.apidocs table.rows code { background: transparent; padding: 0; }
.apidocs .apistatus { display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem; align-items: center; background: #fff; border: 1px solid #e3e3e3; border-radius: 4px; padding: 0.6rem 0.9rem; margin: 0.6rem 0 0.4rem; }
.apidocs .pill { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 10px; color: #fff; }
.apidocs .pill.on { background: #2e7d32; }
.apidocs .pill.off { background: #6c757d; }
.apidocs .reqtok { display: inline-block; font-size: 0.7rem; padding: 0.05rem 0.4rem; border-radius: 3px; background: #b8860b; color: #fff; }
