:root {
  --bg: #c0c0c0;
  --panel: #ffffff;
  --panel-2: #f0f0f0;
  --panel-3: #e0e0e0;
  --line: #808080;
  --line-light: #ffffff;
  --text: #000000;
  --dim: #303030;
  --faint: #808080;
  --accent: #0000ee;
  --accent-ink: #ffffff;
  --visited: #551a8b;
  --warn: #cc0000;
  --sans: "Huninn", "Times New Roman", Times, "Songti SC", "SimSun", serif;
  --mono: "Huninn", "Courier New", Courier, "Songti SC", "SimSun", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sans);
  font-size: 20px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ================= 整體 ================= */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
}
.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--side-w, 340px) 12px minmax(0, 1fr);
  gap: 0;
}
.side {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  min-width: 0;
}
.list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* ================= 工具列 ================= */
.toolbar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.toolbar h1 {
  font-size: 18px;
  font-weight: bold;
  margin: 0 12px 0 0;
  font-family: var(--sans);
}
.toolbar .spacer { flex: 1; }
.toolbar .hint-inline {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--dim);
  font-style: italic;
}
.btn {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 10px;
  height: 30px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn:hover { background: var(--panel-2); }
.btn:active { background: var(--line-light); }
.btn svg { width: 13px; height: 13px; flex: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: bold;
}
.btn.primary:hover { background: #0000cc; }
.btn.primary:active { background: #0000aa; }

/* ================= 目前曲目 ================= */
.now {
  flex: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px 8px;
}
.now-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 6px;
}
.now-no {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--dim);
}
.now-title {
  font-family: var(--sans);
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: bold;
  line-height: 1.25;
  overflow-wrap: anywhere;
  min-height: 2.5em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.now-file {
  margin-top: 4px;
  font-size: 12px;
  color: var(--faint);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now-file.missing { font-family: var(--sans); color: var(--warn); }
.now-clock { margin-top: 10px; }
.now-clock .remain-label {
  font-size: 12px;
  color: var(--dim);
  font-family: var(--mono);
}
.now-clock .remain {
  display: inline-block;
  margin-top: 2px;
  font-family: var(--mono);
  font-weight: bold;
  font-size: clamp(40px, 5vw, 56px);
  line-height: 1.05;
  color: #000080;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.now-clock .sub-times {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.now-clock .sub-times b { color: var(--text); font-weight: bold; }

.progress {
  position: relative;
  height: 26px;
  margin-top: 6px;
  cursor: pointer;
  touch-action: none;
  display: flex;
  align-items: center;
}
.progress .track {
  position: relative;
  width: 100%;
  height: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 0;
}
.progress .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: var(--accent);
}
.progress .offset-mark {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--warn);
  display: none;
}
.progress .head {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 10px;
  height: 18px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 0;
  transform: translate(-50%, -50%);
  display: none;
}
.progress.has-media .head { display: block; }
.progress-times {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ================= 狀態標籤（純文字 + 方括號） ================= */
.chip {
  display: inline;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text);
  border: 0;
  background: transparent;
  padding: 0;
  white-space: nowrap;
}
.chip::before { content: "["; color: var(--faint); }
.chip::after { content: "]"; color: var(--faint); }
.chip .dot { display: none; }
.chip.st-standby { color: var(--text); font-weight: bold; }
.chip.st-paused { color: var(--text); font-weight: bold; }
.chip.st-playing { color: var(--accent); font-weight: bold; }
.chip.st-done { color: var(--faint); font-style: italic; }
.chip.st-nofile { color: var(--warn); font-weight: bold; }

/* ================= 播放控制 ================= */
.transport {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  align-content: start;
  gap: 8px;
}
.btn-go {
  height: 64px;
  border: 1px solid var(--accent);
  border-radius: 0;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--sans);
  font-size: 20px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-go:hover { background: #0000cc; }
.btn-go:active { background: #0000aa; }
.btn-go svg { width: 22px; height: 22px; }
.btn-go.is-pause {
  background: var(--panel-3);
  color: var(--text);
  border-color: var(--line);
}
.btn-go.is-pause:hover { background: var(--panel-2); }
.btn-transport {
  height: 64px;
  border-radius: 0;
  cursor: pointer;
  background: var(--panel-3);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-transport:hover { background: var(--panel-2); }
.btn-transport svg { width: 15px; height: 15px; }
.btn-transport:disabled { opacity: .4; cursor: default; }
.btn-transport:disabled:hover { background: var(--panel-3); }
.next-box {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  padding: 6px 12px;
  min-width: 0;
}
.next-box .nb-label {
  font-size: 11.5px;
  color: var(--faint);
  font-family: var(--mono);
}
.next-box .nb-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-box .nb-title .nb-no {
  font-family: var(--mono);
  color: var(--dim);
  margin-right: 8px;
  font-size: 13px;
}
.master {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  padding: 6px 12px 2px;
}
.master label {
  font-size: 12px;
  color: var(--dim);
  font-family: var(--sans);
  display: flex;
  justify-content: space-between;
}
.master label output {
  font-family: var(--mono);
  color: var(--text);
  font-size: 12px;
}
.master input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ================= 快捷鍵說明 ================= */
.help {
  flex: 1;
  min-height: 0;
  overflow: auto;
  align-content: start;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
}
.help .help-title {
  grid-column: 1 / -1;
  color: var(--text);
  font-weight: bold;
  font-family: var(--sans);
}
kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 4px;
  margin-right: 2px;
}

/* ================= 曲目清單 ================= */
.list-head {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 2px 6px;
}
.list-head h2 {
  font-size: 15px;
  font-weight: bold;
  margin: 0;
}
.list-head .lh-note {
  font-size: 12px;
  color: var(--faint);
  font-family: var(--mono);
}
.cue-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-right: 2px;
}
.list-foot {
  flex: none;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--faint);
  font-family: var(--mono);
  font-style: italic;
}
.empty-list {
  border: 1px dashed var(--line);
  border-radius: 0;
  padding: 40px 20px;
  text-align: center;
  color: var(--dim);
  font-size: 14px;
  font-style: italic;
  line-height: 1.9;
  font-size: 20px;
}
.empty-list b { color: var(--text); font-weight: bold; }

/* 曲目：像表格列，用凹陷分隔線串起來 */
.cue {
  flex: none;
  display: grid;
  align-items: center;
  gap: 8px 10px;
  grid-template-columns: 30px minmax(0, 1fr) 48px 96px 150px 72px 72px;
  grid-template-areas: "no main dur start vol status acts";
  background: var(--panel);
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line-light);
  border-radius: 0;
  padding: 6px 10px;
  cursor: pointer;
}
.cue-list > .cue:first-child { border-top: 0; }
.cue-list > .cue:last-child { border-bottom: 0; }
.cue:hover { background: var(--panel-2); }
.cue.is-standby {
  background: var(--panel-2);
  border-top-color: var(--accent);
  border-bottom-color: var(--accent);
}
.cue.is-playing {
  background: var(--panel-2);
  border-top-color: var(--accent);
  border-bottom-color: var(--accent);
}
.cue.is-done { color: var(--faint); }
.cue.is-done .c-title { color: var(--faint); }
.cue.is-done.is-standby { color: var(--text); }
.cue.is-done.is-standby .c-title { color: var(--text); }
.cue .c-no {
  grid-area: no;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--faint);
  text-align: center;
}
.cue.is-standby .c-no,
.cue.is-playing .c-no { color: var(--text); font-weight: bold; }
.cue .c-main { grid-area: main; min-width: 0; }
.cue .c-title {
  width: 100%;
  height: 26px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 0 6px;
  margin-left: -6px;
}
.cue .c-title:hover { border-color: var(--line); }
.cue .c-title:focus {
  border-color: var(--text);
  background: var(--panel);
  outline: none;
}
.cue .c-file {
  font-size: 11px;
  color: var(--faint);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cue .c-file.missing { font-family: var(--sans); color: var(--warn); }
.cue .c-dur {
  grid-area: dur;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cue .c-dur .dur-label { display: none; }
.cue .c-start {
  grid-area: start;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--dim);
}
.cue .c-start input {
  width: 52px;
  height: 26px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 6px;
}
.cue .c-vol { grid-area: vol; display: flex; align-items: center; gap: 6px; }
.cue .c-vol input[type="range"] {
  flex: 1;
  min-width: 60px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.cue .c-vol output {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cue .c-status { grid-area: status; justify-self: start; }
.cue .c-acts { grid-area: acts; display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 0;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn.armed {
  background: var(--warn);
  border-color: var(--warn);
  color: #ffffff;
  width: auto;
  padding: 0 6px;
  font-size: 11.5px;
  font-family: var(--sans);
  white-space: nowrap;
}

/* ================= 拖放提示 / 通知 ================= */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  background: rgba(0, 0, 0, .8);
  color: #ffffff;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--sans);
  font-size: 22px;
  font-weight: bold;
}
.drop-overlay.on { display: flex; }
.drop-overlay .box {
  border: 2px dashed #ffffff;
  border-radius: 0;
  padding: 40px 56px;
}
.drop-overlay small {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  font-weight: normal;
  color: #cccccc;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .3);
  opacity: 0;
  pointer-events: none;
  z-index: 70;
  max-width: min(92vw, 560px);
  text-align: center;
}
.toast.on { opacity: 1; }

/* ================= 可調整大小的分隔線 ================= */
.splitter { position: relative; flex: none; touch-action: none; outline: none; }
.splitter::before {
  content: "";
  position: absolute;
  background: var(--line);
  border-radius: 0;
  transition: background .15s;
}
.splitter:hover::before,
.splitter:focus-visible::before,
.splitter.dragging::before { background: var(--accent); }
.splitter-v { cursor: col-resize; }
.splitter-v::before { left: 5px; right: 5px; top: 0; bottom: 0; }
.splitter-h { cursor: row-resize; height: 10px; }
.splitter-h::before { top: 4px; bottom: 4px; left: 0; right: 0; }
.has-size { overflow: auto; }
body.is-resizing { user-select: none; -webkit-user-select: none; }
body.is-resizing * { cursor: inherit !important; }

#player {
  position: absolute;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
  left: -10px;
  top: -10px;
}

/* ================= 經典捲軸 ================= */
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: var(--panel-3); }
::-webkit-scrollbar-thumb {
  background: var(--panel-3);
  border: 1px solid var(--line);
}
::-webkit-scrollbar-thumb:hover { background: var(--panel-2); }

/* ================= 窄螢幕 ================= */
@media (max-width: 1180px) {
  .main { grid-template-columns: var(--side-w, 310px) 12px minmax(0, 1fr); }
  .cue {
    grid-template-columns: 30px minmax(0, 1fr) 48px 96px 140px 72px;
    grid-template-areas: "no main dur start vol acts";
  }
  .cue .c-status { display: none; }
}

@media (max-width: 860px), (max-height: 600px) {
  html, body { height: auto; }
  body { overflow: auto; }
  .app { height: auto; }
  .main { display: flex; flex-direction: column; gap: 12px; }
  .side { gap: 10px; }
  .splitter { display: none; }
  .now, .transport { height: auto !important; }
  .has-size { overflow: visible; }
  .cue-list { overflow: visible; }
  .help { flex: none; overflow: visible; }
  .cue {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    grid-template-areas:
      "no main main"
      "no dur acts"
      "no start start"
      "no vol vol";
    row-gap: 6px;
  }
  .cue .c-status { display: none; }
  .cue .c-dur { text-align: left; }
  .cue .c-dur .dur-label {
    display: inline;
    color: var(--faint);
    font-size: 12px;
    margin-right: 6px;
  }
}

/* ================= 新手引導 ================= */
.guide-root { position: fixed; inset: 0; z-index: 200; }
.guide-dim { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.guide-spot {
  position: fixed;
  border: 2px solid var(--accent);
  border-radius: 0;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5);
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
  pointer-events: none;
}
.guide-card {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  padding: 16px 18px 14px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .35);
}
.guide-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: bold;
  font-family: var(--sans);
}
.guide-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--dim);
}
.guide-foot {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.guide-count {
  font-size: 12px;
  color: var(--faint);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.guide-btns { display: flex; gap: 8px; }

/* ================= 待命 Cue 對話框 ================= */
.next-box { cursor: pointer; }
.cue-dlg-root { position: fixed; inset: 0; z-index: 180; }
.cue-dlg-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.cue-dlg {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 94vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  padding: 20px 22px 18px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .35);
}
.cue-dlg-kicker {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 6px;
}
.cue-dlg h3 {
  margin: 0 0 14px;
  font-size: 26px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  font-family: var(--sans);
  font-weight: bold;
}
.cue-dlg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  margin: 0 0 12px;
}
.cue-dlg-grid dt {
  font-size: 12px;
  color: var(--faint);
  font-family: var(--mono);
  margin-bottom: 2px;
}
.cue-dlg-grid dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 19px;
  color: #000080;
  font-variant-numeric: tabular-nums;
}
.cue-dlg-file {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 16px;
}
.cue-dlg-file.missing {
  font-family: var(--sans);
  color: var(--warn);
  white-space: normal;
}
.cue-dlg-actions { display: flex; gap: 10px; }
.cue-dlg-actions .btn { height: 46px; padding: 0 18px; font-size: 15px; }
.cue-dlg-actions .cue-dlg-play {
  flex: 1;
  font-size: 17px;
  font-weight: bold;
}

.niao {
  margin: 0 auto;
}