:root {
  --bg: #0f1115;
  --panel: #171a20;
  --panel-2: #1d2128;
  --panel-3: #252a33;
  --line: #323844;
  --text: #f4f1e8;
  --muted: #aeb5c0;
  --accent: #ff7a1a;
  --accent-2: #ff9c52;
  --ok: #52c77b;
  --warn: #f0b94d;
  --bad: #ec6a6a;
  --info: #71a7ff;
  --radius: 14px;
  --shadow: 0 12px 28px rgba(0,0,0,.22);
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: radial-gradient(circle at top right, rgba(255,122,26,.08), transparent 32%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--info); }
.shell { max-width: 1320px; margin: 0 auto; padding: 24px; }
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  margin-bottom: 18px;
}
.brand h1 { margin: 0; font-size: clamp(1.35rem, 2.5vw, 2rem); letter-spacing: -.02em; }
.brand p { margin: 6px 0 0; color: var(--muted); max-width: 780px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font-weight: 700;
}
.btn:hover:not(:disabled) { border-color: #555d6b; background: #232832; }
.btn-primary { background: var(--accent); color: #131313; border-color: transparent; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-danger { border-color: #6c3939; color: #ffb6b6; }
.btn-small { padding: 7px 10px; font-size: .88rem; }
.btn-ghost { background: transparent; }
.lock-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 22px; }
.lock-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: #141820; color: #d8dde6; font-size: .86rem;
}
.lock-chip::before { content: "●"; color: var(--ok); font-size: .7rem; }
.stepper {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin-bottom: 18px;
}
.step-tab {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--muted);
  padding: 12px; text-align: left;
}
.step-tab strong { display: block; color: var(--text); margin-top: 2px; }
.step-tab.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255,122,26,.2); }
.step-tab.done::after { content: " ✓"; color: var(--ok); }
.panel { background: rgba(23,26,32,.95); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.step { display: none; }
.step.active { display: block; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.section-head h2 { margin: 0; font-size: 1.08rem; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.section-body { padding: 20px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label { font-size: .88rem; color: #dfe4eb; font-weight: 700; }
.field small { color: var(--muted); line-height: 1.4; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #10141a; color: var(--text);
  padding: 11px 12px; outline: none;
}
textarea { resize: vertical; min-height: 110px; line-height: 1.48; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,122,26,.12); }
.inline-fields { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.subcard { border: 1px solid var(--line); border-radius: 12px; background: #12161c; padding: 14px; }
.subcard h3 { margin: 0 0 12px; font-size: .96rem; }
.notice { border-radius: 10px; padding: 11px 12px; border: 1px solid var(--line); color: #dfe4eb; background: #12161c; }
.notice strong { color: var(--text); }
.notice-warn { border-color: #6e5a2b; background: #241e11; }
.notice-info { border-color: #31517f; background: #111c2b; }
.notice-bad { border-color: #743f3f; background: #2a1717; }
.notice-ok { border-color: #315f40; background: #122017; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.output-box { min-height: 250px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
.arabic, .rtl { direction: rtl; text-align: right; font-family: "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif; }
.status-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 14px; }
.status-card[data-state="ready"] { border-color: #315f40; background: #122017; }
.status-card[data-state="ready_with_repairs"] { border-color: #31517f; background: #111c2b; }
.status-card[data-state="ready_with_warnings"] { border-color: #6e5a2b; background: #241e11; }
.status-card[data-state="action_required"], .status-card[data-state="cut_off"] { border-color: #743f3f; background: #2a1717; }
.status-title { font-size: 1.05rem; font-weight: 800; }
.issue-list { margin: 10px 0 0; padding-left: 20px; color: #d8dde6; }
.issue-list li { margin: 6px 0; }
.issue-code { color: var(--muted); font-family: ui-monospace, monospace; font-size: .78rem; }
.split { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(320px,.85fr); gap: 16px; }
.review-section { margin-bottom: 16px; }
.review-section > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.review-section h3 { margin: 0; font-size: 1rem; }
.editor-card { border: 1px solid var(--line); border-radius: 12px; background: #11151b; padding: 12px; margin-bottom: 10px; }
.editor-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.id-chip { font: 700 .75rem ui-monospace, monospace; border: 1px solid var(--line); padding: 4px 7px; border-radius: 7px; color: var(--muted); }
.editor-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.editor-grid .wide { grid-column: 1/-1; }
.remove-btn { border: 0; background: transparent; color: #ff9b9b; font-weight: 800; }
.language-groups { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.lang-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #11151b; }
.lang-card h3 { margin: 0 0 10px; font-size: .95rem; }
.lang-list { margin: 0; padding: 0; list-style: none; }
.lang-list li { padding: 7px 0; border-bottom: 1px solid #252a33; }
.lang-list li:last-child { border-bottom: 0; }
.prompt-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.meta-chip { border: 1px solid var(--line); background: #11151b; color: var(--muted); padding: 5px 8px; border-radius: 999px; font-size: .78rem; }
.future { opacity: .65; }
.footer { color: var(--muted); font-size: .82rem; text-align: center; margin: 20px 0 4px; }
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 390px;
  border: 1px solid var(--line); background: #12161c; color: var(--text); padding: 12px 14px; border-radius: 10px;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.bad { border-color: #743f3f; }
.storage-banner { display:none; margin-bottom:12px; }
.storage-banner.show { display:block; }
@media (max-width: 900px) {
  .grid-2,.grid-3,.split,.language-groups { grid-template-columns: 1fr; }
  .inline-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .stepper { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .topbar { flex-direction: column; }
}
@media (max-width: 560px) {
  .shell { padding: 14px; }
  .section-body { padding: 14px; }
  .inline-fields,.editor-grid { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: 1fr; }
}

/* Storyboard v1.1 */
.storyboard-mode-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.storyboard-card { border-color: #405066; background: #111821; }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.check-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 9px; background: #0f141a; color: #d9dee7;
  font-size: .82rem; cursor: pointer;
}
.check-chip input { width: auto; margin: 0; accent-color: var(--accent); }
@media (max-width: 560px) { .storyboard-mode-grid { grid-template-columns: 1fr; } }
