:root {
  --outlook-blue: #0078D4;
  --outlook-blue-dark: #106EBE;
  --outlook-blue-light: #DEECF9;
  --surface: #FFFFFF;
  --surface-muted: #F3F2F1;
  --border: #E1DFDD;
  --text: #201F1E;
  --text-secondary: #605E5C;
  --danger: #D13438;
  --success: #107C10;
  --sheet-radius: 16px;
  --touch: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", "Segoe UI Variable", system-ui, sans-serif;
  color: var(--text);
  background: #1a1a1a;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.phone-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 390px;
  margin: 0 auto;
  background: var(--surface);
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
}

@media (min-width: 480px) {
  body { padding: 24px 0; background: linear-gradient(160deg, #2b2b2b 0%, #111 100%); }
  .phone-shell {
    height: min(844px, calc(100vh - 48px));
    border-radius: 24px;
    overflow: hidden;
  }
}

.screen { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.screen.hidden { display: none !important; }

/* Splash */
.splash-header {
  background: var(--outlook-blue);
  color: #fff;
  padding: 16px 20px;
}
.splash-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 10px;
  border-radius: 4px;
}
.splash-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 24px;
  background: linear-gradient(180deg, #fff 0%, var(--surface-muted) 100%);
  min-height: 0;
}
.splash-body h1 {
  margin: 12px 0 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.splash-body .tagline {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.45;
}
.splash-card {
  margin-top: 24px;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.splash-card strong { color: var(--text); font-weight: 600; }
.btn-primary {
  display: block;
  width: 100%;
  margin-top: 28px;
  min-height: var(--touch);
  border: none;
  border-radius: 4px;
  background: var(--outlook-blue);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:active { background: var(--outlook-blue-dark); }
.splash-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 16px 24px 28px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.splash-footer img { height: 40px; width: auto; opacity: 0.95; }

/* App chrome */
.app-header {
  flex-shrink: 0;
  background: var(--outlook-blue);
  color: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.icon-btn {
  min-width: var(--touch);
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.12); }
.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  color: var(--outlook-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.progress-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}
.progress-bar button {
  border: none;
  background: none;
  color: var(--outlook-blue);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}

/* Inbox list */
#email-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
}
.email-row {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  min-height: 72px;
}
.email-row:active { background: var(--surface-muted); }
.email-row.done { opacity: 0.72; }
.row-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  background: var(--outlook-blue);
}
.row-main { flex: 1; min-width: 0; }
.row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.row-sender {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-time { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.row-subject {
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-preview {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-clip {
  position: absolute;
  right: 16px;
  bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.decision-pill {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 2px;
  letter-spacing: 0.03em;
}
.decision-pill.keep { background: #dff6dd; color: var(--success); }
.decision-pill.delete { background: #fde7e9; color: var(--danger); }

.bottom-nav {
  flex-shrink: 0;
  display: flex;
  justify-content: space-around;
  padding: 6px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  font-size: 11px;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 64px;
  min-height: var(--touch);
  justify-content: center;
  pointer-events: none;
}
.nav-item.active { color: var(--outlook-blue); }
.nav-item i { font-size: 20px; }

/* Reading pane */
.read-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.read-header .title { flex: 1; font-size: 15px; font-weight: 600; }
.read-header .ghost { color: var(--text-secondary); }

.sender-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  background: #fff;
  min-height: 64px;
}
.sender-row:active { background: var(--surface-muted); }
.sender-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--outlook-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}
.sender-meta { flex: 1; min-width: 0; }
.sender-name { font-weight: 600; font-size: 15px; }
.sender-to { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.sender-time {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.read-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  background: #fff;
}
#email-subject {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 16px;
}
.body-content { font-size: 15px; line-height: 1.55; color: var(--text); }
.body-content p { margin: 0 0 12px; }
.interactive {
  color: var(--outlook-blue);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
}

.chips-section { margin-top: 20px; }
.chips-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  min-height: var(--touch);
}
.chip:active { border-color: var(--outlook-blue); background: var(--outlook-blue-light); }
.chip-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.chip-icon.link { background: #cfe4fa; color: var(--outlook-blue); }
.chip-icon.file { background: #f3e0c6; color: #8a6116; }
.chip-text { flex: 1; min-width: 0; }
.chip-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.action-bar {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: #fff;
}
.action-bar.hidden { display: none; }
.btn-keep, .btn-delete {
  flex: 1;
  min-height: var(--touch);
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
}
.btn-keep { background: var(--success); }
.btn-keep:active { filter: brightness(0.92); }
.btn-delete { background: var(--danger); }
.btn-delete:active { filter: brightness(0.92); }

.processed-banner {
  flex-shrink: 0;
  padding: 12px 16px;
  background: #fff4ce;
  color: #6c5700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.processed-banner.hidden { display: none; }

/* Bottom sheets */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-overlay.hidden { display: none !important; }
.sheet {
  width: 100%;
  max-width: 390px;
  max-height: 85vh;
  overflow-y: auto;
  background: #fff;
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  animation: sheetUp 0.22s ease-out;
}
@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-handle {
  width: 36px;
  height: 4px;
  background: #c8c6c4;
  border-radius: 2px;
  margin: 10px auto 0;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sheet-body { padding: 16px; }
.sheet-foot {
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}
.btn-secondary {
  width: 100%;
  min-height: var(--touch);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:active { background: #e8e6e4; }

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.field-block { margin-bottom: 16px; }
.addr-line {
  font-size: 15px;
  word-break: break-all;
  line-height: 1.4;
}
.domain-hl {
  background: #fff4ce;
  color: #6c5700;
  padding: 1px 4px;
  border-radius: 2px;
  font-weight: 700;
}
.tip-box {
  margin-top: 8px;
  padding: 12px;
  background: var(--outlook-blue-light);
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}
.mono-box {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  word-break: break-all;
  line-height: 1.45;
}
.compare-row {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}
.details-toggle {
  margin-top: 8px;
  border: none;
  background: none;
  color: var(--outlook-blue);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  min-height: 40px;
}
.details-panel.hidden { display: none; }

.result-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-weight: 600;
}
.result-banner.ok { background: #dff6dd; color: var(--success); }
.result-banner.bad { background: #fde7e9; color: var(--danger); }
.signal-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.signal-list li { margin-bottom: 6px; }

/* Score */
#score-screen {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#score-screen.hidden { display: none !important; }
.score-card {
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}
.score-title { margin: 0; font-size: 20px; font-weight: 700; }
.score-number {
  margin: 12px 0 4px;
  font-size: 40px;
  font-weight: 700;
  color: var(--outlook-blue);
}
.score-sub { color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }
.missed-block { margin-top: 8px; }
.missed-block h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.missed-item {
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.4;
}
.missed-item .subj { font-weight: 600; }
.missed-item .sig { color: var(--text-secondary); margin-top: 4px; }
.score-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.score-actions .btn-primary,
.score-actions .btn-secondary { margin: 0; }

.training-watermark {
  position: absolute;
  bottom: 56px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(0, 120, 212, 0.25);
  pointer-events: none;
  transform: rotate(-8deg);
}
