/* PicsNBeats — desktop APP shell. Layers on styles.css (tokens + component styles)
   and turns the page into a full-height application: top bar, accordion sidebar,
   centered preview stage, bottom waveform. */

:root[data-theme='dark'] { --app-panel: #111114; --app-stage: #0a0a0b; }
:root[data-theme='light'] { --app-panel: #fafaf8; --app-stage: #f0f0ee; }

html, body.app { height: 100%; }
body.app {
  margin: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 312px 1fr;
  grid-template-rows: 58px minmax(0, 1fr) clamp(150px, 23vh, 220px);
  grid-template-areas:
    "top  top"
    "side stage"
    "side wave";
  height: 100vh;
}
@media (max-width: 760px) {
  body.app { grid-template-columns: 1fr; grid-template-rows: 58px auto minmax(0, 1fr) clamp(140px, 22vh, 200px); grid-template-areas: "top" "side" "stage" "wave"; overflow: auto; }
  .sidebar { max-height: 42vh; }
}

/* ---------- sign-in gate ---------- */
.login-gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--app-stage);
}
.login-gate.hidden { display: none; }
.login-card {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--app-panel); border: 1.5px solid var(--border);
  padding: 28px 26px;
}
.login-brand { font-family: var(--display); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.02em; text-transform: uppercase; text-align: center; }
.login-sub { margin: -4px 0 6px; text-align: center; color: var(--muted); font-family: var(--mono); font-size: 0.74rem; }
.login-field { display: flex; flex-direction: column; gap: 5px; font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.login-field input {
  font-family: var(--mono); font-size: 0.9rem; color: var(--ink);
  background: var(--field-bg); border: 1.5px solid var(--border); border-radius: 0; padding: 9px 11px;
}
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-btn { margin-top: 6px; width: 100%; justify-content: center; padding: 11px; }
.login-error { margin: 0; min-height: 1em; text-align: center; color: var(--danger); font-family: var(--mono); font-size: 0.72rem; }

/* ---------- top bar ---------- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--app-panel);
  position: relative; z-index: 20;
  animation: none; /* override styles.css `header { animation: rise }` (conflicts with GSAP) */
}
.brand {
  font-family: var(--display); font-weight: 800; font-size: 1.25rem;
  letter-spacing: -0.02em; text-transform: uppercase; white-space: nowrap;
}
.brand .wm-n { background: var(--accent); color: var(--accent-ink); padding: 0 0.12em; margin: 0 0.04em; display: inline-block; }

/* tool tabs (Slideshow / Animate) */
.mode-nav { display: flex; gap: 2px; margin-left: 6px; }
.mode-link {
  font-family: var(--mono); font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); text-decoration: none;
  padding: 7px 12px; border: 1.5px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.mode-link:hover { color: var(--ink); }
.mode-link.active { color: var(--ink); border-color: var(--border); background: var(--accent-dim); }
@media (max-width: 760px) { .mode-nav { display: none; } }

.toolbar { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.tb-sep { width: 1px; height: 24px; background: var(--rule); margin: 0 2px; }
/* theme toggle → icon only (moon in dark, sun in light). Overrides styles.css. */
.topbar .theme-toggle {
  position: static; top: auto; right: auto;
  background: transparent; border: none; padding: 6px; gap: 0;
  color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.topbar .theme-toggle:hover { background: transparent; color: var(--accent); }
.topbar .theme-toggle::after { content: none !important; }
:root[data-theme='dark'] .topbar .theme-toggle .icon-sun { display: none; }
:root[data-theme='light'] .topbar .theme-toggle .icon-moon { display: none; }

.tbtn {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  background: transparent; color: var(--ink);
  border: 1.5px solid var(--border); border-radius: 0; padding: 8px 14px; cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
}
.tbtn:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); border-color: var(--border); }
.tbtn:active:not(:disabled) { transform: translateY(1px); }
.tbtn:disabled { opacity: 0.4; cursor: not-allowed; }
.tbtn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tbtn.primary:hover:not(:disabled) { background: transparent; color: var(--ink); border-color: var(--border); }
.tbtn.ghost { background: transparent; }
.tbtn.danger { border-color: rgba(255,98,98,0.5); color: var(--danger); }

/* edit-mode transform inspector — single transparent row flush in the preview's
   top-right corner. #id beats the web `#inspector { margin/padding/border-top }`
   rule from styles.css (which otherwise pushes it down with a gap). It lives
   inside #canvas-wrap, so it tracks the preview edge regardless of letterboxing. */
#inspector.insp-panel {
  position: absolute; top: 8px; right: 8px; z-index: 7;
  margin: 0; padding: 0; border: none; box-shadow: none; background: transparent;
  display: flex; flex-direction: row; align-items: center; gap: 10px;
}
#inspector.insp-panel.hidden { display: none; }
.insp-grid { display: flex; align-items: center; gap: 9px; }
.insp-grid label { display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55); }
.insp-panel input[type="number"] {
  width: 4ch; box-sizing: content-box; font-family: var(--mono); font-size: 0.72rem;
  background: var(--field-bg); color: var(--ink); border: 1.5px solid var(--border);
  border-radius: 0; padding: 3px 5px; text-align: right;
}
.insp-panel #btn-reset-cue { padding: 4px 9px; font-size: 0.62rem; }

/* number inputs: hide the spin buttons (they steal width and clip the value) */
.app input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.app input[type="number"]::-webkit-outer-spin-button,
.app input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* render progress fills the toolbar's empty middle while exporting.
   Use #id.class so it beats the base `#export-progress` panel box from styles.css. */
#export-progress.topprogress {
  flex: 1; min-width: 0; margin: 0; padding: 0 24px;
  background: transparent; border: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.topprogress #export-status { margin: 0; color: var(--accent); font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.topprogress .bar { margin: 0; width: 100%; max-width: 460px; height: 6px; border: 1.5px solid rgba(200, 245, 73, 0.45); background: transparent; }

/* ---------- sidebar accordion ---------- */
.sidebar {
  grid-area: side;
  border-right: 1px solid var(--rule);
  background: var(--app-panel);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
}
.acc { border-bottom: 1px solid var(--rule); }
.acc-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: transparent; color: var(--ink); border: 0; cursor: pointer;
  padding: 16px; font: inherit; text-align: left;
  transition: background 0.15s;
}
.acc-head:hover { background: var(--accent-dim); }
.acc-num { font-family: var(--mono); font-size: 0.7rem; color: var(--accent); letter-spacing: 0.12em; }
.acc-title { font-family: var(--display); font-weight: 800; text-transform: uppercase; font-size: 0.95rem; letter-spacing: -0.01em; }
.acc-meta { margin-left: auto; font-family: var(--mono); font-size: 0.66rem; color: var(--muted); }
.acc-chev { margin-left: 8px; color: var(--muted); font-size: 1.1rem; line-height: 1; transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
.acc.open .acc-head { background: var(--accent-dim); }
.acc.open .acc-chev { transform: rotate(90deg); color: var(--accent); }

/* smooth collapse: CSS height transition; app-shell.js measures height once per toggle */
.acc-panel { height: 0; overflow: hidden; transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
@media (prefers-reduced-motion: reduce) { .acc-panel { transition: none; } .acc-chev { transition: none; } }

.acc-inner { padding: 4px 14px 14px; }
.acc-inner .dropzone { padding: 16px 14px; }
.acc-inner .thumbs { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); max-height: 220px; }
.acc-inner .img-tools { gap: 6px; margin-top: 12px; }

/* compact Style panel so it fits without scrolling */
.acc-inner .mode-row { gap: 8px; }
.acc-inner .mode-box { padding: 9px 11px; }
.acc-inner .mode-box strong { font-size: 0.72rem; }
.acc-inner .mode-box p { margin-top: 3px; font-size: 0.66rem; line-height: 1.35; }
.acc-inner .options-grid { grid-template-columns: 1fr 1fr; gap: 9px 12px; margin-top: 11px; }
.acc-inner .options-grid label { min-width: 0; gap: 4px; font-size: 0.58rem; }
.acc-inner .options-grid label.check { font-size: 0.74rem; }
/* let grid children shrink so long <select>/inputs never overflow the sidebar */
.acc-inner .options-grid select,
.acc-inner .options-grid input[type="number"],
.acc-inner .options-grid input[type="color"] { width: 100%; min-width: 0; box-sizing: border-box; padding: 7px 8px; font-size: 0.76rem; }
.acc-inner .options-grid input[type="range"] { width: 100%; min-width: 0; height: 26px; }

/* "Render on a server" block in the Export panel */
.srv-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule); }
.srv-block > .check { font-size: 0.74rem; }
.srv-block > .check .hint { font-size: 0.64rem; }
.srv-block #srv-fields { margin-top: 10px; }
.srv-block #srv-fields.hidden { display: none; }

/* music track card */
.track-card { margin-top: 12px; border: 1.5px solid var(--rule); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.track-card.hidden { display: none; }
.track-name { font-family: var(--mono); font-size: 0.8rem; color: var(--ink); word-break: break-word; }
.track-meta { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- preview stage ---------- */
.stage {
  grid-area: stage; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0; padding: 0; margin: 0; max-width: none;
  background: var(--app-stage);
}
.stage .canvas-wrap { max-width: 100%; max-height: 100%; aspect-ratio: 16 / 9; } /* JS sets the ratio */
.stage #canvas { display: block; width: 100%; height: 100%; }

/* transport overlays the bottom of the preview */
.stage .transport {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  margin: 0; padding: 12px 16px 14px; gap: 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
}
.stage .transport .time { color: #d8d8d2; }
.stage .transport .vol-label { color: #b8b8b2; }

/* editing help "?" (only while editing) */
.preview-help {
  position: absolute; right: 14px; bottom: 62px; z-index: 6;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); border: none;
  font-family: var(--mono); font-weight: 700; font-size: 0.95rem; cursor: help;
  display: none; align-items: center; justify-content: center;
}
body.editing .preview-help { display: flex; }
.preview-help-tip {
  position: absolute; right: 0; bottom: 40px; width: 280px;
  background: var(--invert-bg, #000); color: #fff; border: 1.5px solid var(--accent);
  padding: 12px 14px; font-size: 0.72rem; line-height: 1.5; text-align: left; font-family: var(--mono);
  opacity: 0; pointer-events: none; transform: translateY(6px); transition: opacity 0.15s, transform 0.15s;
}
.preview-help:hover .preview-help-tip, .preview-help:focus .preview-help-tip { opacity: 1; transform: translateY(0); }

/* ---------- waveform bar (header BELOW the waveform) ---------- */
.wavebar {
  grid-area: wave;
  border-top: 1px solid var(--rule); border-right: none;
  background: var(--app-panel);
  margin: 0; padding: 10px 16px 10px; text-align: left;
  display: flex; flex-direction: column; gap: 8px; min-height: 0;
}
.wavebar .timeline { flex: 1; min-height: 90px; }
.wavebar-head { display: flex; align-items: center; gap: 12px; }
.wavebar-title { font-family: var(--display); font-weight: 800; text-transform: uppercase; font-size: 0.8rem; letter-spacing: -0.01em; }
.wavebar-hint { margin-left: auto; }

/* ---------- LIGHT MODE ONLY: lime is too pale directly on white ---------- */
/* Use the darker olive accent (--accent-strong) wherever the lime sits straight
   on a white surface with nothing behind it. Dark mode is untouched. */
:root[data-theme='light'] .acc-num { color: var(--accent-strong); }
:root[data-theme='light'] .acc.open .acc-chev { color: var(--accent-strong); }
:root[data-theme='light'] .topprogress #export-status { color: var(--accent-strong); }
:root[data-theme='light'] #export-progress.topprogress .bar { border-color: var(--accent-strong); }
:root[data-theme='light'] .topprogress .bar-fill { background: var(--accent-strong); }

/* transport: drop the dark fade (looks muddy on the light stage) and darken its
   text so it stays readable without the dark backdrop behind it */
:root[data-theme='light'] .stage .transport { background: none; }
:root[data-theme='light'] .stage .transport .time { color: var(--ink); }
:root[data-theme='light'] .stage .transport .vol-label { color: var(--muted); }
