/* Layout and theme on top of 98.css.
   Palette stays in the 98 family but a touch warmer and dimmer than pure
   white, so long reading sessions are easier on the eyes. */

:root {
  --desktop:      #6b7b8c;   /* muted slate, not the classic harsh teal */
  --surface:      #d6d3ce;   /* window chrome, slightly warm grey */
  --field:        #f4f2ef;   /* text fields / lists: off-white, not #fff */
  --field-alt:    #eceae6;   /* zebra striping */
  --ink:          #1c1c1c;
  --ink-soft:     #55524e;
  --accent:       #0a246a;   /* 98 selection blue */
  --accent-text:  #ffffff;
  --unread:       #0a246a;
  --hairline:     #a9a5a0;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--desktop);
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
}

.screen { height: 100vh; }
.screen.center { display: grid; place-items: center; }
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 24, 30, .45);
  display: grid; place-items: center;
}
[hidden] { display: none !important; }

/* icons ------------------------------------------------------------ */
.svg-inline, [data-lucide] { vertical-align: -2px; }
svg[class*="lucide"] { width: 14px; height: 14px; stroke-width: 2; }
.tb-icon svg, svg.tb-icon { width: 12px; height: 12px; }
.empty-icon svg, svg.empty-icon { width: 40px; height: 40px; opacity: .35; }

/* login ------------------------------------------------------------ */
.login-window { width: 330px; }
.login-actions { justify-content: flex-end; margin-top: 12px; }
.error { color: #8a1010; margin: 8px 0 0; font-size: 12px; }

/* app frame -------------------------------------------------------- */
.app-window {
  width: calc(100vw - 24px);
  height: calc(100vh - 24px);
  margin: 12px;
  display: flex; flex-direction: column;
}
.app-window > .window-body { flex: 1; min-height: 0; margin: 6px; }

.menu-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 6px;
  border-bottom: 1px solid var(--hairline);
}
.menu-bar button { min-width: 0; padding: 3px 9px; display: inline-flex; align-items: center; gap: 5px; }
.menu-sep { width: 1px; height: 18px; background: var(--hairline); margin: 0 4px; }
.menu-spacer { flex: 1; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap .search-icon { position: absolute; left: 5px; opacity: .5; pointer-events: none; }
.search-wrap input { padding-left: 22px; width: 230px; }

/* three panes ------------------------------------------------------ */
.app-body { display: grid; grid-template-columns: 172px 340px 1fr; gap: 6px; }
.pane { background: var(--field); min-height: 0; display: flex; flex-direction: column; }
.pane-header {
  padding: 4px 8px; font-weight: bold; background: var(--surface);
  border-bottom: 1px solid var(--hairline); flex: 0 0 auto;
}
.scroll { overflow-y: auto; flex: 1; min-height: 0; }

/* folders ---------------------------------------------------------- */
.folder-item {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; cursor: default; user-select: none;
}
.folder-item:hover { background: var(--field-alt); }
.folder-item.active { background: var(--accent); color: var(--accent-text); }
.folder-item .count { margin-left: auto; font-size: 11px; opacity: .8; }
.folder-item.has-unread .fname { font-weight: bold; }
.folder-item.active .count { opacity: .95; }

/* message list ----------------------------------------------------- */
.msg-row {
  padding: 6px 9px; cursor: default; user-select: none;
  border-bottom: 1px solid #e2dfda;
}
.msg-row:nth-child(even) { background: var(--field-alt); }
.msg-row:hover { background: #e4e9f2; }
.msg-row.active { background: var(--accent); color: var(--accent-text); }
.msg-row.active .msg-sub, .msg-row.active .msg-preview, .msg-row.active .msg-date { color: var(--accent-text); }
.msg-top { display: flex; align-items: baseline; gap: 6px; }
.msg-from { font-weight: bold; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-date { font-size: 11px; color: var(--ink-soft); flex: 0 0 auto; }
.msg-sub { margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row.unread .msg-from, .msg-row.unread .msg-sub { color: var(--unread); font-weight: bold; }
.msg-preview {
  font-size: 11px; color: var(--ink-soft); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-badges { display: inline-flex; gap: 4px; opacity: .7; }

/* reader ----------------------------------------------------------- */
.reader-head { padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--hairline); }
.reader-subject { font-size: 15px; font-weight: bold; margin: 0 0 6px; }
.reader-meta { font-size: 11px; color: var(--ink-soft); line-height: 1.55; }
.reader-meta b { color: var(--ink); }
.reader-actions { display: flex; gap: 4px; margin-top: 9px; flex-wrap: wrap; }
.reader-actions button { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; }
.reader-body { padding: 12px; }
.reader-body pre {
  margin: 0; white-space: pre-wrap; word-wrap: break-word;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; line-height: 1.5;
}
#html-frame { width: 100%; border: 0; background: #fff; min-height: 320px; }
.attachments { padding: 8px 12px; border-top: 1px solid var(--hairline); background: var(--surface); }
.attachments a { display: inline-flex; align-items: center; gap: 5px; margin-right: 12px; }
.empty-state {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; color: var(--ink-soft);
}

/* compose / admin -------------------------------------------------- */
.compose-window { width: min(720px, 94vw); }
.compose-window .field-row { margin-bottom: 6px; }
.compose-window .field-row label { width: 62px; }
.compose-window .field-row input { flex: 1; }
.compose-window textarea { width: 100%; box-sizing: border-box; font-family: ui-monospace, Consolas, monospace; }
.compose-actions { justify-content: flex-start; gap: 6px; margin-top: 10px; align-items: center; }
.compose-from { margin-left: auto; font-size: 11px; color: var(--ink-soft); }

.admin-window { width: min(880px, 94vw); max-height: 88vh; }
.admin-panel { max-height: 62vh; overflow: auto; }
.admin-panel table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-panel th, .admin-panel td { text-align: left; padding: 4px 7px; border-bottom: 1px solid var(--hairline); }
.admin-panel th { background: var(--surface); position: sticky; top: 0; }
.admin-add { display: flex; gap: 6px; margin-bottom: 10px; align-items: center; }
.pill { padding: 1px 6px; border: 1px solid var(--hairline); background: var(--field-alt); font-size: 11px; }
.ok { color: #14601a; } .fail { color: #8a1010; }

@media (max-width: 1000px) {
  .app-body { grid-template-columns: 140px 1fr; }
  .pane-read { display: none; }
  .app-body.reading { grid-template-columns: 1fr; }
  .app-body.reading .pane-folders, .app-body.reading .pane-list { display: none; }
  .app-body.reading .pane-read { display: flex; }
}
