/* ============================================================
   Chora Mail — Webmail unificado (IMAP)
   Tema light por padrão, dark via [data-theme="dark"]
   Base: Chora API Revolution Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* brand accent — same in both themes (orange só em CTAs/destaques) */
  --accent:        #ff5b00;
  --accent-hover:  #ff7a2e;
  --accent-ghost:  rgba(255, 91, 0, 0.10);
  --accent-border: rgba(255, 91, 0, 0.22);

  --font-body:    'Outfit', sans-serif;
  --font-display: 'Sora', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --green:  #16a34a;
  --red:    #e5484d;
  --blue:   #0ea5e9;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 9999px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 160ms;

  /* account palette (auto-assigned) */
  --acc-1: #6366f1; /* indigo */
  --acc-2: #16a34a; /* green  */
  --acc-3: #8b5cf6; /* violet */
  --acc-4: #0ea5e9; /* sky    */
  --acc-5: #e5484d; /* rose   */
  --acc-6: #0d9488; /* teal   */
}

/* ---------- LIGHT (default) ---------- */
:root, [data-theme="light"] {
  --bg:        #eef0f4;
  --chrome:    #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #eceef1;
  --hover:     #f3f4f6;
  --active:    #fff4ec;
  --active-bar:var(--accent);
  --border:    #e3e5ea;
  --border-2:  #d7dae0;
  --text-1:    #14161a;
  --text-2:    #41454d;
  --text-3:    #777d87;
  --text-4:    #9aa0ab;
  --shadow-sm: 0 1px 2px rgba(20,22,26,.06);
  --shadow-md: 0 4px 16px rgba(20,22,26,.08), 0 1px 3px rgba(20,22,26,.06);
  --shadow-lg: 0 18px 48px rgba(20,22,26,.16), 0 4px 12px rgba(20,22,26,.10);
  --scrim:     rgba(20,22,26,.32);
}

/* ---------- DARK ---------- */
[data-theme="dark"] {
  --bg:        #000000;
  --chrome:    #0a0a0a;
  --surface:   #0e0e0e;
  --surface-2: #161616;
  --surface-3: #1e1e1e;
  --hover:     #161616;
  --active:    #1c140d;
  --active-bar:var(--accent);
  --border:    #1d1d1d;
  --border-2:  #2a2a2a;
  --text-1:    #ffffff;
  --text-2:    #d8d8d8;
  --text-3:    #8a8a8a;
  --text-4:    #5a5a5a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow-md: 0 4px 20px rgba(0,0,0,.55);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.7), 0 4px 16px rgba(0,0,0,.5);
  --scrim:     rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
#root { height: 100%; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 9999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; }

.mono { font-family: var(--font-mono); }
.display { font-family: var(--font-display); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- TOPBAR ---------- */
.topbar {
  height: 58px;
  flex: 0 0 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--chrome);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 244px;
  flex: 0 0 244px;
  user-select: none;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  display: grid; place-items: center;
  flex: 0 0 30px;
  box-shadow: 0 2px 8px rgba(255,91,0,.35);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.03em;
  color: var(--text-1);
  line-height: 1;
}
.brand-name b { color: var(--accent); }
.brand-tag {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .22em;
  color: var(--text-4);
  text-transform: uppercase;
  margin-top: 3px;
}

/* search */
.search {
  flex: 1 1 auto;
  max-width: 720px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-input {
  width: 100%;
  height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 0 110px 0 40px;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search-input::placeholder { color: var(--text-4); }
.search-input:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-ghost);
}
.search-ico { position: absolute; left: 13px; color: var(--text-4); display: flex; pointer-events: none; }
.search-kbd {
  position: absolute; right: 10px;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em;
  color: var(--text-4);
}
.search-kbd .key {
  border: 1px solid var(--border-2); border-radius: 4px;
  padding: 2px 6px; line-height: 1; background: var(--surface-2);
}
.search-scope {
  position:absolute; left:40px; display:none;
}

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* icon button */
.iconbtn {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--text-3);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
}
.iconbtn:hover { background: var(--hover); color: var(--text-1); }
.iconbtn.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.avatar {
  width: 34px; height: 34px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff;
  font-family: var(--font-display);
  flex: 0 0 auto;
  letter-spacing: -.02em;
}
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px 4px 4px; border-radius: var(--r-pill);
  transition: background var(--dur) var(--ease);
}
.user-chip:hover { background: var(--hover); }
.user-chip .nm { font-size: 13px; font-weight: 600; color: var(--text-1); line-height: 1.1; }
.user-chip .em { font-size: 11px; color: var(--text-3); line-height: 1.2; }

/* ---------- BODY 3-COL ---------- */
.body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 244px; flex: 0 0 244px;
  background: var(--chrome);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar-scroll { overflow-y: auto; flex: 1 1 auto; padding: 14px 12px 8px; }
.compose-btn {
  width: 100%; height: 46px;
  background: var(--accent); color: #fff;
  border-radius: var(--r-md);
  font-weight: 700; font-size: 14.5px; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 2px 10px rgba(255,91,0,.32);
  transition: background var(--dur) var(--ease);
  letter-spacing: -.01em;
}
.compose-btn:hover { background: var(--accent-hover); }

.nav-group { margin-top: 16px; }
.nav-label {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-4); padding: 0 10px; margin-bottom: 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  height: 38px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 14px; font-weight: 500;
  position: relative;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item .ico { display: flex; color: var(--text-3); flex: 0 0 auto; }
.nav-item:hover { background: var(--hover); }
.nav-item:hover .ico { color: var(--text-2); }
.nav-item.active { background: var(--active); color: var(--text-1); font-weight: 600; }
.nav-item.active .ico { color: var(--accent); }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; border-radius: 3px; background: var(--accent);
}
.nav-item .lbl { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--text-3); background: var(--surface-2);
  border-radius: var(--r-pill); padding: 1px 8px; min-width: 22px; text-align: center;
}
.nav-item.active .nav-count { background: var(--accent); color: #fff; }

/* botão + na seção Minhas Pastas */
.nav-addbtn {
  width: 22px; height: 22px; border-radius: 5px;
  display: grid; place-items: center; color: var(--text-3);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-addbtn:hover { background: var(--hover); color: var(--accent); }

/* input inline de criar pasta */
.folder-create {
  display: flex; align-items: center; gap: 11px;
  height: 38px; padding: 0 10px; border-radius: var(--r-sm);
  background: var(--active); border: 1px solid var(--accent-border);
}
.folder-create-input {
  flex: 1 1 auto; border: none; background: none; outline: none;
  font-size: 14px; color: var(--text-1); font-weight: 500;
}
.folder-create-input::placeholder { color: var(--text-4); }

/* menu "Mover para" */
.move-wrap { position: relative; }
.move-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); padding: 6px;
}
.move-menu-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-4); padding: 6px 10px 8px;
}
.move-menu .from-opt { font-size: 13.5px; color: var(--text-1); cursor: pointer; }
.move-menu-empty { font-size: 12px; color: var(--text-3); padding: 8px 10px; line-height: 1.5; }

.iconbtn-danger:hover { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }

/* account rows */
.acct-item { display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 10px; border-radius: var(--r-sm); transition: background var(--dur) var(--ease); }
.acct-item:hover { background: var(--hover); }
.acct-item.active { background: var(--active); }
.acct-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 16%, transparent); }
.acct-meta { flex: 1 1 auto; min-width: 0; }
.acct-name { font-size: 13px; font-weight: 600; color: var(--text-1); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-email { font-size: 11px; color: var(--text-3); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-prov { font-size: 9px; font-family: var(--font-mono); letter-spacing: .04em; color: var(--text-4); }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  display: flex; flex-direction: column; gap: 2px;
}

/* ---------- LIST COLUMN ---------- */
.listcol {
  width: 400px; flex: 0 0 400px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.list-head {
  flex: 0 0 auto;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.list-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.list-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: -.02em; color: var(--text-1); }
.list-sub { font-size: 12px; color: var(--text-3); margin-left: 2px; }
.list-tools { display: flex; align-items: center; gap: 8px; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  height: 32px; padding: 0 12px; border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  border: 1px solid var(--border-2);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn-ghost:hover { background: var(--hover); color: var(--text-1); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost .ico { color: var(--text-3); display: flex; }
.btn-ghost:hover .ico { color: var(--accent); }
.btn-ghost.is-syncing { color: var(--text-4); }
.sync-note { font-size: 11px; color: var(--text-4); margin-left: auto; font-family: var(--font-mono); letter-spacing: .02em; }

/* filter chips */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  height: 28px; padding: 0 12px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; color: var(--text-3);
  border: 1px solid var(--border-2); background: transparent;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all var(--dur) var(--ease);
}
.chip:hover { color: var(--text-1); border-color: var(--text-4); }
.chip.active { background: var(--text-1); color: var(--surface); border-color: var(--text-1); }
.chip .cdot { width: 7px; height: 7px; border-radius: 50%; }

.list-scroll { overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; }

/* email row */
.mailrow {
  display: flex; gap: 12px;
  padding: 13px 16px 13px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; position: relative;
  transition: background var(--dur) var(--ease);
}
.mailrow:hover { background: var(--hover); }
.mailrow.selected { background: var(--active); }
.mailrow.selected::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent);
}
.mailrow.unread .mr-subject, .mailrow.unread .mr-from { color: var(--text-1); font-weight: 700; }
.mr-railwrap { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 0 0 auto; padding-top: 2px; }
.mr-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.mr-unread-dot.hidden { background: transparent; }
.mr-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; font-family: var(--font-display); flex: 0 0 auto; }
.mr-body { flex: 1 1 auto; min-width: 0; }
.mr-line1 { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.mr-from { font-size: 13.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; }
.mr-time { font-size: 11.5px; color: var(--text-3); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.mailrow.unread .mr-time { color: var(--accent); font-weight: 600; }
.mr-subject { font-size: 13px; color: var(--text-2); font-weight: 500; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-snippet { font-size: 12.5px; color: var(--text-3); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.mr-meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 19px; padding: 0 8px; border-radius: var(--r-pill);
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  background: color-mix(in srgb, var(--tg) 13%, transparent);
  color: var(--tg);
}
[data-theme="dark"] .tag { background: color-mix(in srgb, var(--tg) 20%, transparent); }
.tag .tdot { width: 6px; height: 6px; border-radius: 50%; background: var(--tg); }
.mr-attach { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }
.mr-star { margin-left: auto; color: var(--text-4); display: flex; transition: color var(--dur) var(--ease); }
.mr-star:hover { color: var(--accent); }
.mr-star.on { color: #f5a524; }

/* compact density */
.app[data-density="compact"] .mailrow { padding: 8px 16px 8px 14px; }
.app[data-density="compact"] .mr-avatar { width: 28px; height: 28px; font-size: 11px; }
.app[data-density="compact"] .mr-snippet { display: none; }
.app[data-density="compact"] .mr-meta { margin-top: 5px; }

/* ---------- READER COLUMN ---------- */
.readercol { flex: 1 1 auto; background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.reader-empty { flex: 1; display: grid; place-items: center; padding: 40px; }
.empty-card { text-align: center; max-width: 320px; }
.empty-ico { width: 72px; height: 72px; border-radius: 20px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 20px; color: var(--text-4); }
.empty-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--text-1); margin-bottom: 8px; letter-spacing: -.02em; }
.empty-text { font-size: 13.5px; color: var(--text-3); line-height: 1.6; }

.reader-toolbar {
  flex: 0 0 auto; height: 56px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px; border-bottom: 1px solid var(--border);
}
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  height: 36px; padding: 0 16px; border-radius: var(--r-sm);
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13.5px;
  transition: background var(--dur) var(--ease); box-shadow: 0 1px 6px rgba(255,91,0,.28);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-soft {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 600; font-size: 13px;
  border: 1px solid var(--border-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn-soft:hover { background: var(--hover); color: var(--text-1); }
.btn-soft .ico { color: var(--text-3); display: flex; }
.btn-soft:hover .ico { color: var(--accent); }
.tb-sep { width: 1px; height: 24px; background: var(--border); margin: 0 2px; }

.reader-scroll { overflow-y: auto; flex: 1 1 auto; }
.reader-inner { max-width: 800px; margin: 0 auto; padding: 28px 40px 60px; }
.reader-subject { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: var(--text-1); line-height: 1.25; margin: 0 0 18px; }
.reader-subject .tag { vertical-align: middle; margin-right: 10px; transform: translateY(-2px); }
.reader-from-row { display: flex; align-items: center; gap: 13px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.rf-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff; font-family: var(--font-display); flex: 0 0 auto; }
.rf-meta { flex: 1 1 auto; min-width: 0; }
.rf-name { font-size: 15px; font-weight: 700; color: var(--text-1); }
.rf-email { font-size: 13px; color: var(--text-3); }
.rf-to { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.rf-to b { color: var(--text-2); font-weight: 600; }
.rf-date { font-size: 12.5px; color: var(--text-3); text-align: right; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.rf-actions { display: flex; gap: 4px; margin-top: 6px; justify-content: flex-end; }

.mailbody { font-size: 14.5px; line-height: 1.7; color: var(--text-2); padding-top: 22px; }
.mailbody p { margin: 0 0 15px; }
.mailbody a { color: var(--accent); text-decoration: none; }
.mailbody a:hover { text-decoration: underline; }
.mailbody strong { color: var(--text-1); }
.mailbody .sig { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 13px; line-height: 1.6; }
.mailbody .sig .sig-name { font-weight: 700; color: var(--text-2); }
.mailbody blockquote { margin: 16px 0; padding: 4px 0 4px 16px; border-left: 3px solid var(--border-2); color: var(--text-3); }

.attach-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.attach-chip {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface-2);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  min-width: 200px;
}
.attach-chip:hover { border-color: var(--accent-border); background: var(--surface); }
.attach-ico { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-family: var(--font-mono); font-size: 9px; font-weight: 600; flex: 0 0 auto; }
.attach-meta { min-width: 0; }
.attach-name { font-size: 13px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.attach-size { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }
.attach-dl { margin-left: auto; color: var(--text-3); display: flex; }
.attach-dl:hover { color: var(--accent); }

/* center wrapper (list + reader/compose) */
.center { flex: 1 1 auto; display: flex; min-width: 0; min-height: 0; }

/* reading pane bottom layout */
.app[data-pane="bottom"] .body { }
.app[data-pane="bottom"] .listcol { flex: 1 1 auto; width: auto; }
.app[data-pane="bottom"] .center {
  flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0;
}
.app[data-pane="bottom"] .listcol { border-right: none; border-bottom: 1px solid var(--border); flex: 0 0 46%; }
.app[data-pane="right"] .center { display: flex; flex: 1 1 auto; min-width: 0; }

/* ============================================================
   COMPOSE
   ============================================================ */
.compose-wrap { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.compose-head {
  flex: 0 0 auto; height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--border);
}
.compose-head .ttl { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--text-1); letter-spacing: -.02em; }
.compose-scroll { flex: 1 1 auto; overflow-y: auto; }
.compose-inner { max-width: 860px; margin: 0 auto; padding: 8px 24px 28px; }

.field-row { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); min-height: 50px; }
.field-label { width: 52px; flex: 0 0 52px; font-size: 13px; color: var(--text-3); font-weight: 600; }
.field-input { flex: 1 1 auto; border: none; background: none; outline: none; font-size: 14px; color: var(--text-1); padding: 14px 0; }
.field-input::placeholder { color: var(--text-4); }

/* from selector */
.from-select { position: relative; flex: 1 1 auto; }
.from-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; border-radius: var(--r-md); border: 1px solid var(--border-2);
  background: var(--surface-2); transition: border-color var(--dur) var(--ease);
}
.from-trigger:hover:not(.locked) { border-color: var(--text-4); }
.from-trigger.locked { cursor: not-allowed; background: var(--surface-3); }
.from-trigger .chev { margin-left: auto; color: var(--text-3); display: flex; }
.from-name { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.from-addr { font-size: 12px; color: var(--text-3); }
.lock-badge {
  display: inline-flex; align-items: center; gap: 5px; margin-left: auto;
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface); border: 1px solid var(--border-2);
  padding: 3px 8px; border-radius: var(--r-pill);
}
.from-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 280px; overflow-y: auto;
}
.from-opt { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); transition: background var(--dur) var(--ease); }
.from-opt:hover { background: var(--hover); }
.from-opt.sel { background: var(--active); }

.lock-hint {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 10px;
  font-size: 12px; color: var(--text-3); line-height: 1.5;
  background: var(--accent-ghost); border: 1px solid var(--accent-border);
  padding: 9px 12px; border-radius: var(--r-md);
}
.lock-hint .ico { color: var(--accent); flex: 0 0 auto; margin-top: 1px; }

.cc-toggle { display: flex; gap: 14px; margin-left: auto; }
.cc-toggle button { font-size: 12px; font-weight: 600; color: var(--text-3); }
.cc-toggle button:hover { color: var(--accent); }

/* rich text toolbar */
.rt-toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 10px 0; margin-top: 6px; border-bottom: 1px solid var(--border);
}
.rt-btn { width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--text-2); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.rt-btn:hover { background: var(--hover); color: var(--text-1); }
.rt-btn.on { background: var(--accent-ghost); color: var(--accent); }
.rt-sep { width: 1px; height: 20px; background: var(--border); margin: 0 5px; }
.rt-color { position: relative; }
.rt-swatches { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 9px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.rt-swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-2); }

.editor {
  min-height: 220px; padding: 18px 2px; font-size: 14.5px; line-height: 1.7; color: var(--text-1);
  outline: none;
}
.editor:empty::before { content: attr(data-placeholder); color: var(--text-4); }
.editor .sig { margin-top: 26px; color: var(--text-3); font-size: 13px; line-height: 1.6; border-top: 1px solid var(--border); padding-top: 14px; }
.editor .sig .sig-name { font-weight: 700; color: var(--text-2); }
.editor a { color: var(--accent); }

/* dropzone */
.dropzone {
  margin-top: 18px; border: 2px dashed var(--border-2); border-radius: var(--r-lg);
  padding: 22px; text-align: center; color: var(--text-3); font-size: 13px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-ghost); color: var(--accent); }
.dropzone .dz-ico { color: var(--text-4); margin-bottom: 8px; display: inline-flex; }
.dropzone.drag .dz-ico { color: var(--accent); }
.dropzone b { color: var(--text-2); font-weight: 600; }
.dz-limit { font-family: var(--font-mono); font-size: 11px; color: var(--text-4); margin-top: 4px; }

.upload-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.upload-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.upload-meta { flex: 1 1 auto; min-width: 0; }
.upload-name { font-size: 13px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-bar { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 7px; overflow: hidden; }
.upload-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .2s linear; }
.upload-size { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); flex: 0 0 auto; }
.upload-x { color: var(--text-4); display: flex; }
.upload-x:hover { color: var(--red); }
.upload-done { color: var(--green); display: flex; }

.compose-foot {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface);
}
.btn-danger-ghost {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--r-sm); color: var(--text-3); font-weight: 600; font-size: 13.5px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn-danger-ghost:hover { background: var(--red); color: #fff; }
.send-btn { height: 40px; padding: 0 22px; font-size: 14px; }
.compose-status { margin-left: auto; font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }

/* ============================================================
   MODALS (add account, settings)
   ============================================================ */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 100; display: grid; place-items: center; padding: 24px; animation: fade .15s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; animation: pop .18s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-lg { max-width: 880px; }
.modal-head { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-head .ttl { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--text-1); letter-spacing: -.02em; }
.modal-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.modal-x { margin-left: auto; }
.modal-body { flex: 1 1 auto; overflow-y: auto; padding: 22px; }
.modal-foot { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.form-field .hint { font-size: 11.5px; color: var(--text-4); margin-top: 6px; line-height: 1.4; }
.form-control {
  width: 100%; height: 42px; padding: 0 13px; border-radius: var(--r-md);
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-1);
  font-size: 14px; outline: none; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.form-control:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-ghost); background: var(--surface); }
.form-control::placeholder { color: var(--text-4); }
textarea.form-control { height: auto; padding: 12px 13px; min-height: 90px; resize: vertical; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }

.provider-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 4px; }
.provider-card {
  display: flex; align-items: center; gap: 11px; padding: 13px 14px;
  border: 1.5px solid var(--border-2); border-radius: var(--r-md); background: var(--surface);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  text-align: left;
}
.provider-card:hover { border-color: var(--text-4); }
.provider-card.sel { border-color: var(--accent); background: var(--accent-ghost); }
.provider-logo { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; font-family: var(--font-display); font-weight: 800; color: #fff; font-size: 15px; }
.provider-name { font-size: 13.5px; font-weight: 700; color: var(--text-1); }
.provider-desc { font-size: 11px; color: var(--text-3); }

.sec-note {
  display: flex; gap: 11px; padding: 13px 15px; border-radius: var(--r-md);
  background: var(--accent-ghost); border: 1px solid var(--accent-border); margin-top: 4px;
}
.sec-note .ico { color: var(--accent); flex: 0 0 auto; margin-top: 1px; }
.sec-note .t { font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.sec-note .t b { color: var(--text-1); }

.test-result { display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600; padding: 10px 13px; border-radius: var(--r-md); margin-top: 4px; }
.test-result.ok { color: var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); }
.test-result.run { color: var(--text-3); background: var(--surface-2); }

/* settings layout */
.settings-tabs { display: flex; gap: 2px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.settings-tab { height: 46px; padding: 0 14px; font-size: 13.5px; font-weight: 600; color: var(--text-3); position: relative; transition: color var(--dur) var(--ease); }
.settings-tab:hover { color: var(--text-1); }
.settings-tab.active { color: var(--accent); }
.settings-tab.active::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }

.setting-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; margin-bottom: 12px; }
.setting-row { display: flex; align-items: center; gap: 14px; }
.setting-row + .setting-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.setting-info { flex: 1 1 auto; }
.setting-title { font-size: 14px; font-weight: 700; color: var(--text-1); }
.setting-desc { font-size: 12.5px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }

.toggle { width: 42px; height: 24px; border-radius: 9999px; background: var(--border-2); position: relative; transition: background var(--dur) var(--ease); flex: 0 0 auto; }
.toggle.on { background: var(--accent); }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left var(--dur) var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle.on .knob { left: 21px; }

.badge-soft { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.badge-ok { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.badge-warn { color: #b45309; background: rgba(180,83,9,.12); }
[data-theme="dark"] .badge-warn { color: #fbbf24; background: rgba(251,191,36,.12); }

.seg { display: inline-flex; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border-2); }
.seg button { height: 30px; padding: 0 14px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 600; color: var(--text-3); transition: all var(--dur) var(--ease); }
.seg button.on { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-sm); }

/* signature editor */
.sig-editor { border: 1px solid var(--border-2); border-radius: var(--r-md); overflow: hidden; }
.sig-editor .se-bar { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.sig-editor .se-area { min-height: 110px; padding: 14px; font-size: 13px; line-height: 1.6; color: var(--text-1); outline: none; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen { height: 100%; display: flex; background: var(--bg); }
.login-aside {
  flex: 0 0 46%; max-width: 620px; position: relative; overflow: hidden;
  background: #000; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px;
}
.login-aside .grid-tex {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,91,0,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,91,0,.05) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(120% 90% at 30% 20%, #000 40%, transparent 100%);
}
.login-aside .glow { position: absolute; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, rgba(255,91,0,.22), transparent 65%); top: -120px; right: -120px; filter: blur(20px); }
.login-aside-inner { position: relative; z-index: 2; }
.login-headline { font-family: var(--font-display); font-size: 40px; font-weight: 800; letter-spacing: -.04em; line-height: 1.08; margin: 26px 0 18px; }
.login-headline .g { color: var(--accent); }
.login-sub { font-size: 15px; color: #b8b8b8; line-height: 1.65; max-width: 420px; }
.login-feats { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 16px; }
.login-feat { display: flex; gap: 13px; align-items: flex-start; }
.login-feat .fi { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,91,0,.12); border: 1px solid rgba(255,91,0,.25); display: grid; place-items: center; color: var(--accent); flex: 0 0 auto; }
.login-feat .ft { font-size: 14px; font-weight: 600; color: #fff; }
.login-feat .fd { font-size: 12.5px; color: #9a9a9a; line-height: 1.5; margin-top: 2px; }

.login-main { flex: 1 1 auto; display: grid; place-items: center; padding: 32px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -.03em; color: var(--text-1); margin: 0 0 6px; }
.login-card .lead { font-size: 14px; color: var(--text-3); margin: 0 0 26px; line-height: 1.55; }
.login-card .form-field { margin-bottom: 14px; }
.login-submit { width: 100%; height: 46px; margin-top: 8px; font-size: 14.5px; }
.login-meta { display: flex; align-items: center; justify-content: space-between; margin: 10px 2px 0; font-size: 12.5px; }
.login-meta a { color: var(--accent); font-weight: 600; text-decoration: none; }
.login-secure { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 26px; font-size: 12px; color: var(--text-4); font-family: var(--font-mono); letter-spacing: .03em; }

/* toast */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 11px; padding: 11px 18px; border-radius: var(--r-md);
  background: var(--text-1); color: var(--surface); font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: toastin .22s var(--ease);
}
.toast .ico { color: var(--accent); display: flex; }
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } }

/* responsive guard */
@media (max-width: 1100px) {
  .brand-tag { display: none; }
}
