:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #e3e7ee;
  --line-strong: #cfd6e2;
  --blue: #2563eb;
  --teal: #0f766e;
  --green: #12805c;
  --amber: #b7791f;
  --red: #c2410c;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.08);
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-family: var(--font);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #fbfcfe 0%, var(--bg) 44%, #eef2f7 100%);
  color: var(--ink);
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.portal-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(24px) saturate(150%);
  padding: 24px 18px;
}
.brand img { display: block; height: 34px; width: auto; }
.brand-tagline {
  margin: -14px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}
.sidebar nav { display: grid; gap: 5px; }
.sidebar a { text-decoration: none; }
.sidebar nav a,
.signout {
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
}
.sidebar nav a.active,
.sidebar nav a:hover {
  background: #eef4ff;
  color: var(--blue);
}
.sidebar-note {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}
.brand-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  padding-top: 12px;
}
.brand-footer strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  margin-bottom: 3px;
}
.sidebar-note span,
.signal-card span,
.packet-grid span,
.script-list span,
.stage-preview span,
.module-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.sidebar-note strong { display: block; margin: 7px 0 5px; }

.workspace {
  display: grid;
  gap: 16px;
  padding: 28px;
  min-width: 0;
}
.workspace-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(150%);
  padding: 24px;
  min-width: 0;
}
.workspace-header > div:first-child { max-width: 850px; }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; min-width: 270px; }

.eyebrow,
.section-label {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 44px; line-height: 1; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 24px; letter-spacing: 0; }
h3 { margin-bottom: 7px; font-size: 16px; }
p { color: var(--muted); line-height: 1.5; }

.primary-action,
.secondary-action,
.full-button,
.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
  padding: 0 14px;
  text-decoration: none;
}
.primary-action,
.full-button.dark {
  border: 0;
  background: var(--ink);
  color: #fff;
}
.secondary-action,
.full-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}
.text-link {
  min-height: 36px;
  border: 1px solid var(--line);
  color: var(--blue);
  background: #fff;
  font-size: 13px;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.signal-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  min-width: 0;
}
.signal-card { padding: 16px; }
.signal-card strong { display: block; margin: 8px 0 5px; font-size: 34px; letter-spacing: 0; }
.signal-card p { margin: 0; font-size: 13px; }
.signal-card.urgent strong { color: var(--blue); }
.signal-card.ready strong { color: var(--teal); }
.signal-card.packets strong { color: var(--green); }
.signal-card.stale strong { color: var(--red); }

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .55fr);
  gap: 16px;
}
.panel { padding: 18px; }
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.live-pill {
  flex: 0 0 auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
  white-space: normal;
}

.touch-table {
  display: grid;
  gap: 6px;
}
.touch-row {
  display: grid;
  grid-template-columns: .7fr 1fr 1.1fr .75fr 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}
.touch-row:not(.touch-head):hover,
.touch-row.active {
  border-color: #9bbcff;
  background: #f7faff;
}
.touch-head {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.status {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 8px;
  text-transform: uppercase;
}
.status.ready { background: #ecfdf3; color: var(--green); }
.status.warning { background: #fff8e6; color: var(--amber); }
.status.urgent { background: #fff1eb; color: var(--red); }

.action-panel dl {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}
.action-panel dl div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}
dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
dd { margin: 3px 0 0; font-weight: 700; }
.check-stack {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}
.check-stack label {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.check-stack input { margin-top: 2px; accent-color: var(--blue); }
.full-button { width: 100%; margin-top: 8px; }

.packet-grid,
.module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.packet-grid article,
.module-grid article,
.script-list article,
.stage-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}
.packet-grid strong { display: block; margin: 8px 0 7px; }
.packet-grid p,
.module-grid p,
.script-list p { margin: 0; font-size: 13px; }

.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 12px;
}
.script-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.teleprompter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  padding: 0 12px;
}
.script-list .teleprompter-button { margin-top: 12px; width: 100%; }
.stage-preview {
  display: grid;
  align-content: center;
  min-height: 260px;
  background: #111827;
  color: #fff;
}
.stage-preview span,
.stage-preview p { color: rgba(255, 255, 255, .72); }
.stage-preview h3 { font-size: 26px; }
.stage-preview p { font-size: 20px; line-height: 1.55; }

.teleprompter {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 7, 18, .88);
  padding: 18px;
}
.tp-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1100px, 100%);
  height: 100%;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  background: #030712;
  color: #fff;
  overflow: hidden;
}
.tp-stage header,
.tp-stage footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.tp-stage footer {
  border-top: 1px solid rgba(255, 255, 255, .12);
  border-bottom: 0;
  flex-wrap: wrap;
}
.tp-stage button {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-weight: 800;
  padding: 0 12px;
}
.tp-stage main { overflow: auto; padding: 12vh 9vw; scroll-behavior: smooth; }
.tp-stage main p {
  max-width: 920px;
  margin: 0 auto;
  color: #fff;
  font-weight: 800;
  line-height: 1.42;
  text-align: center;
}
.tp-stage.mirrored main p { transform: scaleX(-1); }
.tp-stage label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, .72);
  font-size: 13px;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 110;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 800;
  padding: 12px 14px;
}

@media (max-width: 1120px) {
  .signal-grid,
  .packet-grid,
  .module-grid,
  .script-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .work-grid,
  .studio-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  body { overflow-x: hidden; }
  .portal-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
    overflow: hidden;
  }
  .brand img { height: 28px; }
  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-width: 100%;
    min-width: 0;
  }
  .sidebar nav a {
    font-size: 13px;
    padding: 8px 10px;
  }
  .sidebar-note { display: none; }
  .workspace-header { display: grid; }
  .header-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
    min-width: 0;
    width: 100%;
  }
  .header-actions .primary-action,
  .header-actions .secondary-action { width: 100%; }
  .eyebrow { overflow-wrap: anywhere; }
  .tp-stage header {
    display: grid;
    align-items: stretch;
  }
  .tp-stage header div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .tp-stage header button { flex: 1 1 auto; }
  .tp-stage main { padding: 8vh 6vw; }
}
@media (max-width: 680px) {
  .workspace { padding: 16px; }
  h1 { font-size: 34px; }
  .signal-grid,
  .packet-grid,
  .module-grid,
  .script-list { grid-template-columns: 1fr; }
  .touch-row { grid-template-columns: 1fr; }
  .touch-head { display: none; }
}
