:root {
  --ink: #080a0b;
  --glass: #0d1113;
  --panel: #111619;
  --line: #263034;
  --muted: #899499;
  --bone: #ece9df;
  --cyan: #79eef5;
  --amber: #f3a640;
  --red: #ff665f;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--bone);
  background: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--ink); overflow: hidden; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.noise { position: fixed; inset: 0; pointer-events: none; opacity: .045; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.eyebrow { margin: 0 0 10px; color: var(--muted); font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; }

.gate { min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; padding: 32px; }
.gate[hidden] { display: none; }
.gate h1 { margin: 3px 0 12px; font: 400 clamp(38px, 6vw, 72px)/.95 Georgia, serif; letter-spacing: -.045em; }
.gate-copy { max-width: 480px; margin: 0 0 30px; color: #aeb7ba; line-height: 1.6; }
.gate-status { color: var(--muted); font-size: 12px; min-height: 18px; }
.gate-mark { width: 156px; height: 126px; position: relative; margin-bottom: 36px; border: 1px solid #313b3f; background: #101517; box-shadow: 0 24px 70px #000; }
.gate-mark::before { content: ""; position: absolute; inset: 16px; border: 1px solid #20292c; }
.gate-mark .slot { position: absolute; left: 22px; right: 22px; top: 46px; height: 34px; border: 1px solid #465156; background: #07090a; box-shadow: inset 0 10px 20px #000; }
.seal { position: absolute; z-index: 2; left: 59px; top: 49px; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--cyan); border-radius: 50%; color: var(--cyan); background: #0c1113; font: 700 12px/1 ui-monospace, monospace; letter-spacing: -.06em; }
.button { border: 1px solid #3a4448; background: #161c1f; color: var(--bone); padding: 11px 16px; text-decoration: none; cursor: pointer; }
.button:hover { border-color: #657277; }
.button.primary { border-color: var(--cyan); color: var(--cyan); padding: 14px 22px; font-weight: 700; }
.button.send { border-color: var(--amber); background: var(--amber); color: #17100a; font-weight: 800; }
.button.danger { border-color: var(--red); color: var(--red); }

.desk { min-height: 100vh; }
.masthead { height: 64px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 0 22px; background: #090c0d; }
.wordmark { display: flex; align-items: center; gap: 11px; font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.wordmark-2r { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--bone); border-radius: 50%; letter-spacing: -.08em; font-size: 10px; }
.mast-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.presence { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.presence.busy { animation: presence 1s ease-in-out infinite; }
@keyframes presence { 50% { opacity: .2; } }
.identity { margin-left: 14px; border: 1px solid var(--line); background: transparent; color: var(--bone); padding: 7px 10px; cursor: pointer; }

.workspace { height: calc(100vh - 64px); display: grid; grid-template-columns: 220px minmax(300px, 390px) 1fr; }
.rail, .correspondence { border-right: 1px solid var(--line); min-width: 0; }
.rail { display: flex; flex-direction: column; padding: 22px 14px 14px; background: #0a0d0f; }
.compose-button { width: 100%; border: 1px solid #3a4549; background: var(--bone); color: #0b0e10; padding: 11px 13px; text-align: left; font-weight: 800; cursor: pointer; }
.compose-button span { margin-right: 6px; }
.mailboxes { margin-top: 24px; display: grid; gap: 3px; }
.mailbox { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; border-left: 2px solid transparent; background: transparent; color: #a9b2b5; text-align: left; padding: 9px 11px; cursor: pointer; }
.mailbox:hover { color: var(--bone); background: #121719; }
.mailbox.active { border-left-color: var(--cyan); background: #141a1d; color: var(--bone); }
.mailbox small { color: #657075; }
.agent-state { margin-top: auto; padding: 14px 10px; border-top: 1px solid var(--line); }
.agent-line { display: flex; justify-content: space-between; gap: 8px; margin: 9px 0; color: #8f9a9e; font: 600 9px/1.25 ui-monospace, monospace; }
.agent-line b { color: var(--cyan); }
.agent-line b.off { color: var(--amber); }
.stop-control { display: flex; align-items: center; gap: 10px; width: 100%; border: 1px solid #683936; background: #1d1111; color: #ffc2bd; padding: 11px; text-align: left; cursor: pointer; }
.stop-control small { display: block; color: #9a7571; margin-top: 2px; }
.stop-control.stopped { border-color: var(--red); background: var(--red); color: #180807; }
.stop-control.stopped small { color: #481514; }
.stop-glyph { font-size: 11px; }

.correspondence { overflow: hidden; background: #0d1113; }
.list-head { height: 106px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px; border-bottom: 1px solid var(--line); }
.list-head h2 { margin: 0; font: 400 25px/1 Georgia, serif; }
.search { display: flex; align-items: center; gap: 7px; width: 138px; border-bottom: 1px solid #3a4448; color: var(--muted); }
.search input { width: 100%; border: 0; background: transparent; color: var(--bone); padding: 7px 0; font-size: 12px; }
.message-list { height: calc(100% - 106px); overflow-y: auto; }
.message-row { width: 100%; min-height: 106px; display: block; border: 0; border-bottom: 1px solid #20282b; background: transparent; color: inherit; padding: 16px 18px; text-align: left; cursor: pointer; }
.message-row:hover, .message-row.active { background: #151b1e; }
.message-row.active { box-shadow: inset 2px 0 var(--cyan); }
.message-row.unread .row-subject { color: var(--bone); }
.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.row-sender { font-size: 12px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-time { color: #707b7f; font: 9px/1 ui-monospace, monospace; white-space: nowrap; }
.row-subject { margin: 8px 0 4px; color: #abb4b7; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-preview { margin: 0; color: #667176; font-size: 11px; line-height: 1.35; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.empty-list { padding: 44px 22px; color: var(--muted); text-align: center; line-height: 1.6; }

.dispatch { min-width: 0; overflow-y: auto; background: #0a0d0e; }
.tray-empty { min-height: 100%; display: grid; place-content: center; justify-items: center; text-align: center; padding: 44px; }
.tray-empty h2 { margin: 0 0 8px; font: 400 32px/1 Georgia, serif; }
.tray-empty > p:last-child { max-width: 360px; color: var(--muted); line-height: 1.55; }
.dispatch-object { width: 190px; height: 120px; position: relative; margin-bottom: 34px; border: 1px solid #333d41; background: #111618; box-shadow: 0 30px 70px #000; overflow: hidden; }
.dispatch-object::before, .dispatch-flap { content: ""; position: absolute; left: 20px; right: 20px; height: 80px; border: 1px solid #313b3f; transform: rotate(45deg); top: -46px; }
.dispatch-seal { position: absolute; z-index: 2; left: calc(50% - 22px); top: 40px; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--cyan); border-radius: 50%; background: #0b1012; color: var(--cyan); font: 800 12px/1 ui-monospace, monospace; }
.message { padding: clamp(28px, 5vw, 74px); max-width: 940px; margin: 0 auto; }
.message-head h1 { margin: 4px 0 22px; max-width: 760px; font: 400 clamp(32px, 4vw, 54px)/1.02 Georgia, serif; letter-spacing: -.035em; }
.address-block { display: flex; align-items: center; gap: 12px; }
.address-block small { display: block; color: var(--muted); margin-top: 3px; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #415055; border-radius: 50%; color: var(--cyan); font: 700 11px/1 ui-monospace, monospace; }
.message-actions { display: flex; gap: 4px; margin: 24px 0; }
.message-actions button { border: 1px solid #2d383c; background: transparent; color: #aab4b7; padding: 8px 11px; cursor: pointer; }
.message-body { margin: 30px 0; border-top: 1px solid var(--line); padding-top: 30px; color: #d5d5cf; font: 400 15px/1.75 ui-sans-serif, sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }

dialog { color: var(--bone); }
dialog::backdrop { background: rgb(0 0 0 / .76); }
.composer { width: min(720px, calc(100vw - 30px)); height: min(680px, calc(100vh - 30px)); border: 1px solid #465156; background: #0d1113; padding: 0; box-shadow: 0 30px 100px #000; }
.composer form { height: 100%; display: grid; grid-template-rows: auto auto auto 1fr auto auto; }
.composer header { display: flex; justify-content: space-between; padding: 24px; border-bottom: 1px solid var(--line); }
.composer h2 { margin: 0; font: 400 27px/1 Georgia, serif; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 28px; cursor: pointer; }
.composer label { display: grid; grid-template-columns: 78px 1fr; align-items: center; border-bottom: 1px solid var(--line); padding: 0 24px; color: var(--muted); font-size: 12px; }
.composer input { border: 0; background: transparent; color: var(--bone); padding: 16px 0; }
.composer textarea { resize: none; border: 0; background: transparent; color: var(--bone); padding: 24px; line-height: 1.65; }
.composer footer { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 24px; border-top: 1px solid var(--line); }
.compose-status { min-height: 18px; margin: 0; padding: 0 24px 14px; color: var(--muted); font-size: 11px; text-align: right; }
.confirm-dialog { width: min(450px, calc(100vw - 30px)); border: 1px solid #673a38; background: #120d0e; padding: 30px; }
.confirm-dialog h2 { font: 400 32px/1 Georgia, serif; margin: 0 0 12px; }
.confirm-dialog p:not(.eyebrow) { color: #b4a5a2; line-height: 1.55; }
.confirm-dialog form > div { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 76px minmax(280px, 360px) 1fr; }
  .rail { padding-inline: 8px; }
  .rail .eyebrow, .compose-button:not(:focus) { font-size: 0; }
  .compose-button span { font-size: 22px; }
  .mailbox { justify-content: center; padding-inline: 5px; }
  .mailbox span { max-width: 48px; overflow: hidden; font-size: 9px; text-align: center; }
  .mailbox small, .agent-state { display: none; }
  .stop-control { justify-content: center; }
  .stop-control span:last-child { display: none; }
}

@media (max-width: 700px) {
  body { overflow: auto; }
  .workspace { height: auto; min-height: calc(100vh - 64px); grid-template-columns: 58px 1fr; }
  .correspondence { border-right: 0; }
  .dispatch { grid-column: 2; min-height: 60vh; border-top: 1px solid var(--line); }
  .list-head { padding: 16px; }
  .message { padding: 30px 22px; }
  .wordmark span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) { .presence.busy { animation: none; } }
