:root {
  color-scheme: light;
  --paper: #f3f2ec;
  --surface: #fffefa;
  --ink: #19251f;
  --muted: #758079;
  --line: #dfe4de;
  --green: #177050;
  --green-soft: #e5f3eb;
  --warn: #a25143;
  --shadow: 0 25px 70px rgba(28, 39, 32, .12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--paper); overflow: hidden; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient { position: fixed; z-index: -1; width: 42vw; height: 42vw; border-radius: 50%; filter: blur(90px); opacity: .22; }
.ambient-a { top: -20vw; left: -8vw; background: #88c7a7; }
.ambient-b { right: -18vw; bottom: -24vw; background: #d4b98d; }
.eyebrow { color: var(--green); font-size: 9px; font-weight: 900; letter-spacing: 1.8px; }
.muted { color: var(--muted); }

.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px, 3vw, 48px); border-bottom: 1px solid rgba(35, 52, 43, .09); background: rgba(246, 246, 241, .78); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; color: white; background: var(--ink); }
.brand-mark svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 18px; font-weight: 500; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 8px; letter-spacing: .6px; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.privacy-pill { display: inline-flex; align-items: center; gap: 7px; margin-right: 8px; color: #4d665a; font-size: 10px; font-weight: 800; }
.privacy-pill i { width: 7px; height: 7px; border-radius: 50%; background: #27916b; box-shadow: 0 0 0 4px rgba(39,145,107,.1); }

.button { border: 0; border-radius: 11px; padding: 10px 15px; font-size: 11px; font-weight: 850; transition: .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .5; transform: none; }
.button-primary { color: #fff; background: var(--ink); }
.button-primary:hover { background: #0f1814; }
.button-ghost { border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.72); }
.mobile-menu-button { display: none; }

.mail-shell { width: min(1540px, calc(100% - 36px)); height: calc(100vh - 104px); min-height: 640px; margin: 14px auto; display: grid; grid-template-columns: 286px minmax(350px, 430px) minmax(420px, 1fr); overflow: hidden; border: 1px solid rgba(35, 52, 43, .12); border-radius: 24px; background: rgba(255,255,252,.89); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.sidebar { min-width: 0; display: flex; flex-direction: column; padding: 20px 14px 16px; border-right: 1px solid var(--line); background: rgba(239, 243, 237, .76); }
.library-head { padding: 2px 7px 12px; }
.library-head h1 { margin: 5px 0 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.account-import-form { margin: 0 3px 12px; padding: 10px; border: 1px solid #cadbd1; border-radius: 13px; background: rgba(255,255,255,.78); }
.account-import-form > label { display: block; margin-bottom: 7px; color: #355747; font-size: 9px; font-weight: 900; }
.account-import-form textarea { width: 100%; min-height: 72px; max-height: 132px; resize: none; border: 1px solid var(--line); border-radius: 9px; outline: 0; padding: 9px 10px; color: var(--ink); background: #fff; font: 9px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; overflow: auto; }
.account-import-form textarea:focus { border-color: #83ad98; box-shadow: 0 0 0 3px rgba(23,112,80,.08); }
.import-format { display: flex; align-items: center; gap: 5px; margin: 7px 1px 0; color: var(--muted); font-size: 8px; }
.import-format code { border-radius: 5px; padding: 2px 4px; color: #3b6652; background: var(--green-soft); font-size: 8px; font-weight: 800; }
.import-feedback { min-height: 0; margin: 0; overflow-wrap: anywhere; color: var(--muted); font-size: 8px; line-height: 1.45; }
.import-feedback:not(:empty) { margin-top: 7px; }
.import-feedback.success { color: var(--green); }
.import-feedback.warning { color: #936128; }
.import-feedback.error { color: #a23b35; }
.import-submit { width: 100%; margin-top: 8px; padding: 8px 10px; border-radius: 9px; font-size: 9px; }
.account-search, .mail-search-wrap { position: relative; display: block; }
.account-search { margin: 0 4px 10px; }
.account-search svg, .mail-search-wrap svg { position: absolute; width: 15px; fill: none; stroke: #87918c; stroke-width: 1.7; pointer-events: none; }
.account-search svg { left: 11px; top: 10px; }
.account-search input, .mail-search-wrap input { width: 100%; border: 1px solid var(--line); outline: 0; color: var(--ink); background: rgba(255,255,255,.8); }
.account-search input { height: 36px; padding: 0 10px 0 34px; border-radius: 10px; font-size: 11px; }
.account-search input:focus, .mail-search-wrap input:focus { border-color: #83ad98; box-shadow: 0 0 0 3px rgba(23,112,80,.08); }
.account-list { max-height: 170px; min-height: 48px; overflow: auto; padding: 0 3px 10px; }
.account-row { position: relative; display: flex; align-items: center; border-radius: 12px; }
.account-row:hover { background: rgba(255,255,255,.62); }
.account-row.active { background: #fff; box-shadow: 0 7px 22px rgba(31,46,37,.08); }
.account-select { min-width: 0; flex: 1; border: 0; display: flex; align-items: center; gap: 9px; padding: 8px 29px 8px 7px; color: inherit; background: transparent; text-align: left; }
.avatar { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(145deg, #25866a, #155c48); font-family: Georgia, serif; font-size: 16px; }
.avatar.small { width: 30px; height: 30px; border-radius: 10px; font-size: 12px; }
.account-copy { min-width: 0; }
.account-copy strong, .account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 10px; }
.account-copy small { margin-top: 3px; color: #8b958f; font-size: 8px; }
.account-copy small.status-warn { color: var(--warn); font-weight: 800; }
.account-remove { position: absolute; right: 4px; width: 25px; height: 25px; border: 0; border-radius: 8px; color: #99a19d; background: transparent; opacity: 0; }
.account-row:hover .account-remove, .account-remove:focus { opacity: 1; }
.account-remove:hover { color: #a23b35; background: #fae9e6; }
.account-list-empty { margin: 20px 0; color: var(--muted); text-align: center; font-size: 10px; }
.folder-section { min-height: 0; display: flex; flex: 1; flex-direction: column; border-top: 1px solid var(--line); }
.current-account { display: flex; align-items: center; gap: 10px; margin: 14px 6px 8px; min-width: 0; }
.current-account div { min-width: 0; }
.current-account small, .current-account strong { display: block; }
.current-account small { margin-bottom: 3px; color: var(--muted); font-size: 8px; font-weight: 750; text-transform: uppercase; letter-spacing: .6px; }
.current-account strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.folder-list { min-height: 0; display: grid; align-content: start; gap: 3px; padding: 5px 0 12px; overflow: auto; }
.folder-button { width: 100%; border: 0; border-radius: 10px; display: flex; align-items: center; gap: 10px; padding: 9px 11px; color: #46534c; background: transparent; text-align: left; font-size: 11px; font-weight: 750; }
.folder-button:hover { background: rgba(255,255,255,.72); }
.folder-button.active { color: #fff; background: var(--ink); box-shadow: 0 9px 18px rgba(24,35,31,.13); }
.folder-icon { width: 18px; color: #789085; text-align: center; }
.folder-button.active .folder-icon { color: #a9d8c4; }
.sidebar-footer { margin-top: auto; }
.safe-box { display: flex; gap: 9px; align-items: flex-start; padding: 10px; border: 1px solid #cfe0d6; border-radius: 12px; background: var(--green-soft); }
.safe-dot { width: 7px; height: 7px; margin-top: 4px; flex: 0 0 auto; border-radius: 50%; background: #2a9a71; }
.safe-box b, .safe-box small { display: block; }
.safe-box b { color: #285846; font-size: 9px; }
.safe-box small { margin-top: 3px; color: #5c786c; font-size: 8px; line-height: 1.4; }
.sidebar-backdrop { display: none; }

.inbox-panel { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(255,255,253,.75); }
.mobile-current-account { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 25px 22px 15px; }
.panel-head h2 { margin: 7px 0 4px; font-family: Georgia, serif; font-size: 30px; font-weight: 500; }
.panel-head p { margin: 0; font-size: 10px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; color: #4d5c54; background: #fff; }
.icon-button:hover { background: #f1f5f0; }
.icon-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.icon-button.loading svg { animation: spin .8s linear infinite; }
.mail-search-wrap { padding: 0 22px 16px; }
.mail-search-wrap svg { left: 35px; top: 11px; }
.mail-search-wrap input { height: 38px; padding: 0 12px 0 37px; border-radius: 11px; font-size: 11px; }
.mail-list { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--line); }
.mail-item { width: 100%; border: 0; border-bottom: 1px solid #e8ebe6; padding: 15px 18px; display: block; color: inherit; background: transparent; text-align: left; transition: .14s ease; }
.mail-item:hover { background: #f4f7f2; }
.mail-item.active { background: #eaf3ee; box-shadow: inset 3px 0 var(--green); }
.mail-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mail-sender { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 750; }
.mail-date { flex: 0 0 auto; color: #89928d; font-size: 8px; }
.mail-subject { margin: 6px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: Georgia, serif; font-size: 15px; }
.mail-preview { margin: 0; overflow: hidden; color: var(--muted); font-size: 9px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.mail-item.unread .mail-sender::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: #2e8b69; vertical-align: 1px; }
.empty-list { min-height: 220px; display: grid; align-content: center; justify-items: center; gap: 13px; padding: 50px 30px; color: var(--muted); text-align: center; font-size: 11px; }
.empty-list p { margin: 0; }
.empty-library > span { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; color: var(--green); background: var(--green-soft); font-family: Georgia, serif; font-size: 20px; }
.empty-library h3 { margin: 3px 0 0; color: var(--ink); font-family: Georgia, serif; font-size: 20px; font-weight: 500; }
.empty-library p { max-width: 270px; line-height: 1.6; }

.detail-panel { min-width: 0; overflow: auto; background: rgba(255,255,255,.7); }
.detail-empty { min-height: 100%; display: grid; align-content: center; justify-items: center; padding: 50px; text-align: center; }
.detail-empty-icon { width: 55px; height: 55px; display: grid; place-items: center; border-radius: 19px; color: var(--green); background: var(--green-soft); font-family: Georgia, serif; font-size: 25px; }
.detail-empty h3 { margin: 18px 0 7px; font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.detail-empty p { max-width: 360px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.detail-content { padding: 29px clamp(22px, 3vw, 44px) 40px; }
.detail-head { padding-bottom: 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; }
.detail-sender { margin: 0 0 8px; color: var(--green); font-size: 10px; font-weight: 800; }
.detail-head h2 { margin: 0 0 9px; font-family: Georgia, serif; font-size: clamp(25px, 2.5vw, 36px); font-weight: 500; line-height: 1.16; letter-spacing: -.7px; }
.detail-head .muted { margin: 0; font-size: 9px; }
.detail-close { display: none; flex: 0 0 auto; font-size: 19px; }
.code-panel { margin: 20px 0; padding: 15px 17px; border: 1px solid #cbe2d8; border-radius: 15px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: linear-gradient(135deg, #edf8f2, #f6faf7); }
.code-panel span, .code-panel small { display: block; }
.code-panel span { color: #245f48; font-size: 10px; font-weight: 900; }
.code-panel small { margin-top: 4px; color: #769084; font-size: 8px; }
.code-list { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.code-button { border: 0; border-radius: 10px; padding: 8px 11px; color: #fff; background: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 17px; font-weight: 900; letter-spacing: 2px; }
.view-switch { width: max-content; margin: 20px 0 12px; display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #f1f3ef; }
.view-switch button { border: 0; border-radius: 7px; padding: 6px 10px; color: #6f7974; background: transparent; font-size: 9px; font-weight: 800; }
.view-switch button.active { color: var(--ink); background: #fff; box-shadow: 0 3px 10px rgba(24,35,31,.08); }
.body-text { margin: 0; color: #38443e; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.8 Inter, ui-sans-serif, sans-serif; }
.body-html { width: 100%; min-height: 500px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 100; transform: translate(-50%, 20px); pointer-events: none; opacity: 0; padding: 10px 15px; border-radius: 10px; color: #fff; background: #17231e; box-shadow: 0 12px 35px rgba(0,0,0,.18); font-size: 11px; font-weight: 750; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
  .mail-shell { grid-template-columns: 260px 370px 1fr; }
}

@media (max-width: 880px) {
  .topbar { height: 68px; padding: 0 18px; }
  .brand small, .privacy-pill { display: none; }
  .mail-shell { width: 100%; height: calc(100vh - 68px); min-height: 0; margin: 0; border: 0; border-radius: 0; grid-template-columns: 248px minmax(320px, 1fr); backdrop-filter: none; }
  .detail-panel { display: none; position: fixed; inset: 68px 0 0 0; z-index: 30; background: #fff; }
  .detail-panel.mobile-open { display: block; }
  .detail-close { display: grid; }
  .detail-content { padding: 24px 20px 40px; }
  .body-html { min-height: 420px; }
}

@media (max-width: 560px) {
  .mobile-menu-button { display: inline-block; }
  .mail-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 68px 52px 0 0; z-index: 50; transform: translateX(-105%); border-right: 0; background: #f0f4ef; box-shadow: 20px 0 60px rgba(15,27,20,.2); transition: transform .2s ease; }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 68px 0 0; z-index: 45; border: 0; background: rgba(16,26,21,.35); }
  .sidebar-backdrop.show { display: block; }
  .mobile-current-account { width: 100%; border: 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 9px; padding: 10px 16px; color: inherit; background: #f5f7f3; text-align: left; }
  .mobile-current-account > span:nth-child(2) { min-width: 0; flex: 1; }
  .mobile-current-account small, .mobile-current-account strong { display: block; }
  .mobile-current-account small { color: var(--muted); font-size: 8px; }
  .mobile-current-account strong { margin-top: 2px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-current-account b { color: var(--green); font-size: 9px; }
  .panel-head { padding: 18px 17px 12px; }
  .panel-head h2 { font-size: 27px; }
  .mail-search-wrap { padding-inline: 17px; }
  .mail-search-wrap svg { left: 30px; }
  .mail-item { padding-inline: 16px; }
  .account-list { max-height: 25vh; }
}
