/* Lab Mail. Neutral system look: follows light/dark, system font, one blue accent. */

:root {
  --bg: #FFFFFF;
  --bg-side: #F5F5F7;
  --surface: #FFFFFF;
  --fill: #EEEEF1;
  --fill-hover: #E4E4E8;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --text: #111114;
  --text-2: #5C5D66;
  --text-3: #8D8E97;
  --accent: #0A6CFF;
  --accent-press: #0058DB;
  --accent-soft: rgba(10, 108, 255, 0.10);
  --on-accent: #FFFFFF;
  --danger: #E5383B;
  --star: #F2A20C;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.14);
  --seg-active: #FFFFFF;
  --av-s: 55%; --av-bg-l: 92%; --av-fg-l: 36%;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --list-w: 384px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D0D0F;
    --bg-side: #131316;
    --surface: #1A1A1E;
    --fill: #1F1F24;
    --fill-hover: #2A2A30;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.18);
    --text: #F3F3F5;
    --text-2: #A5A6AE;
    --text-3: #74757D;
    --accent: #3B8BFF;
    --accent-press: #5C9FFF;
    --accent-soft: rgba(59, 139, 255, 0.18);
    --danger: #FF5C5F;
    --star: #F5B542;
    --shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
    --seg-active: #34343B;
    --av-s: 32%; --av-bg-l: 22%; --av-fg-l: 78%;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.error { color: var(--danger); min-height: 1.4em; margin: 0; font-size: 14px; }
.link { color: var(--accent); font-weight: 500; padding: 8px 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline: none; }

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

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: background 160ms var(--ease), color 160ms var(--ease);
}
.icon-btn:hover { background: var(--fill); color: var(--text); }
.icon-btn.accent { color: var(--accent); }

.btn-primary {
  background: var(--accent); color: var(--on-accent); border-radius: 12px; padding: 11px 20px; font-weight: 600;
  transition: transform 160ms var(--ease), background 160ms var(--ease);
}
.btn-primary:hover { background: var(--accent-press); }
.btn-primary:active { transform: scale(0.98); }
.btn-ghost {
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 18px; font-weight: 500;
  transition: background 160ms var(--ease);
}
.btn-ghost:hover { background: var(--fill); }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.login-mark {
  width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; margin: 0 auto 6px;
}
.login-mark svg { width: 28px; height: 28px; }
.login-card h1 { font: 700 28px/1.1 var(--font); letter-spacing: -0.025em; margin: 0; }
.login-card p { margin: 0 0 6px; }
.login-card input {
  width: 100%; padding: 14px 16px; border-radius: 12px; background: var(--fill); border: 1px solid transparent;
  font-size: 22px; letter-spacing: 0.3em; text-align: center; outline: none;
}
.login-card input:focus { border-color: var(--accent); background: var(--bg); }
.login-card .btn-primary { padding: 14px 20px; }

/* ---------- app frame ---------- */
.app { position: fixed; top: var(--vvt, 0px); left: 0; right: 0; height: var(--vvh, 100%); display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); overflow: hidden; overflow: clip; }
.pane { position: relative; height: 100%; min-height: 0; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.thread-pane {
  position: absolute; inset: 0; transform: translateX(100%); transition: transform 300ms var(--ease);
  z-index: 2;
}
.app.show-thread .thread-pane { transform: translateX(0); }

@media (min-width: 900px) {
  .app { grid-template-columns: var(--list-w) 1fr; }
  .list-pane { background: var(--bg-side); border-right: 1px solid var(--line); }
  .thread-pane { position: relative; transform: none; transition: none; }
  #backBtn { display: none; }
  .app:not(.show-thread) .thread-head { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .thread-pane, .sheet-card, .toast { transition: none !important; animation: none !important; }
}

/* ---------- list pane ---------- */
.list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--sat) + 12px) 10px 4px 18px;
}
.title {
  display: inline-flex; align-items: center; gap: 4px; min-width: 0;
  font: 700 26px/1.15 var(--font); letter-spacing: -0.028em; color: var(--text); padding: 2px 6px 2px 0; border-radius: 8px;
}
.title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title svg { width: 18px; height: 18px; color: var(--text-3); stroke-width: 2.2; flex: none; margin-top: 3px; transition: transform 200ms var(--ease); }
.title.open svg { transform: rotate(180deg); }
.title.single svg { display: none; }
.title.single { cursor: default; }
.head-actions { display: flex; gap: 2px; flex: none; }

.chips { display: flex; gap: 6px; padding: 6px 16px 4px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  padding: 6px 12px; border-radius: 100px; background: var(--fill); color: var(--text-2); font-size: 13px; font-weight: 500;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.chip:hover { background: var(--fill-hover); }
.chip.active { background: var(--accent-soft); color: var(--accent); }
.chip.connect { background: none; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--accent); }
.chip-sep { width: 1px; background: var(--line); margin: 4px 2px; }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin: 8px 16px 8px; padding: 2px;
  background: var(--fill); border-radius: 10px;
}
.tab {
  padding: 6px 10px; border-radius: 8px; color: var(--text-2); font-size: 13px; font-weight: 600;
  display: inline-flex; gap: 6px; align-items: center; justify-content: center;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.tab.active { background: var(--seg-active); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
.tab .count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 600; line-height: 18px; font-variant-numeric: tabular-nums;
}
.tab .count:empty { display: none; }

.search { display: flex; gap: 6px; padding: 0 10px 8px 16px; align-items: center; }
.search input {
  flex: 1; min-width: 0; padding: 9px 14px; border-radius: 10px; background: var(--fill); border: 1px solid transparent; outline: none;
  font-size: 16px; -webkit-appearance: none;
}
.search input:focus { border-color: var(--accent); background: var(--bg); }

.list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 2px 0 var(--sab); }
.row-wrap { position: relative; overflow: hidden; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.row {
  position: relative; z-index: 1; background: var(--bg);
  display: grid; grid-template-columns: 8px 42px minmax(0, 1fr); gap: 0 10px; align-items: center;
  width: 100%; text-align: left; padding: 10px 16px 10px 5px;
  transition: background 140ms var(--ease), transform 220ms var(--ease); touch-action: pan-y;
}
.row.search-hit { grid-template-columns: 8px 42px minmax(0, 1fr); }
.row-wrap.swiping .row { transition: background 140ms var(--ease); }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; }
.row.unread .unread-dot { background: var(--accent); }
.swipe-bg {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 8px; padding: 0 20px;
  color: #fff; font-weight: 600; font-size: 13px; opacity: 0; transition: opacity 140ms var(--ease);
}
.swipe-bg.archive { background: var(--accent); justify-content: flex-start; }
.swipe-bg.move { background: #FF9500; justify-content: flex-end; }
.swipe-bg svg { width: 20px; height: 20px; }
.row-wrap.swiping:not(.left) .swipe-bg.archive, .row-wrap.swiping.left .swipe-bg.move { opacity: 0.6; }
.row-wrap.swiping.past:not(.left) .swipe-bg.archive, .row-wrap.swiping.past.left .swipe-bg.move { opacity: 1; }
.row-actions {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%); z-index: 2; display: none; gap: 0;
  background: var(--surface); border-radius: 100px; padding: 2px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16), 0 0 0 0.5px var(--line-strong);
}
.row-actions .icon-btn { width: 32px; height: 32px; }
.row-actions .icon-btn svg { width: 16px; height: 16px; }
.row:hover { background: var(--fill); }
.row.active { background: var(--accent-soft); }
@media (hover: hover) and (min-width: 900px) {
  .row-wrap:hover .row-actions { display: flex; }
  .row-wrap:hover .row { background: var(--fill); }
  .row-wrap:hover .row.active { background: var(--accent-soft); }
}
@media (min-width: 900px) {
  .list { padding: 2px 8px 8px; }
  .row-wrap { border-radius: 12px; margin-bottom: 1px; }
  .row { background: var(--bg-side); padding: 10px 12px 10px 3px; }
}
.avatar {
  --h: 220;
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font: 600 14px/1 var(--font); letter-spacing: 0.01em;
  background: hsl(var(--h) var(--av-s) var(--av-bg-l)); color: hsl(var(--h) var(--av-s) var(--av-fg-l));
}
.avatar svg { width: 19px; height: 19px; stroke-width: 1.8; }
.row-main { min-width: 0; }
.row-top { display: flex; gap: 6px; align-items: baseline; }
.row-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.unread .row-name { font-weight: 700; }
.row-time { color: var(--text-3); font-size: 12px; white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }
.row.unread .row-time { color: var(--accent); font-weight: 600; }
.row-star { color: var(--star); flex: none; align-self: center; display: inline-flex; }
.row-star svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.row-subject { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row.unread .row-subject { font-weight: 600; }
.row-preview { color: var(--text-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-preview.two { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 1px; }
.list .empty, .thread .empty { padding: 48px 24px; color: var(--text-3); text-align: center; }
.thread .empty { display: flex; flex-direction: column; align-items: center; gap: 12px; justify-content: center; height: 100%; }
.thread .empty p { margin: 0; }
.empty-mark { width: 56px; height: 56px; border-radius: 50%; background: var(--fill); color: var(--text-3); display: grid; place-items: center; }
.empty-mark svg { width: 24px; height: 24px; }
.load-more { display: block; width: 100%; padding: 14px; color: var(--accent); font-weight: 500; font-size: 14px; }
.import-bar {
  padding: 8px 18px calc(var(--sab) + 8px); border-top: 1px solid var(--line); color: var(--text-3);
  font-size: 12px; font-variant-numeric: tabular-nums; display: flex; gap: 10px; align-items: center;
}
.import-bar .track { flex: 1; height: 3px; background: var(--fill); border-radius: 2px; overflow: hidden; }
.import-bar .fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* ---------- thread pane ---------- */
.thread-head {
  display: flex; align-items: center; gap: 2px; padding: calc(var(--sat) + 8px) 8px 8px; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
#backBtn { color: var(--accent); }
#backBtn svg { width: 24px; height: 24px; stroke-width: 2; }
.who { flex: 1; min-width: 0; text-align: left; padding: 4px 8px; border-radius: 10px; }
.who:hover { background: var(--fill); }
.who .name { font: 600 16px/1.25 var(--font); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .addr { color: var(--text-3); margin-top: 1px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.star-btn.on { color: var(--star); }
.star-btn.on svg { fill: currentColor; }
@media (min-width: 900px) { .thread-head { padding-left: 16px; padding-right: 14px; } }

.thread { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 8px 14px 16px; }
@media (min-width: 900px) { .thread { padding: 8px 24px 20px; } }
.day { text-align: center; color: var(--text-3); font-size: 12px; font-weight: 500; margin: 20px 0 8px; }
.subject { color: var(--text-2); font-size: 12px; font-weight: 600; margin: 14px 6px 4px; }
.subject.me { text-align: right; }

.msg { display: flex; flex-direction: column; align-items: flex-start; margin: 3px 0; max-width: 100%; }
.msg.me { align-items: flex-end; }
.bubble {
  max-width: min(80%, 620px); padding: 9px 14px; border-radius: 20px; background: var(--fill); color: var(--text);
  white-space: pre-wrap; word-break: break-word; line-height: 1.42; border-bottom-left-radius: 6px;
  text-align: left; cursor: pointer; transition: background 140ms var(--ease);
}
.bubble:hover { background: var(--fill-hover); }
.msg.me .bubble { background: var(--accent); color: var(--on-accent); border-bottom-left-radius: 20px; border-bottom-right-radius: 6px; }
.msg.me .bubble:hover { background: var(--accent-press); }
@media (prefers-color-scheme: dark) { .msg.me .bubble { background: #1F6FEB; } .msg.me .bubble:hover { background: #2A7BF5; } }
.bubble a { color: var(--accent); }
.msg.me .bubble a { color: var(--on-accent); text-decoration: underline; }
.bubble .more { display: block; margin-top: 6px; color: var(--text-3); font-size: 12px; }
.msg.me .bubble .more { color: var(--on-accent); opacity: 0.75; }
.meta { color: var(--text-3); font-size: 11px; margin: 3px 8px 0; display: flex; gap: 6px; align-items: center; }
.meta .unread-mark { color: var(--accent); font-weight: 600; }
.msg.sending .bubble { opacity: 0.6; }
.meta .retry { color: var(--danger); font-size: 11px; font-weight: 600; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; max-width: min(80%, 620px); }
.msg.me .atts { justify-content: flex-end; }
.att {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border-radius: 14px; background: var(--bg);
  border: 1px solid var(--line-strong); color: var(--text); max-width: 100%; text-align: left;
}
.att:hover { background: var(--fill); }
.att .thumb { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; background: var(--fill); }
.att .ico { width: 42px; height: 42px; border-radius: 9px; display: grid; place-items: center; background: var(--fill); color: var(--text-2); }
.att .fn { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.att .fs { color: var(--text-3); font-size: 11px; }
.att.image-only { padding: 0; border: 0; background: none; }
.att.image-only img { max-width: min(320px, 70vw); max-height: 320px; border-radius: 16px; display: block; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); animation: fade 200ms ease; }
.sheet-card {
  position: relative; width: min(560px, 100%); max-height: 88vh; overflow-y: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(var(--sab) + 18px); box-shadow: var(--shadow);
  animation: rise 300ms var(--ease);
}
@media (min-width: 900px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 20px; padding: 18px 20px 20px; }
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet h2 { font: 700 19px/1.2 var(--font); letter-spacing: -0.02em; margin: 6px 0 12px; }
.sheet .kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: 14px; margin-bottom: 14px; }
.sheet .kv .k { color: var(--text-3); }
.sheet .kv .v { color: var(--text-2); word-break: break-word; }
.sheet .actions { display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: var(--fill); }
.sheet .actions button, .sheet .actions a {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 13px 16px;
  color: var(--text); text-decoration: none; text-align: left; font-weight: 500;
}
.sheet .actions > * + * { box-shadow: inset 0 1px 0 var(--line); }
.sheet .actions button:hover, .sheet .actions a:hover { background: var(--fill-hover); }
.sheet .actions .danger { color: var(--danger); }
.sheet pre { white-space: pre-wrap; word-break: break-word; font: inherit; color: var(--text-2); background: var(--fill); padding: 12px 14px; border-radius: 14px; margin: 8px 0 12px; max-height: 40vh; overflow: auto; }
.sheet iframe { width: 100%; height: 70vh; border: 0; border-radius: 12px; background: #fff; }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 10px; }
@media (min-width: 900px) { .sheet .grabber { display: none; } }

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 30; background: rgba(8, 8, 10, 0.96); color: #F3F3F5; display: flex; flex-direction: column; }
.viewer .icon-btn { color: #C9CAD1; }
.viewer .icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.viewer-head { display: flex; align-items: center; gap: 6px; padding: calc(var(--sat) + 8px) 10px 8px 16px; }
.viewer-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; font-weight: 500; }
.viewer-body { flex: 1; display: grid; place-items: center; overflow: auto; padding: 8px 8px calc(var(--sab) + 8px); }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 8px; }
.viewer-body .nofile { color: #A5A6AE; text-align: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 24px); transform: translateX(-50%); z-index: 40;
  background: #1D1D21; color: #F3F3F5; padding: 11px 18px; border-radius: 14px; font-weight: 500; font-size: 14px;
  box-shadow: var(--shadow); animation: rise 260ms var(--ease);
  display: flex; gap: 16px; align-items: center; white-space: nowrap; max-width: calc(100vw - 24px);
}
@media (prefers-color-scheme: dark) { .toast { background: #2C2C33; } }
.toast-action { color: #6AA8FF; font-weight: 600; padding: 2px 2px; }

/* ---------- reply bar ---------- */
.reply {
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 8px 10px calc(var(--sab) + 8px) 12px; display: flex; flex-direction: column; gap: 6px;
}
@media (min-width: 900px) { .reply { padding: 10px 22px 14px 24px; } }
.reply-meta { display: none; justify-content: space-between; align-items: center; gap: 12px; padding: 0 6px; }
.reply.open .reply-meta { display: flex; }
.reply-subject { color: var(--text-2); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding: 2px 0; }
.reply-subject.empty { color: var(--text-3); }
.reply-subject:hover, .from-chip:hover { color: var(--accent); }
.from-chip { font-size: 12px; font-weight: 500; color: var(--text-3); white-space: nowrap; flex: none; padding: 2px 0; }
.reply-subject-input {
  width: 100%; padding: 9px 14px; border-radius: 12px; background: var(--fill); border: 1px solid transparent; outline: none; font-size: 16px;
}
.reply-subject-input:focus { border-color: var(--accent); background: var(--bg); }
.reply-row { display: flex; align-items: flex-end; gap: 8px; }
.reply-row textarea {
  flex: 1; min-width: 0; resize: none; min-height: 40px; max-height: 160px; padding: 9px 16px; border-radius: 20px; outline: none;
  background: var(--fill); border: 1px solid transparent; color: var(--text); font-size: 16px; line-height: 1.35;
  -webkit-appearance: none; transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
.reply-row textarea::placeholder, .compose textarea::placeholder, .compose input::placeholder, .search input::placeholder { color: var(--text-3); }
.reply-row textarea:focus { border-color: var(--line-strong); background: var(--bg); }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none;
  transition: transform 160ms var(--ease), background 160ms var(--ease), color 160ms var(--ease), opacity 160ms var(--ease);
}
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.5; }
.send-btn svg { stroke-width: 2.4; width: 19px; height: 19px; }
.reply-row textarea:placeholder-shown + .send-btn { background: var(--fill); color: var(--text-3); }

/* ---------- compose sheet ---------- */
.compose { display: flex; flex-direction: column; }
.compose .field { display: flex; align-items: flex-start; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.compose .label { color: var(--text-3); font-size: 14px; padding-top: 5px; width: 58px; flex: none; }
.compose input { flex: 1; min-width: 80px; background: none; border: 0; outline: none; padding: 4px 0; font-size: 16px; color: var(--text); }
.to-wrap { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; cursor: text; }
.to-chip {
  display: inline-flex; align-items: center; gap: 2px; background: var(--accent-soft); color: var(--accent); border-radius: 100px;
  padding: 3px 4px 3px 11px; font-size: 14px; font-weight: 500; max-width: 100%;
}
.to-chip button { color: var(--accent); width: 20px; height: 20px; border-radius: 50%; font-size: 15px; line-height: 1; opacity: 0.7; }
.to-chip button:hover { opacity: 1; }
.suggest { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.suggest button { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; text-align: left; width: 100%; }
.suggest button:hover { background: var(--fill); }
.suggest .avatar { width: 32px; height: 32px; font-size: 12px; }
.suggest .muted { font-size: 12px; }
.compose textarea {
  width: 100%; min-height: 150px; resize: vertical; padding: 12px 2px; background: none; border: 0;
  outline: none; color: var(--text); font-size: 16px; line-height: 1.45;
}
.compose-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }
.compose-foot .btn-primary { margin-left: auto; border-radius: 100px; padding: 10px 22px; }

/* ---------- files and links panel ---------- */
.side {
  position: fixed; z-index: 15; top: var(--vvt, 0px); right: 0; height: var(--vvh, 100%); width: 100%;
  background: var(--bg); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 300ms var(--ease);
}
.side.open { transform: none; }
@media (min-width: 900px) {
  .side { width: 380px; border-left: 1px solid var(--line); box-shadow: var(--shadow); }
}
@media (min-width: 1240px) {
  .side { box-shadow: none; }
  .app.side-open { right: 380px; }
}
.side-head { display: flex; align-items: center; gap: 6px; padding: calc(var(--sat) + 10px) 8px 6px 18px; }
.side-titles { flex: 1; min-width: 0; }
.side-title { font: 700 19px/1.2 var(--font); letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-scopes { display: flex; gap: 6px; overflow-x: auto; padding: 6px 16px 2px; scrollbar-width: none; flex: none; }
.side-scopes::-webkit-scrollbar { display: none; }
.scope { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--fill); color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.scope:hover { background: var(--fill-hover); }
.scope.on { background: var(--text); color: var(--bg); }
.side-tabs { flex: none; grid-template-columns: repeat(3, 1fr); }
.stab {
  padding: 6px 10px; border-radius: 8px; color: var(--text-2); font-size: 13px; font-weight: 600;
  display: inline-flex; gap: 6px; align-items: center; justify-content: center;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.stab.active { background: var(--seg-active); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
.scount { color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.scount:empty { display: none; }
.side-filter { padding: 0 16px 6px; flex: none; }
.side-filter input {
  width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid transparent; background: var(--fill);
  color: var(--text); font: inherit; font-size: 14px; outline: none;
}
.side-filter input:focus { border-color: var(--accent); background: var(--bg); }
.side-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0 8px calc(var(--sab) + 16px); }
.side-empty { color: var(--text-3); text-align: center; padding: 48px 16px; font-size: 14px; }
.smonth { color: var(--text-3); font-size: 12px; font-weight: 600; padding: 14px 10px 4px; }
.srow { display: flex; align-items: center; border-radius: 12px; }
.srow:hover { background: var(--fill); }
.srow-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px 4px 8px 8px; text-align: left; color: inherit; text-decoration: none; }
.stile { width: 40px; height: 40px; border-radius: 10px; flex: none; object-fit: cover; background: var(--fill); }
.stile.ext, .stile.site {
  display: grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  background: hsl(var(--h) var(--av-s) var(--av-bg-l)); color: hsl(var(--h) var(--av-s) var(--av-fg-l));
}
.stile.site { font-size: 16px; border-radius: 50%; }
.srow-text { min-width: 0; display: flex; flex-direction: column; }
.srow-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow-sub { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow-jump { flex: none; color: var(--text-3); opacity: 0; }
.srow:hover .srow-jump, .srow-jump:focus-visible { opacity: 1; }
@media (hover: none) { .srow-jump { opacity: 1; } }
.srow-jump svg { width: 18px; height: 18px; }
.sgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 0 8px; }
.sthumb { aspect-ratio: 1; padding: 0; border-radius: 8px; overflow: hidden; background: var(--fill); }
.sthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.list-label { color: var(--text-3); font-size: 12px; font-weight: 600; padding: 12px 20px 4px; }
.row.person-hit { grid-template-columns: 8px 42px minmax(0, 1fr); }
.msg.flash .bubble { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

.rename-form input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; border: 1px solid transparent;
  background: var(--fill); color: var(--text); font: inherit; font-size: 16px; outline: none;
}
.rename-form input:focus { border-color: var(--accent); background: var(--bg); }
.rename-form .actions button[type=submit] { color: var(--accent); font-weight: 600; }

/* ---------- move to folder ---------- */
.folder-filter {
  width: 100%; padding: 10px 14px; margin-bottom: 10px; border-radius: 12px; border: 1px solid transparent;
  background: var(--fill); color: var(--text); font: inherit; font-size: 16px; outline: none;
}
.folder-filter:focus { border-color: var(--accent); background: var(--bg); }
.folder-pick { max-height: 60vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.folder-pick .actions { margin-bottom: 4px; }
.folder-pick .actions button { display: flex; align-items: center; justify-content: flex-start; gap: 12px; text-align: left; }
.folder-pick .actions button span { flex: 1; min-width: 0; }
.folder-pick .actions button svg { width: 20px; height: 20px; flex: none; color: #FF9500; }
.folder-pick .actions button[hidden] { display: none; }
.folder-group { color: var(--text-3); font-size: 12px; font-weight: 600; margin: 12px 4px 6px; }
.folder-group[hidden] { display: none; }

/* ---------- inbox picker ---------- */
.list-head { position: relative; }
.title.dot::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); align-self: center; margin-left: 2px; }
.inbox-menu {
  position: absolute; z-index: 12; left: 12px; top: calc(var(--sat) + 52px); min-width: 240px;
  background: var(--surface); border-radius: 14px; padding: 6px;
  box-shadow: var(--shadow), 0 0 0 0.5px var(--line-strong);
}
.inbox-menu button, .inbox-menu a {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-size: 15px; font-weight: 500; text-align: left;
}
.inbox-menu button:hover, .inbox-menu a:hover { background: var(--fill); }
.inbox-menu span:first-child { flex: 1; }
.inbox-menu .n { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.inbox-menu .connect { color: var(--accent); font-size: 13px; }
.inbox-menu svg { width: 18px; height: 18px; color: var(--accent); stroke-width: 2.4; flex: none; }

/* ---------- unsubscribe ---------- */
.unsub-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 14px 7px 18px; border-bottom: 1px solid var(--line); background: var(--bg-side);
  color: var(--text-3); font-size: 13px;
}
.unsub-bar button { color: var(--accent); font-size: 13px; font-weight: 600; padding: 4px 8px; border-radius: 8px; }
.unsub-bar button:hover { background: var(--accent-soft); }
.unsub-bar.hidden { display: none; }
@media (min-width: 900px) { .unsub-bar { padding-left: 26px; padding-right: 22px; } }
.bubble .link-site { opacity: 0.6; font-size: 0.92em; }

/* ---------- a colour per person in group threads ---------- */
.msg.tinted .bubble { background: hsl(var(--h) var(--av-s) var(--av-bg-l)); }
.msg.tinted .bubble:hover { background: hsl(var(--h) var(--av-s) calc(var(--av-bg-l) - 4%)); }
.msg.tinted .who-name { color: hsl(var(--h) var(--av-s) var(--av-fg-l)); font-weight: 600; }

/* ---------- folders in the inbox menu ---------- */
.inbox-menu { max-height: calc(var(--vvh, 100vh) - var(--sat) - 80px); overflow-y: auto; }
.inbox-menu .menu-head { padding: 12px 12px 4px; color: var(--text-3); font-size: 12px; font-weight: 600; border-top: 1px solid var(--line); margin-top: 6px; }
.inbox-menu .menu-note { padding: 8px 12px; color: var(--text-3); font-size: 14px; }
.inbox-menu button.folder { padding-left: calc(12px + var(--d, 0) * 16px); font-weight: 400; }
.inbox-menu button.folder svg:first-child { color: var(--text-3); stroke-width: 1.8; }
.inbox-menu button.folder span:not(.n) { flex: 1; }
