:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --text: #17202a;
  --muted: #5d6875;
  --line: #d9dee5;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --blue: #2563eb;
  --orange: #c2410c;
  --red: #dc2626;
  --shadow: 0 10px 28px rgba(17, 24, 39, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

button:hover {
  border-color: #aeb8c4;
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
}

input[type="range"] {
  min-height: 24px;
  accent-color: var(--teal);
}

.studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand p,
.brand h1 {
  margin: 0;
}

.brand p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1 {
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1.1;
}

.header-nav {
  display: flex;
  gap: 10px;
}

.header-nav a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--text);
  text-decoration: none;
  background: #ffffff;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
  grid-template-areas:
    "rundown library"
    "settings library"
    "transport transport";
  gap: 16px;
  padding: 16px clamp(16px, 3vw, 32px) 32px;
}

.transport-panel,
.settings-panel,
.rundown-panel,
.library-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.transport-panel {
  grid-area: transport;
  padding: 16px;
}

.settings-panel {
  grid-area: settings;
  padding: 16px;
}

.rundown-panel {
  grid-area: rundown;
  min-height: 460px;
  padding: 16px;
}

.library-panel {
  grid-area: library;
  min-height: 640px;
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.02rem;
}

.button-group {
  display: flex;
  gap: 8px;
}

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

.time-strip div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-muted);
}

.time-strip span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.time-strip strong {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.15rem, 2vw, 1.6rem);
  line-height: 1.1;
  white-space: nowrap;
}

.now-block {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.status-pill {
  display: inline-flex;
  min-width: 72px;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
}

.status-pill.is-live {
  background: #dcfce7;
  color: #166534;
}

.status-pill.is-recording {
  background: #fee2e2;
  color: #991b1b;
}

.now-block h2 {
  margin: 12px 0 6px;
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 2.2vw, 1.95rem);
  line-height: 1.18;
}

.now-block p {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.progress-shell {
  height: 10px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress-shell span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--teal);
  transition: width 140ms linear;
}

.seek-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.track-seek {
  width: 100%;
  accent-color: var(--teal);
}

.seek-row span {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.transport-controls {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 48px minmax(120px, 1fr) 48px minmax(110px, 0.8fr) 48px;
  gap: 8px;
  margin-top: 14px;
}

.record-button,
.play-button,
.fade-button {
  padding: 0 14px;
  font-weight: 800;
}

.record-button {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--red);
}

.record-button.is-recording {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.play-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.play-button.is-ready {
  border-color: var(--blue);
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.fade-button {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--orange);
}

.icon-button {
  width: 48px;
  padding: 0;
  font-size: 1rem;
}

.recording-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}

.level-meter {
  height: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f1f5f9;
}

.level-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--blue);
  transition: width 90ms linear;
}

.recording-output {
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.recording-output a {
  color: var(--blue);
  font-weight: 700;
}

.field {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
}

.field span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.compact-field {
  grid-template-columns: 92px 88px 32px;
}

.field select {
  width: 100%;
  padding: 0 10px;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
}

.switch-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--teal);
}

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

.cue-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.cue-item.is-current {
  border-color: var(--teal);
  background: #f0fdfa;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.cue-item.is-ready {
  border-color: var(--blue);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.cue-number {
  display: flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.cue-body {
  min-width: 0;
}

.cue-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px repeat(3, 40px);
  gap: 8px;
  align-items: center;
}

.cue-select {
  min-width: 0;
  min-height: 40px;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: var(--text);
}

.cue-select strong,
.cue-select span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cue-select span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.cue-main button:not(.cue-select) {
  width: 40px;
  min-height: 36px;
  padding: 0;
}

.cue-main .cue-play-button {
  width: 48px;
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
  font-weight: 900;
}

.cue-item.is-ready .cue-play-button,
.cue-play-button.is-ready {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
}

.cue-item.is-current .cue-number {
  background: var(--teal);
  color: #ffffff;
}

.cue-item.is-ready .cue-number {
  background: var(--blue);
  color: #ffffff;
}

.cue-controls {
  display: grid;
  grid-template-columns: 88px minmax(120px, 1fr) 88px 80px 80px;
  gap: 8px;
  margin-top: 8px;
}

.cue-controls select,
.cue-controls input {
  width: 100%;
  padding: 0 8px;
}

.cue-controls input[type="number"] {
  min-width: 0;
}

.cue-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.cue-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cue-toggles input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

.empty-state {
  border: 1px dashed #b8c2ce;
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.search-input {
  width: 100%;
  padding: 0 12px;
}

.library-list {
  display: grid;
  gap: 10px;
  max-height: 650px;
  overflow: auto;
  margin-top: 12px;
  padding-right: 2px;
}

.song-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px 54px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
}

.song-row strong,
.song-row span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.song-row button {
  width: 54px;
  padding: 0;
  font-weight: 800;
}

.song-row button[data-add-role="music"] {
  border-color: #bae6fd;
  color: #075985;
}

.song-row button[data-add-role="bgm"] {
  border-color: #bbf7d0;
  color: #166534;
}

@media (max-width: 1120px) {
  .studio-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "rundown"
      "library"
      "settings"
      "transport";
  }

  .library-list {
    max-height: 460px;
  }
}

@media (max-width: 760px) {
  .studio-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .time-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .transport-controls,
  .recording-row,
  .cue-controls,
  .seek-row,
  .song-row {
    grid-template-columns: 1fr;
  }

  .icon-button,
  .song-row button {
    width: 100%;
  }

  .cue-main {
    grid-template-columns: minmax(0, 1fr) 44px repeat(3, 36px);
  }

  .seek-row span {
    text-align: left;
  }
}

@media (max-width: 520px) {
  .studio-layout,
  .transport-panel,
  .settings-panel,
  .rundown-panel,
  .library-panel {
    padding-left: 12px;
    padding-right: 12px;
  }

  .time-strip {
    grid-template-columns: 1fr;
  }

  .field {
    grid-template-columns: 1fr;
  }

  .field output {
    text-align: left;
  }
}
