:root {
  --bg: #1a1512;
  --panel: #241e19;
  --panel-raised: #2d2620;
  --cream: #f1e8d8;
  --cream-dim: #a89a86;
  --amber: #e8a33d;
  --amber-dim: #a97a34;
  --red: #d1503f;
  --font-display: "Fraunces", serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #26201b 0%, var(--bg) 60%);
  color: var(--cream);
  font-family: var(--font-body);
  padding: 32px 16px;
}

.room {
  width: 100%;
  max-width: 860px;
}

/* ---- Masthead ---- */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 20px;
  padding: 0 4px;
}

.marquee-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px 1px rgba(209, 80, 63, 0.7);
  flex-shrink: 0;
  align-self: center;
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.masthead-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(22px, 3vw, 30px);
  margin: 0;
  color: var(--cream);
}

.masthead-sub {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

/* Who's signed in. Click it to sign out. */
.masthead-user {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cream);
  background: var(--panel);
  border: 1px solid var(--amber-dim);
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.masthead-user:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.masthead-user::before {
  content: "\1F464"; /* bust in silhouette */
  font-size: 12px;
  opacity: 0.8;
}

/* ---- Player panel: slides open when a video is picked ---- */

.player-panel {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.5s ease, opacity 0.4s ease, margin-bottom 0.5s ease;
  margin-bottom: 0;
}

.player-panel.open {
  max-height: 1600px;
  opacity: 1;
  margin-bottom: 30px;
}

.now-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.now-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(18px, 2.4vw, 24px);
  margin: 0;
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-drive {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--cream-dim);
  padding: 3px 8px;
  border: 1px solid var(--cream-dim);
  border-radius: 4px;
  white-space: nowrap;
}

/* ---- Description: editable blurb under the title ---- */

.now-description {
  display: block;
  width: 100%;
  margin: 0 4px 14px;
  background: transparent;
  color: var(--cream-dim);
  border: none;
  border-bottom: 1px dashed rgba(241, 232, 216, 0.18);
  border-radius: 0;
  padding: 5px 2px;
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.now-description::placeholder {
  color: var(--cream-dim);
  opacity: 0.55;
}

.now-description:hover { border-bottom-color: rgba(241, 232, 216, 0.35); }

.now-description:focus {
  outline: none;
  color: var(--cream);
  border-bottom-color: var(--amber);
}

/* ---- Screen ---- */

.screen-wrap {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(232, 163, 61, 0.12),
    0 20px 60px -20px rgba(0, 0, 0, 0.8),
    0 0 90px -30px rgba(232, 163, 61, 0.25);
  aspect-ratio: 16 / 9;
}

#player {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 6, 0.75);
  font-family: var(--font-mono);
  color: var(--cream-dim);
  font-size: 14px;
  letter-spacing: 0.04em;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.screen-overlay.hidden { opacity: 0; }

/* ---- Sprocket track: scrub bar doubling as annotation markers ---- */

.sprocket-track {
  position: relative;
  height: 26px;
  margin-top: 10px;
  background: var(--panel);
  border-radius: 5px;
  overflow: hidden;
}

.sprocket-progress {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--amber-dim), var(--amber));
  transition: width 0.2s linear;
}

.sprocket-holes {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
}

.sprocket-hole {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  transform: translate(-50%, -50%);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4);
}

.sprocket-hole.marker {
  background: #fff;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.sprocket-hole.marker:hover { transform: translate(-50%, -50%) scale(1.35); }

.sprocket-hole.marker { box-shadow: 0 0 6px 2px rgba(232, 163, 61, 0.9); }  /* amber */

/* ---- Controls ---- */

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.time-readout {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--cream-dim);
  min-width: 100px;
}

.time-sep { margin: 0 4px; opacity: 0.5; }

.note-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: transform 0.15s ease, background 0.15s ease;
  background: var(--panel-raised);
  color: var(--cream);
  box-shadow: 0 0 0 1px rgba(241, 232, 216, 0.08);
}

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

.note-icon { color: var(--amber); font-size: 15px; }

/* Share sits beside the note button; dimmed until a video is playing. */
.share-btn[disabled] {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.status-line {
  margin: 14px 4px 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--cream-dim);
  min-height: 16px;
}

/* ---- Leave-a-note modal ---- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border-radius: 14px;
  padding: 26px 24px 24px;
  box-shadow:
    0 0 0 1px rgba(232, 163, 61, 0.14),
    0 30px 80px -20px rgba(0, 0, 0, 0.85);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--cream-dim);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.modal-close:hover { color: var(--cream); }

.modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim);
  margin: 0 0 4px;
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 20px;
  color: var(--cream);
}

.modal-title span { color: var(--amber); font-family: var(--font-mono); font-size: 18px; }

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

.field-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--cream-dim);
}

.text-input {
  width: 100%;
  background: var(--bg);
  color: var(--cream);
  border: none;
  border-radius: 8px;
  padding: 11px 13px;
  font-family: var(--font-body);
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(241, 232, 216, 0.1);
}

.text-input:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--amber);
}

.note-text-area {
  resize: vertical;
  min-height: 72px;
  line-height: 1.4;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

.save-btn {
  background: var(--amber);
  color: #241a0a;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

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

/* ---- Annotations list (below the player) ---- */

.annotations {
  margin-top: 22px;
  border-top: 1px solid rgba(241, 232, 216, 0.08);
  padding-top: 18px;
}

.annotations-head {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim);
  margin: 0 0 12px;
}

.annotation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.annotation-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border-radius: 8px;
  padding: 9px 12px;
  border-left: 3px solid var(--amber);
}

.annotation-time {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--amber);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  transition: background 0.12s ease;
}

.annotation-time:hover { background: rgba(232, 163, 61, 0.15); }

.annotation-body {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.annotation-label {
  font-size: 14px;
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Attribution: who left the note and when, tucked after the text. */
.annotation-meta {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--cream-dim);
  white-space: nowrap;
}

.annotation-edit-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--cream);
  background: var(--panel-raised);
  border: 1px solid var(--amber-dim);
  border-radius: 5px;
  padding: 5px 8px;
}

.annotation-edit-input:focus {
  outline: none;
  border-color: var(--amber);
}

.annotation-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0.45;
  transition: opacity 0.12s ease;
}

/* Idle rows keep the controls faint; hovering (or focusing one) brings them
   fully forward. They stay visible on touch, where there's no hover. */
.annotation-row:hover .annotation-actions,
.annotation-actions:focus-within {
  opacity: 1;
}

.annotation-action {
  font-size: 14px;
  line-height: 1;
  color: var(--cream-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 5px;
  transition: background 0.12s ease, color 0.12s ease;
}

.annotation-action:hover { background: rgba(232, 163, 61, 0.15); color: var(--cream); }
.annotation-action.delete:hover { background: rgba(209, 80, 63, 0.18); color: var(--red); }

.annotations-empty {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--cream-dim);
  margin: 0;
}

/* ---- Library: hard drives and their videos ---- */

.library-loading {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--cream-dim);
  padding: 4px;
}

.library-loading code {
  color: var(--amber);
  background: rgba(232, 163, 61, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
}

.drive-group { margin-bottom: 26px; }

.drive-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 10px;
  border-bottom: 1px solid rgba(241, 232, 216, 0.08);
}

.drive-icon { font-size: 17px; }

.drive-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--cream);
}

.drive-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--cream-dim);
}

.video-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.video-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(241, 232, 216, 0.04);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.video-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(232, 163, 61, 0.4);
}

.video-item.active {
  background: var(--panel-raised);
  box-shadow: 0 0 0 1px var(--amber);
}

.video-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.video-title {
  font-size: 14.5px;
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-desc {
  font-size: 12.5px;
  color: var(--cream-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-desc[hidden] { display: none; }

.video-meta {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cream-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.video-badge { color: var(--amber); }

@media (prefers-reduced-motion: reduce) {
  .marquee-dot { animation: none; }
  .player-panel { transition: opacity 0.2s ease; }
}

/* ---- Sign-in page ---- */

.login-room {
  max-width: 420px;
}

.login-panel {
  background: var(--panel-raised);
  border: 1px solid rgba(241, 232, 216, 0.08);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Give each label a little breathing room above its input. */
.login-form .field-label {
  margin-top: 8px;
}
.login-form .field-label:first-child {
  margin-top: 0;
}

.login-error {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--red);
}

.login-panel .panel-actions {
  justify-content: stretch;
  margin-top: 16px;
}

.login-panel .save-btn {
  width: 100%;
}
