:root {
  color-scheme: light;
  --ground: #f5f4f2;
  --paper: #ffffff;
  --ink: #202b38;
  --muted: #5f6c7b;
  --line: #dde2e8;
  --accent: #245b86;
  --accent-hover: #19486d;
  --selected: #edf4fa;
  --error: #a03331;
  --warning: #80580d;
  --success: #276746;
  --focus: #2c6d9e;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--ground);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button, input, textarea, a { outline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); }
::selection { color: #12354f; background: #d3e7f5; }
a { color: var(--accent); text-underline-offset: 3px; }
.app { width: min(100%, 920px); min-height: 100dvh; margin-inline: auto; padding: 28px 24px 40px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 18px; line-height: 1.4; font-weight: 650; letter-spacing: -.025em; }
.brand-icon { width: 24px; height: 24px; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mailbox-button { display: inline-flex; align-items: center; gap: 7px; max-width: 48%; min-height: 32px; overflow: hidden; padding: 5px 9px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-button:hover { color: var(--ink); background: #e8edf2; }
.mailbox-button.is-connected::before { flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--success); content: ''; }
.search-bar { display: grid; grid-template-columns: minmax(0, 1fr) 104px; align-items: end; gap: 8px; margin: 0; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { color: #4e5d6c; font-size: 12px; font-weight: 600; line-height: 18px; }
input, textarea { display: block; width: 100%; min-height: 40px; padding: 9px 11px; color: var(--ink); background: var(--paper); border: 1px solid #b9c4cf; border-radius: 7px; line-height: 20px; caret-color: var(--accent); transition: border-color 150ms ease-out; }
input { height: 40px; }
textarea { height: 40px; min-height: 40px; max-height: 120px; resize: vertical; overflow-y: auto; }
input::placeholder, textarea::placeholder { color: #697887; opacity: 1; }
input:hover, textarea:hover { border-color: #91a2b3; }
input:focus, textarea:focus { border-color: var(--focus); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: 7px; white-space: nowrap; font-weight: 600; font-size: 13px; transition: background-color 150ms ease-out; }
.button-primary { color: var(--paper); background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-primary:active:not(:disabled) { background: #123d5e; }
.button-secondary { color: var(--accent); background: #f5f8fb; border-color: var(--line); }
.button-secondary:hover:not(:disabled) { background: #e9f1f7; }
.status-message { min-height: 28px; margin: 0; padding: 6px 0; color: var(--muted); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
.status-message[data-tone="error"], .connection-status[data-tone="error"] { color: var(--error); }
.status-message[data-tone="warning"] { color: var(--warning); }
.status-message[data-tone="success"], .connection-status[data-tone="success"] { color: var(--success); }
.status-message[data-tone="pending"], .connection-status[data-tone="pending"] { color: var(--accent); }
.workspace { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.message-column { min-width: 0; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.message-list { max-height: min(36dvh, 320px); margin: 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; }
.message-list li + li { border-top: 1px solid #e8ecf0; }
.message-row { display: block; width: 100%; padding: 12px 16px; border: 0; border-radius: 0; color: var(--ink); background: var(--paper); text-align: left; }
.message-row:hover { background: #f5f8fb; }
.message-row[aria-current="true"] { background: var(--selected); }
.message-row:focus-visible { position: relative; outline-offset: -3px; }
.row-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.row-sender { flex: 1; min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.row-date { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-subject { display: block; overflow: hidden; margin-top: 2px; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row-snippet { display: block; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.row-snippet:empty { display: none; }
.row-attachments { display: block; margin-top: 3px; color: var(--accent); font-size: 11px; }
.list-empty { padding: 28px 20px; color: var(--muted); font-size: 13px; text-align: center; }
.load-more { display: flex; margin: 12px auto; }
.reader { min-width: 0; padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; scroll-margin-top: 20px; }
.reader[aria-busy="true"] { cursor: progress; }
.reader-empty { color: var(--muted); }
.message-header h2 { margin: 0 0 14px; font-size: 20px; line-height: 1.4; font-weight: 650; letter-spacing: -.02em; overflow-wrap: anywhere; }
.message-metadata { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0 0 16px; font-size: 12px; line-height: 18px; }
.message-metadata dt { color: var(--muted); }
.message-metadata dd { margin: 0; overflow-wrap: anywhere; }
.body-controls { display: flex; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
.body-controls button { min-height: 30px; padding: 5px 10px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 600; }
.body-controls button:hover:not(:disabled) { background: #f0f4f8; }
.body-controls button[aria-pressed="true"] { color: var(--accent); background: #eaf2f8; }
.message-text { max-width: 75ch; margin: 0; font: inherit; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-html { width: 100%; height: 60dvh; min-height: 200px; border: 0; background: var(--paper); }
.attachments { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.attachments h3 { margin: 0 0 8px; font-size: 12px; font-weight: 650; }
.attachments ul { margin: 0; padding: 0; list-style: none; }
.attachments li { padding: 4px 0; overflow-wrap: anywhere; }
.attachment-download { border: 0; padding: 0; background: transparent; color: var(--accent); font-size: 12px; text-align: left; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.mailbox-dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; color: var(--ink); background: var(--paper); border: 0; border-radius: 16px; box-shadow: 0 20px 64px rgb(21 35 51 / .2); opacity: 0; transform: translateY(8px); transition: opacity 180ms ease-out, transform 180ms ease-out, display 180ms allow-discrete, overlay 180ms allow-discrete; }
.mailbox-dialog[open] { opacity: 1; transform: translateY(0); }
.mailbox-dialog::backdrop { background: rgb(27 41 57 / 0); transition: background-color 180ms ease-out, display 180ms allow-discrete, overlay 180ms allow-discrete; }
.mailbox-dialog[open]::backdrop { background: rgb(27 41 57 / .28); }
.connection-form { display: grid; gap: 12px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.dialog-header h2 { margin: 0; font-size: 20px; line-height: 1.4; font-weight: 650; letter-spacing: -.02em; }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 auto; width: 32px; height: 32px; padding: 7px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; }
.icon-button:hover { color: var(--ink); background: #f0f3f6; }
.icon-button svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.host-port { display: grid; grid-template-columns: minmax(0, 1fr) 80px; gap: 10px; }
.connection-status { margin: 0; font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
.connection-status:empty { display: none; }
.test-button { width: 100%; margin-top: 4px; }
@starting-style { .mailbox-dialog[open] { opacity: 0; transform: translateY(8px); } .mailbox-dialog[open]::backdrop { background: rgb(27 41 57 / 0); } }
@media (max-width: 640px) { .app { padding: 20px 16px 32px; } .app-header { margin-bottom: 20px; } .reader { padding: 18px; } .row-sender { flex-basis: 100%; } }
@media (max-width: 360px) { .search-bar { grid-template-columns: minmax(0, 1fr) auto; } .mailbox-dialog { padding: 20px; } .host-port { grid-template-columns: minmax(0, 1fr) 72px; } }
@media (pointer: coarse) { .button, .body-controls button, .mailbox-button, .icon-button, input, textarea { min-height: 44px; } input, textarea { padding-block: 11px; } .icon-button { width: 44px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
