/* ------------------------------------------------------------------ tokens --
   Copied from the app's globals.css so the simulation matches the real thing.
   .dark on #app flips the night palette exactly as the app's theme toggle does. */
:root {
  --background: oklch(0.99 0 0);
  --foreground: oklch(0.21 0 0);
  --card: oklch(1 0 0);
  --popover: oklch(1 0 0);
  --primary: #B42025;
  --primary-foreground: oklch(0.99 0 0);
  --secondary: oklch(0.962 0 0);
  --muted: oklch(0.965 0 0);
  --muted-foreground: oklch(0.45 0 0);
  --border: oklch(0.9 0 0);
  --input: oklch(0.87 0 0);
  --ring: #B42025;
  --success: #0F7B45; --success-foreground: #fff; --success-subtle: #E7F5EC;
  --warning: #A16207; --warning-foreground: #fff; --warning-subtle: #FDF6E8;
  --danger: #B91C1C;  --danger-foreground: #fff;  --danger-subtle: #FCEAEA;
  --info: #0369A1;    --info-foreground: #fff;    --info-subtle: #E6F2FA;
  --chart-1: #0369A1; --chart-2: #B45309;
  --radius: 0.625rem;

  /* tutorial chrome (outside the simulated app) */
  --t-bg: #111318;
  --t-rail: #181b22;
  --t-rail-border: #262a34;
  --t-text: #e8eaef;
  --t-muted: #9aa1b1;
  --t-accent: #B42025;
  --t-card: #ffffff;
  --t-card-text: #1c1e24;
}
.app.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --popover: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --success: #34D399; --success-foreground: #05261A; --success-subtle: #0C2E22;
  --warning: #FBBF24; --warning-foreground: #2A1E00; --warning-subtle: #33270A;
  --danger: #F87171;  --danger-foreground: #3A0D0D;  --danger-subtle: #3A1717;
  --info: #38BDF8;    --info-foreground: #062A3A;    --info-subtle: #0B2C3B;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--t-bg);
  color: var(--t-text);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }
[hidden] { display: none !important; }

/* ----------------------------------------------------------------- layout -- */
.tutorial { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }
.rail {
  background: var(--t-rail); border-right: 1px solid var(--t-rail-border);
  display: flex; flex-direction: column; min-height: 0;
}
.rail-head { padding: 20px 20px 14px; border-bottom: 1px solid var(--t-rail-border); }
.rail-logo { height: 28px; display: block; margin-bottom: 14px; }
.rail-logo-light { display: none; }
.rail-title { font-weight: 700; font-size: 15px; line-height: 1.3; }
.rail-sub { color: var(--t-muted); font-size: 12px; margin-top: 4px; }
.rail-modules { flex: 1; overflow-y: auto; padding: 10px 12px; }
.rail-module { margin-bottom: 6px; }
.rail-module-title {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--t-text); padding: 9px 10px; border-radius: 8px;
  font-weight: 600; font-size: 13px;
}
.rail-module-title:hover { background: rgba(255,255,255,.05); }
.rail-module-title .num {
  width: 22px; height: 22px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; background: #2a2f3b; color: var(--t-muted); flex-shrink: 0;
}
.rail-module.is-active .rail-module-title .num { background: var(--t-accent); color: #fff; }
.rail-module.is-done .rail-module-title .num { background: #1f6f47; color: #fff; }
.rail-steps { list-style: none; margin: 2px 0 4px; padding: 0 0 0 42px; }
.rail-steps li { font-size: 12px; color: var(--t-muted); padding: 4px 0; display: flex; gap: 8px; align-items: center; }
.rail-steps li button { background: none; border: 0; color: inherit; padding: 0; text-align: left; }
.rail-steps li.is-current { color: var(--t-text); font-weight: 600; }
.rail-steps li.is-done { color: #7fc9a2; }
.rail-steps li .tick { width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex-shrink: 0; }
.rail-foot { padding: 14px 20px 18px; border-top: 1px solid var(--t-rail-border); }
.rail-progress { height: 6px; background: #2a2f3b; border-radius: 999px; overflow: hidden; }
.rail-progress-bar { height: 100%; width: 0; background: var(--t-accent); transition: width .3s ease; }
.rail-progress-text { font-size: 12px; color: var(--t-muted); margin-top: 8px; }
.rail-restart { margin-top: 10px; background: none; border: 1px solid var(--t-rail-border); color: var(--t-muted); font-size: 12px; padding: 6px 10px; border-radius: 6px; }
.rail-restart:hover { color: var(--t-text); }

.stage { padding: 22px; min-width: 0; min-height: 0; display: flex; }
.browser {
  flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative;
  border-radius: 12px; overflow: hidden; background: var(--background);
  box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.06);
}
.browser-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #2b2f38; }
.dot { width: 11px; height: 11px; border-radius: 999px; display: inline-block; }
.dot-r { background: #ff5f57; } .dot-y { background: #febc2e; } .dot-g { background: #28c840; }
.urlbar { margin-left: 10px; flex: 1; background: #1c1f26; color: #c8cdd8; font-size: 12px; padding: 6px 12px; border-radius: 6px; }
.app { flex: 1; overflow-y: auto; background: var(--background); color: var(--foreground); position: relative; }

/* ----------------------------------------------------------- simulated app -- */
.nav {
  position: sticky; top: 0; z-index: 30; height: 64px; border-bottom: 1px solid color-mix(in oklab, var(--border) 40%, transparent);
  background: color-mix(in oklab, var(--background) 95%, transparent); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
}
.nav-left { display: flex; align-items: center; gap: 40px; }
.nav-logo { height: 28px; display: block; }
.nav-links { display: flex; gap: 24px; }
.nav-link {
  background: none; border: 0; padding: 0; font-size: 14px; font-weight: 500; color: var(--muted-foreground);
  display: inline-flex; align-items: center; gap: 6px;
}
.nav-link:hover, .nav-link.is-active { color: var(--primary); }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center; height: 16px; min-width: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--primary); color: var(--primary-foreground); font-size: 10px; font-weight: 700;
  animation: pulse 2s infinite;
}
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-user { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-foreground); }
.icon-btn { width: 36px; height: 36px; border: 0; background: none; border-radius: 8px; color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--muted); color: var(--foreground); }
.icon-btn.is-on { color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }

.page { max-width: 42rem; margin: 0 auto; padding: 40px 16px; }
.page-wide { max-width: 64rem; }
.h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.lead { color: var(--muted-foreground); margin: 8px 0 0; font-size: 16px; }

.card-ui {
  background: var(--card); border: 1px solid color-mix(in oklab, var(--border) 50%, transparent);
  border-radius: 14px; box-shadow: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
}
.form { padding: 24px; display: flex; flex-direction: column; gap: 24px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-foreground); }
.control {
  height: 44px; width: 100%; border: 1px solid var(--input); border-radius: 8px; background: var(--background);
  color: var(--foreground); padding: 0 12px; font-size: 14px; outline: none; text-align: left;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.control:focus, .control.is-open { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent); }
.control:disabled { opacity: .5; cursor: not-allowed; }
.control .placeholder { color: var(--muted-foreground); }
.control .chev { width: 16px; height: 16px; color: var(--muted-foreground); flex-shrink: 0; }
textarea.control { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; display: block; }
.input-wrap { position: relative; }
.input-wrap .check { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--success); }
.dropdown.tall { max-height: 60vh; }
.dropdown {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); border: 1px solid var(--border);
  background: var(--popover); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.18); max-height: 256px; overflow-y: auto; padding: 4px;
}
.dd-group { font-size: 12px; font-weight: 600; color: var(--muted-foreground); padding: 8px 10px 4px; }
.dd-item {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 9px 10px; border: 0; background: none; text-align: left;
  font-size: 14px; color: var(--foreground); border-radius: 6px;
}
.dd-item:hover { background: var(--muted); }
.dd-item.is-selected { font-weight: 600; }
.dd-item .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 500; }
.dd-item .desc { color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-empty { padding: 8px 12px; font-size: 14px; color: var(--muted-foreground); }
.select-wrap { position: relative; }

.btn-ui {
  height: 44px; padding: 0 16px; border-radius: 8px; border: 0; font-weight: 600; font-size: 16px;
  background: var(--primary); color: var(--primary-foreground); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-ui:hover { filter: brightness(1.08); }
.btn-ui:disabled { opacity: .5; cursor: not-allowed; }
.btn-ui.full { width: 100%; }
.btn-ui.outline { background: transparent; border: 1px solid var(--input); color: var(--foreground); }
.btn-ui.sm { height: 34px; font-size: 13px; padding: 0 12px; }
.form-error {
  padding: 12px; font-size: 14px; font-weight: 500; color: var(--danger); background: color-mix(in oklab, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--danger) 20%, transparent); border-radius: 6px;
}

/* login */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 40px 16px;
  background: radial-gradient(ellipse at 20% 50%, rgba(180,32,37,.06) 0%, transparent 60%), radial-gradient(ellipse at 80% 20%, rgba(0,0,0,.04) 0%, transparent 60%); }
.login-card { width: 100%; max-width: 28rem; }
.login-head { text-align: center; padding: 32px 32px 24px; }
.login-head .nav-logo { height: 40px; margin: 0 auto 24px; }
.login-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.login-sub { color: var(--muted-foreground); margin: 8px 0 0; font-size: 14px; }
.login-body { padding: 0 32px 32px; }
.login-body .form { padding: 0; gap: 20px; }
.link { color: var(--primary); font-weight: 500; text-decoration: none; font-size: 12px; }
.link:hover { text-decoration: underline; }
.muted-center { text-align: center; font-size: 14px; color: var(--muted-foreground); }

/* dialogs inside the app */
.dlg-backdrop { position: absolute; inset: 0; z-index: 40; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dlg { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 100%; box-shadow: 0 30px 60px rgba(0,0,0,.35); }
.dlg.sm { max-width: 24rem; } .dlg.md { max-width: 28rem; } .dlg.lg { max-width: 32rem; }
.dlg-row { display: flex; gap: 12px; align-items: flex-start; }
.dlg-icon { width: 40px; height: 40px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dlg-icon.danger { background: color-mix(in oklab, var(--danger) 10%, transparent); color: var(--danger); }
.dlg-icon.warning { background: color-mix(in oklab, var(--warning) 10%, transparent); color: var(--warning); }
.dlg-icon svg { width: 20px; height: 20px; }
.dlg-title { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.dlg-desc { font-size: 14px; color: var(--muted-foreground); margin: 0; line-height: 1.5; }
.dlg-desc strong { color: var(--foreground); font-weight: 500; }
.dlg-desc .danger-text { color: var(--danger); font-weight: 600; }
.dlg-onfile { margin-top: 12px; border: 1px solid color-mix(in oklab, var(--border) 40%, transparent); background: color-mix(in oklab, var(--muted) 30%, transparent); padding: 8px; border-radius: 6px; font-size: 12px; color: var(--muted-foreground); }
.dlg-onfile b { color: var(--foreground); font-weight: 600; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

/* success */
.success-card { text-align: center; padding: 48px 24px; }
.success-card .emoji { font-size: 60px; line-height: 1; margin-bottom: 16px; }
.success-card .title { font-size: 24px; font-weight: 600; margin: 0 0 8px; }
.success-card .desc { color: var(--muted-foreground); font-size: 16px; margin: 0; }
.success-actions { display: flex; justify-content: center; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* ---- status board ---- */
.stat-panel { border-radius: 14px; overflow: hidden; margin-bottom: 32px; }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent); background: color-mix(in oklab, var(--muted) 30%, transparent); }
.stat-scope { display: flex; align-items: center; gap: 10px; }
.stat-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; font-weight: 600; letter-spacing: .08em; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--background); color: color-mix(in oklab, var(--foreground) 75%, transparent); }
.stat-airport { background: none; border: 1px solid transparent; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--foreground); height: 32px; padding: 0 6px; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px; }
.stat-airport:hover { background: color-mix(in oklab, var(--muted) 70%, transparent); }
.switcher { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; border: 1px solid color-mix(in oklab, var(--border) 60%, transparent); background: color-mix(in oklab, var(--muted) 40%, transparent); }
.switcher button { border: 0; background: none; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted-foreground); display: inline-flex; align-items: center; gap: 6px; }
.switcher button.is-active { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.switcher svg { width: 14px; height: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: color-mix(in oklab, var(--border) 60%, transparent); }
.stat-cell { background: var(--card); padding: 16px; min-height: 104px; }
.stat-cell.span3 { grid-column: span 3; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .06em; }
.stat-label svg { width: 14px; height: 14px; }
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tone-info { color: var(--info); } .tone-warning { color: var(--warning); } .tone-danger { color: var(--danger); } .tone-success { color: var(--success); } .tone-neutral { color: var(--foreground); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 500; }
.chip.success { border-color: color-mix(in oklab, var(--success) 30%, transparent); color: var(--success); background: color-mix(in oklab, var(--success) 10%, transparent); }
.chip.warning { border-color: color-mix(in oklab, var(--warning) 30%, transparent); color: var(--warning); background: color-mix(in oklab, var(--warning) 10%, transparent); }
.chip.danger  { border-color: color-mix(in oklab, var(--danger) 30%, transparent);  color: var(--danger);  background: color-mix(in oklab, var(--danger) 10%, transparent); }
.chip.neutral { border-color: var(--border); color: var(--muted-foreground); background: var(--muted); }
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.type-grid .chip { justify-content: space-between; }
.none-recent { font-size: 14px; color: color-mix(in oklab, var(--success) 60%, transparent); margin-top: 10px; display: block; }
.ring-wrap { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.ring-wrap svg { width: 56px; height: 56px; transform: rotate(-90deg); flex-shrink: 0; }
.ring-wrap .track { fill: none; stroke: var(--border); stroke-width: 5; }
.ring-wrap .arc { fill: none; stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-pct { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.ring-sub { font-size: 12px; color: var(--muted-foreground); margin-top: 4px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 12px; border: 1px solid var(--border); background: color-mix(in oklab, var(--muted) 40%, transparent); margin-bottom: 32px; }
.tab { min-height: 44px; border: 0; background: none; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tab.is-active { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--border); }
.tab .count { border-radius: 999px; padding: 2px 6px; font-size: 11px; font-weight: 600; background: color-mix(in oklab, var(--muted-foreground) 10%, transparent); color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.tab.is-active .count { background: color-mix(in oklab, var(--primary) 10%, transparent); color: var(--primary); }

.filters { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 32px; }
.filters .select-wrap { width: 200px; } .filters .select-wrap.wide { width: 220px; }
.filters .control { height: 36px; font-size: 14px; }
.filters .search { flex: 1; min-width: 200px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tcard-wrap { position: relative; min-width: 0; animation: cardIn .18s ease; }
.tcard-wrap.is-leaving { animation: cardOut .18s ease forwards; }
.unread-dot { position: absolute; top: -4px; right: -4px; z-index: 10; width: 14px; height: 14px; }
.unread-dot::before { content: ""; position: absolute; inset: 0; border-radius: 999px; background: var(--primary); opacity: .75; animation: ping 1s cubic-bezier(0,0,.2,1) infinite; }
.unread-dot::after { content: ""; position: absolute; inset: 0; border-radius: 999px; background: var(--primary); }
.tcard { height: 100%; cursor: pointer; border-left: 4px solid var(--border); border-radius: 14px; transition: box-shadow .2s; display: flex; flex-direction: column; }
.tcard:hover { box-shadow: 0 10px 20px -5px rgba(0,0,0,.15); }
.tcard.OPEN { border-left-color: var(--info); } .tcard.IN_PROGRESS { border-left-color: var(--warning); } .tcard.WAITING_ON_PARTS { border-left-color: var(--danger); } .tcard.COMPLETED { border-left-color: var(--success); }
.tcard.has-unread { box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary) 40%, transparent); }
.tcard-head { padding: 16px 16px 12px; border-bottom: 1px solid color-mix(in oklab, var(--border) 10%, transparent); }
.tcard-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.tcard-badges { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tcard-type { margin: 4px 0 0; text-align: right; font-size: 12px; color: var(--muted-foreground); }
.tcard-body { padding: 16px; font-size: 14px; white-space: pre-wrap; word-break: break-word; flex: 1; }
.tcard-meta { padding: 0 16px 8px; display: flex; flex-direction: column; gap: 4px; }
.tcard-last { font-size: 12px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.tcard-last.is-unread { color: var(--foreground); font-weight: 500; }
.tcard-last b { font-weight: 600; }
.tcard-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12px; color: var(--muted-foreground); padding: 12px 16px; background: color-mix(in oklab, var(--muted) 20%, transparent); border-top: 1px solid color-mix(in oklab, var(--border) 20%, transparent); border-radius: 0 0 14px 0; }
.tcard-foot .loc { display: inline-flex; align-items: center; gap: 4px; }
.tcard-foot svg { width: 14px; height: 14px; }

.gbadge { position: relative; display: inline-flex; }
.gbadge::before { content: ""; position: absolute; inset: 0; border-radius: 999px; filter: blur(6px); opacity: .6; background: var(--g); }
.gbadge > span { position: relative; display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 500; background: var(--g); color: var(--gf); }
.gbadge .gdot { position: relative; width: 6px; height: 6px; border-radius: 999px; background: var(--gf); flex-shrink: 0; }
.gbadge.pulse .gdot::before { content: ""; position: absolute; inset: 0; border-radius: 999px; background: var(--gf); opacity: .75; animation: gping 2s ease-in-out infinite; }
.gbadge.info { --g: var(--info); --gf: var(--info-foreground); }
.gbadge.warning { --g: var(--warning); --gf: var(--warning-foreground); }
.gbadge.error { --g: var(--danger); --gf: var(--danger-foreground); }
.gbadge.success { --g: var(--success); --gf: var(--success-foreground); }
.badge { display: inline-flex; align-items: center; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 500; border: 1px solid transparent; }
.badge.secondary { background: var(--secondary); color: var(--foreground); }
.badge.outline { border-color: var(--border); color: var(--muted-foreground); }
.badge .eref { text-decoration: none; color: inherit; } .badge .eref:hover { text-decoration: underline; }
.badge.owner { background: color-mix(in oklab, var(--oc) 10%, transparent); color: var(--oc); border-color: color-mix(in oklab, var(--oc) 20%, transparent); }

.chat-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 6px 10px; border-radius: 6px; border: 1px solid transparent; background: none; color: var(--muted-foreground); }
.chat-btn:hover { background: color-mix(in oklab, var(--muted) 50%, transparent); color: var(--foreground); }
.chat-btn.has-unread { color: var(--primary); background: color-mix(in oklab, var(--primary) 10%, transparent); border-color: color-mix(in oklab, var(--primary) 30%, transparent); }
.chat-btn .cnt { display: inline-flex; align-items: center; justify-content: center; height: 16px; min-width: 16px; padding: 0 4px; border-radius: 999px; font-size: 10px; font-weight: 700; background: var(--muted); color: var(--muted-foreground); }
.chat-btn .cnt.new { background: var(--primary); color: var(--primary-foreground); animation: pulse 2s infinite; }

.empty { text-align: center; padding: 64px 16px; color: var(--muted-foreground); }
.empty .ico { width: 44px; height: 44px; margin: 0 auto 12px; opacity: .5; }
.empty .ico svg { width: 44px; height: 44px; }
.empty .t { font-weight: 600; color: var(--foreground); font-size: 16px; }
.empty .d { font-size: 14px; margin-top: 4px; }
.tab-note { margin: -16px 0 24px; font-size: 14px; color: var(--muted-foreground); }

/* ticket dialog + chat */
.tdlg-desc { margin: 16px 0 0; font-size: 14px; white-space: pre-wrap; max-height: 160px; overflow-y: auto; }
.tdlg-meta { margin-top: 12px; padding-top: 12px; border-top: 1px solid color-mix(in oklab, var(--border) 20%, transparent); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted-foreground); }
.chat { margin-top: 16px; border: 1px solid color-mix(in oklab, var(--border) 30%, transparent); border-radius: 10px; overflow: hidden; background: color-mix(in oklab, var(--background) 50%, transparent); }
.chat-msgs { padding: 12px; min-height: 160px; max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.chat-empty { text-align: center; padding: 32px 0; color: var(--muted-foreground); font-size: 12px; }
.chat-empty .e { font-size: 24px; opacity: .4; margin-bottom: 8px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; animation: cardIn .2s ease; }
.msg.own { align-items: flex-end; }
.msg-who { font-size: 11px; font-weight: 500; color: var(--muted-foreground); margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.msg.own .msg-who { flex-direction: row-reverse; }
.staff { display: inline-flex; padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; background: color-mix(in oklab, var(--warning) 15%, transparent); color: var(--warning); border: 1px solid color-mix(in oklab, var(--warning) 20%, transparent); }
.msg-bubble { max-width: 85%; padding: 8px 12px; border-radius: 16px; font-size: 14px; line-height: 1.5; word-break: break-word; background: color-mix(in oklab, var(--muted) 60%, transparent); border: 1px solid color-mix(in oklab, var(--border) 20%, transparent); border-bottom-left-radius: 6px; }
.msg.own .msg-bubble { background: var(--primary); color: var(--primary-foreground); border: 0; border-bottom-left-radius: 16px; border-bottom-right-radius: 6px; }
.msg-time { font-size: 10px; color: color-mix(in oklab, var(--muted-foreground) 60%, transparent); margin-top: 2px; padding: 0 4px; }
.chat-form { display: flex; gap: 8px; padding: 8px; border-top: 1px solid color-mix(in oklab, var(--border) 20%, transparent); background: color-mix(in oklab, var(--muted) 10%, transparent); }
.chat-form .control { height: 36px; font-size: 14px; }
.chat-form .btn-ui { height: 36px; padding: 0 16px; }
.chat-form .btn-ui svg { width: 16px; height: 16px; }

/* push toast (browser notification look) */
.toasts { position: absolute; right: 16px; top: 76px; z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; width: 340px; background: #fff; color: #1c1e24; border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.3); padding: 12px 14px; display: flex; gap: 10px; animation: toastIn .25s ease; border: 1px solid rgba(0,0,0,.08); }
.toast img { width: 28px; height: 28px; }
.toast .tt { font-weight: 600; font-size: 13px; }
.toast .tb { font-size: 12px; color: #4a4f5c; margin-top: 2px; }
.toast .ts { font-size: 11px; color: #8a8f9c; margin-top: 4px; }

/* ---------------------------------------------------------------- coach --- */
.coach { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.blocker { position: fixed; background: rgba(6,8,12,.55); pointer-events: auto; }
.coach.no-target .blocker { background: rgba(6,8,12,.62); }
.spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 3px var(--t-accent), 0 0 24px 4px rgba(180,32,37,.45); transition: all .25s ease; pointer-events: none; }
.coach.no-target .spot { display: none; }
.card {
  position: fixed; width: 380px; max-width: calc(100vw - 32px); background: var(--t-card); color: var(--t-card-text);
  border-radius: 14px; padding: 18px 20px 14px; box-shadow: 0 24px 60px rgba(0,0,0,.45); pointer-events: auto;
  transition: top .25s ease, left .25s ease;
}
.card::after { content: ""; position: absolute; width: 14px; height: 14px; background: var(--t-card); transform: rotate(45deg); display: none; }
.card.arrow-top::after { display: block; top: -7px; left: var(--ax, 30px); }
.card.arrow-bottom::after { display: block; bottom: -7px; left: var(--ax, 30px); }
.card.arrow-left::after { display: block; left: -7px; top: var(--ay, 30px); }
.card.arrow-right::after { display: block; right: -7px; top: var(--ay, 30px); }
.coach.no-target .card { width: 560px; padding: 26px 28px 18px; }
.card-kicker { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--t-accent); }
.card-title { font-size: 18px; font-weight: 700; margin: 6px 0 8px; line-height: 1.25; }
.card-body { font-size: 14px; line-height: 1.55; color: #3b3f4a; }
.card-body p { margin: 0 0 10px; } .card-body p:last-child { margin-bottom: 0; }
.card-body ul { margin: 6px 0 10px; padding-left: 20px; } .card-body li { margin: 3px 0; }
.card-body code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: #f1f2f5; padding: 1px 5px; border-radius: 4px; }
.card-body .rule { display: block; margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: #FCEAEA; color: #7a1414; border-left: 3px solid #B91C1C; font-weight: 500; }
.card-body .tip { display: block; margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: #E6F2FA; color: #0b3d5c; border-left: 3px solid #0369A1; }
.card-body .pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.card-body .pill.open { background: #E6F2FA; color: #0369A1; } .card-body .pill.prog { background: #FDF6E8; color: #A16207; } .card-body .pill.parts { background: #FCEAEA; color: #B91C1C; } .card-body .pill.done { background: #E7F5EC; color: #0F7B45; }
.card-task { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: #fff7ed; border: 1px dashed #f0a35b; font-size: 13.5px; font-weight: 600; color: #7c3a00; display: flex; gap: 8px; align-items: flex-start; }
.card-task.is-done { background: #E7F5EC; border-color: #0F7B45; color: #0F7B45; }
.card-task .tk { flex-shrink: 0; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; }
.card-step { font-size: 12px; color: #8a8f9c; }
.btn { height: 36px; padding: 0 14px; border-radius: 8px; border: 0; font-weight: 600; font-size: 14px; }
.btn-primary { background: var(--t-accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { background: #cfd2d9; color: #7b8090; cursor: not-allowed; }
.btn-ghost { background: none; color: #5b606d; }
.btn-ghost:hover { background: #f1f2f5; }
.btn-ghost:disabled { opacity: .4; cursor: not-allowed; }

/* quiz */
.quiz-q { margin: 0 0 8px; font-weight: 600; }
.quiz-opts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.quiz-opt { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1px solid #dfe2e8; border-radius: 8px; cursor: pointer; font-size: 13.5px; background: #fff; }
.quiz-opt:hover { border-color: #b8bdc9; }
.quiz-opt input { margin-top: 3px; }
.quiz-opt.is-right { border-color: #0F7B45; background: #E7F5EC; }
.quiz-opt.is-wrong { border-color: #B91C1C; background: #FCEAEA; }
.quiz-fb { font-size: 13px; padding: 8px 12px; border-radius: 8px; margin-top: 4px; }
.quiz-fb.ok { background: #E7F5EC; color: #0F7B45; } .quiz-fb.no { background: #FCEAEA; color: #7a1414; }
.score { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; margin: 6px 0; }

/* summary cards on the final step */
.recap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.recap div { background: #f5f6f8; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.recap b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #6b7080; margin-bottom: 2px; }

/* ---------------------------------------------------------- animations ---- */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes ping { 75%,100% { transform: scale(2); opacity: 0; } }
@keyframes gping { 0%,100% { transform: scale(1); opacity: .75; } 50% { transform: scale(2.5); opacity: 0; } }
@keyframes cardIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
@keyframes cardOut { to { opacity: 0; transform: scale(.97); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(180,32,37,.0); } 30% { box-shadow: 0 0 0 4px rgba(180,32,37,.55); } 100% { box-shadow: 0 0 0 0 rgba(180,32,37,0); } }

/* ----------------------------------------------------------- responsive --- */
@media (max-width: 1100px) {
  /* Narrow: the outline collapses to a slim header so the app keeps most of
     the height, and the coach card pins to the bottom over it. */
  .tutorial { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { flex-direction: row; align-items: center; gap: 12px; padding: 8px 16px; border-right: 0; border-bottom: 1px solid var(--t-rail-border); }
  .rail-head { padding: 0; border: 0; display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
  .rail-logo { height: 22px; margin: 0; flex-shrink: 0; }
  .rail-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rail-sub, .rail-modules { display: none; }
  .rail-foot { padding: 0; border: 0; margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
  .rail-progress { width: 90px; }
  .rail-progress-text, .rail-restart { margin: 0; }
  .stage { padding: 12px; }
  .card { bottom: 12px; max-height: 46vh; overflow: auto; padding: 14px 16px 12px; }
  .coach.no-target .card { width: calc(100vw - 32px); padding: 18px 20px 14px; }
}
@media (max-width: 640px) {
  .rail-progress-text, .rail-title { display: none; }
  .nav-user, #nav-cb { display: none; }
  .nav-left { gap: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-cell.span3 { grid-column: span 2; }
  .nav-links { display: none; }
  .card { width: calc(100vw - 32px); left: 16px !important; top: auto !important; bottom: 16px; }
  .card::after { display: none !important; }
}
