:root {
  --ink: #eef1f4;
  --ink-dim: rgba(238, 241, 244, 0.62);
  --ink-faint: rgba(238, 241, 244, 0.38);
  --glass: rgba(14, 18, 24, 0.52);
  --glass-strong: rgba(14, 18, 24, 0.72);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #f3c98b;
  --accent-2: #9fd4ff;
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0e12; color: var(--ink); font-family: var(--sans); }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
button { font: inherit; color: inherit; }
kbd { font-family: var(--sans); font-size: 10px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--ink-faint); }

.ui { transition: opacity 0.5s ease, transform 0.5s ease; }
body.hide-ui .ui, body.cine .ui { opacity: 0; pointer-events: none; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at 50% 40%, #1a2230, #07090c 70%);
  transition: opacity 1.1s ease;
}
#loader.gone { opacity: 0; pointer-events: none; }
.ld-title { font-family: var(--serif); font-weight: 600; font-size: clamp(34px, 6vw, 64px); letter-spacing: 0.08em; }
.ld-bar { width: min(320px, 70vw); height: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; border-radius: 2px; }
.ld-bar i { display: block; height: 100%; width: 40%; background: var(--accent); animation: ld 1.3s ease-in-out infinite; }
@keyframes ld { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.ld-sub { font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-dim); }

/* ---------- title block ---------- */
#titleblock {
  position: fixed; top: 20px; left: 22px; z-index: 5; padding: 18px 22px 16px; width: 330px;
  background: var(--glass); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--line); border-radius: 14px;
}
#titleblock h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 38px; line-height: 1; letter-spacing: 0.04em; }
.rule { display: flex; align-items: center; gap: 10px; margin: 10px 0 14px; font-family: var(--serif); font-size: 15px; letter-spacing: 0.22em; color: var(--ink-dim); }
.rule::before, .rule::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; }
.stats div { min-width: 0; }
.stats dt { font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.stats dd { margin: 3px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.note { margin: 12px 0 0; font-size: 12px; color: var(--accent); }

/* ---------- side panel ---------- */
#panel {
  position: fixed; top: 20px; right: 22px; z-index: 5; width: 262px; padding: 6px 16px;
  background: var(--glass); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--line); border-radius: 14px; font-size: 12.5px;
}
#panel section { padding: 12px 0; }
#panel section + section { border-top: 1px solid var(--line); }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row.head { margin-bottom: 8px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.12em; font-size: 10.5px; }
.row.head b { font-size: 16px; color: var(--ink); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.dim { color: var(--ink-faint); }
#cut-label { font-weight: 500; font-variant-numeric: tabular-nums; }
input[type='range'] { width: 100%; accent-color: var(--accent); margin: 4px 0; }
input[type='range']:disabled { opacity: 0.35; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chips button {
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); border-radius: 999px; padding: 4px 9px; font-size: 11px; cursor: pointer;
}
.chips button:hover { background: rgba(255, 255, 255, 0.12); }
.toggles { display: flex; flex-direction: column; gap: 7px; }
.toggles label { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.toggles label span { flex: 1; }
.toggles input[type='checkbox'] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.actions button {
  width: 100%; padding: 8px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); cursor: pointer;
}
.actions button:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------- view bar ---------- */
#views {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%); z-index: 5; display: flex; gap: 4px; padding: 5px;
  background: var(--glass-strong); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 14px;
  max-width: calc(100vw - 32px); overflow-x: auto;
}
#views button {
  display: flex; align-items: center; gap: 7px; white-space: nowrap; border: 0; background: transparent; padding: 9px 13px; border-radius: 10px;
  font-size: 13px; cursor: pointer; color: var(--ink-dim);
}
#views button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.07); }
#views button.on { color: #11151a; background: var(--ink); }
#views button.on kbd { color: rgba(0, 0, 0, 0.45); border-color: rgba(0, 0, 0, 0.18); }
#views button.cine { color: var(--accent); }

/* ---------- hud ---------- */
#hud {
  position: fixed; left: 22px; bottom: 16px; z-index: 5; font-size: 11px; letter-spacing: 0.08em; color: var(--ink-dim);
  font-variant-numeric: tabular-nums; display: flex; gap: 8px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#hud .hint { margin-left: 14px; color: var(--ink-faint); letter-spacing: 0.02em; }
#sheet {
  position: fixed; right: 22px; bottom: 16px; z-index: 5; font-size: 10.5px; letter-spacing: 0.18em; color: var(--ink-faint);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#sheet b { margin-left: 10px; font-family: var(--serif); font-size: 15px; letter-spacing: 0.06em; color: var(--ink-dim); }

/* ---------- annotations ---------- */
.labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
body.no-labels .labels, body.cine .labels { display: none; }
.callout { display: flex; align-items: center; gap: 0; pointer-events: none; transform-origin: left center; }
.callout .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18); flex: none; }
.callout .ln { width: 46px; height: 1px; background: rgba(255, 255, 255, 0.7); flex: none; }
.callout .tx {
  padding: 4px 9px; border-radius: 6px; background: rgba(10, 13, 18, 0.62); border: 1px solid var(--line);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); white-space: nowrap;
}
.callout b { display: block; font-size: 11px; letter-spacing: 0.14em; font-weight: 600; }
.callout small { display: block; font-size: 10.5px; color: var(--ink-dim); margin-top: 1px; }
.callout.ghost .dot { background: var(--accent-2); }
.callout.ghost b { color: var(--accent-2); }

/* ---------- cinematic ---------- */
#bars .bar { position: fixed; left: 0; right: 0; height: 0; background: #000; z-index: 8; transition: height 0.9s cubic-bezier(0.6, 0, 0.2, 1); }
#bars .top { top: 0; }
#bars .bottom { bottom: 0; }
body.cine #bars .bar { height: 10.5vh; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 9; }
#shot-title {
  position: fixed; left: 6vw; bottom: calc(10.5vh + 34px); z-index: 10; display: flex; align-items: center; gap: 16px;
  opacity: 0; transform: translateY(10px); transition: opacity 0.9s ease, transform 0.9s ease; pointer-events: none;
}
#shot-title.show { opacity: 1; transform: none; }
#shot-title .n { font-family: var(--serif); font-size: 44px; color: var(--accent); line-height: 1; }
#shot-title b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: 0.04em; }
#shot-title small { display: block; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-dim); margin-top: 4px; }
#cine-hint {
  position: fixed; right: 4vw; top: calc(10.5vh + 18px); z-index: 10; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint); opacity: 0; transition: opacity 0.6s; pointer-events: none;
}
body.cine #cine-hint { opacity: 1; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  #titleblock { width: auto; right: 16px; left: 16px; top: 12px; padding: 12px 16px; }
  #titleblock h1 { font-size: 28px; }
  .stats dd { font-size: 13px; }
  #panel { top: auto; bottom: 112px; right: 16px; width: 230px; max-height: 46vh; overflow: auto; }
  #views { bottom: 40px; }
  #hud .hint, #sheet { display: none; }
  #hud { left: 16px; }
}
