:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f0f1e9;
  background: #131410;
  color-scheme: dark;
  --page: #131410;
  --sidebar: #191b16;
  --list: #1d201a;
  --reader: #181a15;
  --surface: #22251e;
  --surface-hover: #2a2e23;
  --selected: #2d3522;
  --border: #373b31;
  --border-strong: #535a48;
  --text: #f0f1e9;
  --muted: #b0b6a6;
  --accent: #dbfb3c;
  --accent-hover: #e5ff78;
  --on-accent: #151a0d;
  --error: #ffaea8;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.12rem; letter-spacing: -.025em; font-weight: 670; }
h3 { overflow-wrap: anywhere; }
button, input, select { font: inherit; }

.site-header { background: var(--page); border-bottom: 1px solid var(--border); }
.header-inner, .main-content { width: min(1512px, calc(100% - 64px)); margin-inline: auto; }
.header-inner { min-height: 73px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.main-content { padding-block: 26px 28px; }
.wordmark { display: flex; align-items: center; gap: 11px; font-size: 1.3rem; font-weight: 730; letter-spacing: -.05em; line-height: 1; }
.brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #363a2e;
  border-radius: 11px;
  background: #1d2017;
}
.brand-mark img { display: block; width: 100%; height: 100%; transform: scale(1.72); mix-blend-mode: screen; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
}
.button-primary { color: var(--on-accent); background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-quiet { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
.button-quiet:hover:not(:disabled) { background: var(--surface-hover); }
.button-small { min-height: 35px; padding-inline: 10px; font-size: .79rem; }
.button-danger { background: transparent; color: var(--error); border-color: transparent; }
.button-danger:hover:not(:disabled) { color: #ffcbc7; background: #362821; }
.button:disabled { cursor: default; opacity: .58; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
label { color: var(--muted); font-size: .8rem; font-weight: 620; }
input, select {
  min-height: 42px;
  min-width: 0;
  width: 100%;
  padding: 9px 11px;
  color: var(--text);
  background: var(--page);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: .87rem;
}
input::placeholder { color: var(--muted); opacity: 1; }

.startup { max-width: 448px; margin: 100px auto; text-align: center; color: var(--muted); }
.login-card {
  width: min(100%, 424px);
  margin: clamp(34px, 10vh, 108px) auto;
  padding: clamp(22px, 5vw, 36px);
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-top-color: #666e4d;
  border-radius: 16px;
  box-shadow: 0 22px 68px #080a0670;
}
.login-card h2 { font-size: clamp(1.8rem, 5vw, 2.25rem); letter-spacing: -.045em; line-height: 1.12; }
.login-card > p { margin-top: 9px; color: var(--muted); font-size: .96rem; line-height: 1.5; }
.login-card form { display: grid; gap: 10px; margin-top: 26px; }
.login-card form > .button { margin-top: 6px; }

.mailbox-layout {
  display: grid;
  grid-template-columns: clamp(238px, 19.3%, 286px) clamp(310px, 27.5%, 428px) minmax(0, 1fr);
  min-height: 552px;
  height: calc(100dvh - 128px);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 42px #08090648;
}

.sidebar, .message-panel, .reader-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); }
.message-panel { background: var(--list); border-right: 1px solid var(--border); }
.reader-panel { background: var(--reader); }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 67px;
  padding: 12px 19px;
  border-bottom: 1px solid var(--border);
}
.reader-header { padding-inline: clamp(18px, 2.25vw, 36px); }

.create-form { display: grid; gap: 12px; padding: 20px 17px 22px; border-bottom: 1px solid var(--border); }
.lifetime-field { display: grid; gap: 6px; }
.lifetime-field select { min-height: 38px; }
.create-form .button { width: 100%; }

.address-panel { display: flex; flex-direction: column; min-height: 0; }
.address-panel h2 { padding: 19px 17px 10px; }
.sidebar-empty { padding: 0 17px 20px; }
.sidebar-empty, .panel-empty { color: var(--muted); font-size: .87rem; line-height: 1.5; }
.panel-empty { padding: 20px 19px; }

.selected-address { display: grid; gap: 12px; padding: 15px 19px 14px; border-bottom: 1px solid var(--border); }
.selected-address-details { min-width: 0; }
.address-value { font: 650 .82rem/1.5 var(--mono); overflow-wrap: anywhere; user-select: all; }
.supporting-text { color: var(--muted); font-size: .79rem; margin-top: 4px; }
.address-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.address-actions #copy { color: var(--accent); }

.search-field { position: relative; padding: 14px 19px; border-bottom: 1px solid var(--border); }
.search-field input { min-height: 38px; padding-left: 34px; background: #171914; }
.search-field .icon-search { position: absolute; top: 50%; left: 30px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field:has(input:disabled) { opacity: .57; }
.message-list-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-color: var(--border-strong) transparent; }

.item-list { margin: 0; padding: 0; list-style: none; }
.item-list button {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  text-align: left;
  gap: 4px;
  width: 100%;
  min-height: 54px;
  padding: 11px 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  cursor: pointer;
}
.item-list button:hover { background: var(--surface-hover); }
.item-list button[aria-current="true"] { border-left-color: var(--accent); background: var(--selected); }
.item-list button:focus-visible { position: relative; z-index: 1; outline-offset: -3px; }
.address-panel .item-list { padding: 0 8px 15px; overflow-y: auto; scrollbar-color: var(--border-strong) transparent; }
.address-panel .item-list li + li { margin-top: 3px; }
.address-panel .item-list button { padding-inline: 9px; border-radius: 7px; }
.message-panel .item-list li { border-bottom: 1px solid var(--border); }
.message-panel .item-list button { min-height: 66px; padding-inline: 17px; }
.item-title {
  font-size: .88rem;
  font-weight: 640;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-detail {
  color: var(--muted);
  font-size: .77rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mail-address { font: 600 .76rem/1.45 var(--mono); }

.reader-placeholder {
  display: grid;
  place-content: center;
  justify-items: center;
  flex: 1;
  min-height: 190px;
  padding: 24px 16px 38px;
  text-align: center;
  color: var(--muted);
  font-size: .91rem;
}
.reader-placeholder:has(#reader-empty[hidden]),
.reader-panel:has(#message-content:not([hidden])) .reader-placeholder { display: none; }
.empty-illustration {
  display: grid;
  place-items: center;
  width: 53px;
  height: 53px;
  margin-bottom: 14px;
  border: 1px solid #444a38;
  border-radius: 15px;
  color: #c8d0b8;
  background: #25291e;
}
#close-message { display: none; }

.message-content { flex: 1; min-height: 0; overflow-y: auto; padding: clamp(20px, 2.9vw, 42px); scrollbar-color: var(--border-strong) transparent; }
.message-content h3 { font-size: clamp(1.4rem, 2.5vw, 2.14rem); font-weight: 670; line-height: 1.18; letter-spacing: -.04em; }
.message-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 15px;
  margin: 20px 0 24px;
  padding-bottom: 19px;
  border-bottom: 1px solid var(--border);
  font-size: .86rem;
}
.message-meta dt { color: var(--muted); }
.message-meta dd { margin: 0; overflow-wrap: anywhere; }
.message-body { min-height: 52px; margin: 0; font: inherit; font-size: .96rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }

.icon { position: relative; flex: none; display: inline-block; width: 14px; height: 14px; color: inherit; }
.icon::before, .icon::after { position: absolute; display: block; content: ""; }
.icon-plus::before { inset: 6px 1px auto; height: 2px; background: currentColor; border-radius: 2px; }
.icon-plus::after { inset: 1px auto 1px 6px; width: 2px; background: currentColor; border-radius: 2px; }
.icon-search::before { top: 0; left: 0; width: 10px; height: 10px; border: 1.5px solid currentColor; border-radius: 50%; }
.icon-search::after { right: 0; bottom: 2px; width: 6px; height: 1.5px; border-radius: 1px; background: currentColor; transform: rotate(45deg); }
.icon-refresh::before { inset: 1px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; }
.icon-refresh::after { right: 0; top: 0; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; }
.icon-back::before { top: 4px; left: 2px; width: 6px; height: 6px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.icon-back::after { inset: 6px 0 auto 2px; height: 1.5px; background: currentColor; border-radius: 1px; }
.icon-mail { width: 24px; height: 18px; border: 1.5px solid currentColor; border-radius: 4px; }
.icon-mail::before { top: -1px; left: 5px; width: 11px; height: 11px; transform: rotate(45deg); border-bottom: 1.5px solid currentColor; border-right: 1.5px solid currentColor; border-radius: 0 0 2px; }

.error { color: var(--error); font-size: .86rem; line-height: 1.45; }
.workspace-error { margin-bottom: 12px; padding: 10px 13px; background: #32241f; border: 1px solid #63433e; border-radius: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-width: 1030px) {
  .header-inner, .main-content { width: calc(100% - 40px); }
  .mailbox-layout { grid-template-columns: minmax(212px, .65fr) minmax(0, 1.35fr); }
  .message-panel { border-right: 0; }
  .reader-panel { display: none; }
  #workspace.has-open-message .message-panel { display: none; }
  #workspace.has-open-message .reader-panel { display: flex; }
  #close-message { display: inline-flex; }
}

@media (max-width: 640px) {
  .header-inner, .main-content { width: calc(100% - 24px); }
  .header-inner { min-height: 62px; }
  .main-content { padding-block: 12px 24px; }
  .brand-mark { height: 34px; width: 34px; border-radius: 9px; }
  .wordmark { font-size: 1.18rem; gap: 8px; }
  .mailbox-layout { grid-template-columns: minmax(0, 1fr); min-height: 0; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .create-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; padding: 14px; gap: 10px; }
  .create-form .button { min-height: 38px; }
  .address-panel h2 { padding: 14px 14px 8px; }
  .sidebar-empty { padding: 0 14px 15px; }
  .address-panel .item-list { padding-bottom: 9px; max-height: 224px; }
  .message-panel { min-height: 270px; }
  .panel-header { min-height: 59px; padding-inline: 14px; }
  .selected-address, .search-field { padding-inline: 14px; }
  .search-field .icon-search { left: 25px; }
  .panel-empty { padding-inline: 14px; }
  .message-panel .item-list button { padding-inline: 12px; }
  #workspace.has-open-message .sidebar { display: none; }
  .reader-panel { min-height: min(455px, calc(100dvh - 102px)); }
}

@media (max-width: 320px) {
  .create-form { grid-template-columns: minmax(0, 1fr); }
}

