/* ============ tokens ============ */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --hover: rgba(32, 33, 36, .06);
  --press: rgba(32, 33, 36, .10);
  --text: #1f1f1f;
  --text-2: #5f6368;
  --text-3: #80868b;
  --border: #e3e5e8;
  --divider: #eceef1;
  --accent: #1a5fd6;
  --accent-hover: #174fb4;
  --accent-text: #ffffff;
  --nav-active: #d8e4fb;
  --nav-active-text: #0e2a5c;
  --compose: #d8e4fb;
  --compose-hover: #cddbf6;
  --row-read: #f5f7fa;
  --row-sel: #dfe8fb;
  --row-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px 0 rgba(60, 64, 67, .28), 0 1px 3px 1px rgba(60, 64, 67, .14);
  --star: #e6a400;
  --danger: #c5221f;
  --menu-shadow: 0 2px 6px 2px rgba(60, 64, 67, .15), 0 1px 2px rgba(60, 64, 67, .3);
  --win-shadow: 0 8px 10px 1px rgba(0, 0, 0, .14), 0 3px 14px 2px rgba(0, 0, 0, .12), 0 5px 5px -3px rgba(0, 0, 0, .2);
  --composer-head: #edf1f7;
  --card: #f5f7fa;
  --snack: #2d2e30;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181b;
    --surface: #202124;
    --surface-2: #2a2b2f;
    --hover: rgba(232, 234, 237, .07);
    --press: rgba(232, 234, 237, .12);
    --text: #e3e3e3;
    --text-2: #a8abb0;
    --text-3: #868a90;
    --border: #3a3b3f;
    --divider: #2f3034;
    --accent: #8ab4f8;
    --accent-hover: #a5c5fa;
    --accent-text: #0f1c33;
    --nav-active: #233552;
    --nav-active-text: #d6e3fb;
    --compose: #2b3a52;
    --compose-hover: #33445f;
    --row-read: #1c1d20;
    --row-sel: #253247;
    --row-shadow: inset 1px 0 0 #3c4043, inset -1px 0 0 #3c4043, 0 1px 3px rgba(0, 0, 0, .6);
    --star: #f3bb2a;
    --danger: #f28b82;
    --menu-shadow: 0 2px 8px rgba(0, 0, 0, .6);
    --win-shadow: 0 8px 24px rgba(0, 0, 0, .6);
    --composer-head: #2d2e31;
    --card: #26282c;
    --snack: #e3e3e3;
    color-scheme: dark;
  }
}

/* ============ base ============ */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.grow { flex: 1; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.mark {
  width: 30px; height: 30px; border-radius: 7px; background: var(--accent) center / 22px no-repeat;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3.5 6.5h17v11h-17zM3.5 7.3L12 13l8.5-5.7' fill='none' stroke='white' stroke-width='1.9' stroke-linejoin='round'/></svg>");
  flex: none;
}
@media (prefers-color-scheme: dark) {
  .mark { background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3.5 6.5h17v11h-17zM3.5 7.3L12 13l8.5-5.7' fill='none' stroke='%230f1c33' stroke-width='1.9' stroke-linejoin='round'/></svg>"); }
}

/* icon button */
.ib {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent;
  display: inline-grid; place-items: center; color: var(--text-2); flex: none; position: relative;
}
.ib:hover { background: var(--hover); color: var(--text); }
.ib:active { background: var(--press); }
.ib:disabled { opacity: .38; pointer-events: none; }
.ib.sm { width: 32px; height: 32px; }
.ib.sm svg { width: 18px; height: 18px; }
.ib.on svg { fill: var(--star); stroke: var(--star); }

.btn {
  height: 36px; padding: 0 20px; border-radius: 18px; border: 1px solid transparent;
  font-weight: 500; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-outline:hover { background: var(--hover); color: var(--text); }
.linkbtn { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 500; }
.linkbtn:hover { text-decoration: underline; }

input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }

/* ============ sign in ============ */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 40px 36px 32px; display: flex; flex-direction: column;
}
.login-logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 500; margin-bottom: 24px; }
.login-card h1 { font-size: 24px; line-height: 32px; font-weight: 400; margin: 0; }
.login-sub { color: var(--text-2); margin: 4px 0 28px; font-size: 15px; }
.float { position: relative; margin-bottom: 16px; }
.float input {
  width: 100%; height: 54px; padding: 18px 14px 4px; border: 1px solid var(--border); border-radius: 6px;
  background: transparent; font-size: 16px; outline: none;
}
.float input:focus { border: 2px solid var(--accent); padding: 17px 13px 3px; }
.float label {
  position: absolute; left: 14px; top: 17px; color: var(--text-2); font-size: 16px; pointer-events: none;
  transition: top .12s, font-size .12s, color .12s;
}
.float input:focus + label, .float input:not(:placeholder-shown) + label { top: 6px; font-size: 12px; }
.float input:focus + label { color: var(--accent); }
.showpw { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; margin: 0 0 8px 2px; cursor: pointer; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 8px; display: flex; gap: 6px; }
.login-actions { display: flex; justify-content: flex-end; margin-top: 28px; }
.login-actions .btn { padding: 0 24px; }

/* ============ app shell ============ */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 64px; display: flex; align-items: center; gap: 4px; padding: 8px 16px 8px 12px; flex: none; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 500; width: 196px; padding-left: 6px; color: var(--text); }
.search {
  flex: 1; max-width: 720px; height: 48px; border-radius: 24px; background: var(--surface-2);
  display: flex; align-items: center; padding: 0 4px; transition: background .15s, box-shadow .15s;
}
@media (prefers-color-scheme: light) { .search { background: #e9eef6; } }
.search:focus-within { background: var(--surface); box-shadow: var(--menu-shadow); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; padding: 0 4px; min-width: 0; }
.search input::placeholder { color: var(--text-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 4px; padding-left: 16px; }
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; color: #fff; font-weight: 500; font-size: 15px;
  display: grid; place-items: center; outline: 4px solid transparent;
}
.avatar-btn:hover { outline-color: var(--hover); }

.shell { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 256px; flex: none; padding: 8px 0 16px; overflow-y: auto; transition: width .15s; }
.compose-btn {
  height: 56px; margin: 0 0 16px 8px; padding: 0 24px 0 18px; border: 0; border-radius: 16px;
  background: var(--compose); color: var(--nav-active-text); font-weight: 500; font-size: 14px;
  display: inline-flex; align-items: center; gap: 14px; transition: box-shadow .15s, background .15s;
}
.compose-btn:hover { box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15); background: var(--compose-hover); }
.compose-btn svg { width: 22px; height: 22px; }
.folders { display: flex; flex-direction: column; padding-right: 16px; }
.folder {
  height: 32px; border: 0; background: none; border-radius: 0 16px 16px 0; text-align: left;
  display: flex; align-items: center; gap: 18px; padding: 0 12px 0 26px; color: var(--text); font-size: 14px;
}
.folder:hover { background: var(--hover); }
.folder.active { background: var(--nav-active); color: var(--nav-active-text); font-weight: 700; }
.folder svg { width: 20px; height: 20px; color: var(--text-2); }
.folder.active svg { color: var(--nav-active-text); }
.folder .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { font-size: 12px; font-weight: 700; }
.folder.unread .name { font-weight: 700; }
.folder.drop { background: var(--nav-active); }
.nav-label { font-size: 13px; color: var(--text-2); padding: 16px 0 6px 26px; font-weight: 500; }

/* collapsed sidebar (desktop) */
.app.nav-collapsed .sidebar { width: 72px; }
.app.nav-collapsed .compose-btn { width: 56px; padding: 0; justify-content: center; margin-left: 8px; }
.app.nav-collapsed .compose-btn span,
.app.nav-collapsed .folder .name,
.app.nav-collapsed .folder .count,
.app.nav-collapsed .nav-label { display: none; }
.app.nav-collapsed .folders { padding-right: 0; }
.app.nav-collapsed .folder { width: 56px; margin-left: 8px; border-radius: 16px; padding: 0; justify-content: center; }

.main {
  flex: 1; min-width: 0; background: var(--surface); border-radius: 16px; margin: 0 16px 16px 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.toolbar {
  height: 48px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--divider);
}
.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.cb-wrap { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.cb-wrap:hover { background: var(--hover); }
.range { font-size: 12px; color: var(--text-2); padding: 0 8px; white-space: nowrap; }

/* ============ message rows ============ */
.list-scroll { flex: 1; overflow-y: auto; }
.search-note { padding: 10px 20px; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--divider); }
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  height: 40px; display: flex; align-items: center; padding: 0 16px 0 10px; cursor: pointer;
  border-bottom: 1px solid var(--divider); background: var(--row-read); position: relative;
}
.row.unread { background: var(--surface); }
.row:hover { box-shadow: var(--row-shadow); z-index: 1; }
.row.selected { background: var(--row-sel); }
.row .cb-wrap { width: 32px; height: 32px; flex: none; }
.row .star { width: 32px; height: 32px; flex: none; color: var(--text-3); }
.row .star svg { width: 18px; height: 18px; }
.row .star.on svg { fill: var(--star); stroke: var(--star); }
.row .from {
  width: 200px; flex: none; padding: 0 16px 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text);
}
.row .from .cnt { color: var(--text-2); font-size: 12px; margin-left: 4px; font-weight: 400; }
.row .from .draft { color: var(--danger); }
.row .content { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.row .subject { color: var(--text); }
.row .snippet::before { content: " – "; }
.row .att { color: var(--text-3); margin-left: 12px; display: inline-flex; }
.row .att svg { width: 16px; height: 16px; }
.row .date { width: 76px; flex: none; text-align: right; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.row.unread .from, .row.unread .subject, .row.unread .date { font-weight: 700; color: var(--text); }
.row .hover-actions { display: none; position: absolute; right: 8px; top: 0; bottom: 0; align-items: center; background: inherit; padding-left: 8px; }
.row:hover .hover-actions { display: flex; }
.row:hover .date { visibility: hidden; }
.row .hover-actions .ib { width: 36px; height: 36px; }
.row .hover-actions svg { width: 18px; height: 18px; }
.empty-list { padding: 64px 24px; text-align: center; color: var(--text-2); }
.empty-list strong { display: block; font-size: 16px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.loading-bar { height: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: slide 1s linear infinite; }
@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* ============ reading view ============ */
.read-scroll { flex: 1; overflow-y: auto; padding: 20px 24px 40px 72px; }
.msg-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 20px; }
.msg-head h1 { font-size: 22px; line-height: 28px; font-weight: 400; margin: 0; word-break: break-word; }
.folder-tag { font-size: 12px; background: var(--surface-2); color: var(--text-2); padding: 1px 8px; border-radius: 4px; }
.sender { display: flex; gap: 12px; align-items: flex-start; margin-left: -56px; margin-bottom: 16px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 500; font-size: 17px; background: #5f6368;
}
.sender-main { flex: 1; min-width: 0; }
.sender-line { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.sender-name { font-weight: 700; }
.sender-addr { font-size: 12px; color: var(--text-2); }
.to-line { border: 0; background: none; padding: 0; color: var(--text-2); font-size: 12px; display: inline-flex; align-items: center; gap: 2px; }
.to-line svg { width: 16px; height: 16px; }
.details {
  margin-top: 8px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px;
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; color: var(--text-2); max-width: 560px; box-shadow: var(--menu-shadow); background: var(--surface);
}
.details b { font-weight: 400; color: var(--text-3); text-align: right; }
.details span { color: var(--text); word-break: break-word; }
.sender-right { display: flex; align-items: center; gap: 0; color: var(--text-2); font-size: 12px; white-space: nowrap; }
.msg-date { margin-right: 6px; }
.notice {
  font-size: 13px; color: var(--text-2); padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 12px; background: var(--surface-2);
}
.msg-body { border-radius: 12px; overflow: hidden; background: transparent; }
.msg-body.paper { background: #fff; border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
#msg-frame { width: 100%; border: 0; display: block; background: transparent; }
#msg-text {
  margin: 0; padding: 4px 0 8px; white-space: pre-wrap; word-break: break-word;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--surface);
}
#msg-text a { color: var(--accent); }

.att-section { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--divider); }
.att-title { font-size: 14px; font-weight: 500; margin-bottom: 12px; }
.att-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.att-card {
  width: 196px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; background: var(--surface);
}
.att-card:hover { box-shadow: var(--menu-shadow); }
.att-thumb { height: 96px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.att-thumb svg { width: 36px; height: 36px; stroke-width: 1.3; }
.att-meta { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--border); }
.att-type { font-size: 10px; font-weight: 700; color: #fff; background: var(--text-3); border-radius: 3px; padding: 1px 4px; text-transform: uppercase; flex: none; }
.att-type.pdf { background: #d93025; } .att-type.img { background: #1e8e3e; } .att-type.doc { background: #1a5fd6; }
.att-type.xls { background: #188038; } .att-type.zip { background: #8a5a00; }
.att-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.att-size { font-size: 11px; color: var(--text-2); }

.reply-actions { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }

/* ============ composer window ============ */
.composer {
  position: fixed; right: 24px; bottom: 0; width: 560px; height: 580px; max-height: calc(100vh - 80px);
  background: var(--surface); border-radius: 10px 10px 0 0; box-shadow: var(--win-shadow);
  display: flex; flex-direction: column; z-index: 30; overflow: hidden;
}
.composer.min { height: 40px; width: 280px; }
.composer.min .composer-body { display: none; }
.composer.max {
  right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(1100px, calc(100vw - 80px));
  height: calc(100vh - 80px); border-radius: 10px;
}
.composer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 29; }
.composer-head {
  height: 40px; flex: none; display: flex; align-items: center; padding: 0 8px 0 16px; gap: 2px;
  background: var(--composer-head); font-weight: 500; font-size: 14px; cursor: pointer; user-select: none;
}
.composer-head #composer-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb { width: 28px; height: 28px; border: 0; background: none; border-radius: 4px; display: grid; place-items: center; color: var(--text-2); }
.hb:hover { background: var(--hover); color: var(--text); }
.hb svg { width: 16px; height: 16px; stroke-width: 2; }
.composer-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.cf { display: flex; align-items: center; gap: 8px; margin: 0 16px; border-bottom: 1px solid var(--divider); min-height: 38px; }
.cf label { color: var(--text-2); }
.cf input { flex: 1; border: 0; outline: 0; background: transparent; padding: 8px 0; min-width: 0; }
.cf input::placeholder { color: var(--text-2); }
.cf-link { border: 0; background: none; color: var(--text-2); padding: 2px 4px; font-size: 14px; }
.cf-link:hover { color: var(--text); text-decoration: underline; }
.editor { flex: 1; overflow-y: auto; padding: 12px 16px; outline: none; word-break: break-word; line-height: 1.5; }
.editor blockquote { margin: 4px 0 4px 6px; padding-left: 10px; border-left: 1px solid #ccc; color: var(--text-2); }
.editor .quote-head { color: var(--text-2); }
.editor a { color: var(--accent); }
.editor img { max-width: 100%; }

/* ============ dialogs (signature settings) ============ */
.modal { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; }
.modal-card {
  background: var(--surface); border-radius: 10px; box-shadow: var(--win-shadow); width: min(680px, 100%);
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; padding: 18px 20px 16px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 500; }
.modal-sub { margin: 4px 0 12px; color: var(--text-2); font-size: 13px; }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.sig-tools, .sig-imgbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px; padding: 4px 6px;
  border: 1px solid var(--border); border-bottom: 0; border-radius: 6px 6px 0 0; background: var(--surface-2);
}
.sig-tools button, .sig-tools label, .sig-imgbar button {
  border: 0; background: none; min-width: 30px; height: 30px; border-radius: 4px; color: var(--text-2);
  font-size: 15px; display: inline-grid; place-items: center; cursor: pointer; padding: 0 6px; position: relative;
}
.sig-tools button:hover, .sig-tools label:hover, .sig-imgbar button:hover { background: var(--hover); color: var(--text); }
.sig-tools svg { width: 18px; height: 18px; }
.sig-tools select { height: 28px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); margin: 0 2px; }
.sig-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sig-color svg { color: var(--sig-color, var(--text-2)); }
.sig-imgbar { border-radius: 0; font-size: 13px; background: var(--nav-active); color: var(--nav-active-text); }
.sig-imgbar > span:first-child { margin: 0 6px; }
.sig-imgbar button { font-size: 13px; color: var(--nav-active-text); }
.sig-editor {
  min-height: 180px; max-height: 46vh; overflow: auto; padding: 14px 16px; outline: none; line-height: 1.5;
  border: 1px solid var(--border); border-radius: 0 0 6px 6px; word-break: break-word;
  /* shown on "paper", the way most recipients will see it */
  background: #fff; color: #222; font-family: Arial, Helvetica, sans-serif; font-size: 14px;
}
.sig-editor:focus { border-color: var(--accent); }
.sig-editor:empty::before { content: attr(data-placeholder); color: #9aa0a6; }
.sig-editor a { color: #1a5fd6; }
.sig-editor img { max-width: 100%; cursor: pointer; }
.sig-editor img.sel { outline: 2px solid #1a5fd6; outline-offset: 1px; }
.sig-opts { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; color: var(--text-2); }
.sig-opts label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.icon-menu { padding: 10px 12px; max-width: 300px; }
.icon-menu .menu-label { padding: 0 0 6px; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 36px); gap: 4px; margin-bottom: 10px; }
.icon-grid button { width: 36px; height: 36px; border: 0; border-radius: 6px; background: none; display: grid; place-items: center; }
.icon-grid button:hover { background: var(--hover); }
.icon-grid img { width: 24px; height: 24px; }
.icon-colors { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.icon-colors button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.icon-colors button.on { border-color: var(--text); }
.icon-colors input { width: 26px; height: 24px; border: 0; padding: 0; background: none; }
.c-atts { display: flex; flex-direction: column; gap: 4px; padding: 0 16px; }
.c-atts:empty { display: none; }
.c-att {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 4px; padding: 4px 6px 4px 10px;
  font-size: 13px; max-width: 420px;
}
.c-att .nm { color: var(--accent); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.c-att .sz { color: var(--text-2); }
.c-att .x { border: 0; background: none; color: var(--text-2); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.c-att .x:hover { background: var(--hover); }
.c-att .x svg { width: 14px; height: 14px; }
.c-att.off .nm { text-decoration: line-through; color: var(--text-3); }
.fmt-bar {
  display: flex; align-items: center; gap: 2px; margin: 6px 16px 0; padding: 4px 6px; border-radius: 6px;
  box-shadow: var(--menu-shadow); flex-wrap: wrap;
}
.fmt-bar button { border: 0; background: none; min-width: 30px; height: 30px; border-radius: 4px; color: var(--text-2); font-size: 15px; }
.fmt-bar button:hover { background: var(--hover); color: var(--text); }
.fsep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.composer-foot { display: flex; align-items: center; gap: 2px; padding: 10px 12px 12px 16px; flex: none; }
.send-btn { padding: 0 24px; margin-right: 8px; }
.composer-foot .ib { width: 36px; height: 36px; cursor: pointer; }
.c-status { font-size: 12px; color: var(--text-2); margin-right: 6px; }

/* ============ menu, snackbar ============ */
.menu {
  position: fixed; z-index: 50; min-width: 200px; max-width: 320px; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border-radius: 6px; box-shadow: var(--menu-shadow); padding: 6px 0;
}
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; text-align: left;
  padding: 0 16px; height: 34px; font-size: 14px;
}
.menu-item:hover, .menu-item:focus { background: var(--hover); outline: 0; }
.menu-item svg { width: 18px; height: 18px; color: var(--text-2); }
.menu-head { padding: 12px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--divider); margin-bottom: 6px; }
.menu-head .avatar { width: 40px; height: 40px; }
.menu-head .who { min-width: 0; }
.menu-head .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head .who .em { font-size: 12px; color: var(--text-2); }
.menu-label { font-size: 12px; color: var(--text-2); padding: 6px 16px 4px; }
.menu-input { margin: 4px 16px 8px; display: flex; gap: 6px; }
.menu-input input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; background: transparent; outline: 0; }
.menu-input input:focus { border-color: var(--accent); }
.menu-input button { border: 0; background: none; color: var(--accent); font-weight: 500; }

.snackbar {
  position: fixed; left: 24px; bottom: 24px; z-index: 60; background: var(--snack); color: var(--surface);
  border-radius: 4px; padding: 6px 6px 6px 16px; min-height: 48px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 3px 5px -1px rgba(0,0,0,.2), 0 6px 10px rgba(0,0,0,.14); max-width: calc(100vw - 48px); font-size: 14px;
}
#snack-action { border: 0; background: none; color: #8ab4f8; font-weight: 500; padding: 8px; border-radius: 4px; }
@media (prefers-color-scheme: dark) { #snack-action { color: var(--accent-text); } }
.snack-x { border: 0; background: none; color: inherit; opacity: .8; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.snack-x svg { width: 18px; height: 18px; }
.snackbar.err { background: var(--danger); color: #fff; }

/* ============ split view (reading pane on the right) ============ */
.split-only { display: none; }
.pane-resizer { display: none; }
.read-empty { display: none; }

.main.split { flex-direction: row; }
.main.split #list-view { width: var(--list-w, 420px); flex: none; min-width: 300px; }
.main.split #read-view { display: flex !important; flex: 1; min-width: 0; }
.main.split .split-only { display: inline-grid; }
.main.split #back-btn, .main.split #back-btn + .tb-sep { display: none; }
.main.split .pane-resizer {
  display: block; width: 1px; flex: none; background: var(--divider); position: relative; cursor: col-resize;
}
.main.split .pane-resizer::after { content: ""; position: absolute; inset: 0 -4px; }
.main.split .pane-resizer:hover, .main.split .pane-resizer.dragging { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }

/* empty reading pane */
.main.split #read-view.empty .toolbar,
.main.split #read-view.empty .read-scroll { display: none; }
.main.split #read-view.empty .read-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--text-2); text-align: center; padding: 24px;
}
.read-empty svg { width: 56px; height: 56px; stroke-width: 1; color: var(--text-3); margin-bottom: 8px; }
.read-empty .re-title { font-size: 16px; color: var(--text); font-weight: 500; }
.read-empty .re-sub { font-size: 13px; }

/* two-line message cards in the list */
.main.split .row {
  height: auto; display: grid; padding: 9px 14px 10px 6px; gap: 0 4px; align-items: center;
  grid-template-columns: 32px minmax(0, 1fr) auto auto;
  grid-template-areas: "cb from att date" "star content content content";
  border-left: 3px solid transparent;
}
.main.split .row .cb-wrap { grid-area: cb; }
.main.split .row .star { grid-area: star; align-self: start; margin-top: -2px; }
.main.split .row .from { grid-area: from; width: auto; padding: 0 4px; }
.main.split .row .att { grid-area: att; margin-left: 6px; }
.main.split .row .date { grid-area: date; width: auto; padding-left: 8px; }
.main.split .row .content { grid-area: content; padding: 0 4px; white-space: normal; }
.main.split .row .subject { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 20px; }
.main.split .row .snippet { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-2); line-height: 18px; }
.main.split .row .snippet::before { content: none; }
.main.split .row.unread { border-left-color: var(--accent); }
.main.split .row.unread .snippet { color: var(--text-2); font-weight: 400; }
.main.split .row.active { background: var(--row-sel); border-left-color: var(--accent); }
.main.split .row:hover { box-shadow: none; background: var(--hover); }
.main.split .row.active:hover { background: var(--row-sel); }
.main.split .row .hover-actions { top: 4px; bottom: auto; height: 32px; padding-left: 4px; }
.main.split .row .hover-actions .ib { width: 30px; height: 30px; }

/* Zoho-style reading pane */
.main.split .read-scroll { padding: 22px 32px 48px; }
.main.split .read-scroll > * { max-width: 980px; }
.main.split .msg-head { margin-bottom: 18px; gap: 10px; }
.main.split .msg-head h1 { font-size: 22px; font-weight: 600; line-height: 30px; letter-spacing: -.01em; }
.folder-tag { border-radius: 999px; padding: 2px 10px; font-weight: 500; }
.main.split .sender {
  margin: 0 0 22px; padding: 14px 16px 14px 14px; border: 0; border-radius: 14px; background: var(--card);
  align-items: center;
}
.main.split .sender .avatar { width: 44px; height: 44px; font-size: 18px; box-shadow: 0 0 0 3px var(--card), 0 0 0 4px var(--border); }
.main.split .sender-name { font-weight: 600; }
.main.split .sr-actions { background: var(--surface); border-radius: 999px; padding: 2px; margin-left: 6px; box-shadow: 0 0 0 1px var(--border); }
.main.split .sr-actions .ib.sm { width: 32px; height: 32px; }
.main.split .msg-body.paper { margin-top: 4px; }
.main.split .reply-actions { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--divider); }
.main.split .reply-actions .btn { height: 38px; padding: 0 18px 0 14px; }
.main.split .sender-line { flex-direction: column; gap: 0; align-items: flex-start; }
.main.split .sender-name { font-size: 15px; }
.main.split .sender-addr { font-size: 12.5px; }
.main.split .to-line { margin-top: 2px; }
.main.split .msg-date { margin: 0; }
.main.split .sr-actions { display: inline-flex; gap: 2px; }
.sr-actions { display: inline-flex; }
.main:not(.split) .sr-actions [data-act="replyAll"],
.main:not(.split) .sr-actions [data-act="forward"] { display: none; }
.main.split .sender-right { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; max-width: 50%; }
.main.split .msg-date { width: 100%; text-align: right; margin-bottom: 2px; }
.main.split .reply-actions { margin-top: 24px; }
.main.split .att-section { margin-top: 20px; }

/* ============ responsive ============ */
@media (max-width: 900px) {
  .brand { width: auto; }
  .brand span:last-child { display: none; }
  .row .from { width: 150px; }
  .read-scroll { padding-left: 24px; }
  .sender { margin-left: 0; }
}
@media (max-width: 720px) {
  .topbar { padding: 8px; }
  .search { height: 44px; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; background: var(--surface); width: 280px;
    transform: translateX(-100%); transition: transform .2s; padding-top: 16px; box-shadow: var(--win-shadow);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-collapsed .sidebar { width: 280px; }
  .main { margin: 0; border-radius: 0; }
  .row { height: auto; padding: 10px 12px 10px 4px; align-items: flex-start; flex-wrap: wrap; }
  .row .from { width: auto; flex: 1; padding-left: 4px; }
  .row .content { order: 5; flex-basis: 100%; white-space: normal; padding-left: 68px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .row .snippet { display: block; }
  .row .snippet::before { content: ""; }
  .row .hover-actions { display: none !important; }
  .row:hover .date { visibility: visible; }
  .range { display: none; }
  .read-scroll { padding: 16px; }
  .composer, .composer.max { inset: 0; width: auto; height: auto; max-height: none; transform: none; border-radius: 0; }
  .composer.min { inset: auto 0 0 auto; width: 240px; height: 40px; }
  .snackbar { left: 12px; right: 12px; bottom: 12px; }
}

/* ============ password & recovery ============ */
.login-actions { align-items: center; }
.login-actions .linkbtn { font-size: 14px; }
.small-card { width: min(460px, 100%); gap: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); margin-top: 12px; }
.field .muted { font-weight: 400; color: var(--text-3); }
.field input {
  height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; background: transparent;
  font-size: 14px; color: var(--text); outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.small-card .showpw { margin-top: 10px; font-size: 13px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 12px; }
.linkbtn.danger { color: var(--danger); }

.pw-meter { display: flex; align-items: center; gap: 10px; margin: 8px 0 2px; min-height: 16px; }
.pw-meter span { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); position: relative; overflow: hidden; }
.pw-meter span::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--pw, 0%); background: var(--pw-color, var(--text-3));
  border-radius: 2px; transition: width .2s, background .2s;
}
.pw-meter em { font-style: normal; font-size: 12px; color: var(--pw-color, var(--text-3)); min-width: 64px; text-align: right; }
.float + .pw-meter { margin: -8px 0 12px; }

.otp-input {
  width: 100%; height: 56px; margin: 4px 0 6px; border: 1px solid var(--border); border-radius: 8px; background: transparent;
  text-align: center; font: 600 28px/1 SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 12px; padding-left: 12px;
  color: var(--text); outline: none;
}
.otp-input:focus { border: 2px solid var(--accent); }
.otp-input::placeholder { color: var(--text-3); letter-spacing: 12px; }
.fp-resend { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.fp-resend .linkbtn:disabled { color: var(--text-3); cursor: default; text-decoration: none; }
.done-badge {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 16px;
  background: color-mix(in srgb, #1e8e3e 16%, transparent); color: #1e8e3e;
}
.done-badge svg { width: 30px; height: 30px; stroke-width: 2.2; }

.rec-current {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--card, var(--surface-2));
  margin-bottom: 4px;
}
.rec-current > svg { color: #1e8e3e; width: 24px; height: 24px; }
.rc-label { font-size: 12px; color: var(--text-2); }
.rc-addr { font-weight: 500; word-break: break-all; }
.rec-sent { margin: 12px 0 8px; font-size: 14px; color: var(--text-2); }
.rec-sent b { color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
