:root {
  color-scheme: dark;
  --bg: #091018;
  --panel: rgba(14, 22, 34, 0.88);
  --panel-2: rgba(18, 28, 44, 0.96);
  --panel-3: rgba(255,255,255,0.04);
  --line: rgba(148, 163, 184, 0.12);
  --line-strong: rgba(148, 163, 184, 0.20);
  --text: #e7eef8;
  --muted: #8fa1ba;
  --accent: #58a9ff;
  --accent-2: #7f5cff;
  --good: #35d59b;
  --warn: #ffb14b;
  --bad: #ff6e77;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  --track-h: 106px;
  --label-w: 148px;
  --ruler-h: 46px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(88,169,255,.16), transparent 32%),
    radial-gradient(circle at top right, rgba(127,92,255,.14), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  padding: 12px;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.auth-screen {
  min-height: calc(100vh - 24px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(520px, 100%);
  padding: 24px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.auth-body {
  margin-top: 18px;
}

.auth-text {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

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

.app-shell {
  max-width: 1680px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-auth {
  align-items: flex-start;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: .08em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

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

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

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 10px;
  backdrop-filter: blur(14px);
}

.user-card img {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
  background: rgba(255,255,255,0.06);
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-meta strong {
  font-size: 14px;
}

.user-meta span {
  color: var(--muted);
  font-size: 12px;
}

.main-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.compact-panel,
.timeline-panel,
.player-panel {
  padding: 14px;
}

.recording-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
  margin-bottom: 12px;
}

.indicator-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 6px rgba(255,255,255,0.035);
  flex: 0 0 auto;
}

.indicator-dot.good { background: var(--good); }
.indicator-dot.bad { background: var(--bad); }
.indicator-dot.warn { background: var(--warn); }

.recording-banner-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.indicator-title {
  color: var(--muted);
  font-size: 12px;
}

.recording-banner strong {
  font-size: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: end;
}

.toolbar-group {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar label,
.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 132px;
}

.toolbar span,
.settings-grid span {
  font-size: 12px;
  color: var(--muted);
}

input[type="datetime-local"],
input[type="text"],
input[type="number"],
input[type="time"],
input[type="range"],
select {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(88,169,255,.56);
  box-shadow: 0 0 0 4px rgba(88,169,255,.10);
}

.primary-btn,
.ghost-btn,
.delete-btn {
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
  transition: .16s ease;
  font-size: 13px;
}

.primary-btn {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #3e7eff);
}

.ghost-btn {
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}

.delete-btn {
  background: rgba(255,110,119,.10);
  color: #ffd7da;
  border: 1px solid rgba(255,110,119,.18);
}

.primary-btn:hover,
.ghost-btn:hover,
.delete-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.primary-btn:disabled,
.ghost-btn:disabled,
.delete-btn:disabled,
input:disabled,
select:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

.zoom-readout {
  min-width: 76px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.section-head,
.section-subhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.section-head h2,
.section-subhead strong,
.player-head h3 {
  margin: 0;
  font-size: 17px;
}

.section-head p,
.player-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.timeline-shell {
  display: grid;
  grid-template-columns: var(--label-w) minmax(0, 1fr);
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(4, 9, 16, 0.42);
}

.timeline-labels {
  display: grid;
  grid-template-rows: var(--ruler-h) var(--track-h) var(--track-h);
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.timeline-label {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.timeline-label:last-child {
  border-bottom: none;
}

.timeline-label strong {
  font-size: 13px;
}

.timeline-label span,
.ruler-label {
  color: var(--muted);
  font-size: 12px;
}

.timeline-viewport {
  overflow: auto hidden;
  scroll-behavior: auto;
}

.timeline-content {
  position: relative;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(88,169,255,0.75));
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05),
    0 0 16px rgba(88,169,255,0.32),
    0 0 32px rgba(88,169,255,0.16);
  z-index: 8;
  pointer-events: none;
  transition: transform 100ms linear, opacity .18s ease;
  will-change: transform;
}

.ruler {
  position: relative;
  height: var(--ruler-h);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
}

.grid-line::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  background: rgba(148,163,184,0.10);
}

.grid-line.major::before {
  background: rgba(148,163,184,0.20);
}

.grid-label {
  position: absolute;
  top: 8px;
  left: 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.track-lane {
  position: relative;
  min-height: var(--track-h);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  transition: background .18s ease, box-shadow .18s ease;
}

.track-lane:last-child {
  border-bottom: none;
}

.track-lane.lane-active.inbound {
  background:
    linear-gradient(180deg, rgba(88,169,255,0.06), rgba(88,169,255,0.02));
  box-shadow: inset 0 0 0 1px rgba(88,169,255,0.12);
}

.track-lane.lane-active.outbound {
  background:
    linear-gradient(180deg, rgba(127,92,255,0.07), rgba(127,92,255,0.02));
  box-shadow: inset 0 0 0 1px rgba(127,92,255,0.14);
}

.segment {
  position: absolute;
  top: 18px;
  height: 54px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background:
    linear-gradient(180deg, rgba(88,169,255,0.20), rgba(88,169,255,0.08)),
    rgba(255,255,255,0.03);
  overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  z-index: 3;
  transition: transform .14s ease, outline-color .14s ease, box-shadow .14s ease;
}

.segment:hover {
  transform: translateY(-1px);
}

.segment.outbound {
  background:
    linear-gradient(180deg, rgba(127,92,255,0.22), rgba(127,92,255,0.08)),
    rgba(255,255,255,0.03);
}

.segment.active {
  outline: 2px solid rgba(88,169,255,0.72);
  outline-offset: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 0 0 1px rgba(88,169,255,0.16);
}

.segment canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.segment-label {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.82);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.empty-state {
  padding: 16px 4px 2px;
  color: var(--muted);
  font-size: 13px;
}

.player-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-head-main {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.player-status-pill {
  min-width: 110px;
  text-align: center;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.player-status-pill.playing {
  color: #eafff7;
  background: rgba(53,213,155,0.12);
  border-color: rgba(53,213,155,0.24);
}

.player-status-pill.paused {
  color: #fff3de;
  background: rgba(255,177,75,0.12);
  border-color: rgba(255,177,75,0.24);
}

.player-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.playback-meta-hero {
  padding: 14px 16px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(88,169,255,0.08), rgba(127,92,255,0.04)),
    rgba(255,255,255,0.025);
  border: 1px solid var(--line);
}

.playback-meta strong {
  font-size: 16px;
}

.playback-meta span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.source-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.035);
  min-height: 92px;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.source-card.active {
  transform: translateY(-1px);
}

.source-card.active.inbound {
  background:
    linear-gradient(180deg, rgba(88,169,255,0.10), rgba(88,169,255,0.04)),
    rgba(255,255,255,0.035);
  border-color: rgba(88,169,255,0.24);
  box-shadow: 0 0 0 1px rgba(88,169,255,0.10);
}

.source-card.active.outbound {
  background:
    linear-gradient(180deg, rgba(127,92,255,0.11), rgba(127,92,255,0.04)),
    rgba(255,255,255,0.035);
  border-color: rgba(127,92,255,0.24);
  box-shadow: 0 0 0 1px rgba(127,92,255,0.10);
}

.source-card strong {
  font-size: 13px;
  line-height: 1.35;
}

.source-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.source-kind {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.source-kind.inbound {
  color: #dff0ff;
  background: rgba(88,169,255,0.16);
  border-color: rgba(88,169,255,0.30);
}

.source-kind.outbound {
  color: #efe3ff;
  background: rgba(127,92,255,0.16);
  border-color: rgba(127,92,255,0.30);
}

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

.player-main-btn {
  min-width: 160px;
}

.player-progress-card {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
}

.player-progress {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  gap: 10px;
  align-items: center;
}

.player-progress span {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

#player-seek {
  width: 100%;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  accent-color: var(--accent);
}

.transport-audio {
  display: none;
}

.window-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.window-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 18, 0.52);
  backdrop-filter: blur(4px);
}

.window-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(920px, calc(100vw - 28px));
  max-height: calc(100vh - 34px);
  transform: translate(-50%, -50%);
  overflow: auto;
  background: rgba(13, 20, 33, 0.96);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.window-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(13,20,33,0.96);
  backdrop-filter: blur(12px);
  z-index: 2;
}

.window-head h3 {
  margin: 0;
  font-size: 18px;
}

.window-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.window-body {
  padding: 16px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-box {
  padding: 13px;
  border-radius: 16px;
  background: var(--panel-3);
  border: 1px solid var(--line);
}

.status-box span,
.status-box small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-box strong {
  display: block;
  margin: 8px 0 5px;
  font-size: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-block {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-3);
}

.detail-block h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

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

.detail-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.detail-list span {
  color: var(--muted);
}

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

.mode-actions,
.save-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.schedule-row {
  display: grid;
  grid-template-columns: 82px 1fr 1fr 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
}

.checkbox-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 1200px) {
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 880px) {
  body {
    padding: 8px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-right {
    justify-content: space-between;
  }

  .timeline-shell {
    grid-template-columns: 112px minmax(0, 1fr);
  }

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

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

  .window-card {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .player-progress {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
  }

  .player-sources {
    grid-template-columns: 1fr;
  }

  .player-head-main {
    flex-direction: column;
    align-items: stretch;
  }
}