/* ---------------------------------------------------------
   Focus Mitra — "night study desk"
   Ink-blue room, one warm lamp. The signature interaction is
   Lights out: the chrome dims and only the lecture + notes
   stay lit, like switching off the room lights.
---------------------------------------------------------- */

:root {
  --ink: #0f151e;        /* room */
  --panel: #171f2b;      /* desk surfaces */
  --panel-2: #1d2735;
  --line: #2a3547;
  --paper: #ede7da;      /* warm text, like paper under lamp light */
  --muted: #8a94a3;
  --lamp: #efae58;       /* the lamp */
  --lamp-soft: rgba(239, 174, 88, 0.14);
  --danger: #d97a6c;
  --radius: 14px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Spline Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 600px at 78% -10%, rgba(239,174,88,0.07), transparent 60%),
    var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px 14px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  font-size: 26px;
  filter: drop-shadow(0 0 14px var(--lamp-soft));
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: 0.2px;
  margin: 0;
}

.tagline {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.lamp-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.lamp-btn:hover { border-color: var(--lamp); }

.lamp-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  transition: background .25s, box-shadow .25s;
}

body.focus-mode .lamp-dot {
  background: var(--lamp);
  box-shadow: 0 0 10px 2px var(--lamp-soft), 0 0 0 3px rgba(239,174,88,0.12);
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 22px;
  padding: 22px 26px;
  max-width: 1380px;
  margin: 0 auto;
}

/* ---------- rail (queue) ---------- */

.rail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  align-self: start;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}

.rail-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.add-form { margin-bottom: 18px; }

.add-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.add-row input {
  flex: 1;
  min-width: 0;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--paper);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
}

.add-row input:focus {
  outline: 2px solid var(--lamp);
  outline-offset: 1px;
  border-color: transparent;
}

.add-row button {
  background: var(--lamp);
  color: #221602;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform .12s ease, filter .2s;
}

.add-row button:hover { filter: brightness(1.06); }
.add-row button:active { transform: scale(0.97); }

.hint {
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.hint.error { color: var(--danger); }

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.count {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  padding: 1px 9px;
  border-radius: 999px;
}

.queue {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.queue-item {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.queue-item:hover { border-color: #3b4a63; }

.queue-item.active {
  border-color: var(--lamp);
  background: linear-gradient(0deg, var(--lamp-soft), var(--lamp-soft)), var(--panel-2);
}

.queue-thumb {
  width: 68px;
  height: 40px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--ink);
}

.queue-meta { flex: 1; min-width: 0; }

.queue-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.queue-item.watched .queue-title { color: var(--muted); }

.queue-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.queue-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 6px;
  line-height: 1;
}

.icon-btn:hover { color: var(--paper); background: var(--line); }
.icon-btn.del:hover { color: var(--danger); }

.rail-empty { padding: 22px 6px; text-align: center; font-size: 13.5px; }
.rail-empty p { margin: 4px 0; }
.muted { color: var(--muted); }

/* ---------- stage ---------- */

.stage { min-width: 0; }

.player-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.player-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-empty {
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 24px;
}

.empty-lamp {
  font-size: 44px;
  filter: drop-shadow(0 0 26px var(--lamp-soft));
  margin-bottom: 6px;
}

.player-empty h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  margin: 0;
}

.player-empty p { color: var(--muted); margin: 4px 0 0; }

.now-playing {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
}

.np-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lamp);
  white-space: nowrap;
}

.np-title {
  font-family: var(--font-display);
  font-size: 16.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- notes ---------- */

.notes {
  margin-top: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.notes-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.notes-head h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  margin: 0;
}

.notes-head p { margin: 2px 0 0; font-size: 12.5px; }

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

.ghost-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s;
}

.ghost-btn:hover { border-color: var(--lamp); }

#notesArea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.65;
  padding: 14px;
}

#notesArea:focus {
  outline: 2px solid var(--lamp);
  outline-offset: 1px;
  border-color: transparent;
}

/* ---------- footer ---------- */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 26px 22px;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 1380px;
  margin: 0 auto;
}

/* ---------- signature: Lights out ---------- */

body.focus-mode .dimmable {
  opacity: 0.16;
  transition: opacity .5s ease;
}

body.focus-mode .dimmable:hover,
body.focus-mode .dimmable:focus-within {
  opacity: 1;
}

.dimmable { transition: opacity .5s ease; }

body.focus-mode .player-wrap,
body.focus-mode .notes {
  box-shadow: 0 0 0 1px rgba(239,174,88,0.25), 0 0 60px rgba(239,174,88,0.06);
}

/* ---------- focus visibility & motion ---------- */

button:focus-visible, input:focus-visible, textarea:focus-visible, .queue-item:focus-visible {
  outline: 2px solid var(--lamp);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .rail { position: static; max-height: none; order: 2; }
  .stage { order: 1; }
  .topbar { padding: 14px 16px 12px; }
  .foot { flex-direction: column; gap: 4px; padding: 12px 16px 20px; }
  .np-title { white-space: normal; }
}
