/* Tokens match liftlog and macrolog deliberately — same user, same phone, same
   visual grammar. Inter for UI text; JetBrains Mono for anything numeric,
   which here means the countdown, because the countdown is the product. */
:root {
  --bg:      #FAFAFA;
  --surface: #FFFFFF;
  --card:    #F5F5F7;
  --border:  #E5E5EA;
  --text:    #1C1C1E;
  --muted:   #8E8E93;

  --blue:    #4C7FF0;
  --teal:    #2FA89C;
  --green:   #34C759;
  --indigo:  #6C63FF;
  --amber:   #FF9F0A;
  --red:     #FF3B30;

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Wider than macrolog's 560px: a message list needs the room, and the MacBook
   is a first-class client here rather than the analysis-only afterthought. */
.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 120px;
}

h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 600; }
a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sp-top { margin-top: 16px; }
.error { color: var(--red); }
.ok { color: var(--teal); }
code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--card);
  padding: 1px 5px;
  border-radius: 5px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.error-card { border-color: var(--red); }
.notice { border-color: var(--amber); }
.empty { text-align: center; padding: 32px 20px; }
.empty h2 { margin-bottom: 6px; }

/* ── header and search ──────────────────────────────────────────── */

.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head h1 { flex: none; }
.search { flex: 1; display: flex; gap: 6px; min-width: 200px; }
.search input {
  flex: 1; min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font: inherit; color: inherit;
}

.back-link { color: var(--muted); font-size: 13px; }

/* ── filters ────────────────────────────────────────────────────── */

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}
.chip.is-active { border-color: var(--blue); color: var(--blue); font-weight: 600; }

/* ── message list ───────────────────────────────────────────────── */

.msglist { list-style: none; display: flex; flex-direction: column; gap: 8px; }

/* The row is the clipping frame; .msg-swipe-surface is what actually carries
   the old padding/flex layout and is what moves during a drag, so the reveal
   panel underneath (only present on a pending, swipeable row) stays clipped
   to the row's own rounded corners instead of spilling past them. */
.msg {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
/* Unread is a left edge, not a bold everything: at 40 messages a screen the
   bold treatment stops meaning anything. */
.msg.is-unread { border-left: 3px solid var(--blue); }

.msg-swipe-surface {
  position: relative;
  background: var(--surface);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  /* Vertical list-scrolling stays native; horizontal is inbox.js's to run. */
  touch-action: pan-y;
}
.msg.is-dragging .msg-swipe-surface { transition: none; }

.msg-swipe-reveal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  background: var(--teal);
  color: #fff;
  font-weight: 600;
}
.msg-swipe-icon {
  opacity: 0.55;
  transform: scale(0.85);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
/* The visual feedback a swipe past the commit threshold gets, before release
   actually fires the keep — the icon steps up rather than the commit being a
   surprise the instant a finger lifts. */
.msg.is-committed .msg-swipe-icon { opacity: 1; transform: scale(1.15); }

/* The Keep button is the no-JS baseline (CLAUDE.md decision 10) — shown by
   default, hidden only once `.js` on <html> confirms the gesture that
   replaces it is actually available. Scoped to .swipeable specifically:
   Un-keep and Restore, in the kept and trash views, are unrelated single
   actions with no gesture standing in for them and stay visible regardless. */
.js .msg.swipeable .msg-actions { display: none; }

.msg-main { flex: 1; min-width: 0; display: block; }
.msg-line { display: flex; align-items: center; gap: 8px; }
.msg-from {
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-subject { margin-top: 1px; }
.msg-snippet {
  font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-deadline { margin-top: 6px; font-size: 12px; color: var(--amber); }
.msg-deadline.is-kept { color: var(--teal); }
.msg-deadline.is-trash { color: var(--muted); }

.msg-provider {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px;
  background: var(--card); color: var(--muted);
  flex: none;
}
.prov-gmail   { color: var(--red); }
.prov-outlook { color: var(--blue); }
.prov-icloud  { color: var(--indigo); }

.msg-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }

/* The "Load more" row: a real link (works with JS off — CLAUDE.md decision
   10) that msglist-more.js also uses as its scroll-into-view sentinel. Dimmed
   rather than hidden while a fetch is in flight, so a second click reads as
   already-in-progress instead of dead. */
.msglist-more { text-align: center; }
.msglist-more.is-loading .btn { opacity: 0.6; pointer-events: none; }

/* ── buttons ────────────────────────────────────────────────────── */

.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer;
  /* Comfortably tappable, not Apple's bare minimum — liftlog learned this the
     hard way and the fix is written into its design language. */
  min-height: 40px;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-keep { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-quiet { color: var(--muted); font-size: 13px; padding: 6px 12px; }
.btn-danger { color: var(--red); border-color: var(--red); }

.actionbar { display: flex; flex-wrap: wrap; gap: 8px; }

/* A card that is itself a link to somewhere else — Settings → Accounts. */
.link-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

/* ── forms ──────────────────────────────────────────────────────── */

.field { display: block; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field-hint { display: block; font-size: 12px; margin-top: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font: inherit; color: inherit;
}
.field textarea { resize: vertical; min-height: 160px; }

/* ── message view ───────────────────────────────────────────────── */

.meta { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.meta .mono { font-size: 12px; }
.is-kept { color: var(--teal); }
.is-trash { color: var(--muted); }

.body-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
}

.body-html {
  width: 100%;
  min-height: 400px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.attachments { list-style: none; margin-top: 8px; }
.attachments li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}

/* ── accounts ───────────────────────────────────────────────────── */

.acctlist { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.acct-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.badge {
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: var(--card); color: var(--muted);
  flex: none;
}
.badge-ok { color: var(--teal); }

/* ── nav ────────────────────────────────────────────────────────── */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  padding: 12px 4px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab.is-active { color: var(--blue); font-weight: 600; }
.tab-count { font-size: 11px; }
