:root {
  --bg: #0f1218;
  --panel: #171b24;
  --panel-2: #1e2430;
  --line: #2a3140;
  --text: #e8ebf0;
  --muted: #9aa3b2;
  --accent: #f2c14e;
  --accent-ink: #1a1400;
  --ok: #58c38b;
  --warn: #f08a4b;
  --err: #e2586b;
  --mention: #6ea8fe;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; }
code { font-family: var(--mono); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 6px; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.quick { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button[disabled] { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
textarea { resize: vertical; }
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); }
.en { color: var(--muted); font-weight: 400; font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.error { color: var(--err); }

.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); gap: 16px; flex-wrap: wrap; }
.brand { display: flex; gap: 12px; align-items: center; }
.moon { font-size: 28px; color: var(--accent); }
.name { font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.tagline { color: var(--muted); font-size: 12px; }
.session { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.session .label { font-size: 11px; color: var(--muted); }
.session code { background: var(--panel-2); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); }

.gate { display: grid; place-items: center; min-height: calc(100% - 70px); padding: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; max-width: 520px; width: 100%; }
.card h1 { margin: 0 0 12px; font-size: 20px; }
.card p { color: var(--muted); line-height: 1.6; }

.app { display: grid; grid-template-columns: minmax(320px, 5fr) minmax(360px, 7fr); gap: 16px; padding: 16px; height: calc(100% - 70px); }
@media (max-width: 900px) { .app { grid-template-columns: 1fr; height: auto; } }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pane-head { padding: 14px 16px 8px; border-bottom: 1px solid var(--line); }
.pane-head h2 { margin: 0 0 4px; font-size: 15px; }
.hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.acting { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.acting select { width: auto; padding: 2px 6px; }

.compose { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.compose label.file input { padding: 4px; }
.status { color: var(--muted); font-size: 12px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.list { overflow: auto; padding: 8px 16px 16px; flex: 1; }
.mail-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 8px; background: var(--panel-2); }
.mail-item.received { border-left: 3px solid var(--ok); }
.mail-item.sent { border-left: 3px solid var(--muted); }
.mail-item .meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.mail-item .subject { font-weight: 600; margin: 4px 0; }
.mail-item pre { white-space: pre-wrap; margin: 6px 0 0; font-family: var(--sans); color: var(--text); font-size: 13px; line-height: 1.5; }
.mail-item .att { font-size: 12px; color: var(--muted); margin-top: 6px; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--line); color: var(--text); }
.badge.received { background: rgba(88,195,139,.2); color: var(--ok); }

.posts { overflow: auto; padding: 8px 16px 16px; flex: 1; }
.empty { color: var(--muted); padding: 24px; text-align: center; line-height: 1.6; }
.thread { border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; background: var(--panel-2); }
.post { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.post .who { font-weight: 600; font-size: 13px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.post .who .time { color: var(--muted); font-weight: 400; font-size: 11px; }
.post .avatar { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: 12px; }
.post.person .avatar { background: var(--mention); color: #04122a; }
.post pre { white-space: pre-wrap; margin: 0; font-family: var(--sans); line-height: 1.55; font-size: 13px; }
.post .mention { color: var(--mention); font-weight: 600; }
.post .actions { margin-top: 8px; display: flex; gap: 8px; }
.post .actions button.cancel { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.replies .post { padding-left: 28px; background: rgba(0,0,0,.12); }
.reply-form { padding: 10px 12px 12px 28px; }
.reply-form textarea { margin-bottom: 6px; }

.samples { margin-top: 8px; }
.samples button { padding: 4px 10px; font-size: 12px; }
.spacer { flex: 1; }
/* The phone panel gets its own row so escalation SMS stay readable next to a long mailbox. */
.pane.mail { display: grid; grid-template-rows: auto auto minmax(160px, 1fr) minmax(220px, 32%); }
.pane.mail .list { min-height: 0; }
.phone { border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.phone .pane-head { padding-top: 10px; }
.phone .list { min-height: 0; }
.sms-item { border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 8px; padding: 8px 12px; margin-top: 8px; background: var(--panel-2); font-size: 13px; }
.sms-item .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.sms-item .status { text-transform: uppercase; letter-spacing: .04em; }
.plan { margin: 8px 0 0; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; font-size: 12px; background: rgba(242,193,78,.06); }
.plan .title { font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.plan ol { margin: 0; padding-left: 18px; }
.plan li { margin: 2px 0; }
.plan li.sent { color: var(--ok); }
.plan li.skipped { color: var(--muted); text-decoration: line-through; }
.plan li.pending { color: var(--text); }
.plan .why { color: var(--muted); margin-top: 4px; }
.plan .status { float: right; font-size: 11px; color: var(--muted); }
.actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.actions button.ack, .actions button.adopt { background: var(--ok); color: #04200f; }
.actions button.cancel, .actions button.dismiss { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.policy { border-top: 1px solid var(--line); padding: 8px 16px 12px; max-height: 40%; overflow: auto; }
.policy summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.policy ul { list-style: none; padding: 0; margin: 8px 0; }
.policy li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; font-size: 13px; border-bottom: 1px dotted var(--line); }
.policy li code { color: var(--muted); font-size: 11px; white-space: nowrap; }
.policy li .origin { font-size: 11px; color: var(--muted); }
.policy li button { padding: 2px 8px; font-size: 11px; margin-left: auto; }
.policy .notes li { color: var(--muted); }
.policy .notes li .state { font-size: 11px; border: 1px solid var(--line); border-radius: 10px; padding: 0 6px; }
.policy form input { flex: 1; }
.reassign-to { width: auto; padding: 2px 6px; }
