@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;
  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;
  padding: .75rem 1.25rem;
  background: var(--ink);
  color: #fff;
}
.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; }
.container.wide { max-width: 1320px; }
.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: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 1.25rem; align-items: start; }
.stage { display: grid; gap: 1rem; min-width: 0; }

.ideas { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.idea { 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 details summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.idea .actions { margin-top: auto; padding-top: .5rem; }

.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; }
.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: sticky; top: 1rem; display: flex; flex-direction: column; max-height: calc(100vh - 2rem); padding: 1rem; }
.messages { list-style: none; padding: 0; margin: 0 0 .75rem; overflow-y: auto; display: grid; gap: .6rem; flex: 1; min-height: 120px; align-content: start; }
.message { padding: .5rem .8rem; border-radius: 12px; font-size: .93rem; }
.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; }
.tool { font-size: .75rem; padding: 0 .5rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--muted); }
.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; gap: .5rem; }
.chat-actions { display: flex; gap: .5rem; }

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

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .chat { position: static; max-height: none; }
  .messages { max-height: 60vh; }
  .topbar { gap: .75rem; padding: .6rem .9rem; flex-wrap: wrap; }
}
