.mail-shell { grid-template-columns: 236px minmax(320px, 400px) 1fr; }
.compose-btn { margin: 0 2px 10px; height: 38px; }

/* ---------- list ---------- */
.list-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-inline-end: 1px solid var(--border); background: var(--surface); }
.list-head { display: grid; gap: 10px; padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.list-head h1 { margin: 0; font-size: 22px; font-weight: 400; color: var(--text-strong); text-transform: capitalize; }
.list-tools { display: flex; align-items: center; gap: 4px; min-height: 28px; }
.list-tools .sel-count { font-size: 12.5px; color: var(--muted); margin: 0 6px; }
.list-scroll { flex: 1; overflow: auto; }
.msg {
  position: relative; display: grid; grid-template-columns: 20px 32px 1fr; gap: 0 10px; padding-block: 12px; padding-inline: 10px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background-color 0.12s ease;
}
html[data-density="compact"] .msg { padding-top: 8px; padding-bottom: 8px; }
html[data-density="compact"] .msg .snippet { display: none; }
.msg:hover { background: var(--surface-2); }
.msg[aria-selected="true"] { background: var(--active); }
.msg.checked { background: color-mix(in srgb, var(--blue-bg) 60%, var(--surface)); }
.msg .pick { display: grid; place-items: center; height: 32px; }
.msg .pick input { width: 14px; height: 14px; margin: 0; accent-color: var(--ink); opacity: 0; transition: opacity 0.12s; }
.msg:hover .pick input, .msg .pick input:checked, .list-pane.selecting .pick input { opacity: 1; }
.msg .unread-dot { position: absolute; inset-inline-start: 4px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--unread-dot); }
.msg:hover .unread-dot, .list-pane.selecting .unread-dot { display: none; }
.msg .body { min-width: 0; }
.msg .line1 { display: flex; align-items: baseline; gap: 8px; }
.msg .from { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text); }
.msg .date { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; flex: none; }
.msg .subject { font-size: 13.5px; color: var(--text); }
.msg .snippet { font-size: 12.5px; color: var(--muted); }
.msg.unread .from, .msg.unread .subject { color: var(--text-strong); font-weight: 600; }
.msg.unread .date { color: var(--text-strong); font-weight: 600; }
.msg .marks { display: inline-flex; gap: 4px; color: var(--faint); }
.msg .marks .flag { color: var(--yellow); }
.msg .marks .flag svg { fill: currentColor; }
.load-more { display: flex; justify-content: center; padding: 14px; }

/* ---------- reader ---------- */
.reader-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.reader-bar { display: flex; align-items: center; gap: 2px; height: 56px; padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.reader-bar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.reader-scroll { flex: 1; overflow: auto; }
.reader { max-width: 880px; margin: 0 auto; padding: 28px 32px 64px; }
.reader h2 { margin: 0 0 20px; font-size: 28px; font-weight: 400; color: var(--text-strong); overflow-wrap: anywhere; }
.reader .headers { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.reader .headers .who { flex: 1; min-width: 0; font-size: 13px; }
.reader .headers .who b { color: var(--text-strong); font-size: 14px; }
.reader .headers .who .addr { color: var(--muted); }
.reader .headers .recips { color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.reader .headers .when { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.notice { display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin-bottom: 14px; border-radius: 8px; background: var(--yellow-bg); color: var(--yellow); font-size: 13px; }
.notice .btn { margin-inline-start: auto; }
.mail-body { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; overflow: hidden; }
.mail-body iframe { display: block; width: 100%; border: 0; min-height: 120px; background: #fff; border-radius: 7px; }
.mail-body pre { margin: 0; padding: 18px 20px; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.65 inherit; font-family: inherit; color: var(--text); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.att { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); text-decoration: none; max-width: 280px; transition: border-color 0.15s; }
.att:hover { border-color: var(--border-strong); }
.att .glyph { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; background: var(--hover); color: var(--muted); flex: none; }
.att .meta { min-width: 0; font-size: 12.5px; }
.att .meta b { display: block; font-weight: 500; color: var(--text-strong); }
.att .meta small { color: var(--muted); }
.quick-reply { margin-top: 20px; display: flex; gap: 8px; }

.thread-item { margin-bottom: 10px; }
.thread-item summary { list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; }
.thread-item summary::-webkit-details-marker { display: none; }
.thread-item[open] summary { border-radius: 8px 8px 0 0; border-bottom: 0; }
.thread-item .tbody { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 8px 8px; background: var(--surface); }
.thread-item .tbody pre { margin: 0; padding: 14px 16px; white-space: pre-wrap; font-family: inherit; font-size: 13.5px; }

/* ---------- compose (docked) ---------- */
.composer {
  position: fixed; inset-inline-end: 24px; bottom: 0; z-index: 70; width: min(620px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 40px));
  display: flex; flex-direction: column; background: var(--surface); border-radius: 10px 10px 0 0; box-shadow: var(--shadow-pop);
  animation: rise 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
.composer.min .composer-body, .composer.min .composer-foot { display: none; }
.composer.max { inset-inline-end: auto; left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(980px, calc(100vw - 48px)); height: calc(100dvh - 64px); max-height: none; border-radius: 12px; animation: none; }
.composer-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); cursor: default; }
.composer-head b { flex: 1; font-size: 13.5px; color: var(--text-strong); }
.composer-body { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.cline { display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.cline label { width: 56px; font-size: 12.5px; color: var(--muted); }
.cline input { flex: 1; height: 38px; border: 0; background: none; outline: none; color: var(--text-strong); min-width: 0; }
.cline .toggles { display: flex; gap: 2px; }
.composer textarea { flex: 1; min-height: 240px; border: 0; outline: none; resize: none; padding: 14px 16px; background: none; line-height: 1.65; color: var(--text-strong); }
.fab { display: none; position: absolute; inset-inline-end: 18px; bottom: 18px; z-index: 5; width: 56px; height: 56px; place-items: center; border: 0; border-radius: 18px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent); transition: transform 0.15s ease; }
.fab:active { transform: scale(0.94); }
.fab .icon { width: 22px; height: 22px; }

/* formatting editor */
.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.editor-bar .tool { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; transition: background-color 0.12s, color 0.12s; }
.editor-bar .tool:hover { background: var(--hover); color: var(--text-strong); }
.editor-bar .tool[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent-text); }
.editor-bar .sep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 4px; }
.editor-area { position: relative; flex: 1; min-height: 220px; padding: 14px 16px; outline: none; line-height: 1.75; color: var(--text-strong); overflow-wrap: anywhere; cursor: text; }
.editor-area.empty::before { content: attr(data-placeholder); color: var(--faint); pointer-events: none; position: absolute; }
.editor-area blockquote { margin: 6px 0; padding: 2px 12px; border-inline-start: 3px solid var(--accent); color: var(--muted); }
.editor-area ul, .editor-area ol { margin: 4px 0; padding-inline-start: 24px; }
.editor-area a { color: var(--accent-text); }
.composer .chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; background: var(--surface-2); }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; }
.chip button:hover { background: var(--hover); color: var(--text-strong); }
.composer-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.composer-foot .hint { margin-inline-start: auto; font-size: 12px; color: var(--muted); }

.shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 28px; }
.shortcuts div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }

.settings-section { margin-bottom: 26px; }
.settings-section h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--text-strong); }

.quota { padding: 10px 10px 4px; }
.quota .bar { height: 4px; border-radius: 2px; background: var(--active); overflow: hidden; margin-top: 6px; }
.quota .bar i { display: block; height: 100%; background: var(--ink); border-radius: 2px; }

@media (max-width: 1180px) {
  .mail-shell { grid-template-columns: 220px minmax(280px, 340px) 1fr; }
  .reader { padding: 22px 22px 48px; }
}
@media (max-width: 860px) {
  .mail-shell { grid-template-columns: 1fr; }
  .mail-shell .reader-pane { display: none; }
  .mail-shell.reading .list-pane { display: none; }
  .mail-shell.reading .reader-pane { display: flex; }
  .list-pane { border-inline-end: 0; position: relative; }
  /* Phones: each message is a bordered card, and Compose floats over the list. */
  .list-scroll { padding: 10px 10px 88px; background: var(--bg); }
  .msg { border: 1px solid var(--border-strong); border-radius: 12px; margin-bottom: 8px; background: var(--surface); padding-inline: 10px 12px; }
  .msg.unread { border-inline-start: 3px solid var(--accent); }
  .msg .unread-dot { display: none; }
  .fab { display: grid; }
  .reader { padding: 18px 16px 48px; }
  .reader h2 { font-size: 22px; }
  .composer, .composer.max { inset: 0; transform: none; width: 100%; height: 100dvh; max-height: none; border-radius: 0; }
  .shortcuts { grid-template-columns: 1fr; }
}

/* ---------- developer page (personal API keys) ---------- */
.mail-shell.dev-mode { grid-template-columns: 236px 1fr; }
.mail-shell.dev-mode .list-pane { display: none; }
.mail-shell.dev-mode .reader-pane { display: flex; }
.reader.dev { max-width: 820px; }
.policy { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 22px; }
.policy > div { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 13px; color: var(--text); }
.policy .icon { color: var(--blue); margin-top: 2px; }
.key-row { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.key-row:last-child { border-bottom: 0; }
.session-list { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.session-list .key-row { padding: 10px 14px; }
.section-title { margin: 30px 0 10px; font-size: 15px; color: var(--text-strong); }
.steps { margin: 0 0 14px; padding-inline-start: 20px; display: grid; gap: 6px; color: var(--text); }
.secret { display: flex; gap: 10px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); margin-top: 12px; }
.secret code { flex: 1; background: none; padding: 0; overflow-wrap: anywhere; font-size: 13px; }
.wrap-seg { flex-wrap: wrap; }
@media (max-width: 860px) {
  .mail-shell.dev-mode { grid-template-columns: 1fr; }
  .policy { grid-template-columns: 1fr; }
  .key-row { flex-wrap: wrap; }
}
