/* =====================================================================
   PinguinMail – styles
   A kid-friendly look inspired by modern webmail interfaces.
   ===================================================================== */

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-alt: #f2f6fc;
  --text: #1f1f1f;
  --muted: #5f6368;
  --border: #e3e6ea;
  --blue: #0b57d0;
  --blue-hover: #0842a0;
  --blue-light: #d3e3fd;
  --compose: #c2e7ff;
  --hover: #eaf1fb;
  --danger: #d93025;
  --danger-light: #fce8e6;
  --success: #16a34a;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  --shadow-lg: 0 8px 24px rgba(60, 64, 67, .25), 0 2px 6px rgba(60, 64, 67, .2);
  --font: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Mission theme (overridden by .theme-* classes) */
  --theme: var(--blue);
  --theme-light: var(--blue-light);
  --theme-dark: var(--blue-hover);
}

.theme-blue   { --theme: #2563eb; --theme-light: #dbeafe; --theme-dark: #1e40af; }
.theme-pink   { --theme: #db2777; --theme-light: #fce7f3; --theme-dark: #9d174d; }
.theme-teal   { --theme: #0891b2; --theme-light: #cffafe; --theme-dark: #155e75; }
.theme-purple { --theme: #7c3aed; --theme-light: #ede9fe; --theme-dark: #5b21b6; }
.theme-orange { --theme: #ea580c; --theme-light: #ffedd5; --theme-dark: #9a3412; }
.theme-green  { --theme: #059669; --theme-light: #d1fae5; --theme-dark: #065f46; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: .9em;
  background: #f1f3f4;
  padding: 1px 6px;
  border-radius: 6px;
}

svg.icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  display: block;
}

[data-icon], [data-penguin] { display: inline-flex; }

/* ---------- Buttons ---------- */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(60, 64, 67, .08); color: var(--text); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 18px; height: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border-radius: 22px;
  font-weight: 800;
  font-size: 15px;
  transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); box-shadow: var(--shadow-sm); }
.btn-ghost { color: var(--blue); }
.btn-ghost:hover { background: var(--hover); }
.btn-outline { border: 1px solid #747775; color: var(--text); }
.btn-outline:hover { background: var(--hover); }
.btn-small { height: 36px; padding: 0 14px; font-size: 14px; }
.btn-small svg { width: 18px; height: 18px; }
.btn-theme { background: var(--theme); color: #fff; }
.btn-theme:hover { background: var(--theme-dark); box-shadow: var(--shadow-sm); }
.btn-block { width: 100%; height: 52px; font-size: 17px; border-radius: 26px; }

.link-btn {
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  transition: background .15s, color .15s;
}
.link-btn:hover { color: var(--text); text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  height: 68px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  min-width: 210px;
}
.brand-logo svg { width: 44px; height: 44px; display: block; }
.brand-name { font-size: 25px; font-weight: 900; color: #334155; letter-spacing: -.3px; }
.brand-name span {
  background: linear-gradient(90deg, #0b57d0, #7c3aed 55%, #ea580c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.search {
  flex: 1;
  max-width: 720px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 16px;
  background: #e9eef6;
  border-radius: 24px;
  color: var(--muted);
  transition: background .2s, box-shadow .2s;
}
.search:focus-within { background: #fff; box-shadow: var(--shadow-sm); }
.search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 16px;
  min-width: 0;
}

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

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
  font-size: 15px;
  background: var(--muted);
}
.avatar.small { width: 28px; height: 28px; font-size: 13px; }
.avatar.large { width: 44px; height: 44px; font-size: 18px; }
.avatar-user {
  width: 40px;
  height: 40px;
  font-size: 17px;
  background: linear-gradient(135deg, #7c3aed, #0b57d0);
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--blue-light);
}

/* ---------- Mission tabs ---------- */
.mission-tabs {
  display: flex;
  gap: 12px;
  padding: 2px 16px 14px;
  flex-shrink: 0;
  align-items: stretch;
  overflow-x: auto;
}

.mission-tab {
  flex: 1 1 0;
  min-width: 165px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: 18px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, border-color .15s, background .15s;
}
.mission-tab:hover { transform: translateY(-2px); }
.mission-tab.active { border-color: var(--theme); background: var(--theme-light); }

.mission-tab-emoji {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--theme-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.mission-tab.active .mission-tab-emoji { background: #fff; }

.mission-tab-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.mission-tab-text small {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--theme);
}
.mission-tab-text strong,
.mission-tab-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mission-tab-text strong { font-size: 16px; font-weight: 900; }
.mission-tab-text span { font-size: 12.5px; color: var(--muted); }

.mission-tab-status { margin-left: auto; font-size: 20px; flex-shrink: 0; }
.mission-tab.done .mission-tab-status { animation: pop .5s; }

.progress-pill {
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: #fff7d6;
  border-radius: 18px;
  font-weight: 900;
  font-size: 18px;
  color: #92400e;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

/* ---------- Main layout ---------- */
.app {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 360px;
  grid-template-areas: "side main panel";
  gap: 16px;
  padding: 0 16px 16px 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-top: 2px;
}

.compose-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  height: 58px;
  padding: 0 28px 0 18px;
  margin-left: 12px;
  align-self: flex-start;
  background: var(--compose);
  color: #001d35;
  border-radius: 18px;
  font-weight: 800;
  font-size: 16px;
  transition: box-shadow .15s, background .15s;
}
.compose-btn:hover { box-shadow: var(--shadow-sm); background: #b3dcf7; }
.compose-btn.pulse { animation: pulse 2s infinite; }

.folders { list-style: none; margin: 4px 0 0; padding: 0; }
.folder {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
  padding: 0 14px 0 24px;
  border-radius: 0 20px 20px 0;
  font-size: 15px;
  transition: background .15s;
}
.folder svg { width: 20px; height: 20px; }
.folder:hover { background: rgba(60, 64, 67, .08); }
.folder.active { background: var(--blue-light); font-weight: 800; color: #041e49; }
.folder .count { margin-left: auto; font-size: 13px; font-weight: 800; }

.sidebar-tip {
  margin: auto 0 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 14px;
  background: linear-gradient(160deg, #e0f2fe, #ede9fe);
  border-radius: 20px;
  text-align: center;
}
.sidebar-tip-penguin svg { width: 68px; height: 68px; display: block; transition: transform .3s; }
.sidebar-tip-penguin:hover svg { transform: rotate(-8deg) scale(1.08); }
.sidebar-tip-penguin.wiggle svg { animation: wiggle .5s; }
.sidebar-tip-bubble strong {
  font-size: 12px;
  color: #5b21b6;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.sidebar-tip-bubble p { margin: 4px 0 0; font-size: 14px; line-height: 1.45; }

body.sidebar-collapsed .app { grid-template-columns: 84px minmax(0, 1fr) 360px; }
body.sidebar-collapsed .sidebar .label,
body.sidebar-collapsed .folder .count,
body.sidebar-collapsed .sidebar-tip { display: none; }
body.sidebar-collapsed .compose-btn { padding: 0; width: 58px; justify-content: center; }
body.sidebar-collapsed .folder { padding-left: 30px; }

/* ---------- Mail area ---------- */
.mail-area {
  grid-area: main;
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.mail-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 8px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mail-toolbar h2 { margin: 0 0 0 4px; font-size: 18px; font-weight: 800; }
.mail-toolbar .toolbar-count { margin-left: auto; font-size: 13px; }
.mail-toolbar .icon-btn.spin svg { animation: spin .7s linear; }

.mail-content { flex: 1; overflow-y: auto; }

.mail-row {
  display: grid;
  grid-template-columns: 40px 190px minmax(0, 1fr) 24px 64px;
  align-items: center;
  gap: 8px;
  padding: 0 16px 0 8px;
  height: 50px;
  border-bottom: 1px solid #f1f3f4;
  background: var(--surface-alt);
  cursor: pointer;
  position: relative;
  outline: none;
}
.mail-row.unread { background: #fff; font-weight: 800; }
.mail-row:hover, .mail-row:focus-visible {
  box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  z-index: 1;
}
.mail-row.new { animation: newMail 1.6s ease-out; }

.mail-row .star {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #b0b4b8;
}
.mail-row .star svg { width: 20px; height: 20px; }
.mail-row .star:hover { background: rgba(60, 64, 67, .08); }
.mail-row .star.on { color: #f4b400; }
.mail-row .star.on svg { fill: #f4b400; }

.mail-sender, .mail-summary { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-summary .snippet { color: var(--muted); font-weight: 400; }
.mail-clip { color: var(--muted); }
.mail-clip svg { width: 18px; height: 18px; }
.mail-date { text-align: right; font-size: 13px; color: var(--muted); }
.mail-row.unread .mail-date { color: var(--text); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 56px 24px;
  color: var(--muted);
  text-align: center;
}
.empty-state svg { width: 100px; height: 100px; }
.empty-state strong { color: var(--text); font-size: 18px; }

/* ---------- Reading view ---------- */
.mail-view { padding: 22px 28px 36px; }

.view-subject {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.folder-tag {
  font-size: 12px;
  font-weight: 700;
  background: #e8eaed;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 6px;
}

.view-sender { display: flex; gap: 12px; align-items: flex-start; }
.view-sender-info { flex: 1; min-width: 0; }
.view-sender-info .sender-line { overflow-wrap: anywhere; }
.view-date { color: var(--muted); font-size: 13px; white-space: nowrap; }

.view-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
  display: inline-block;
}
.view-details summary::-webkit-details-marker { display: none; }
.view-details summary::after { content: ' ▾'; }
.view-details dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 8px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  max-width: 540px;
  background: #fff;
}
.view-details dt { color: var(--muted); text-align: right; }
.view-details dd { margin: 0; overflow-wrap: anywhere; }
.bcc-highlight { background: #ffedd5; color: #9a3412; font-weight: 800; border-radius: 4px; padding: 0 4px; }

.view-body {
  margin: 24px 0 0 56px;
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.view-attachments { margin: 24px 0 0 56px; padding-top: 16px; border-top: 1px solid var(--border); }
.view-attachments h4 { margin: 0 0 12px; font-size: 14px; }
.att-cards { display: flex; flex-wrap: wrap; gap: 12px; }
.att-card {
  width: 180px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-align: left;
  background: #fff;
  transition: box-shadow .15s, transform .15s;
}
.att-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.att-card-preview {
  height: 90px;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
}
.att-card-info { padding: 8px 10px; font-size: 13px; color: var(--muted); }
.att-card-info strong {
  display: block;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-actions { margin: 28px 0 0 56px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Mission panel ---------- */
.mission-panel {
  grid-area: panel;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  overflow-y: auto;
  min-height: 0;
  border-top: 6px solid var(--theme);
}

.mission-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px;
  background: var(--theme-light);
  border-radius: 18px;
}
.mission-hero-emoji {
  font-size: 38px;
  width: 64px;
  height: 64px;
  background: #fff;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.mission-hero small {
  color: var(--theme-dark);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .6px;
}
.mission-hero h2 { margin: 2px 0 0; font-size: 19px; line-height: 1.25; font-weight: 900; }

.mission-done-banner {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fef9c3;
  color: #854d0e;
  border-radius: 12px;
  font-weight: 800;
}

.mission-story { line-height: 1.6; font-size: 15.5px; margin: 16px 0; }
.mission-panel h3 { font-size: 15px; font-weight: 900; margin: 18px 0 10px; }

.address-book ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.address-book li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border-radius: 12px;
}
.address-book li > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.address-book strong { font-size: 14px; }
.address-book code {
  background: none;
  padding: 0;
  color: var(--theme-dark);
  font-weight: 700;
  font-size: 14px;
  overflow-wrap: anywhere;
  user-select: all;
}

.checklist { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
  font-size: 14.5px;
  transition: color .2s;
}
.check-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #64748b;
  flex-shrink: 0;
  transition: background .25s, border-color .25s, color .25s;
}
.checklist li.ok { color: #15803d; }
.checklist li.ok .check-mark { background: var(--success); border-color: var(--success); color: #fff; }
.checklist li.ok.just-done .check-mark { animation: pop .35s; }
.checklist li.bad { color: #b3261e; }
.checklist li.bad .check-mark { background: var(--danger); border-color: var(--danger); color: #fff; }

.theory {
  margin-top: 16px;
  border: 2px solid var(--theme-light);
  border-radius: 14px;
  padding: 0 14px;
}
.theory summary { cursor: pointer; padding: 12px 0; font-weight: 800; }
.theory > div { padding-bottom: 6px; line-height: 1.55; }
.theory p { margin: 0 0 10px; }

.pingo-tip {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  padding: 12px;
  background: #f0f9ff;
  border-radius: 14px;
}
.pingo-tip svg { width: 54px; height: 54px; flex-shrink: 0; }
.pingo-tip p { margin: 0; line-height: 1.45; font-size: 14px; }

/* ---------- Compose window ---------- */
.compose {
  position: fixed;
  right: 24px;
  bottom: 0;
  width: 560px;
  height: min(600px, calc(100vh - 90px));
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
  animation: composeIn .25s ease-out;
}
.compose.minimized { height: auto; width: 320px; }

/* On wide screens keep the mission panel (and its live checklist) visible. */
@media (min-width: 1181px) {
  .compose { right: 392px; }
}
.compose.minimized .compose-body,
.compose.minimized .compose-footer { display: none; }

.compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 16px;
  background: var(--surface-alt);
  flex-shrink: 0;
}
.compose.minimized .compose-header { cursor: pointer; }
.compose-title { font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-header-actions { display: flex; }

.compose-body { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }

.compose-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 16px;
  min-height: 46px;
  border-bottom: 1px solid #eceff1;
  flex-shrink: 0;
}
.compose-field > label { color: var(--muted); width: 42px; flex-shrink: 0; font-size: 15px; }
.compose-field.appear { animation: fieldIn .3s ease-out; }

.chip-box {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  cursor: text;
  padding: 3px 0;
  min-width: 0;
}
.chip-box input {
  flex: 1;
  min-width: 140px;
  border: none;
  outline: none;
  font-size: 15px;
  padding: 6px 0;
  background: transparent;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 3px;
  border: 1px solid #dadce0;
  border-radius: 15px;
  background: #fff;
  font-size: 14px;
  max-width: 100%;
  animation: pop .2s;
}
.chip-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}
.chip-remove:hover { background: rgba(60, 64, 67, .12); color: var(--text); }
.chip.invalid { border-color: var(--danger); background: var(--danger-light); color: #b3261e; }
.chip.invalid .chip-avatar { background: var(--danger) !important; }

.cc-toggles { display: flex; gap: 2px; align-self: flex-start; margin-top: 7px; }

.hint-glow {
  animation: glow 1.4s infinite;
  color: var(--theme-dark) !important;
  background: var(--theme-light);
}

.subject-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  padding: 8px 0;
  background: transparent;
  min-width: 0;
}

.body-input {
  flex: 1;
  min-height: 150px;
  border: none;
  outline: none;
  resize: none;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.55;
}

/* Original message under a Reply / Forward */
.quoted-block { padding: 0 16px 12px; flex-shrink: 0; }
.quoted-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 2px 10px 2px 2px;
  border-radius: 10px;
}
.quoted-toggle:hover { background: var(--hover); color: var(--text); }
.quoted-dots {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  background: #e8eaed;
  border-radius: 6px;
  font-size: 11px;
  letter-spacing: 1px;
}
.quoted-text {
  margin-top: 8px;
  padding: 8px 0 8px 12px;
  border-left: 3px solid #dadce0;
  color: var(--muted);
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.mission-badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 900;
  color: #fff;
  background: var(--theme);
  padding: 1px 8px;
  border-radius: 8px;
  margin-right: 4px;
  vertical-align: 1px;
}

.attachment-list { display: flex; flex-direction: column; gap: 8px; padding: 0 16px 10px; }
.attachment-list:empty { display: none; }
.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 8px 12px;
  background: #f5f5f5;
  border-radius: 10px;
  max-width: 440px;
  animation: pop .25s;
}
.attachment-icon { font-size: 24px; }
.attachment-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.attachment-name {
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}
.attachment-size { font-size: 12px; color: var(--muted); }
.progress { height: 5px; background: #dadce0; border-radius: 3px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--blue); border-radius: 3px; }

.compose-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 12px 16px;
  border-top: 1px solid #eceff1;
  flex-shrink: 0;
}
.send-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 20px 0 24px;
  background: var(--blue);
  color: #fff;
  border-radius: 21px;
  font-weight: 800;
  font-size: 15px;
  transition: background .15s, box-shadow .15s;
}
.send-btn:hover { background: var(--blue-hover); box-shadow: var(--shadow-sm); }
.send-btn svg { width: 18px; height: 18px; }
.compose-note { font-size: 12px; color: var(--muted); }
#discardBtn { margin-left: auto; }

.drop-overlay {
  position: absolute;
  inset: 52px 8px 8px;
  border: 3px dashed var(--blue);
  border-radius: 14px;
  background: rgba(211, 227, 253, .93);
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: var(--blue-hover);
  pointer-events: none;
  text-align: center;
  padding: 16px;
}
.compose.dragging .drop-overlay { display: flex; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  animation: fadeIn .2s;
}
.modal {
  background: #fff;
  border-radius: 28px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .35s cubic-bezier(.2, 1.4, .4, 1);
}
.modal-wide { max-width: 880px; }
.modal-icon { font-size: 56px; text-align: center; line-height: 1; display: flex; justify-content: center; }
.modal-icon svg { width: 100px; height: 100px; }
.modal h2 { text-align: center; margin: 12px 0 8px; font-size: 24px; font-weight: 900; }
.modal-content { line-height: 1.55; font-size: 15.5px; }
.modal-content h3 { font-size: 17px; margin: 22px 0 12px; }
.modal-content .checklist { margin-top: 14px; }
.modal-lead { text-align: center; font-size: 16.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; flex-wrap: wrap; }

.name-label { display: block; font-weight: 800; margin: 18px 0 8px; font-size: 17px; }
.name-input {
  width: 100%;
  height: 54px;
  padding: 0 18px;
  border: 2px solid var(--border);
  border-radius: 16px;
  font-size: 19px;
  outline: none;
  transition: border-color .15s;
}
.name-input:focus { border-color: var(--blue); }
.shake { animation: shake .4s; border-color: var(--danger) !important; }
.small-note { font-size: 13.5px; color: var(--muted); margin-top: 10px; }

/* Recipient view cards */
.recipient-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.recipient-card {
  border: 2px solid var(--role);
  border-radius: 18px;
  padding: 14px;
  background: var(--role-light);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.role-to  { --role: #0b57d0; --role-light: #eef4fe; }
.role-cc  { --role: #7c3aed; --role-light: #f5f3ff; }
.role-bcc { --role: #ea580c; --role-light: #fff7ed; }
.recipient-head { display: flex; align-items: center; gap: 10px; }
.recipient-head strong { display: block; line-height: 1.2; }
.role-badge {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #fff;
  background: var(--role);
  padding: 2px 8px;
  border-radius: 8px;
}
.mini-header {
  margin: 0;
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  font-size: 13px;
}
.mini-header dt { color: var(--muted); font-weight: 700; }
.mini-header dd { margin: 0; overflow-wrap: anywhere; }
.mini-attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-attachment {
  font-size: 12.5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recipient-note { margin: 0; font-size: 13.5px; font-weight: 700; line-height: 1.4; }

/* ---------- Toast & confetti ---------- */
.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #303030;
  color: #f2f2f2;
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 120;
  transform: translateY(180%);
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.2);
  max-width: calc(100vw - 48px);
  font-size: 14.5px;
}
.toast.show { transform: translateY(0); }
.toast-action { color: #a8c7fa; font-weight: 800; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.toast-action:hover { background: rgba(255, 255, 255, .1); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; width: 100%; height: 100%; }

.sidebar-backdrop { display: none; }

/* ---------- Animations ---------- */
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { transform: scale(.85) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes composeIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fieldIn { from { background: var(--theme-light); } to { background: transparent; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@keyframes newMail { from { background: #fef9c3; } to { background: #fff; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(11, 87, 208, .45); }
  70% { box-shadow: 0 0 0 14px rgba(11, 87, 208, 0); }
  100% { box-shadow: 0 0 0 0 rgba(11, 87, 208, 0); }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 0 4px var(--theme-light); }
}

/* ---------- Responsive: tablets / small laptops ---------- */
@media (max-width: 1180px) {
  html, body { height: auto; }
  body { overflow: auto; min-height: 100vh; }
  .app {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-areas: "side panel" "side main";
  }
  body.sidebar-collapsed .app { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { position: sticky; top: 8px; align-self: start; max-height: calc(100vh - 16px); }
  .mail-area { min-height: 460px; }
  .mission-panel { overflow: visible; }
}

/* ---------- Responsive: phones ---------- */
@media (max-width: 760px) {
  .topbar { gap: 4px; padding: 8px; height: 60px; }
  .brand { min-width: 0; }
  .brand-name { font-size: 21px; }
  .brand-logo svg { width: 38px; height: 38px; }
  .search, .hide-mobile { display: none; }
  .btn-small { padding: 0 10px; }

  .mission-tabs { padding: 0 8px 10px; gap: 8px; }
  .mission-tab { min-width: 150px; padding: 8px 10px; }
  .mission-tab-emoji { width: 40px; height: 40px; font-size: 22px; }
  .mission-tab-text span { display: none; }
  .progress-pill { padding: 0 14px; font-size: 16px; }

  .app,
  body.sidebar-collapsed .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "panel" "main";
    padding: 0 8px 8px;
    gap: 8px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-height: none;
    background: #fff;
    z-index: 60;
    padding: 16px 0;
    transform: translateX(-105%);
    transition: transform .25s;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    z-index: 55;
  }
  body.sidebar-collapsed .sidebar .label,
  body.sidebar-collapsed .folder .count { display: inline; }

  .mail-row {
    grid-template-columns: 36px minmax(0, 1fr) 56px;
    grid-template-rows: auto auto;
    height: auto;
    padding: 8px;
    row-gap: 2px;
  }
  .mail-row .star { grid-row: 1 / 3; }
  .mail-sender { grid-column: 2; grid-row: 1; }
  .mail-date { grid-column: 3; grid-row: 1; }
  .mail-summary { grid-column: 2 / 4; grid-row: 2; }
  .mail-clip { display: none; }

  .mail-view { padding: 16px; }
  .view-body, .view-attachments, .view-actions { margin-left: 0; }

  .compose { inset: 0; width: 100%; height: 100%; border-radius: 0; }
  .compose.minimized { inset: auto 0 0 0; width: 100%; height: auto; }
  .compose-note { display: none; }

  .modal { padding: 22px 18px; border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}