:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #eef3f7;
  --line: #d7dee6;
  --text: #18212b;
  --muted: #607080;
  --accent: #0f7b8f;
  --accent-dark: #075a6a;
  --danger: #b42318;
  --ok: #127a42;
  --warn: #9a6700;
  --shadow: 0 12px 30px rgba(20, 35, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
}

.subtle {
  color: var(--muted);
  margin: 0;
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  min-height: 40px;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #e6edf3;
  color: var(--text);
}

button.secondary:hover {
  background: #dbe5ee;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto 1fr;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 16px;
}

.panel,
.station-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel h2,
.station-card h2 {
  margin: 0;
  font-size: 18px;
}

.station-card {
  overflow: hidden;
}

.station-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.station-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.status-row {
  display: grid;
  grid-template-columns: 170px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.status-row:last-child {
  border-bottom: 0;
}

.label {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  background: var(--panel-soft);
  color: var(--muted);
  white-space: nowrap;
}

.pill.ok {
  background: #dcf5e7;
  color: var(--ok);
}

.pill.warn {
  background: #fff0c2;
  color: var(--warn);
}

.pill.bad {
  background: #ffe1de;
  color: var(--danger);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
}

.audit {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.audit-item {
  padding: 10px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--danger);
  min-height: 20px;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .grid {
    grid-template-columns: 1fr;
  }

  .status-row {
    grid-template-columns: 1fr;
  }
}

.remote-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 28px auto 1fr 22px;
  background: #2f2f2f;
  color: #777b82;
  font-family: "Segoe UI", Tahoma, sans-serif;
  min-width: 0;
}

.remote-titlebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 0 12px;
  background: #2b2b2b;
  border-bottom: 1px solid #434343;
  color: #f3f7ff;
  font-size: 14px;
}

.window-title {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.app-dot {
  position: absolute;
  left: 17px;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #2671a7;
}

.window-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #d7d7d7;
  font-size: 14px;
}

.station-picker {
  width: 140px;
  height: 22px;
  padding: 1px 24px 1px 6px;
  border: 1px solid #555;
  border-radius: 0;
  background: #363636;
  color: #ddd;
  font-size: 12px;
}

.title-logout {
  min-height: 20px;
  padding: 1px 8px;
  border: 1px solid #555;
  border-radius: 0;
  background: #363636;
  color: #ddd;
  font-size: 12px;
}

.window-button {
  min-width: 12px;
  text-align: center;
}

.remote-connectbar {
  display: grid;
  grid-template-columns: minmax(300px, 1.1fr) minmax(300px, 1.15fr) auto;
  gap: 8px;
  padding: 0 clamp(8px, 1.4vw, 16px);
  background: #303030;
  border-bottom: 1px solid #4a4a4a;
  min-width: 0;
}

.connect-block {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr 64px;
  grid-template-rows: 24px 24px 14px;
  gap: 3px 6px;
  align-items: center;
  padding-top: 2px;
  color: #777;
  font-size: 11px;
  min-width: 0;
}

.connect-block.local {
  grid-template-columns: 1fr 64px;
}

.mini-menu,
.start-button {
  height: 20px;
  border: 1px solid #494949;
  background: #333;
  color: #f4a300;
  font-size: 11px;
}

.mini-menu {
  color: #d4d4d4;
  display: grid;
  place-items: center;
}

.connect-block label {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 5px;
  color: #707070;
  font-size: 11px;
}

.connect-block input {
  height: 20px;
  padding: 2px 6px;
  border: 1px solid #4c4c4c;
  border-radius: 0;
  background: #303030;
  color: #a9a9a9;
  font-size: 11px;
}

.connect-block.local label {
  grid-column: 1;
}

.connect-tile {
  grid-column: 3;
  grid-row: 1 / 3;
  height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 1px solid #575757;
  font-size: 11px;
}

.connect-block.local .connect-tile {
  grid-column: 2;
}

.connect-tile.connected {
  background: #ff920c;
  color: #fff;
}

.connect-tile.disconnected {
  background: #303030;
  color: #ff3d25;
}

.server-icon {
  width: 24px;
  height: 20px;
  background: linear-gradient(#f5f5f5 0 35%, #7aa8d7 35% 65%, #f5f5f5 65%);
  border: 2px solid #eee;
}

.connect-caption {
  grid-column: 1 / -1;
  justify-self: center;
  color: #969aa2;
  font-size: 11px;
}

.command-ribbon {
  display: flex;
  align-items: stretch;
  border-left: 1px solid #4a4a4a;
  min-width: 0;
}

.ribbon-command {
  width: clamp(50px, 5vw, 62px);
  min-height: 62px;
  padding: 4px 3px;
  border-radius: 0;
  border-left: 1px solid #4a4a4a;
  background: #303030;
  color: #fff;
  font-size: 11px;
  line-height: 1.05;
}

.ribbon-command span {
  display: block;
  color: #70a9df;
  font-size: 20px;
  line-height: 1;
  margin-bottom: 4px;
}

.remote-workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 40%) minmax(0, 1fr) minmax(190px, 250px);
  grid-template-rows: minmax(150px, auto) minmax(124px, auto) 1fr;
  gap: 0;
  padding: clamp(16px, 2.2vw, 28px) clamp(10px, 2.2vw, 28px) 0;
  overflow: hidden;
}

.viewer-panel {
  position: relative;
  border: 1px solid #4a4a4a;
  background: #303030;
  min-width: 0;
}

.fieldset-title {
  position: absolute;
  top: -11px;
  left: 10px;
  padding: 0 5px;
  background: #303030;
  color: #777;
  font-size: 14px;
}

.program-panel {
  grid-column: 1 / 4;
  grid-row: 1;
  border-bottom: 0;
}

.program-header {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(4, auto);
  align-items: center;
  gap: 16px;
  padding: 6px clamp(18px, 5vw, 70px) 0 clamp(18px, 6vw, 86px);
  color: #777b82;
  font-size: clamp(14px, 1.6vw, 18px);
}

.program-header strong:first-child {
  color: #b8bdc7;
}

.track-lines {
  display: grid;
  gap: clamp(7px, 1.1vw, 13px);
  padding: 16px 18px 0;
  font-size: clamp(17px, 2vw, 24px);
}

.track-lines span {
  display: inline-block;
  width: 70px;
  color: #757b83;
}

.current-line strong {
  color: #fff;
  font-size: clamp(21px, 2.8vw, 32px);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.next-line strong {
  color: #777;
  font-size: clamp(19px, 2.5vw, 30px);
  overflow-wrap: anywhere;
}

.live-detail {
  color: #777;
  font-size: 15px;
}

.live-detail strong {
  color: #9ea5af;
  font-size: 15px;
  font-weight: 400;
}

.time-panel {
  grid-column: 1;
  grid-row: 2 / 4;
  padding: 20px 22px;
}

.player-name {
  color: #ff1717;
  font-size: clamp(22px, 3vw, 31px);
  line-height: 1.2;
  margin: 0 0 16px 28px;
}

.big-clock {
  color: #ffac00;
  font-size: clamp(40px, 6.5vw, 66px);
  line-height: 1;
  margin-left: 38px;
  font-variant-numeric: tabular-nums;
}

.next-code {
  color: #fff;
  font-size: clamp(22px, 3vw, 31px);
  text-align: center;
  margin-top: 18px;
}

.green-date {
  color: #95ff9d;
  font-size: clamp(19px, 2.8vw, 31px);
  font-weight: 700;
  margin: 18px 0 8px 10px;
}

.current-program {
  color: #777;
  font-size: 16px;
}

.state-panel {
  grid-column: 2 / 4;
  grid-row: 2;
  padding: 14px 18px;
}

.state-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  color: #818181;
  font-size: clamp(18px, 2.4vw, 26px);
  margin-bottom: 10px;
}

.state-line {
  display: flex;
  gap: 13px;
  align-items: baseline;
  color: #777;
  font-size: clamp(19px, 2.4vw, 26px);
  margin-top: 9px;
}

.state-line strong {
  font-size: clamp(23px, 3vw, 33px);
  color: #777;
}

.state-line.mod span {
  color: #6ca7ff;
}

.state-line.mod strong {
  color: #89ff95;
  font-size: clamp(21px, 2.6vw, 30px);
  overflow-wrap: anywhere;
}

.next-panel {
  grid-column: 2 / 4;
  grid-row: 3;
  min-height: 112px;
  padding: 16px 12px;
}

.next-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: #777;
  font-size: clamp(19px, 2.3vw, 26px);
  margin: 8px 0;
}

.next-meta span {
  flex: 0 0 clamp(104px, 13vw, 154px);
}

.next-meta strong {
  color: #e8ecf4;
  font-size: clamp(18px, 2.2vw, 25px);
  font-weight: 400;
}

.next-meta em {
  color: #777;
  font-size: clamp(14px, 1.6vw, 17px);
  font-style: normal;
}

.command-panel {
  grid-column: 3;
  grid-row: 1;
  margin: 28px 0 0 10px;
  z-index: 2;
}

.command-stack {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.command-button {
  min-height: 38px;
  border: 1px solid #626262;
  border-radius: 0;
  background: #3a3a3a;
  color: #fff;
  font-weight: 700;
}

.command-button:hover {
  background: #484848;
}

.command-button.ghost {
  color: #888;
  background: #323232;
}

.notice {
  margin: 0 12px 12px;
  border-color: #4c4c4c;
  border-radius: 0;
  background: #292929;
  color: #aaa;
}

.status-panel {
  grid-column: 1 / 3;
  grid-row: 3;
  align-self: end;
  min-height: 62px;
  margin-right: 10px;
  padding: 16px 12px 6px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: #aaa;
}

.mini-refresh {
  min-height: 28px;
  margin-left: auto;
  border: 1px solid #555;
  border-radius: 0;
  background: #3a3a3a;
}

.log-panel {
  display: none;
}

.audit-item {
  border-radius: 0;
  background: #292929;
  color: #aaa;
}

.led {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5), inset 0 0 2px rgba(255,255,255,.35);
}

.led.on {
  background: #20b15b;
}

.led.off {
  background: #c73028;
}

.pill {
  border-radius: 0;
  background: #3b3b3b;
  color: #aaa;
}

.pill.ok {
  background: #254b32;
  color: #91ff9b;
}

.pill.warn {
  background: #4d4220;
  color: #ffd36b;
}

.pill.bad {
  background: #4a2626;
  color: #ff8b82;
}

.remote-footer {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 10px;
  border-top: 1px solid #4a4a4a;
  background: #303030;
  color: #777;
  font-size: 11px;
}

@media (max-height: 900px) and (min-width: 761px) {
  .remote-shell {
    grid-template-rows: 26px auto 1fr 20px;
  }

  .remote-connectbar {
    gap: 6px;
  }

  .connect-block {
    grid-template-rows: 22px 22px 12px;
  }

  .connect-tile {
    height: 52px;
  }

  .ribbon-command {
    min-height: 56px;
  }

  .remote-workspace {
    grid-template-rows: minmax(132px, auto) minmax(108px, auto) 1fr;
    padding-top: 14px;
  }

  .fieldset-title {
    font-size: 12px;
  }

  .program-header {
    font-size: 13px;
    padding-top: 4px;
  }

  .track-lines {
    padding-top: 12px;
  }

  .current-line strong {
    font-size: clamp(20px, 2.2vw, 27px);
  }

  .next-line strong {
    font-size: clamp(18px, 2vw, 25px);
  }

  .time-panel {
    padding: 16px 18px;
  }

  .player-name {
    margin-bottom: 10px;
  }

  .big-clock {
    font-size: clamp(38px, 5.2vw, 56px);
  }

  .next-code {
    margin-top: 12px;
  }

  .green-date {
    margin-top: 12px;
  }

  .state-panel {
    padding: 12px 16px;
  }

  .state-grid {
    margin-bottom: 6px;
  }

  .state-line {
    margin-top: 6px;
  }

  .next-panel {
    min-height: 96px;
    padding-top: 14px;
  }

  .command-panel {
    margin-top: 20px;
  }

  .command-button {
    min-height: 34px;
  }

  .status-panel {
    min-height: 54px;
    padding-top: 14px;
  }
}

@media (max-width: 1050px) {
  .remote-connectbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .command-ribbon {
    grid-column: 1 / -1;
    border-top: 1px solid #4a4a4a;
    border-left: 0;
  }

  .ribbon-command {
    flex: 1 1 0;
    min-height: 56px;
  }

  .ribbon-command span {
    font-size: 20px;
  }

  .remote-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
  }

  .program-panel,
  .state-panel,
  .next-panel,
  .status-panel {
    grid-column: 1 / -1;
  }

  .program-panel {
    grid-row: 1;
  }

  .time-panel {
    grid-column: 1;
    grid-row: 2;
  }

  .state-panel {
    grid-row: 3;
  }

  .next-panel {
    grid-row: 4;
  }

  .command-panel {
    grid-column: 2;
    grid-row: 2;
    margin: 0 0 0 10px;
  }

  .status-panel {
    grid-row: 5;
    margin-right: 0;
  }
}

@media (max-width: 760px) {
  .remote-shell {
    grid-template-rows: auto auto 1fr auto;
  }

  .remote-titlebar {
    min-height: 34px;
    font-size: 13px;
  }

  .app-dot,
  .window-button {
    display: none;
  }

  .window-title {
    justify-content: flex-start;
  }

  .window-actions {
    gap: 6px;
  }

  .station-picker {
    width: 96px;
  }

  .remote-connectbar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .connect-block,
  .connect-block.local {
    grid-template-columns: minmax(0, 1fr) 60px;
    grid-template-rows: auto auto auto;
  }

  .mini-menu,
  .start-button {
    display: none;
  }

  .connect-block label,
  .connect-block.local label {
    grid-column: 1;
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .connect-tile,
  .connect-block.local .connect-tile {
    grid-column: 2;
    grid-row: 1 / 3;
    height: 54px;
  }

  .server-icon {
    width: 22px;
    height: 18px;
  }

  .command-ribbon {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .ribbon-command {
    width: auto;
    min-height: 48px;
    font-size: 10px;
  }

  .ribbon-command span {
    font-size: 16px;
  }

  .remote-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    padding-top: 22px;
  }

  .program-panel,
  .time-panel,
  .state-panel,
  .next-panel,
  .command-panel,
  .status-panel {
    grid-column: 1;
    grid-row: auto;
    margin: 0 0 18px;
  }

  .program-header {
    grid-template-columns: 1fr 1fr;
    padding: 14px 14px 0;
  }

  .track-lines {
    padding: 20px 14px 18px;
  }

  .track-lines span {
    width: 52px;
  }

  .time-panel,
  .state-panel,
  .next-panel {
    padding: 22px 14px;
  }

  .player-name,
  .big-clock {
    margin-left: 0;
  }

  .green-date {
    margin-left: 0;
  }

  .state-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .next-meta {
    flex-wrap: wrap;
  }

  .next-meta span {
    flex-basis: 92px;
  }

  .mini-refresh {
    width: 100%;
    margin-left: 0;
  }

  .remote-footer {
    min-height: 28px;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 4px 10px;
  }
}
