:root {
  color-scheme: light;
  --bg: #eef2f3;
  --panel: #ffffff;
  --text: #172026;
  --muted: #667580;
  --line: #d9e1e6;
  --soft: #f6f8f9;
  --accent: #0f6b5d;
  --accent-2: #d58b25;
  --danger: #b54747;
  --shadow: 0 10px 24px rgba(21, 35, 43, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  min-height: 76px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand, .auth, .user, .toolbar, .fileGroup, .studyBar, .tabs, .lookupWord, .panelMeta {
  display: flex;
  align-items: center;
  gap: 9px;
}
.mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}
h1 { margin: 0 0 3px; font-size: 21px; font-weight: 760; }
h2 { margin: 0 0 12px; font-size: 18px; }
p { margin: 0; color: var(--muted); font-size: 13px; }

button, .fileBtn, .adminLink {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  min-height: 36px;
  padding: 0 13px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:hover, .fileBtn:hover, .adminLink:hover { border-color: var(--accent); color: var(--accent); }
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.primary:hover { color: #fff; filter: brightness(0.96); }
input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  min-width: 160px;
  background: #fff;
}
.hidden { display: none; }
.fileBtn { font-weight: 650; }
.fileBtn input { display: none; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 77px);
}

.playerPanel, .sidePanel, .adminLogin, .adminTable, .stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.playerPanel {
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.toolbar { justify-content: space-between; flex-wrap: wrap; }
.statusLine {
  color: var(--muted);
  font-size: 13px;
  max-width: 440px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
video {
  width: 100%;
  background: #101315;
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 285px);
}
.studyBar {
  flex-wrap: wrap;
  padding: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.studyBar span {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}
.currentCue {
  min-height: 92px;
  padding: 15px 16px;
  border-radius: 8px;
  background: #f7faf8;
  border: 1px solid #d6e7df;
  line-height: 1.75;
  font-size: 18px;
}
.word {
  min-height: auto;
  padding: 0 1px;
  border: 0;
  border-bottom: 2px solid rgba(15, 107, 93, 0.35);
  border-radius: 0;
  background: transparent;
  display: inline;
  font-size: inherit;
  line-height: inherit;
}
.word:hover { color: var(--accent); }

.sidePanel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tabs {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  flex: 1;
  background: var(--soft);
}
.tabs button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.tabBody {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}
.tabBody.active { display: block; }
.panelMeta {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}
.cue {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
}
.cue.active {
  border-color: var(--accent);
  background: #eef8f4;
}
.cue.selected {
  box-shadow: inset 3px 0 0 var(--accent-2);
}
.cueTime {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}
.cueText { line-height: 1.6; }
.empty {
  color: var(--muted);
  padding: 16px;
  text-align: center;
  background: var(--soft);
  border-radius: 8px;
}
.lookupPanel audio { width: 100%; margin: 10px 0; }
.lookupWord {
  justify-content: space-between;
  margin-bottom: 10px;
}
.lookupWord strong { font-size: 24px; margin-right: 8px; }
.lookupWord span { color: var(--muted); }
.def {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.def span {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
}
.def p { color: var(--text); margin: 5px 0; line-height: 1.55; }
.def small, .lookupSentence { color: var(--muted); line-height: 1.5; }
.lookupSentence {
  margin-top: 12px;
  padding: 10px;
  background: var(--soft);
  border-radius: 8px;
}
.simpleList .item {
  border-bottom: 1px solid var(--line);
  padding: 11px 2px;
}
.item strong {
  display: block;
  margin-bottom: 5px;
}
.item strong span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.item small { color: var(--muted); line-height: 1.45; }

.adminPage {
  padding: 18px;
  max-width: 1100px;
  margin: 0 auto;
}
.adminLogin {
  padding: 14px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
}
.statsGrid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat {
  padding: 14px;
}
.stat span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}
.stat strong {
  font-size: 26px;
  display: block;
  margin-top: 6px;
}
.adminTable {
  padding: 14px;
  overflow: auto;
}
.row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 230px 70px 70px 70px;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.row.head {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 980px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .auth { flex-wrap: wrap; }
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }
  .sidePanel { min-height: 520px; }
  .statsGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .studyBar span { width: 100%; margin-left: 0; }
}
