@font-face {
  font-family: Estedad;
  src: url(fonts/estedad-arabic-wght-normal.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: Estedad;
  src: url(fonts/estedad-latin-wght-normal.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-200B, U+2010-206F;
}

:root {
  --ink: #16161a;
  --muted: #6b6b76;
  --line: #e6e4df;
  --ground: #f7f5f0;
  --card: #ffffff;
  --accent: #ffd43b;
  --accent-soft: #fff6d1;
  --danger: #c62828;
  --ok-soft: #e8f5e9;
  --error-soft: #fdecea;
  --radius: 14px;
  --topbar: 56px;
  --chat: 420px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Estedad, Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--ground);
}

a { color: inherit; }
h1, h2, h3 { line-height: 1.4; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .5rem; }
code { font-size: .9em; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: var(--topbar);
  padding: 0 1.25rem;
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar a { text-decoration: none; opacity: .85; }
.topbar a:hover { opacity: 1; }
.brand { font-weight: 800; opacity: 1 !important; }
.topbar-user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.topbar .link { color: #fff; }

.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
/* The project page: the chat is pinned to the left edge under the top bar; the stage takes the rest. */
.container.with-chat { max-width: none; margin: 0; padding-inline: 1.5rem calc(var(--chat) + 1.5rem); }
.container.narrow { max-width: 420px; padding-top: 12vh; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.stack { display: grid; gap: .9rem; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
input, textarea {
  font: inherit;
  font-weight: 400;
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
textarea { resize: vertical; }

.button {
  font: inherit;
  font-weight: 700;
  padding: .5rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.button.small { padding: .25rem .7rem; font-size: .85rem; }
.button:disabled { opacity: .45; cursor: default; }
.link { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; color: inherit; }
.danger { color: var(--danger); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.lead { color: var(--muted); }
.field-error { color: var(--danger); font-weight: 600; margin: 0; }
.label { font-weight: 700; font-size: .8rem; color: var(--muted); margin-inline-end: .35rem; }

.flash { padding: .6rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.flash-ok { background: var(--ok-soft); }
.flash-error { background: var(--error-soft); }
.notice { background: var(--accent-soft); border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1rem; }

.chip {
  display: inline-block;
  font-size: .8rem;
  padding: 0 .6rem;
  border-radius: 999px;
  background: var(--ground);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip-live { background: var(--accent); border-color: var(--accent); }
.chip-warn { background: var(--accent-soft); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.page-head a.muted { text-decoration: none; font-size: .9rem; }

.login h1 { margin-bottom: 1rem; }

.new-project { margin-bottom: 1.25rem; }
.new-project summary { cursor: pointer; font-weight: 700; }
.new-project form { margin-top: 1rem; }
.project-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.project-row { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.project-row strong { flex: 1; }
.project-row:hover { border-color: var(--ink); }

.more { position: relative; }
.more summary { list-style: none; cursor: pointer; font-size: 1.4rem; line-height: 1; padding: .2rem .5rem; border-radius: 8px; }
.more summary::-webkit-details-marker { display: none; }
.more[open] form { position: absolute; inset-inline-end: 0; top: 2.2rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .6rem 1rem; white-space: nowrap; z-index: 5; }

.stepper { display: flex; gap: .4rem; list-style: none; padding: 0; margin: 0 0 1.25rem; flex-wrap: wrap; }
.stepper li { font-size: .85rem; padding: .15rem .8rem; border-radius: 999px; color: var(--muted); border: 1px solid var(--line); background: #fff; }
.stepper li.done { color: var(--ink); }
.stepper li.done::before { content: "✓ "; }
.stepper li.current { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700; }

.workspace { display: block; }
.stage { display: grid; gap: 1rem; min-width: 0; max-width: 1200px; }

/* One idea per row, its parts side by side. */
.ideas { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.idea { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 1.5rem; align-items: start; }
.idea-main { display: flex; flex-direction: column; gap: .4rem; }
.idea header { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.idea .hook { font-weight: 600; }
.idea dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; font-size: .9rem; }
.idea dt { color: var(--muted); }
.idea dd { margin: 0; }
.idea-outline { border-inline-start: 1px solid var(--line); padding-inline-start: 1.5rem; font-size: .93rem; }
.idea-outline .label { display: block; margin-bottom: .2rem; }
.choose { align-self: center; display: flex; flex-direction: column; gap: .5rem; width: 15rem; }
.choose textarea { font-size: .88rem; }

.format { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .4rem; }

.choices { position: relative; min-width: 0; border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.choices legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: .35rem; }
.choice { display: block; cursor: pointer; font-weight: 400; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span { display: flex; flex-direction: column; padding: .4rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; line-height: 1.5; }
.choice small { color: var(--muted); font-size: .8rem; }
.choice input:checked + span { border-color: var(--ink); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--ink); }
.choice input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.info { display: inline-block; margin-inline-start: .4rem; vertical-align: middle; }
.info-button { width: 1.25rem; height: 1.25rem; padding: 0; border-radius: 50%; border: 1px solid var(--muted); background: #fff; color: var(--muted); font: italic 700 .75rem/1 Georgia, serif; cursor: help; }
.info:hover .info-button, .info-button:focus-visible { border-color: var(--ink); color: var(--ink); outline: none; }
.info-tip { display: none; position: absolute; top: 1.9rem; inset-inline-start: 0; z-index: 20; width: max-content; max-width: min(30rem, 100%); padding: .75rem .9rem; background: var(--ink); color: #fff; border-radius: 10px; font-weight: 400; font-size: .84rem; line-height: 1.8; box-shadow: 0 6px 24px rgba(0, 0, 0, .18); }
.info-tip::before { content: ""; position: absolute; bottom: 100%; inset-inline: 0; height: .5rem; }
.info:hover .info-tip, .info:focus-within .info-tip { display: block; }
.info-note { display: block; color: #d6d4cf; margin-bottom: .35rem; }
.info-row { display: block; }
.info-row + .info-row { margin-top: .35rem; }
.info-row strong { color: var(--accent); }

.chosen summary { cursor: pointer; font-weight: 700; }
.script-meta { display: flex; gap: .5rem; align-items: center; }
.scenes { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.scene header { display: flex; justify-content: space-between; margin-bottom: .3rem; }
.scene .narration { font-size: 1.05rem; }
.scene .on-screen { background: var(--accent-soft); border-radius: 8px; padding: .2rem .6rem; display: inline-block; }
/* Text boxes that grow to three lines with what is typed (app.js), then scroll. */
textarea.grow { resize: none; overflow-y: hidden; min-height: 0; }
textarea.comment { display: block; margin-top: .5rem; padding: .35rem .6rem; font-size: .9rem; }
.review-button.sending { background: var(--accent); color: var(--ink); border-color: var(--ink); }
.scene-comment { display: flex; gap: .5rem; margin-top: .4rem; }
.scene-comment input { padding: .3rem .6rem; font-size: .9rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.chat {
  position: fixed;
  top: var(--topbar);
  bottom: 0;
  left: 0;
  width: var(--chat);
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: var(--card);
  border-inline-start: 1px solid var(--line);
  overflow: hidden;
}
/* Long paths, words and code break inside the column; it never scrolls sideways. */
.messages { list-style: none; padding: 0; margin: 0 0 .75rem; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: .6rem; flex: 1; min-height: 120px; min-width: 0; }
.message { padding: .5rem .8rem; border-radius: 12px; font-size: .93rem; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.message p { margin: 0; }
.message-user { background: var(--ink); color: #fff; margin-inline-start: 2rem; }
.message-assistant { background: var(--ground); margin-inline-end: 1rem; }
.message-event { text-align: center; color: var(--muted); font-size: .82rem; padding: .1rem; }
.message-error { background: var(--error-soft); }
.tools { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .3rem; }
.tools-more { font: inherit; font-size: .75rem; padding: 0 .5rem; border-radius: 999px; border: 1px dashed var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.tools-more:hover { color: var(--ink); border-color: var(--muted); }
.tool { font-size: .75rem; padding: 0 .5rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--muted); max-width: 100%; overflow-wrap: anywhere; }
.tool[data-status="started"] { border-color: var(--accent); background: var(--accent-soft); }
.tool[data-status="failed"] { color: var(--danger); }
.live p:empty::after { content: "…"; color: var(--muted); }
.chat-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
.chat-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.chat-head h2 { margin: 0; }
.agent-choice summary { cursor: pointer; font-size: .82rem; color: var(--muted); }
.choice-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; margin-top: .5rem; }
.chat-head, .agent-choice { min-width: 0; max-width: 100%; }
select { max-width: 100%; min-width: 0; font: inherit; font-weight: 400; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.inline-form label { flex: 1; min-width: 0; }
.chat-actions { display: flex; gap: .5rem; }

.secret { margin-bottom: 1rem; }
.inline-form { display: flex; gap: .5rem; margin-bottom: .5rem; align-items: end; flex-wrap: wrap; }

/* The stills in reading order, with the cut between every two (a narrow column). */
.stills { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: stretch; gap: .75rem .35rem; }
/* A still's comment box grows (--grow, set by app.js) and the image gives up the same height, so the card keeps its size. */
.still { flex: 0 1 190px; padding: .5rem; display: flex; flex-direction: column; gap: .3rem; container-type: inline-size; }
.still-image { display: block; cursor: zoom-in; }
.still img { width: 100%; height: calc(100cqi * 16 / 9 - var(--grow, 0px)); object-fit: contain; border-radius: 10px; display: block; background: var(--ground); }
.stills.wide .still { flex-basis: 300px; }
.stills.wide img { height: calc(100cqi * 9 / 16 - var(--grow, 0px)); }
.still textarea.comment { width: 100%; font-size: .82rem; margin-top: auto; }
.lightbox { padding: 0; border: 0; background: transparent; max-width: 94vw; max-height: 94vh; overflow: visible; }
.lightbox::backdrop { background: rgba(10, 10, 12, .82); }
.lightbox img { display: block; max-width: 94vw; max-height: calc(94vh - 2.5rem); width: auto; height: auto; border-radius: 12px; cursor: zoom-out; }
.lightbox-caption { color: #fff; text-align: center; margin: .5rem 0 0; font-weight: 700; }
.lightbox-close { position: absolute; top: -.5rem; inset-inline-start: -.5rem; width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 0; background: #fff; color: var(--ink); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.still-meta { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; }
.still .scene-comment input { font-size: .82rem; }

/* The cut between two stills: its name opens the choices (each plays its sample while pointed at), the «i» plays the
   chosen one's sample. */
.cut { position: relative; flex: 0 0 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center; font-size: .78rem; }
.cut-arrow { font-size: 1.2rem; line-height: 1; color: var(--muted); }
.pick-name { display: block; font-weight: 700; line-height: 1.5; }
.pick-menu > summary { list-style: none; cursor: pointer; padding: .2rem .45rem; border-radius: 8px; background: var(--accent-soft); border: 1px solid var(--accent); }
.pick-menu > summary::-webkit-details-marker { display: none; }
.pick-menu > summary::after { content: ' ▾'; font-weight: 400; color: var(--muted); }
.pick-menu[open] > summary { background: var(--accent); }
.pick-by { color: var(--muted); font-size: .7rem; }
.pick-info { width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: italic 700 .8rem/1 Georgia, serif; cursor: help; padding: 0; }
.pick-info:hover, .pick-info:focus-visible { background: var(--ink); color: #fff; border-color: var(--ink); }
.pick-menu, .pick-sample { position: relative; }
.pick-peek, .pick-options { position: absolute; z-index: 30; left: 50%; transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .16); padding: .4rem; }
.pick-options { top: calc(100% + .4rem); }
.pick-peek { bottom: calc(100% + .4rem); display: none; pointer-events: none; }
.pick-info:hover + .pick-peek, .pick-info:focus + .pick-peek { display: block; }
.pick-peek video, .pick-preview { display: block; width: 135px; height: 240px; border-radius: 8px; background: #000; }
.pick-options { display: flex; gap: .5rem; align-items: flex-start; width: max-content; }
.pick-form { display: flex; flex-direction: column; gap: .15rem; margin: 0; }
.pick-option { font: inherit; font-size: .82rem; text-align: start; padding: .35rem .6rem; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; white-space: nowrap; }
.pick-option:hover, .pick-option:focus-visible { background: var(--ground); }
.pick-option.on { background: var(--accent); font-weight: 700; }
.pick-option:disabled { opacity: .5; cursor: default; }
/* A scene's background motion, under its still. The card keeps its size (container query), which also makes it a
   stacking context: while its menu or sample is open it rises over the cards after it. */
.ambient { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; font-size: .78rem; }
.ambient-label { color: var(--muted); }
.ambient .pick-menu > summary { padding: .1rem .4rem; background: var(--ground); border-color: var(--line); font-weight: 600; }
.ambient .pick-menu[open] > summary { background: var(--accent-soft); }
.ambient .pick-info { width: 1.3rem; height: 1.3rem; font-size: .72rem; }
.still:has(.pick-menu[open]), .still:has(.pick-info:hover), .still:has(.pick-info:focus) { position: relative; z-index: 31; }
@media (max-width: 560px) {
  .cut { flex-basis: 100%; flex-direction: row; justify-content: center; }
  .cut-arrow { transform: rotate(-90deg); }
}
.preview { display: flex; flex-direction: column; align-items: center; gap: .6rem; margin: 0; }
.preview video { width: 100%; max-width: 360px; aspect-ratio: 9 / 16; border-radius: 14px; background: #000; }
.preview .scene-comment { width: 100%; max-width: 420px; }
.preview.wide video { max-width: 720px; aspect-ratio: 16 / 9; }
.notice-error { background: var(--error-soft); }
details.card > summary { cursor: pointer; font-weight: 700; }

.sound summary { font-size: .92rem; }
.sound-body { display: grid; gap: 1rem; margin-top: .8rem; }
.sound-body h3 { font-size: .95rem; margin-bottom: .4rem; }
.sound audio { width: 100%; max-width: 320px; height: 36px; }
.clips { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .3rem; }
.clips li { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.takes { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .5rem; }
.take { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; }
.take.fresh { border-color: var(--accent); background: var(--accent-soft); }
.take-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; align-items: baseline; }
.take-text { margin: .3rem 0 .5rem; line-height: 1.9; }
.take-controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; min-height: 36px; }
.take-controls audio { flex: 1 1 200px; }
.record-button::first-letter { color: var(--danger); }
.button.recording { background: var(--danger); color: #fff; border-color: var(--danger); }
.icon-button { font: inherit; font-size: 1.2rem; line-height: 1; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--danger); cursor: pointer; }
.icon-button:disabled, .take-controls button:disabled { opacity: .5; cursor: default; }
.send-takes { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.send-takes progress { flex: 1 1 120px; height: 8px; accent-color: var(--ink); }
.send-takes .link { margin-inline-start: auto; font-size: .85rem; }
.rebuild { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; background: var(--accent-soft); border-radius: 10px; padding: .5rem .8rem; margin-top: .5rem; }
.final { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 1.25rem; align-items: start; }
.final video { width: 100%; aspect-ratio: 9 / 16; border-radius: 14px; background: #000; }
.final.wide { grid-template-columns: minmax(0, 1fr); }
.final.wide video { max-width: 860px; aspect-ratio: 16 / 9; }
.downloads { display: flex; flex-direction: column; gap: .6rem; align-items: stretch; }
.downloads .button { text-align: center; text-decoration: none; }

.sfx-group { margin-bottom: 1rem; }
.sfx-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.sfx { font: inherit; font-size: .85rem; display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); cursor: pointer; }
.sfx:hover { border-color: var(--ink); }
.sfx.on { background: var(--accent); border-color: var(--ink); }
.sfx-play { font-size: .7rem; color: var(--muted); }

@media (max-width: 1250px) {
  .idea { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
  .idea-outline { border-inline-start: 0; padding-inline-start: 0; border-top: 1px solid var(--line); padding-top: .6rem; }
  .choose { align-self: stretch; width: auto; }
}

@media (max-width: 900px) {
  .final { grid-template-columns: 1fr; }
  .container.with-chat { padding-inline: 1rem; }
  .chat { position: static; width: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 1.25rem; }
  .messages { max-height: 60vh; }
  .topbar { gap: .75rem; padding: .6rem .9rem; flex-wrap: wrap; height: auto; position: static; }
}

/* workspace */
.entry { border-top: 1px solid var(--line); padding: 8px 0; }
.entry:first-of-type { border-top: 0; }
.entry summary { cursor: pointer; }
.memories { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.task h2 { margin-bottom: 0; }
.live { opacity: .85; }
