:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e5ea;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --none: #d92d20;
  --none-bg: #fef1f0;
  --partial: #b54708;
  --partial-bg: #fff6e5;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --code-bg: #15171c;
  --code-ink: #d7dae0;
  --radius: 12px;
  --top: 60px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, select, input { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  height: var(--top); display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand .muted { font-size: 13px; }
.logo { width: 22px; height: 22px; border-radius: 7px; background: conic-gradient(from 200deg, #0f6cbd 0 33%, #8e8e93 0 66%, #ea4335 0); }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 13px;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: #f0f1f4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #4338ca; }
.btn.ghost { border-color: transparent; }
.btn.small { height: 28px; font-size: 12px; }
.select { height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); padding: 0 8px; font-size: 13px; }
.seg { display: inline-flex; background: #eceef2; border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; font-size: 12.5px; cursor: pointer; color: #3b3f48; white-space: nowrap; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
.seg button:disabled { opacity: .4; cursor: default; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 34px; height: 20px; border-radius: 99px; background: #d0d4dc; position: relative; transition: background .15s; }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(320px, 30%) 1fr; height: calc(100vh - var(--top)); }
.layout.no-editor { grid-template-columns: 1fr; }
.layout.no-editor .editor { display: none; }
.editor { display: flex; flex-direction: column; background: var(--code-bg); min-width: 0; border-right: 1px solid #000; }
.editor-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; color: #fff; border-bottom: 1px solid #2a2d35; }
.editor-title { font-weight: 600; font-size: 13px; }
.editor .muted { color: #8b909c; }
.editor .btn { background: #262932; border-color: #353944; color: #e5e7eb; }
.package { margin: 10px 12px 0; padding: 8px 10px; border-radius: 8px; background: #1f2937; color: #cbd5e1; font-size: 12px; line-height: 1.5; }
.package b { color: #fff; }
.package button { background: none; border: 0; color: #93c5fd; cursor: pointer; padding: 0; font-size: 12px; text-decoration: underline; }
.code { flex: 1; display: flex; min-height: 0; position: relative; }
.gutter { margin: 0; padding: 12px 8px 12px 12px; color: #4b5060; text-align: right; user-select: none; overflow: hidden; min-width: 44px; }
.gutter, #source { font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
#source { flex: 1; resize: none; border: 0; outline: none; background: transparent; color: var(--code-ink); padding: 12px 12px 12px 4px; white-space: pre; overflow: auto; tab-size: 2; caret-color: #fff; }

.main { overflow: auto; min-width: 0; }

/* ---------- Preview cards ---------- */
.previews { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 16px; align-items: start; }
.previews.single { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1280px) { .previews { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 8px; margin-right: auto; min-width: 0; }
.card-title h2 { font-size: 15px; margin: 0; }
.card-title small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.card[data-client="outlook"] .client-dot { background: #0f6cbd; }
.card[data-client="apple"] .client-dot { background: #8e8e93; }
.card[data-client="gmail"] .client-dot { background: #ea4335; }
.counts { display: inline-flex; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.none { background: var(--none-bg); color: var(--none); }
.pill.partial { background: var(--partial-bg); color: var(--partial); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }

/* mock client window */
.window { background: #fff; border-bottom: 1px solid var(--line); }
.stage-wrap { height: 640px; overflow: hidden; position: relative; background: #fff; }
.card.mobile .stage-wrap { background: #e9ebef; padding: 16px 0; }
.stage { position: relative; margin: 0 auto; height: 100%; overflow: hidden; background: #fff; }
.card.mobile .stage { border-radius: 28px; box-shadow: 0 0 0 8px #1c1c1e, 0 10px 30px rgba(0,0,0,.2); }
.stage iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: transparent; }
.scale-note { position: absolute; right: 8px; bottom: 8px; font-size: 11px; background: rgba(17,24,39,.75); color: #fff; padding: 2px 8px; border-radius: 99px; pointer-events: none; z-index: 2; }

/* Outlook chrome */
.ch-outlook .bar { background: #0f6cbd; color: #fff; display: flex; align-items: center; gap: 12px; padding: 6px 12px; font: 600 13px "Segoe UI", system-ui, sans-serif; }
.ch-outlook .bar .search { flex: 1; max-width: 260px; height: 24px; border-radius: 4px; background: rgba(255,255,255,.85); color: #555; font-weight: 400; font-size: 12px; display: flex; align-items: center; padding: 0 8px; }
.ch-outlook .head { padding: 12px 16px; font-family: "Segoe UI", system-ui, sans-serif; }
.ch-outlook .subject { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.ch-outlook .from { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.ch-outlook .avatar { background: #c7e0f4; color: #0f548c; }
/* Apple chrome */
.ch-apple .bar { background: #ececec; border-bottom: 1px solid #d6d6d6; display: flex; align-items: center; gap: 7px; padding: 8px 12px; }
.ch-apple .bar i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.ch-apple .bar i:nth-child(1) { background: #ff5f57; } .ch-apple .bar i:nth-child(2) { background: #febc2e; } .ch-apple .bar i:nth-child(3) { background: #28c840; }
.ch-apple .head { padding: 12px 16px; font-family: -apple-system, "Helvetica Neue", sans-serif; display: flex; gap: 10px; }
.ch-apple .subject { font-size: 14px; font-weight: 600; }
.ch-apple .avatar { background: linear-gradient(#a5a5aa, #86868b); color: #fff; }
.ch-apple .meta { font-size: 12px; color: #6e6e73; line-height: 1.5; }
/* Gmail chrome */
.ch-gmail .head { padding: 14px 16px 10px; font-family: Roboto, Arial, sans-serif; }
.ch-gmail .subject { font-size: 20px; color: #1f1f1f; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ch-gmail .chip { font-size: 11px; background: #e8eaed; color: #444; padding: 1px 6px; border-radius: 4px; }
.ch-gmail .from { display: flex; gap: 10px; align-items: center; font-size: 13px; color: #1f1f1f; }
.ch-gmail .avatar { background: #7e57c2; color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.time { margin-left: auto; color: #6b7280; font-size: 12px; white-space: nowrap; }
.from .addr { color: #6b7280; }

/* dark chrome */
.card.dark .window, .card.dark .stage-wrap, .card.dark .stage { background: #1f1f1f; color: #e5e5e5; }
.card.dark .ch-outlook .bar { background: #0c3b5e; }
.card.dark .ch-apple .bar { background: #2b2b2d; border-color: #3a3a3c; }
.card.dark .ch-gmail .subject, .card.dark .ch-gmail .from { color: #e8eaed; }
.card.dark .ch-gmail .chip { background: #3c4043; color: #e8eaed; }
.card.dark .window { border-color: #333; }

/* Issues + considerations */
.section { padding: 14px 16px; border-top: 1px solid var(--line); }
.section:first-of-type { border-top: 0; }
.section h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #4b5060; display: flex; align-items: center; gap: 8px; }
.issue { display: grid; grid-template-columns: 22px 1fr; gap: 4px 8px; padding: 8px 0; border-top: 1px dashed var(--line); }
.issue:first-of-type { border-top: 0; }
.issue .ico { width: 20px; height: 20px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.ico.none { background: var(--none-bg); color: var(--none); }
.ico.partial { background: var(--partial-bg); color: var(--partial); }
.ico.ok { background: var(--ok-bg); color: var(--ok); }
.issue .label { font-weight: 600; font-size: 13px; }
.issue .label .n { color: var(--muted); font-weight: 400; }
.issue .note { grid-column: 2; font-size: 12.5px; color: #3b3f48; line-height: 1.5; }
.issue .where { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px; }
.issue code, .consider code { font: 11px ui-monospace, Menlo, monospace; background: #f1f2f5; padding: 1px 5px; border-radius: 4px; color: #3b3f48; word-break: break-all; }
.empty { font-size: 13px; color: var(--ok); background: var(--ok-bg); padding: 8px 10px; border-radius: 8px; }
details.consider summary { cursor: pointer; list-style: none; }
details.consider summary::-webkit-details-marker { display: none; }
details.consider summary h3 { margin: 0; }
details.consider summary h3::after { content: "▸"; font-size: 11px; transition: transform .15s; }
details.consider[open] summary h3::after { transform: rotate(90deg); }
.consider ol { margin: 10px 0 0; padding-left: 20px; font-size: 12.5px; line-height: 1.5; color: #3b3f48; }
.consider li { margin-bottom: 6px; }
.consider li b { color: var(--ink); }
.consider .subhead { margin: 14px 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---------- Compatibility table ---------- */
.report { padding: 16px; }
.report-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.sum-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.sum-card h3 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sum-card .score { font-size: 28px; font-weight: 700; }
.sum-card .score small { font-size: 13px; font-weight: 500; color: var(--muted); }
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 13px; }
.matrix th, .matrix td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.matrix thead th { background: #f8f9fb; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #4b5060; }
.matrix tr.group td { background: #fafbfc; font-weight: 700; font-size: 12px; color: var(--muted); }
.matrix td.cell { width: 25%; }
.matrix td.cell .st { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.matrix td.cell .nt { display: block; color: #4b5060; font-size: 12px; margin-top: 3px; line-height: 1.45; }
.matrix .feat { font-weight: 600; }
.matrix .feat small { display: block; font-weight: 400; color: var(--muted); }
@media (max-width: 900px) { .report-summary { grid-template-columns: 1fr; } }

/* ---------- Overlays ---------- */
.dropzone { position: fixed; inset: 0; z-index: 50; background: rgba(79,70,229,.12); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.dropzone div { background: var(--panel); border: 2px dashed var(--accent); border-radius: 16px; padding: 32px 48px; font-size: 16px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 90vw; }
.toast.error { background: #b42318; }

@media (max-width: 900px) {
  .topbar { height: auto; flex-direction: column; align-items: stretch; padding: 10px 16px; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .editor { height: 50vh; }
  .main { overflow: visible; }
}

/* Layout risks */
.issue.risk.clickable { cursor: pointer; border-radius: 8px; margin: 0 -6px; padding: 8px 6px; }
.issue.risk.clickable:hover { background: #f6f3ff; }
.issue .why { color: var(--muted); font-style: italic; }
.sev { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 99px; margin-left: 4px; vertical-align: 1px; }
.sev.high { background: var(--none-bg); color: var(--none); }
.sev.medium { background: var(--partial-bg); color: var(--partial); }
.sev.low { background: #eef2ff; color: #4338ca; }

.offstage { position: fixed !important; left: -30000px !important; top: 0 !important; width: 1100px !important; visibility: hidden !important; pointer-events: none !important; }
.ico.na { background: #f1f2f5; color: #9ca3af; }
.ref { font-size: 11px; font-weight: 500; color: var(--accent); text-decoration: none; margin-left: 4px; white-space: nowrap; }
.ref:hover { text-decoration: underline; }
.source { font-size: 11.5px; color: var(--muted); margin: 12px 0 0; }
.source a { color: var(--accent); }

/* Translated code view */
.codeview { border-bottom: 1px solid var(--line); background: var(--code-bg); }
.codebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; color: #9ca3af; font-size: 12px; border-bottom: 1px solid #2a2d35; }
.codebar .btn { background: #262932; border-color: #353944; color: #e5e7eb; }
.codeview pre { margin: 0; height: 640px; overflow: auto; padding: 12px; }
.codeview code { font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--code-ink); white-space: pre; }
details.more { margin-top: 12px; }
details.more summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--accent); }
