:root {
  --bg: #f6f7f9; --panel: #ffffff; --line: #e4e6ea; --text: #1a1d21; --muted: #6b7280;
  --accent: #2563eb; --accent-soft: #e8efff; --ok: #15803d; --warn: #b45309; --err: #b91c1c;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; }
h2 { font-size: 17px; } h3 { font-size: 14px; margin-top: 24px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.banner { background: #fff7ed; border-bottom: 1px solid #fed7aa; color: #9a3412; padding: 8px 16px; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.banner button { font-size: 12px; }

.layout { display: grid; grid-template-columns: 180px 380px 1fr; height: calc(100% - 37px); }
.nav { padding: 16px 10px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; background: var(--panel); }
.nav .brand { font-weight: 700; font-size: 15px; padding: 6px 10px 14px; }
.nav a { padding: 7px 10px; border-radius: 6px; display: flex; justify-content: space-between; color: #374151; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a b { background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.nav .spacer { flex: 1; }

.list { border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel); }
.list-head { padding: 14px 16px; font-weight: 600; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.list-head small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:hover { background: var(--bg); }
.item .from { font-weight: 600; } .item .date { color: var(--muted); font-size: 12px; }
.item .subject { margin: 2px 0 4px; }
.item .summary { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.4; }
.item .n { color: var(--muted); font-size: 12px; }
.item.has-draft { border-left: 3px solid var(--accent); }

.pane { overflow-y: auto; padding: 20px 28px; }
.pane.htmx-request, #pane.htmx-request { opacity: .5; }
.thread-head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.summary-box { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin: 10px 0 0; line-height: 1.45; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row .spacer { flex: 1; }
.meta { margin-top: 2px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #eef0f3; color: #374151; white-space: nowrap; }
.c-needs_reply, .c-draft { background: var(--accent-soft); color: var(--accent); }
.c-urgent, .c-needs_decision { background: #fee2e2; color: var(--err); }
.c-ignore { background: #f3f4f6; color: #9ca3af; }
.c-info, .c-routine { background: #ecfdf5; color: var(--ok); }

.messages { display: flex; flex-direction: column; gap: 12px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.msg.out { background: #fafbff; border-color: #dbe4ff; }
.body { white-space: pre-wrap; word-wrap: break-word; font-family: var(--font); font-size: 14px; line-height: 1.5; margin: 8px 0 0; }
.muted { color: var(--muted); } .small { font-size: 12px; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 6px; }

.draftbox { margin-top: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
textarea { width: 100%; font: inherit; line-height: 1.5; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 10px 0; resize: vertical; }
textarea:focus, input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; }

button, .button { font: inherit; font-size: 13px; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.secondary { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
button.ghost { background: transparent; color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
form.inline { display: inline; }

.error { color: var(--err); background: #fef2f2; padding: 8px 10px; border-radius: 6px; }
.warn { color: var(--warn); background: #fffbeb; padding: 8px 10px; border-radius: 6px; }
.ok { color: var(--ok); }
.empty { color: var(--muted); padding: 40px; text-align: center; }
.htmx-indicator { display: none; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

.settings { padding: 24px 32px; overflow-y: auto; grid-column: 2 / 4; max-width: 800px; }
table { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 500; }

body.center { display: flex; align-items: center; justify-content: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 320px; display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav .brand, .nav .spacer { display: none; }
  .list { max-height: 45vh; }
  .settings { grid-column: 1; }
}
