:root {
  --bg: #0b0e11;
  --bg-2: #13181d;
  --bg-3: #1a2128;
  --ink: #f4ece3;
  --muted: #9a9f9a;
  --muted-2: #6f7670;
  --line: rgba(244, 236, 227, 0.1);
  --line-strong: rgba(244, 236, 227, 0.18);
  --accent: #e2a04a;
  --accent-soft: rgba(226, 160, 74, 0.14);
  --accent-glow: rgba(226, 160, 74, 0.22);
  --ok: #c4b08a;
  --danger: #d97a6c;
  --radius: 18px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
  --scroll-track: #0b0e11;
  --scroll-thumb: #3f3a32;
  --scroll-thumb-hover: #5c5346;
}

* { box-sizing: border-box; }

html {
  color-scheme: dark only;
}

html, body { margin: 0; min-height: 100%; }

/* Page scrollbar: solid dark track — never bright OS white/blue */
html, body {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  background: var(--scroll-track);
}
html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: var(--scroll-track);
}
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid var(--scroll-track);
  background-clip: padding-box;
}
html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  border: 2px solid var(--scroll-track);
  background-clip: padding-box;
}
html::-webkit-scrollbar-corner,
body::-webkit-scrollbar-corner {
  background: var(--scroll-track);
}

/* Nested panels: hide scrollbar chrome, keep scroll */
.scroll-quiet,
.ref-list,
.kind-chips,
.asset-list {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}
.scroll-quiet::-webkit-scrollbar,
.ref-list::-webkit-scrollbar,
.kind-chips::-webkit-scrollbar,
.asset-list::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent !important;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 8% -8%, rgba(226, 160, 74, 0.13), transparent 58%),
    radial-gradient(800px 420px at 100% 0%, rgba(196, 176, 138, 0.05), transparent 50%),
    linear-gradient(180deg, #10151a 0%, var(--bg) 42%, #080a0c 100%);
  overflow-x: hidden;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}
.glow {
  pointer-events: none;
  position: fixed;
  width: 38vw;
  height: 38vw;
  right: -12vw;
  bottom: -12vw;
  background: radial-gradient(circle, rgba(226,160,74,0.1), transparent 70%);
  filter: blur(24px);
  z-index: 0;
}

.top, .shell, .foot, .library-page { position: relative; z-index: 1; }

.top {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.5rem 0.35rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1rem 2rem;
}
.top-nav {
  align-items: center;
  justify-content: space-between;
}
.nav {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}
.nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.nav a:hover { color: var(--ink); border-color: var(--line); }
.nav a.active {
  color: #1a1208;
  background: linear-gradient(135deg, var(--accent), #efc07a);
  border-color: transparent;
}
.name-link {
  text-decoration: none;
  color: inherit;
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.mark {
  width: 12px; height: 12px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #f0c078);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 3.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.88; }
}
.name {
  font-family: var(--display);
  font-size: clamp(2.35rem, 5vw, 3.4rem);
  letter-spacing: -0.02em;
  line-height: 1;
}
.tag {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
  max-width: 30rem;
  line-height: 1.45;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.35rem 1.5rem 1rem;
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 1.15rem;
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
}

.composer, .panel {
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}
.composer { padding: 1.65rem 1.7rem 1.75rem; }
.composer h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.75rem, 3.4vw, 2.4rem);
  margin: 0 0 0.45rem;
  letter-spacing: -0.01em;
}
.lede {
  color: var(--muted);
  margin: 0 0 1rem;
  line-height: 1.55;
  max-width: 40rem;
  font-size: 0.95rem;
}

.field-label {
  display: block;
  font-size: 0.74rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 600;
  margin: 0.9rem 0 0.4rem;
}

.dropzone {
  margin: 0 0 0.85rem;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 16px;
  padding: 1.2rem 1.1rem;
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 72%),
    rgba(0,0,0,0.28);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.dropzone:hover, .dropzone:focus {
  border-color: var(--accent);
  outline: none;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(226, 160, 74, 0.12);
  transform: translateY(-1px);
}
.dz-copy {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: center;
}
.dz-copy strong { font-size: 1rem; font-weight: 600; }
.dz-copy span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.asset-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0 0 0.35rem;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}
.asset-card {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,0.22);
  animation: fadeUp 0.35s ease both;
}
.asset-card .thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--bg-3);
  display: grid;
  place-items: center;
  font-size: 0.66rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  overflow: hidden;
}
.asset-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.asset-card .meta strong {
  display: block;
  font-size: 0.86rem;
  line-height: 1.25;
  word-break: break-word;
}
.asset-card .meta small {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  margin-top: 0.15rem;
}
.asset-card .controls {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: stretch;
}
.asset-card select,
.chips select {
  background: var(--bg-3);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.32rem 0.45rem;
  font: inherit;
  font-size: 0.75rem;
  color-scheme: dark;
}
.asset-card .x {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 0.25rem 0.45rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
}
.asset-card .x:hover { color: var(--danger); border-color: var(--danger); }
.brief-note {
  grid-column: 1 / -1;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.4;
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
}

.ideas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}
.ideas button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.26);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.34rem 0.72rem;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.ideas button:hover {
  border-color: rgba(226,160,74,0.5);
  background: var(--accent-soft);
  color: #ffe8c4;
}

.kind-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  max-height: 148px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 2px 2px 8px 0;
  mask-image: linear-gradient(180deg, #000 78%, transparent);
  -webkit-mask-image: linear-gradient(180deg, #000 78%, transparent);
}
.kind-chips span {
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.26rem 0.52rem;
  white-space: nowrap;
  background: rgba(0,0,0,0.18);
}
.kind-chips span em {
  font-style: normal;
  color: var(--accent);
  margin-left: 0.22rem;
}

.prompt-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 118px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.32);
  color: var(--ink);
  padding: 0.95rem 1.05rem;
  font: inherit;
  font-size: 1.02rem;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  color-scheme: dark;
}
.prompt-form textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 65%, white);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.prompt-form textarea::placeholder { color: var(--muted-2); }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-top: 0.9rem;
}
.chips {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.chips select {
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.68rem 1.2rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #efc07a);
  color: #1a1208;
  border-color: transparent;
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
}
.btn.ghost:hover { border-color: var(--line-strong); background: rgba(255,255,255,0.03); }
.btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
.btn.danger:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border-color: var(--danger);
}

.job { margin-top: 1.2rem; }
.job.hidden, .player-wrap.hidden { display: none; }
.bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #b88945, var(--accent), #f0c078);
  transition: width 0.35s ease;
}
#job-msg { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.9rem; }

.format-picker {
  margin: 1rem 0 0.3rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.8rem 0.85rem 0.95rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  background: rgba(0,0,0,0.18);
}
.format-picker legend {
  padding: 0 0.35rem;
  font-size: 0.74rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 600;
}
.format-option {
  cursor: pointer;
  display: block;
  position: relative;
}
.format-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.format-card {
  display: flex;
  flex-direction: column;
  gap: 0.26rem;
  padding: 0.72rem 0.78rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.24);
  min-height: 100%;
  transition: border-color 0.2s, background 0.2s;
}
.format-option input:focus-visible + .format-card {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.format-option input:checked + .format-card {
  border-color: color-mix(in srgb, var(--accent) 65%, white);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-glow);
}
.format-option input:checked + .format-card .format-preview {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.format-card strong { font-size: 0.9rem; }
.format-card em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}
.format-preview {
  display: block;
  margin-bottom: 0.3rem;
  border-radius: 5px;
  background: linear-gradient(145deg, #2c333a, #12161a);
  border: 1px solid rgba(255,255,255,0.07);
}
.format-preview.vertical { width: 26px; height: 46px; }
.format-preview.horizontal { width: 54px; height: 30px; }
@media (max-width: 560px) {
  .format-picker { grid-template-columns: 1fr; }
}

.player-wrap { margin-top: 1.35rem; }
.player-wrap video {
  width: min(100%, 340px);
  aspect-ratio: 9 / 16;
  border-radius: 16px;
  background: #000;
  display: block;
  border: 1px solid var(--line);
  animation: fadeUp 0.55s ease both;
}
.player-wrap.horizontal video {
  width: min(100%, 720px);
  aspect-ratio: 16 / 9;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.shot-meta {
  margin-top: 0.8rem;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.5;
}

.side { display: flex; flex-direction: column; gap: 0.95rem; }
.panel { padding: 1.15rem 1.25rem; }
.panel h2 {
  margin: 0 0 0.4rem;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 600;
}
.stats { margin: 0 0 0.85rem; font-size: 1.02rem; color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.hint { min-height: 1.15em; margin: 0.65rem 0 0; color: var(--muted); font-size: 0.84rem; }
.hint.error { color: var(--danger); }
.hint.ok { color: var(--ok); }

.panel.refs {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ref-list {
  list-style: none;
  margin: 0;
  padding: 0 2px 10px 0;
  max-height: 360px;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  mask-image: linear-gradient(180deg, #000 86%, transparent);
  -webkit-mask-image: linear-gradient(180deg, #000 86%, transparent);
}
.ref-list li {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 0.65rem;
  padding: 0.4rem;
  border-radius: 11px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.ref-list li:hover {
  border-color: var(--line);
  background: rgba(255,255,255,0.025);
}
.ref-list img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-3);
}
.ref-list strong {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.3;
}
.ref-list span {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  margin-top: 0.18rem;
}

.foot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.35rem 1.5rem 1.75rem;
  color: var(--muted-2);
  font-size: 0.78rem;
}

/* —— Library page —— */
.library-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 2rem;
}
.library-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.library-head h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.9rem, 3.5vw, 2.6rem);
  margin: 0 0 0.35rem;
}
.library-head .lede { margin: 0; max-width: 36rem; }
.library-layout {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 1.1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .library-layout { grid-template-columns: 1fr; }
}
.gallery-panel, .viewer-panel {
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 420px;
}
.gallery-grid {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(70vh, 720px);
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.gallery-card {
  appearance: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.gallery-card:hover {
  border-color: var(--line);
  background: rgba(255,255,255,0.03);
}
.gallery-card.active {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-soft);
}
.gallery-card .g-del {
  appearance: none;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-2);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s, background 0.15s;
}
.gallery-card:hover .g-del,
.gallery-card.active .g-del { opacity: 1; }
.gallery-card .g-del:hover {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.g-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-3);
  border: 1px solid var(--line);
}
.g-thumb.horizontal { height: 48px; }
.g-thumb img, .g-thumb .ph {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.g-thumb .ph {
  background: linear-gradient(145deg, #2a323a, #12161a);
}
.g-meta strong {
  display: block;
  font-size: 0.9rem;
  line-height: 1.3;
}
.g-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  margin-top: 0.2rem;
}
.g-meta em {
  display: block;
  font-style: normal;
  color: var(--accent);
  font-size: 0.74rem;
  margin-top: 0.15rem;
}
.viewer-panel.empty {
  display: grid;
  place-items: center;
}
.viewer-empty {
  color: var(--muted);
  margin: 0;
}
.viewer-body.hidden { display: none; }
.viewer-body video {
  width: min(100%, 320px);
  aspect-ratio: 9 / 16;
  border-radius: 14px;
  background: #000;
  border: 1px solid var(--line);
  display: block;
  margin: 0 auto 1rem;
}
.viewer-panel.horizontal .viewer-body video,
.viewer-body video.horizontal {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
}
.viewer-body h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.55rem;
  margin: 0 0 0.4rem;
}
.viewer-prompt {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0.55rem 0 1rem;
}
.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.done-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.done-link:hover { text-decoration: underline; }

/* Native form controls stay on-theme */
select, textarea, input {
  accent-color: var(--accent);
  color-scheme: dark;
}
