/* Air, Kunal's selected direction (Mail/AIR_DESIGN_HANDOFF.md).
   Five supplied colours, plus the derived tints the handoff names.
   Text on orange is dark charcoal: ivory on orange is only 3.32:1. */
:root {
  --ivory: #FFFCF2; --stone: #CCC5B9; --charcoal: #403D39;
  --ink: #252422;   --orange: #EB5E28;
  --bg: var(--ivory); --text: var(--ink); --muted: var(--charcoal);
  --panel: #F2EEE4;   --line: var(--stone); --ring: var(--ink);
  --tint: #F9E9DC;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
/* Light is the default (Kunal, 16 Sep). Dark only when chosen with the toggle,
   which theme.js applies before first paint. It no longer follows the system. */
:root[data-theme="dark"] {
  --bg: var(--ink); --text: var(--ivory); --muted: var(--stone);
  --panel: #302E2B; --line: #615B53; --ring: var(--ivory);
  --tint: #403D39;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  color: var(--text); font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
.card {
  width: 100%; max-width: 360px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; padding: 28px;
}
.mark { margin: 0 0 22px; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.mark span { color: var(--orange); }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
input {
  width: 100%; height: 48px; padding: 0 14px; font: inherit; font-size: 16px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px;
}
.btn {
  width: 100%; min-height: 48px; margin-top: 16px; font: inherit; font-size: 15px;
  font-weight: 600; border-radius: 12px; cursor: pointer;
  background: var(--orange); color: var(--ink); border: 1px solid var(--orange);
}
.btn.quiet { background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
.btn:disabled { cursor: default; opacity: .6; }
input:focus-visible, .btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.msg { min-height: 20px; margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.msg.err { color: var(--text); font-weight: 600; }
p.note { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ app --
   Air: account rail, list, reader. Values from Mail/designs/air-mobile-tabs:
   32px avatars, 10px row radius, tint plus an orange inset bar on the
   selected row, an orange dot before an unread sender. */
body.app { display: block; padding: 0; height: 100vh; height: 100dvh; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.link { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 6px 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6;
      stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.shell { display: grid; grid-template-columns: 196px var(--list-w, 400px) minmax(0, 1fr); height: 100%; }

.rail { background: var(--panel); border-right: 1px solid var(--line); padding: 22px 12px;
        display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.rail .mark { padding: 0 10px; margin-bottom: 18px; }
.accounts { display: flex; flex-direction: column; gap: 4px; }
.acct { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
        min-height: 48px; padding: 9px 11px; border-radius: 10px; text-align: left; }
.acct small { font-size: 12px; color: var(--muted); }
.acct:hover { background: var(--bg); }
.acct[aria-current="true"] { background: var(--bg); box-shadow: 0 2px 7px #00000008; font-weight: 600; }
.acct:disabled { cursor: default; opacity: .55; }
.acct:disabled:hover { background: none; }
.rail-foot { margin-top: auto; padding: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.theme { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); min-height: 36px; font-size: 14px; }
.theme:hover { color: var(--text); }

.list-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; position: relative; }
/* Drag to resize the list. The grab area is wider than the line it sits on. */
.resizer { position: absolute; top: 0; right: -5px; width: 10px; height: 100%; cursor: col-resize; z-index: 5;
           touch-action: none; }
.resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: transparent;
                  transition: background-color .12s ease; }
.resizer:hover::after, .resizer:focus-visible::after, body.resizing .resizer::after { background: var(--orange); }
.resizer:focus-visible { outline: none; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }
.list-head { padding: 20px 14px 10px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.account-switch { font-size: 20px; font-weight: 600; letter-spacing: -.01em; padding: 0; cursor: default; }
.sync { font-size: 12px; color: var(--muted); white-space: nowrap; }
.views { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
.views::-webkit-scrollbar { display: none; }
.view { padding: 7px 10px; border-radius: 8px; font-size: 14px; color: var(--muted); white-space: nowrap; min-height: 36px; }
.view[aria-selected="true"] { color: var(--text); background: var(--tint); font-weight: 600; }

.rows { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 3px;
        overscroll-behavior: contain; }
.row { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 11px; width: 100%;
       padding: 13px 11px; border-radius: 10px; text-align: left; }
.row:hover { background: var(--panel); }
.row.cursor { background: var(--tint); box-shadow: inset 3px 0 var(--orange); }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
          background: var(--panel); border: 1px solid var(--line); font-size: 12px; font-weight: 600;
          letter-spacing: .02em; color: var(--text); }
.row-main { min-width: 0; }
.row-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.sender { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .sender { font-weight: 650; }
.row.unread .sender::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
                               background: var(--orange); margin: 0 7px 2px 0; }
.time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.subject { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .subject { font-weight: 600; }
.snippet { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.clip { color: var(--muted); font-size: 12px; margin-left: 4px; }
.count { color: var(--muted); font-weight: 400; margin-left: 5px; font-size: 13px; }
.more { margin: 4px 16px 16px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.empty { color: var(--muted); padding: 40px 20px; text-align: center; font-size: 15px; line-height: 1.5; }
.banner { margin: 10px 12px 0; padding: 10px 12px; border-radius: 10px; background: var(--tint); font-size: 14px; }

.reader { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.reader-top { display: flex; align-items: center; justify-content: space-between; gap: 8px;
              padding: 12px 20px; border-bottom: 1px solid var(--line); min-height: 60px; }
.tools { display: flex; gap: 2px; }
.tool { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 8px 11px;
        border-radius: 9px; color: var(--muted); font-size: 14px; }
.tool:hover { background: var(--panel); color: var(--text); }
.tool:disabled { opacity: .4; cursor: default; background: none; }
.back { display: none; }
.reader-body { flex: 1; overflow-y: auto; padding: 22px 28px 40px; overscroll-behavior: contain; }
.reader-empty { color: var(--muted); display: grid; place-content: center; text-align: center; height: 100%; gap: 14px; font-size: 15px; }
.keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; font-size: 13px; }
kbd { font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; background: var(--panel); color: var(--text); }
.thread-subject { font-size: 22px; font-weight: 600; letter-spacing: -.015em; line-height: 1.25; margin: 0 0 20px; overflow-wrap: anywhere; }
.msg-card { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 14px; overflow: hidden; }
.msg-head { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 11px; align-items: start; padding: 14px 16px; }
.msg-from { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.msg-addr, .msg-to { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; margin-top: 2px; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.55; padding: 0 16px 16px 59px; }
.msg-frame { display: block; width: 100%; height: 120px; border: 0; background: #fff; }
.msg-note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted);
            padding: 10px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.files { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 14px 59px; }
.file { font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--muted); }
.thumbbar { display: none; }

/* Reply. Air's reply zone: a bordered panel under the thread, orange Send
   with charcoal text, the save state always visible beside it. */
.reply-zone { border: 1px solid var(--line); border-radius: 14px; margin-top: 6px; background: var(--bg); }
.reply-start { display: flex; gap: 8px; padding: 10px; }
.reply-btn { flex: 1; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; font-weight: 500; }
.reply-btn:hover { background: var(--panel); }
.reply-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
             padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.reply-to { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; min-width: 0; }
.reply-modes { display: flex; gap: 2px; }
.mode { padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); min-height: 32px; }
.mode[aria-pressed="true"] { background: var(--tint); color: var(--text); font-weight: 600; }
.ai-row { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ai-ask { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
          background: var(--panel); color: var(--text); font: inherit; font-size: 14px; }
.ai-ask:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.ai-btn { min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--orange);
          color: var(--text); font-weight: 600; white-space: nowrap; }
.ai-btn:hover { background: var(--tint); }
.reply-text { display: block; width: 100%; min-height: 150px; padding: 14px; border: 0; resize: vertical;
              background: transparent; color: var(--text); font: inherit; font-size: 15px; line-height: 1.55; }
.reply-text:focus { outline: none; }
.reply-zone:focus-within { border-color: var(--text); }
.draft-footer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px;
                border-top: 1px solid var(--line); }
.send { min-height: 40px; padding: 0 18px; border-radius: 10px; background: var(--orange); color: var(--ink); font-weight: 600; }
.send:disabled { opacity: .6; cursor: default; }
.draft-status { font-size: 13px; color: var(--muted); }
.grow { flex: 1; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
         display: flex; align-items: center; gap: 16px; padding: 11px 16px; border-radius: 12px;
         background: var(--ink); color: var(--ivory); font-size: 14px; box-shadow: 0 6px 24px #0003; z-index: 20;
         max-width: calc(100vw - 32px); }
.toast .link { color: var(--orange); font-weight: 600; min-height: 32px; }
:root[data-theme="dark"] .toast { background: var(--ivory); color: var(--ink); }

.sheet { position: fixed; inset: auto 0 0 0; background: var(--panel); border-top: 1px solid var(--line);
         border-radius: 18px 18px 0 0; padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); z-index: 30;
         box-shadow: 0 -8px 30px #0002; }
.sheet .acct { min-height: 52px; }

/* ---------------------------------------------------------------- phone -- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .resizer { display: none; }
  .list-pane { border-right: 0; }
  .list-head { padding-top: calc(14px + env(safe-area-inset-top)); }
  .account-switch { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
  .account-switch::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted);
                           border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-3px); }
  .row { padding: 14px 10px; }
  .reader { display: none; }
  body.reading .list-pane { display: none; }
  body.reading .reader { display: flex; }
  .reader-top { padding: calc(8px + env(safe-area-inset-top)) 8px 8px; min-height: 52px; }
  .back { display: inline-flex; min-height: 44px; }
  .tools.desk { display: none; }
  .reader-body { padding: 18px 14px 24px; }
  .thread-subject { font-size: 20px; }
  .msg-text, .files { padding-left: 16px; }
  .thumbbar { display: flex; justify-content: space-between; margin: 0 12px calc(10px + env(safe-area-inset-bottom));
              padding: 6px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
  .thumbbar .tool { flex-direction: column; gap: 3px; min-height: 56px; min-width: 76px; font-size: 12px; justify-content: center; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.composing .thumbbar { display: none; }
  body.composing .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .send { min-height: 44px; }
  .ai-ask, .ai-btn { min-height: 44px; height: 44px; }
}
@media (prefers-reduced-motion: no-preference) {
  .row, .tool, .view { transition: background-color .12s ease; }
}
