:root {
  --bg: #050a18;
  --panel: #0f172c;
  --panel-soft: #0d1329;
  --panel-loud: #141f3d;
  --ink: #ecf1ff;
  --muted: #a7b2d0;
  --line: rgba(255, 255, 255, 0.14);
  --line-soft: rgba(255, 255, 255, 0.08);
  --bronze: #d8a35d;
  --action: #f15a2b;
  --action-strong: #ff8a5d;
  --good: #2fce8a;
  --warn: #f6be3f;
  --bad: #ff566d;
  --draft: #38b8ff;
  --proposed: #f7be2d;
  --approved: #35cf90;
  --queued: #9b81ff;
  --executed: #13c3d6;
  --failed: #ff607b;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --safe-bottom: env(safe-area-inset-bottom);
  --shadow-elev: 0 16px 50px rgba(3, 9, 24, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  font-family: "Oswald", "Arial Narrow", "Avenir Next", "Segoe UI", "Arial", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(130% 130% at 20% 10%, rgba(31, 44, 84, 0.7), transparent 60%),
    radial-gradient(120% 120% at 80% 90%, rgba(198, 95, 47, 0.1), transparent 45%),
    var(--bg);
  min-height: 100vh;
}

.app-root {
  max-width: 1520px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.top-bar {
  display: grid;
  gap: 12px;
  background: linear-gradient(120deg, #101a30, #1b2c55, #13254b);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.top-title h1 {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: clamp(1rem, 2vw, 1.35rem);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  color: var(--bronze);
  letter-spacing: 0.08em;
  font-size: 12px;
}

.command-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.control,
.role-switch,
.time-window {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--ink);
}

select,
input,
textarea,
button {
  font: inherit;
}

select,
input,
textarea {
  background: #0f1a2e;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 40px;
}

button {
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  transition: transform 100ms ease, box-shadow 120ms ease, background 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #ffd38a;
  outline-offset: 2px;
}

.role-switch button,
.time-window button,
.pill-btn {
  background: linear-gradient(140deg, #1a2a4c, #20325d);
}

.role-switch .active,
.time-window .active,
.pill-btn.active,
.role-pill[aria-pressed="true"],
.time-pill[aria-pressed="true"] {
  background: linear-gradient(120deg, #ff5b29, #e84d23);
  border-color: rgba(255, 154, 103, 0.85);
}

.role-pill,
.time-pill,
.pill {
  border: 1px solid var(--line);
}

.alert-button {
  background: #1d2b4d;
  justify-self: start;
}

.alert-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: var(--warn);
}

.studio-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.frame-nav {
  display: grid;
  gap: 10px;
  align-content: start;
}

.frame-nav button {
  text-align: left;
  padding: 12px 14px;
  width: 100%;
  border-radius: 8px;
  background: #13284f;
  border: 1px solid var(--line);
}

.frame-nav button[aria-current="true"] {
  background: linear-gradient(120deg, #18376f, #2c4c95);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26);
}

.frame-workspace {
  background: #0d1732;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-elev);
  min-height: 75vh;
  display: grid;
  gap: 12px;
  padding: 14px;
  position: relative;
}

.frame-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.frame-head h2 {
  margin: 2px 0 0;
}

.frame-subtitle {
  color: var(--muted);
}

.state-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.panel {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.panel--soft {
  background: var(--panel-soft);
}

.panel--loud {
  background: var(--panel-loud);
}

.panel--rail {
  background: #0f1931;
}

.frame-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(240px, 0.8fr);
  gap: 12px;
  align-items: start;
}

.frame-grid--single {
  grid-template-columns: 1fr;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lane {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.lane li {
  padding: 10px;
  background: #0f1830;
  border-left: 3px solid var(--action);
}

.stat-list,
.impact-table,
.shift-cards,
.action-row {
  display: grid;
  gap: 8px;
}

.stat-list li,
.shift-cards li {
  display: flex;
  justify-content: space-between;
  padding: 8px;
  border-radius: 8px;
  background: #0d1731;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-chip,
.pill-chip {
  background: #1c2d53;
  border-radius: var(--radius-pill);
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
}

.pill,
.state-pill {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid transparent;
}

.pill {
  background: rgba(11, 22, 48, 0.7);
  color: #d4dcf5;
  border-color: rgba(255, 255, 255, 0.22);
}

.pill--conflict,
.state-pill--draft {
  background: rgba(246, 94, 109, 0.16);
  color: #ffd2d9;
  border-color: rgba(255, 146, 168, 0.45);
}

.state-pill--proposed {
  background: rgba(247, 193, 77, 0.14);
  color: #ffe4a4;
  border-color: rgba(247, 193, 77, 0.45);
}

.state-pill--approved,
.state-pill--executed {
  background: rgba(54, 215, 147, 0.16);
  color: #b8ffd3;
  border-color: rgba(54, 215, 147, 0.45);
}

.state-pill--queued {
  background: rgba(144, 114, 255, 0.16);
  color: #e2d7ff;
  border-color: rgba(144, 114, 255, 0.45);
}

.state-pill--failed {
  background: rgba(255, 101, 127, 0.16);
  color: #ffd0d8;
  border-color: rgba(255, 101, 127, 0.45);
}

.state-pill--has-delta {
  background: rgba(247, 193, 77, 0.18);
  color: #ffe7a8;
  border-color: rgba(247, 193, 77, 0.5);
}

.state-pill--no-delta {
  background: rgba(255, 95, 120, 0.18);
  color: #ffc0ce;
  border-color: rgba(255, 95, 120, 0.45);
}

.state-pill--warn {
  background: rgba(246, 190, 63, 0.18);
  color: #ffe7a8;
  border-color: rgba(246, 190, 63, 0.45);
}

.composer-state {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

#availabilityState {
  margin-top: 0;
  align-self: flex-start;
  text-transform: capitalize;
}

.muted,
.small,
small {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.error {
  color: var(--failed);
}

a {
  color: var(--draft);
}

.guest-stack {
  display: grid;
  gap: 12px;
}

.guest-stack.guest-flow {
  display: grid;
  gap: 12px;
}

.hero {
  position: relative;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background:
    linear-gradient(130deg, rgba(255, 90, 50, 0.2), rgba(214, 169, 98, 0.14)),
    #0f1f42;
}

.hero h3 {
  margin: 6px 0;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}

.badge--amber {
  background: rgba(247, 193, 77, 0.16);
  color: #ffe7a8;
}

.impact-table {
  width: 100%;
  border-collapse: collapse;
}

.impact-table th,
.impact-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.split-grid .mini-card {
  padding: 10px;
  background: #0f1934;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.full-width {
  width: 100%;
}

.operator-shell .operator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 320px;
  gap: 12px;
}

.thread-list {
  display: grid;
  gap: 8px;
}

.thread-card {
  text-align: left;
  padding: 10px;
  border-radius: 8px;
  background: #0f1831;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: inherit;
  width: 100%;
}

.thread-card--selected {
  border-color: var(--action);
  box-shadow: 0 6px 16px rgba(241, 90, 43, 0.2);
}

.thread-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.risk-tag {
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
}

.risk-tag--high {
  background: rgba(255, 86, 109, 0.2);
  color: #ffc6d0;
}

.risk-tag--medium {
  background: rgba(247, 193, 77, 0.2);
  color: #ffe3a1;
}

.matrix {
  display: grid;
  gap: 8px;
}

.matrix > div {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.matrix span {
  color: #a6b0ce;
}

.staff-grid,
.frame-workspace .panel {
  overflow: hidden;
}

.shift-cards {
  display: grid;
  gap: 10px;
}

.priority-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.priority-columns ul {
  margin: 0;
  padding-left: 18px;
}

.quick-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.audit-strip {
  border-top: 1px dashed rgba(255, 255, 255, 0.24);
  padding-top: 10px;
}

.audit-strip h3 {
  margin: 0 0 8px;
}

#auditList {
  margin: 0;
  padding-left: 20px;
}

#auditList li {
  padding: 4px 0;
  color: #c8d2f1;
}

.primary,
.secondary,
.ghost,
.danger,
button {
  letter-spacing: 0.02em;
}

.primary {
  background: linear-gradient(140deg, var(--action), var(--action-strong));
}

.secondary {
  background: linear-gradient(140deg, #2e4a80, #223d72);
}

.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.danger {
  background: linear-gradient(120deg, #a40f2f, #c32f51);
}

.reference {
  margin: 8px 0;
  padding: 8px 10px;
  background: #0c1731;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.secondary:disabled,
.ghost:disabled,
.primary:disabled,
.danger:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  filter: saturate(0.45);
  transform: none;
  box-shadow: none;
}

.actions,
.action-row,
.sticky-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  width: 100%;
  padding-bottom: calc(8px + var(--safe-bottom));
}

.action-row,
.sticky-actions {
  position: sticky;
  bottom: 12px;
  z-index: 4;
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  background: rgba(11, 22, 44, 0.92);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.frame-content {
  padding-bottom: 48px;
}

@media (max-width: 980px) {
  .command-controls {
    grid-template-columns: 1fr;
  }

  .studio-shell {
    grid-template-columns: 1fr;
  }

  .frame-nav {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    display: grid;
  }

  .frame-grid,
  .operator-shell .operator-grid,
  .panel-grid,
  .split-grid,
  .priority-columns {
    grid-template-columns: 1fr;
  }

  .app-root {
    padding: 10px;
  }

  .top-bar {
    gap: 10px;
  }
}

@media (max-width: 640px) {
  .top-bar,
  .frame-workspace {
    padding: 10px;
  }

  .frame-head {
    display: block;
  }

  .frame-workspace {
    min-height: auto;
  }

  .actions,
  .action-row,
  .sticky-actions,
  .operator-shell .action-row,
  .guest-stack .action-row {
    position: sticky;
    bottom: 10px;
    background: rgba(11, 19, 40, 0.96);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(4px);
  }

  .frame-content {
    padding-bottom: calc(82px + var(--safe-bottom));
  }

  select,
  input,
  textarea,
  button {
    font-size: 16px;
    min-height: 44px;
  }

  .control,
  .filter-row {
    gap: 6px;
  }

  .top-title h1,
  .frame-head h2 {
    line-height: 1.2;
  }

  .frame-nav {
    gap: 8px;
  }

  .frame-nav button {
    padding: 12px;
  }

  .state-banner,
  .action-row,
  .sticky-actions,
  .quick-row {
    width: 100%;
  }

  #holdTimer {
    font-size: 1.1rem;
  }
}

@media (min-width: 981px) {
  .studio-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .command-controls {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }
}
