/* Asuna Mission Control — JARVIS-style command center skin.
   Data contract unchanged: renderers in mission.js emit the same safe-DOM
   structures; this stylesheet is dashboard-only (the iPad PWA loads pwa.css). */

:root {
  --bg: #030811;
  --bg2: #050d1a;
  --panel: rgba(8, 18, 32, .78);
  --panel2: rgba(10, 24, 42, .85);
  --line: #10314e;
  --line-glow: rgba(39, 197, 232, .35);
  --cyan: #27c5e8;
  --cyan2: #5fe3ff;
  --dim: #55708e;
  --txt: #cfe6f5;
  --bright: #eaf7ff;
  --green: #2ee68a;
  --amber: #f5b133;
  --red: #ff5d6c;
  --grid: rgba(39, 197, 232, .05);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1400px 700px at 75% -10%, rgba(39, 197, 232, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(39, 197, 232, .06), transparent 60%),
    repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 44px),
    linear-gradient(180deg, var(--bg2), var(--bg) 40%);
  color: var(--txt);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Shell: sidebar + main ── */
.shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 18px 26px;
  max-width: 1720px;
  margin: 0 auto;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 14px;
  align-self: start;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 14px 16px;
  box-shadow: inset 0 0 40px rgba(39, 197, 232, .04);
}

.brand { text-align: center; margin-bottom: 26px; }

.ring {
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 22px rgba(39, 197, 232, .45), inset 0 0 14px rgba(39, 197, 232, .3);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px dashed rgba(95, 227, 255, .35);
}

.ring::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px solid rgba(95, 227, 255, .5);
  border-top-color: transparent;
  border-bottom-color: transparent;
}

.ring-core {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--cyan2), var(--cyan) 60%, rgba(39,197,232,.2));
  box-shadow: 0 0 16px var(--cyan);
}

.ring.live::after { animation: spin 5s linear infinite; }
.ring.live .ring-core { animation: corepulse 2.2s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes corepulse { 50% { box-shadow: 0 0 26px var(--cyan2); } }

.brand h1 {
  font-size: 17px;
  letter-spacing: .3em;
  margin: 0 0 0 .3em; /* re-center: letter-spacing adds a trailing gap */
  font-weight: 700;
  color: var(--bright);
  text-shadow: 0 0 12px rgba(95, 227, 255, .5);
}

.brand .sub {
  font-size: 8.5px;
  letter-spacing: .34em;
  color: var(--dim);
  margin-top: 4px;
}

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 10.5px;
  letter-spacing: .22em;
  color: var(--dim);
  text-decoration: none;
  border-radius: 8px;
  border-left: 2px solid transparent;
  transition: color .15s, background .15s;
}

.nav a:hover { color: var(--cyan2); background: rgba(39, 197, 232, .07); }

.nav a.active {
  color: var(--cyan2);
  background: linear-gradient(90deg, rgba(39, 197, 232, .16), rgba(39, 197, 232, .03));
  border-left-color: var(--cyan);
  box-shadow: 0 0 14px rgba(39, 197, 232, .12);
}

.nav-ic { font-size: 12px; width: 14px; text-align: center; }

.sidestatus {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 12px 10px;
  background: rgba(4, 10, 18, .5);
}

.ss-l { font-size: 8.5px; letter-spacing: .26em; color: var(--dim); }

.ss-v {
  font-size: 14px;
  letter-spacing: .18em;
  font-weight: 700;
  color: var(--green);
  margin: 6px 0 8px;
  text-shadow: 0 0 10px rgba(46, 230, 138, .5);
}

.ss-v.off { color: var(--red); text-shadow: 0 0 10px rgba(255, 93, 108, .5); }

.ss-wave { display: flex; align-items: flex-end; gap: 3px; height: 18px; }

.ss-wave i {
  flex: 1;
  background: linear-gradient(180deg, var(--cyan2), rgba(39, 197, 232, .25));
  border-radius: 1px;
  height: 30%;
  opacity: .7;
}

.ss-wave i:nth-child(2n) { height: 60%; }
.ss-wave i:nth-child(3n) { height: 45%; }
.ss-wave i:nth-child(4n) { height: 80%; }

.live-wave i { animation: wave 1.2s ease-in-out infinite; }
.live-wave i:nth-child(2n) { animation-delay: .15s; }
.live-wave i:nth-child(3n) { animation-delay: .3s; }
.live-wave i:nth-child(4n) { animation-delay: .45s; }

@keyframes wave { 50% { transform: scaleY(1.7); } }

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 14px;
}

.greeting { font-size: 19px; color: var(--bright); font-weight: 600; }

.opline {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  font-size: 9.5px;
  letter-spacing: .22em;
  color: var(--dim);
}

.opdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
}

.opdot.g { background: var(--green); box-shadow: 0 0 8px var(--green); }
.opdot.a { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.opdot.r { background: var(--red);   box-shadow: 0 0 8px var(--red); }

.clock {
  font-variant-numeric: tabular-nums;
  color: var(--cyan2);
  letter-spacing: .12em;
  font-size: 13px;
  text-shadow: 0 0 10px rgba(95, 227, 255, .4);
}

/* ── Panel chrome (shared) ── */
.panel, .session, .card {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 12px;
  position: relative;
}

.panel::before, .card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 14px;
  width: 44px;
  height: 1px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  box-shadow: 0 0 8px var(--line-glow);
}

.panel { padding: 14px 16px; min-width: 0; }

.panel h2 {
  font-size: 10.5px;
  letter-spacing: .26em;
  color: var(--cyan2);
  margin: 0 0 12px;
  font-weight: 600;
}

.panel h2 .r {
  float: right;
  color: var(--dim);
  font-size: 8.5px;
  letter-spacing: .18em;
  padding-top: 2px;
}

/* ── Voice session strip ── */
.session {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  margin-bottom: 14px;
}

.session .state {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  letter-spacing: .24em;
  color: var(--cyan2);
  flex: 0 0 auto;
  min-width: 128px;
}

.statedot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dim);
  transition: background .2s;
}

.statedot.idle      { background: var(--dim); }
.statedot.listening { background: var(--green); box-shadow: 0 0 12px var(--green); animation: pulse 1.1s infinite; }
.statedot.thinking  { background: var(--cyan);  box-shadow: 0 0 12px var(--cyan);  animation: pulse 1.1s infinite; }
.statedot.speaking  { background: var(--cyan2); box-shadow: 0 0 12px var(--cyan2); animation: pulse .7s infinite; }
.statedot.working   { background: var(--amber); box-shadow: 0 0 12px var(--amber); animation: pulse .9s infinite; }
.statedot.offline   { background: var(--red); box-shadow: 0 0 10px rgba(255, 93, 108, .6); }

@keyframes pulse { 50% { opacity: .35; } }

.session .convo {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.session .you, .session .her {
  display: flex;
  gap: 10px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session .wl {
  flex: 0 0 44px;
  font-size: 9px;
  letter-spacing: .2em;
  color: var(--dim);
  padding-top: 2px;
}

.session .you span:last-child { color: #d8ecf8; overflow: hidden; text-overflow: ellipsis; }
.session .her span:last-child { color: var(--cyan2); overflow: hidden; text-overflow: ellipsis; }

/* ── Stat cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.card { padding: 14px 16px 18px 66px; overflow: hidden; }

/* hexagonal icon well — glyph set per slot below (CSS-only so the shared
   renderer emits the same DOM the PWA board styles with pwa.css) */
.card::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 16px;
  width: 38px;
  height: 42px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background:
    linear-gradient(160deg, rgba(39, 197, 232, .35), rgba(39, 197, 232, .08));
  box-shadow: inset 0 0 12px rgba(39, 197, 232, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--cyan2);
  text-shadow: 0 0 10px var(--cyan);
}

.cards .card:nth-child(1)::after { content: "▣"; } /* repos */
.cards .card:nth-child(2)::after { content: "▲"; } /* deploy health */
.cards .card:nth-child(3)::after { content: "◆"; } /* attention */
.cards .card:nth-child(4)::after { content: "≋"; } /* in-flight */
.cards .card:nth-child(5)::after { content: "◈"; } /* founder-owed */

.card .lbl {
  font-size: 8.8px;
  letter-spacing: .22em;
  color: var(--dim);
  white-space: nowrap;
}

.card .num {
  font-size: 30px;
  font-weight: 700;
  color: var(--bright);
  margin-top: 6px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px rgba(95, 227, 255, .25);
}

.card .delta {
  font-size: 9.5px;
  letter-spacing: .08em;
  margin-top: 6px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .delta.g { color: var(--green); }
.card .delta.a { color: var(--amber); }
.card .delta.r { color: var(--red); }

/* repurpose the card's top-accent pseudo as the JARVIS underline bar */
.card::before {
  top: auto;
  bottom: 9px;
  left: 16px;
  width: 34%;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  box-shadow: 0 0 8px var(--line-glow);
}

/* ── Grid layouts ── */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.sidecol { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.sidecol .panel { flex: 1; }

.grid3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1.1fr);
  gap: 14px;
}

/* ── Ecosystem overview ── */
.ov {
  display: grid;
  grid-template-columns: minmax(120px, .8fr) minmax(0, 1.4fr) minmax(150px, 1fr);
  gap: 14px;
  align-items: center;
}

.ov-left .k {
  font-size: 8.8px;
  letter-spacing: .24em;
  color: var(--cyan);
  margin-bottom: 6px;
}

.ov-left .bignum {
  font-size: 34px;
  font-weight: 700;
  color: var(--bright);
  line-height: 1;
  margin-bottom: 12px;
  text-shadow: 0 0 16px rgba(95, 227, 255, .3);
}

.ov-left .bignum small { font-size: 11px; color: var(--dim); font-weight: 400; letter-spacing: .14em; margin-left: 6px; }

.ovrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 4px 0;
  color: var(--txt);
}

.ov-globe { min-width: 0; }

.ov-globe canvas {
  display: block;
  width: 100%;
  height: 320px;
}

.ov-right h3 {
  font-size: 9px;
  letter-spacing: .24em;
  color: var(--cyan);
  margin: 0 0 10px;
  font-weight: 600;
}

.trrow { padding: 6px 0; border-bottom: 1px solid rgba(16, 49, 78, .55); }
.trrow:last-child { border-bottom: 0; }

.trtop {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
}

.trtop .n { color: var(--dim); font-variant-numeric: tabular-nums; }
.trtop .repo { color: var(--txt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.trtop .cnt { color: var(--cyan2); font-variant-numeric: tabular-nums; }

.trbar {
  height: 2px;
  margin-top: 5px;
  background: linear-gradient(90deg, var(--cyan), var(--cyan2));
  box-shadow: 0 0 6px var(--line-glow);
  border-radius: 1px;
}

/* ── System health ring ── */
.healthwrap { display: flex; align-items: center; gap: 16px; }

.healthring { flex: 0 0 auto; position: relative; width: 108px; height: 108px; }

.healthring svg { display: block; }

.hr-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.hr-pct { font-size: 20px; font-weight: 700; color: var(--bright); font-variant-numeric: tabular-nums; }
.hr-sub { font-size: 7.5px; letter-spacing: .22em; color: var(--dim); }

ul { list-style: none; margin: 0; padding: 0; }

.health { flex: 1; min-width: 0; }

.health li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  padding: 5px 0;
  color: var(--txt);
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }

.dot.g { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.a { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.dot.r { background: var(--red);   box-shadow: 0 0 8px var(--red); }

.health .s {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: .14em;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}

.health .s.ok   { color: var(--green); }
.health .s.warn { color: var(--amber); }

/* ── Attention alerts ── */
.alert {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(16, 49, 78, .55);
}

.alert:last-child { border: 0; }

.ai { width: 18px; text-align: center; }

.alert .t { font-size: 12px; color: #e6f4fc; }
.alert .m { font-size: 10px; color: var(--dim); margin-top: 1px; }
.alert .ago { margin-left: auto; font-size: 10px; color: var(--dim); }

/* ── Repo status donut ── */
.donut { display: flex; align-items: center; gap: 18px; }

.donut-hole { position: relative; width: 128px; height: 128px; flex: 0 0 auto; }

.donut-hole svg { display: block; }

.dh-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.dh-num { font-size: 26px; font-weight: 700; color: var(--bright); font-variant-numeric: tabular-nums; }
.dh-sub { font-size: 7.5px; letter-spacing: .24em; color: var(--dim); }

.donut-legend { display: flex; flex-direction: column; gap: 6px; }

.legrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--txt);
}

.legrow .cnt { color: var(--bright); font-weight: 700; font-variant-numeric: tabular-nums; }

.leg { width: 9px; height: 9px; border-radius: 2px; display: inline-block; box-shadow: 0 0 6px currentColor; }

#repos .num { font-size: 30px; font-weight: 700; color: var(--bright); }

/* ── Queue items ── */
.q {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(16, 49, 78, .55);
}

.q:last-child { border-bottom: 0; }

.rank {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: rgba(39, 197, 232, .14);
  border: 1px solid rgba(39, 197, 232, .3);
  color: var(--cyan2);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.q .t { font-size: 12.5px; color: #d8ecf8; }
.q .m { font-size: 10px; color: var(--dim); margin-top: 2px; }
.q .score { margin-left: auto; font-size: 11px; color: var(--cyan); font-variant-numeric: tabular-nums; }

/* ── Recent commits ── */
.commit {
  display: flex;
  gap: 10px;
  font-size: 11.5px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(16, 49, 78, .5);
}

.commit:last-child { border: 0; }

.commit::before {
  content: "●";
  color: var(--cyan);
  font-size: 8px;
  padding-top: 2px;
  text-shadow: 0 0 6px var(--cyan);
}

.commit .when { color: var(--cyan); font-variant-numeric: tabular-nums; flex: 0 0 56px; }
.commit .repo { color: var(--dim); flex: 0 0 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.commit .msg { color: var(--txt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }

/* ── Empty state ── */
.empty { color: var(--dim); font-size: 11px; padding: 8px 0; }

/* ── Footer ── */
footer {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 0 4px;
}

.refresh {
  background: rgba(39, 197, 232, .12);
  color: var(--cyan2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 11px;
  letter-spacing: .18em;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}

.refresh:hover { background: rgba(39, 197, 232, .22); box-shadow: 0 0 14px rgba(39, 197, 232, .25); }

.stamp { font-size: 10px; color: var(--dim); letter-spacing: .12em; }

.tagline {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: .3em;
  color: var(--dim);
}

/* ── Narrow screens (iPad portrait) ── */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
  }
  .brand { margin: 0; display: flex; align-items: center; gap: 12px; text-align: left; }
  .ring { width: 44px; height: 44px; margin: 0; }
  .ring-core { width: 14px; height: 14px; }
  .brand h1 { font-size: 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .nav a { padding: 7px 10px; }
  .sidestatus { margin: 0; min-width: 130px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .grid, .grid3 { grid-template-columns: 1fr; }
  .ov { grid-template-columns: 1fr; }
  .ov-globe canvas { height: 260px; }
  .tagline { display: none; }
}

/* prevent long content from forcing horizontal scroll */
.panel, .grid, .grid3, main { min-width: 0; }
body { overflow-x: hidden; }

@media (prefers-reduced-motion: reduce) {
  .ring.live::after, .ring.live .ring-core, .live-wave i,
  .statedot.listening, .statedot.thinking, .statedot.speaking, .statedot.working {
    animation: none;
  }
}
