@font-face { font-family: Geist; src: url("./fonts/geist-latin.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("./fonts/geist-mono-latin.woff2") format("woff2"); font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #fff;
  --surface-2: #f8f9fa;
  --ink: #15191c;
  --muted: #687178;
  --faint: #949ca2;
  --line: #e2e6e8;
  --line-strong: #cbd1d5;
  --primary: #17201c;
  --primary-hover: #26332d;
  --accent: #32765e;
  --accent-soft: #e6f2ed;
  --danger: #a9453e;
  --danger-soft: #f8e9e7;
  --warning: #96651e;
  --focus: rgba(50, 118, 94, .23);
  --shadow: 0 1px 2px rgba(17, 24, 20, .04), 0 8px 24px rgba(17, 24, 20, .035);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0d0f;
  --surface: #111518;
  --surface-2: #151a1d;
  --ink: #edf0f1;
  --muted: #929ba0;
  --faint: #6f777c;
  --line: #252b2f;
  --line-strong: #343c41;
  --primary: #edf0f1;
  --primary-hover: #dfe5e2;
  --accent: #73b79e;
  --accent-soft: #17372d;
  --danger: #e58b83;
  --danger-soft: #3b211f;
  --warning: #d5a65e;
  --focus: rgba(115, 183, 158, .28);
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 12px 30px rgba(0, 0, 0, .15);
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--bg); font-family: Geist, Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.mono { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace; }
svg { display: block; width: 18px; height: 18px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.btn { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; background: transparent; cursor: pointer; font-size: .78rem; font-weight: 650; transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease; }
.btn:active, .icon-btn:active, .switch-new:active, .address:active { transform: translateY(1px); }
.btn-primary { color: var(--surface); background: var(--primary); }
html[data-theme="dark"] .btn-primary, html[data-theme="dark"] .mailbox[aria-current="true"] { color: #101513; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-ghost { min-height: 34px; padding: 0 7px; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }

.input { width: 100%; height: 42px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 9px; outline: 0; color: var(--ink); background: var(--surface); font-size: .8rem; transition: border-color 140ms ease, box-shadow 140ms ease; }
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.form-error { min-height: 17px; margin: 7px 0 0; color: var(--danger); font-size: .7rem; }

/* Sign in */
.login { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 24px; overflow: hidden; }
.login::before { content: ""; position: absolute; width: 440px; height: 440px; top: -280px; right: -170px; border: 80px solid var(--accent-soft); border-radius: 50%; opacity: .7; }
.login-card { position: relative; z-index: 1; width: min(100%, 440px); padding: 38px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.login-head, .brand { display: flex; align-items: center; gap: 9px; }
.wordmark-logo { color: var(--ink); font-size: .93rem; font-weight: 720; letter-spacing: -.055em; }
.login-card h1 { max-width: 330px; margin: 35px 0 11px; font-size: clamp(1.75rem, 7vw, 2.35rem); font-weight: 610; line-height: 1.08; letter-spacing: -.047em; }
.login-copy { margin: 0 0 29px; color: var(--muted); font-size: .84rem; line-height: 1.6; }
.server-gate { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 58px; margin: 0 0 18px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.server-gate-copy { min-width: 0; display: flex; align-items: center; gap: 10px; }
.server-gate-copy > span:last-child { min-width: 0; display: grid; gap: 2px; }
.server-gate strong { font-size: .72rem; font-weight: 680; }
.server-gate small { overflow: hidden; color: var(--muted); font-size: .64rem; line-height: 1.35; text-overflow: ellipsis; }
.server-gate .btn { min-height: 34px; flex: 0 0 auto; padding-inline: 11px; }
.server-gate[data-state="checking"] .dot, .server-gate[data-state="waking"] .dot { animation: pulse 1s ease-in-out infinite; }
.server-gate[data-state="active"] .dot { background: #3d906f; box-shadow: 0 0 0 4px rgba(61, 144, 111, .1); }
.server-gate[data-state="sleeping"] .dot, .server-gate[data-state="error"] .dot { background: #be8133; }
.login-field label { display: block; margin-bottom: 7px; font-size: .71rem; font-weight: 650; }
.login-row { display: flex; gap: 8px; }
.login-row .input, .login-row .btn { height: 44px; }
.login-foot { display: flex; align-items: center; gap: 7px; margin: 18px 0 0; color: var(--muted); font-size: .66rem; }

/* Main shell */
.page { width: min(100% - 32px, 920px); margin: 0 auto; padding-bottom: 34px; }
.bar { height: 68px; display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--ink); text-decoration: none; }
.bar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { display: grid; width: 36px; height: 36px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--surface); cursor: pointer; transition: background 140ms ease, color 140ms ease, transform 140ms ease; }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }

.switch { display: flex; align-items: center; gap: 8px; margin: 9px 0 13px; overflow-x: auto; scrollbar-width: none; }
.switch::-webkit-scrollbar { display: none; }
.switch > .site-chips { display: flex; min-width: 0; gap: 7px; }
.mailbox { min-height: 34px; flex: 0 0 auto; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); cursor: pointer; font-size: .7rem; font-weight: 580; transition: border-color 140ms ease, background 140ms ease, color 140ms ease; }
.mailbox:hover { color: var(--ink); border-color: var(--line-strong); }
.mailbox[aria-current="true"] { color: var(--surface); border-color: var(--primary); background: var(--primary); }
.switch-new { display: grid; width: 34px; height: 34px; flex: 0 0 auto; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: var(--surface); cursor: pointer; }
.switch-new:hover { color: var(--ink); border-color: var(--line-strong); }

.card { margin-top: 12px; padding: 25px 27px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.label { color: var(--muted); font-size: .66rem; font-weight: 690; letter-spacing: .075em; text-transform: uppercase; }
.card-label { display: block; margin-bottom: 9px; }

.address { width: 100%; min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0; border: 0; border-radius: 8px; text-align: left; background: transparent; cursor: pointer; }
.address-text { min-width: 0; overflow: hidden; font-family: "Geist Mono", ui-monospace, monospace; font-size: clamp(1.12rem, 4vw, 1.72rem); font-weight: 520; letter-spacing: -.045em; text-overflow: ellipsis; white-space: nowrap; }
.address-copy { min-height: 37px; display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: var(--surface-2); font-size: .69rem; font-weight: 670; }
.address:hover .address-copy { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.address-copy[data-copied="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.address-copy svg { width: 15px; height: 15px; }

.sites { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding-top: 16px; border-top: 1px solid var(--line); }
.sites-label { margin-right: 3px; color: var(--muted); font-size: .68rem; font-weight: 570; }
.site-chips { display: contents; }
.chip { min-height: 31px; display: inline-flex; align-items: center; gap: 4px; padding: 0 5px 0 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: var(--surface-2); font-size: .67rem; }
.chip-suggested { border-style: dashed; }
.chip button { min-width: 26px; height: 26px; display: grid; padding: 0 4px; place-items: center; border: 0; border-radius: 999px; color: var(--faint); background: transparent; cursor: pointer; font-size: .62rem; }
.chip button svg { width: 13px; height: 13px; }
.chip button:hover { color: var(--danger); background: var(--danger-soft); }
.chip .chip-confirm { width: auto; color: var(--warning); font-weight: 680; }
.chip .chip-confirm:hover { color: var(--accent); background: var(--accent-soft); }
.chip-add { min-height: 31px; padding: 0 4px; border: 0; color: var(--accent); background: transparent; cursor: pointer; font-size: .67rem; font-weight: 650; }
.chip-add:hover { text-decoration: underline; text-underline-offset: 3px; }
.site-add { width: min(210px, 100%); }
.site-add .input { height: 32px; border-radius: 7px; font-size: .7rem; }

/* Inbox */
.card-inbox { padding-bottom: 8px; }
.inbox-head { min-height: 34px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.inbox-title { display: flex; align-items: center; gap: 9px; }
.inbox-count { min-width: 19px; height: 19px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); background: var(--surface-2); font-size: .6rem; }
.inbox-count:empty { display: none; }
.inbox-live { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: .66rem; }
.dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: #be8133; }
.dot-live { background: #3d906f; box-shadow: 0 0 0 4px rgba(61, 144, 111, .1); }

.message-list { margin-top: 5px; }
.msg { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; padding: 21px 0; border-top: 1px solid var(--line); }
.msg-new::before { content: ""; position: absolute; top: 24px; left: -27px; width: 3px; height: 23px; border-radius: 0 4px 4px 0; background: var(--accent); }
.msg-main { min-width: 0; }
.msg-top { min-width: 0; display: flex; align-items: center; gap: 8px; }
.msg-from { min-width: 0; overflow: hidden; font-size: .73rem; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { flex: 0 0 auto; color: var(--faint); font-size: .62rem; }
.msg-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; opacity: 0; transition: opacity 140ms ease; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.msg-actions button { min-height: 28px; padding: 0; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: .62rem; }
.msg-actions button:hover { color: var(--ink); }
.msg-actions .is-danger:hover { color: var(--danger); }
.msg-subject { margin: 7px 0 4px; overflow: hidden; font-size: .86rem; font-weight: 630; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { max-width: 610px; margin: 0; overflow: hidden; color: var(--muted); font-size: .72rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.code-value { min-width: 126px; align-self: center; padding: 10px 12px; border: 1px solid #bfd9cf; border-radius: 9px; color: var(--accent); background: var(--accent-soft); font-family: "Geist Mono", ui-monospace, monospace; font-size: 1.04rem; font-weight: 650; letter-spacing: .13em; cursor: pointer; }
.code-value:hover { border-color: var(--accent); }
.code-value[data-copied="true"] { color: var(--surface); background: var(--accent); }
.msg-body { grid-column: 1 / -1; margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--surface-2); font-family: Geist, sans-serif; font-size: .72rem; line-height: 1.6; white-space: pre-wrap; }

.inbox-empty { padding: 58px 20px 64px; border-top: 1px solid var(--line); text-align: center; }
.inbox-empty h3 { margin: 0 0 7px; font-size: .88rem; font-weight: 630; }
.inbox-empty p { max-width: 360px; margin: 0 auto; color: var(--muted); font-size: .71rem; line-height: 1.55; }
.empty { margin-top: 12px; padding: 80px 30px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: center; box-shadow: var(--shadow); }
.empty h2 { margin: 0 0 8px; font-size: 1.25rem; font-weight: 620; letter-spacing: -.03em; }
.empty p { max-width: 440px; margin: 0 auto 23px; color: var(--muted); font-size: .78rem; line-height: 1.6; }

/* Loading, footer and feedback */
.skeleton-row { padding: 21px 0; border-top: 1px solid var(--line); }
.skeleton { height: 8px; margin-top: 8px; border-radius: 999px; background: var(--surface-2); animation: shimmer 1.25s ease-in-out infinite alternate; }
.skeleton-sm { width: 16%; }
.skeleton-md { width: 39%; }
.skeleton-lg { width: 63%; }
.foot { min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 5px; color: var(--faint); font-size: .61rem; }
.foot-status { display: flex; align-items: center; gap: 7px; }
.foot-status[data-state="ready"] .dot { background: #3d906f; }
.foot-status[data-state="offline"] .dot { background: var(--danger); }
.foot-status[data-state="starting"] .dot { animation: pulse 1.2s ease-in-out infinite; }
.foot-keys { display: flex; gap: 13px; }
.foot-keys > span { display: flex; align-items: center; gap: 4px; }
kbd { min-width: 18px; height: 18px; display: inline-grid; padding: 0 4px; place-items: center; border: 1px solid var(--line); border-bottom-color: var(--line-strong); border-radius: 4px; color: var(--muted); background: var(--surface); font: inherit; }

.toast { position: fixed; z-index: 30; right: 22px; bottom: 22px; max-width: min(360px, calc(100vw - 32px)); padding: 11px 14px; border: 1px solid rgba(255,255,255,.08); border-radius: 9px; color: #fff; background: #17201c; box-shadow: 0 14px 35px rgba(0,0,0,.2); font-size: .71rem; opacity: 0; transform: translateY(7px); pointer-events: none; transition: opacity 170ms ease, transform 170ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@keyframes pulse { 50% { opacity: .3; } }
@keyframes shimmer { from { opacity: .45; } to { opacity: 1; } }

@media (max-width: 640px) {
  .page { width: min(100% - 24px, 920px); }
  .bar { height: 60px; }
  .switch { margin-top: 7px; }
  .card { padding: 21px 18px; border-radius: 12px; }
  .address { min-height: 78px; align-items: flex-start; flex-direction: column; justify-content: center; gap: 11px; }
  .address-text { width: 100%; font-size: 1rem; }
  .address-copy { width: 100%; justify-content: center; }
  .sites { margin-top: 8px; }
  .msg { grid-template-columns: 1fr; gap: 12px; }
  .msg-new::before { left: -18px; }
  .msg-actions { opacity: 1; }
  .code-value { width: 100%; }
  .foot-keys { display: none; }
}

@media (max-width: 430px) {
  .login { padding: 13px; }
  .login-card { padding: 28px 22px; border-radius: 15px; }
  .login-row { flex-direction: column; }
  .login-row .btn { width: 100%; }
  .btn-ghost { display: none; }
  .card { padding-inline: 16px; }
  .inbox-live { font-size: 0; }
  .inbox-live .dot { margin-top: 4px; }
  .msg-top { flex-wrap: wrap; }
  .msg-actions { width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
