/* HKIIT Sound Mixing Simulator — shell styles only (dark teaching-tool aesthetic) */
:root {
  --bg: #0f1218;
  --bg-elevated: #181c26;
  --bg-panel: #1e2430;
  --bg-input: #12161f;
  --border: #2c3444;
  --border-focus: #5b8def;
  --text: #e8ecf4;
  --text-muted: #9aa3b5;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --accent-pressed: #3a72d6;
  --danger: #e57373;
  --success: #6bcb8b;
  --slot-dash: #3a4458;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang HK",
    "Microsoft JhengHei", sans-serif;
  --focus-ring: 0 0 0 3px rgba(79, 140, 255, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Screens ---------- */
.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.screen[hidden] {
  display: none !important;
}

.screen-card {
  width: min(520px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
}

.screen-card--wide {
  width: min(640px, 100%);
}

.app-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
}

.app-subtitle {
  margin: 0 0 1.75rem;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.95rem;
}

.boot-loading {
  margin: 0 0 1rem;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

.audio-loading-bar {
  width: 100%;
  height: 0.55rem;
  margin: 0.5rem 0 1rem;
  border-radius: 999px;
  background: var(--bg-panel, #1a2230);
  border: 1px solid var(--border, #2a3548);
  overflow: hidden;
}
.audio-loading-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent, #3b82f6), #60a5fa);
  transition: width 0.2s ease;
}
body.audio-gate-active [data-transport="play"],
body.audio-gate-active [data-transport="restart"] {
  opacity: 0.45;
  pointer-events: none;
}


.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn:active:not(:disabled) {
  background: var(--accent-pressed);
}

.btn--block {
  width: 100%;
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--bg-panel);
  border-color: var(--text-muted);
}

.btn--transport {
  min-width: 0;
  min-height: 2.5rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  line-height: 1.2;
  letter-spacing: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn--transport .transport-icon {
  font-size: 1.05rem;
  line-height: 1;
  flex: 0 0 auto;
}

.btn--transport .transport-label {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.btn--transport:hover:not(:disabled) {
  background: #262d3c;
  border-color: var(--accent);
}

.btn--transport.is-active,
.btn--transport[aria-pressed='true'] {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: rgba(79, 140, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(79, 140, 255, 0.35);
}

/* ---------- Identity form ---------- */
.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.form-input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
}

.form-input:focus {
  border-color: var(--border-focus);
}

.form-input[aria-invalid='true'] {
  border-color: var(--danger);
}

.form-error {
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.form-error[hidden] {
  display: none !important;
}

.form-actions {
  margin-top: 1.5rem;
}

/* ---------- Task select ---------- */
.task-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
}

.task-card__badge {
  display: inline-block;
  margin-bottom: 0.5rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.15);
  color: var(--accent-hover);
  font-size: 0.75rem;
  font-weight: 600;
}

.task-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.task-card__desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.task-note {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Audio identification (after identity, before Start Task) ---------- */
.screen[data-screen='identify'] {
  justify-content: flex-start;
  overflow: auto;
}

.screen-card--identify {
  width: min(720px, 100%);
  margin: 0.5rem auto 1.5rem;
}

.identify-progress {
  margin: 0 0 1rem;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.identify-prompt {
  margin: 0 0 0.75rem;
  text-align: center;
  font-weight: 600;
}

.identify-play-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.identify-play {
  min-width: 10rem;
}

.identify-play.is-playing {
  background: var(--bg-panel);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.identify-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.identify-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0 0 0.85rem;
}

.identify-choice {
  min-height: 2.75rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.identify-choice.is-selected:not(:disabled) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.identify-choices.is-locked .identify-choice:disabled {
  opacity: 1;
  cursor: default;
}

.identify-choice.is-correct {
  color: #ff4d4f;
  border-color: #ff4d4f;
  background: rgba(255, 77, 79, 0.14);
  box-shadow: inset 0 0 0 1px #ff4d4f;
}

.identify-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.identify-tip {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.identify-tip[hidden] {
  display: none !important;
}

.identify-tip__title {
  margin: 0;
  font-size: 1rem;
}

.identify-correct {
  margin: 0;
  font-size: 0.95rem;
}

.identify-correct-name {
  color: #ff4d4f;
  font-weight: 800;
}

.identify-yours {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.identify-tips {
  margin: 0.15rem 0 0;
  padding-left: 1.15rem;
}

.identify-tips li {
  margin: 0.28rem 0;
}

.identify-next-clip[hidden],
#identify-submit[hidden],
#identify-yours[hidden] {
  display: none !important;
}

.identify-done {
  margin: 0 0 0.75rem;
  text-align: center;
  color: var(--success);
  font-weight: 600;
}

.identify-done[hidden] {
  display: none !important;
}

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

/* ---------- Main layout ---------- */
#screen-main {
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  min-height: 100vh;
}

.main-chrome {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.main-chrome__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.main-chrome__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.main-chrome__meta strong {
  color: var(--text);
  font-weight: 600;
}

.tab-bar {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panels {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 1.25rem 1.5rem;
}

.tab-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.tab-panel[hidden] {
  display: none !important;
}

/* ---------- Mount slots ---------- */
.slot {
  border: 1px dashed var(--slot-dash);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text-muted);
  padding: 1rem;
  min-height: 120px;
  position: relative;
}

.slot__label {
  margin: 0;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-muted);
}

/* ---------- Tab1 layout (stage dominant; Role Intro side column) ---------- */
.tab1-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 0.85rem 1rem;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.tab1-main {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  min-width: 0;
}

/* Role Intro side column (per-role 3D thumbs inside each .role-intro__item) */
.tab1-side {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  min-width: 0;
}

/* ~40% larger stage feel vs prior 280px / flex:1 */
.slot--stage {
  flex: 2.2 1 0;
  min-height: 390px;
  padding: 0.5rem;
}

.slot--mixer-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.65rem;
  flex: 0 0 auto;
  align-items: stretch;
  min-width: 0;
}

/* Compact mini mixer — stage gets flex priority. Channels stay one row; scroll if needed. */
.slot--mini-mixer {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 96px;
  padding: 0.5rem 0.65rem;
  overflow-x: auto;
}

/* Narrow stacked transport so seven mini-mixer channels fit beside it on one row. */
.slot--transport {
  flex: 0 0 156px;
  width: 156px;
  max-width: 156px;
  min-width: 156px;
  min-height: 72px;
  padding: 0.4rem 0.45rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
}

.slot--transport .transport-controls {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.35rem;
}

.slot--transport .btn--transport {
  width: 100%;
  justify-content: flex-start;
  min-height: 2.15rem;
  padding: 0.28rem 0.45rem;
}

.slot--transport .transport-label {
  font-size: 0.68rem;
  line-height: 1.15;
  white-space: normal;
}

.role-intro {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  overflow: auto;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.role-intro__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.role-intro__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.role-intro__item {
  cursor: pointer;
  margin: 0;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.55rem;
}

.role-intro__item:hover {
  border-color: var(--accent-hover);
  background: color-mix(in srgb, var(--bg-panel) 85%, var(--accent-hover));
}

.role-intro__item:focus {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

.role-intro__preview {
  flex: 0 0 64px;
  width: 64px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  background: #0c1420;
  border: 1px solid var(--border);
}

.role-intro__thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.role-intro__text {
  flex: 1 1 auto;
  min-width: 0;
}

.role-intro__name {
  display: block;
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-hover);
}

.role-intro__body {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.slot-hint--stacked {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0;
  flex: 0 0 auto;
  padding: 0.35rem 0.15rem;
}

.slot-hint--stacked .hint-line {
  display: block;
  line-height: 1.35;
}

.slot-hint--stacked .hint-line--en {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.slot-hint--stacked .hint-line--zh {
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 900px) {
  .tab1-layout {
    grid-template-columns: 1fr;
  }

  .tab1-side {
    max-height: none;
  }

  .role-intro {
    max-height: 220px;
  }

  .slot--stage {
    min-height: 320px;
  }
}

.transport-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mixer-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

@media (max-width: 900px) {
  .mixer-layout {
    grid-template-columns: 1fr;
  }
}

.slot--channel-strip {
  min-height: 360px;
  overflow-x: auto;
  /* ChannelStrip.mount adds .cs-console; keep slot id stable */
}

.slot--task-panel {
  min-height: 200px;
}

.checklist-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px) minmax(200px, 280px);
  gap: 1rem;
  flex: 1;
}

@media (max-width: 960px) {
  .checklist-layout {
    grid-template-columns: 1fr;
  }
}

.slot--checklist {
  min-height: 280px;
}

.slot--record,
.slot--vocal-record {
  min-height: 200px;
}

.slot--mp3 {
  min-height: 160px;
}

.slot-hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
