:root {
  --gold: #e8b54a;
  --gold-soft: #f5d98a;
  --ink: #2a2740;
  --night: #1a1830;
  --paper: #fdf8ee;
  --teal: #2e7d6b;
  --danger: #c0392b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Amiri', 'Traditional Arabic', 'Segoe UI', serif;
  background: linear-gradient(180deg, #fdf8ee 0%, #f7eeda 100%);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.7;
}
header {
  background: linear-gradient(135deg, var(--night) 0%, #2c2850 100%);
  color: #fff;
  text-align: center;
  padding: 44px 20px 36px;
  position: relative;
  overflow: hidden;
}
header::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(232,181,74,0.18) 0, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(232,181,74,0.14) 0, transparent 40%);
  pointer-events: none;
}
header > * { position: relative; }
.brand { font-size: 19px; letter-spacing: 1px; color: var(--gold-soft); margin-bottom: 8px; }
h1 { font-size: 38px; margin-bottom: 8px; }
.tagline { font-size: 17px; color: #cfcbe8; }
.hl { color: var(--gold-soft); font-weight: bold; }
main { max-width: 980px; margin: 0 auto; padding: 28px 20px 60px; }
.card {
  background: #fff;
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 8px 30px rgba(42,39,64,0.08);
  margin-bottom: 24px;
  border: 1px solid rgba(232,181,74,0.3);
}
.card h2 {
  color: var(--teal);
  font-size: 23px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  background: var(--gold);
  color: var(--night);
  border-radius: 50%;
  font-size: 15px;
  font-weight: bold;
}
textarea {
  width: 100%;
  border: 1.5px dashed rgba(232,181,74,0.6);
  border-radius: 12px;
  padding: 16px;
  font-family: inherit;
  font-size: 18px;
  color: var(--ink);
  background: var(--paper);
  resize: vertical;
  min-height: 180px;
  outline: none;
}
textarea:focus { border-color: var(--gold); background: #fff; }
.input-actions { display: flex; gap: 10px; margin-top: 10px; }
.settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.settings label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
  color: #555;
}
.settings input, .settings select {
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px;
  background: #fff;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
  color: #555;
}
.field-label {
  font-size: 15px;
  color: #555;
}
.duration-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.dur-opt {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 10px;
  padding: 8px 13px;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  color: #555;
  transition: 0.2s;
  min-width: 44px;
}
.dur-opt:hover {
  border-color: #b8a15a;
}
.dur-opt.active {
  background: linear-gradient(135deg, #d9b34a, #a8842c);
  border-color: #a8842c;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(168, 132, 44, 0.35);
}
.dur-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #777;
  font-size: 14px;
  margin-left: 4px;
}
.dur-custom input {
  width: 62px;
  padding: 8px 10px;
  text-align: center;
}
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  transition: 0.2s;
}
.btn.primary {
  background: linear-gradient(135deg, var(--teal), #1f6b58);
  color: #fff;
  width: 100%;
  font-size: 19px;
  font-weight: bold;
  padding: 15px;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border: 1.5px solid var(--gold); color: var(--teal); }
.btn.ghost:hover { background: rgba(232,181,74,0.12); }
.btn.ghost.small { padding: 7px 14px; font-size: 14px; }
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.results-head h2 { color: var(--teal); font-size: 24px; margin: 0; }
.results-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta { font-size: 14px; color: #777; }
#sceneList { display: flex; flex-direction: column; gap: 18px; }
.scene-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(232,181,74,0.4);
  box-shadow: 0 6px 20px rgba(42,39,64,0.07);
}
.scene-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.scene-num {
  background: var(--night);
  color: var(--gold-soft);
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: bold;
}
.scene-time { color: #888; font-size: 14px; }
.scene-cam { font-size: 14px; color: var(--teal); background: rgba(46,125,107,0.1); padding: 3px 12px; border-radius: 12px; }
.scene-narr {
  background: rgba(46,125,107,0.12);
  border: 1px solid rgba(46,125,107,0.4);
  color: var(--teal);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 600;
}
.prompt-box {
  background: var(--night);
  color: #e9e6fa;
  border-radius: 12px;
  padding: 16px 18px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.8;
  direction: ltr;
  text-align: left;
  margin: 10px 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.ar-desc {
  background: var(--paper);
  border-right: 4px solid var(--gold);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 17px;
  margin-top: 10px;
}
.scene-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.copy-btn { background: var(--teal); color: #fff; border: none; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-family: inherit; font-size: 15px; }
.copy-btn:hover { filter: brightness(1.1); }
.copy-btn.alt { background: var(--gold); color: var(--night); }
.variant-btn { background: transparent; border: 1.5px solid var(--gold); color: var(--teal); border-radius: 8px; padding: 8px 16px; cursor: pointer; font-family: inherit; font-size: 15px; }
.variant-btn:hover { background: rgba(232,181,74,0.15); }
.variant-btn.alt { border-color: var(--teal); color: var(--gold); }
.narr-warn {
  background: rgba(214, 121, 120, 0.18);
  border: 1px solid rgba(214, 121, 120, 0.6);
  color: #e29a97;
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 600;
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--night);
  color: var(--gold-soft);
  padding: 12px 26px;
  border-radius: 30px;
  font-size: 16px;
  opacity: 0;
  transition: 0.3s;
  z-index: 99;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.title-field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: #555; margin-bottom: 12px; }
.title-field input {
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 17px;
  background: #fff;
  outline: none;
}
.title-field input:focus { border-color: var(--gold); }
.chars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
}
.char-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(232,181,74,0.4);
  box-shadow: 0 6px 20px rgba(42,39,64,0.08);
  transition: 0.2s;
}
.char-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(42,39,64,0.14); }
.char-swatches { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 18px 12px 10px; }
.char-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.8); box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.char-card .char-meta { padding: 10px 12px 14px; text-align: center; }
.char-card .char-name { font-size: 18px; font-weight: bold; color: var(--ink); }
.char-card .char-role { font-size: 14px; color: var(--teal); }
.char-card .char-en { font-size: 12px; color: #999; direction: ltr; }
.cover-prompt-box { margin-top: 18px; background: #fff; border-radius: 14px; border: 1px solid rgba(232,181,74,0.4); padding: 16px; }
.cover-prompt-box h3 { color: var(--teal); font-size: 17px; margin-bottom: 10px; }
#coverPromptText {
  width: 100%;
  border: 1.5px solid rgba(46,125,107,0.4);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.7;
  direction: ltr;
  text-align: left;
  color: var(--ink);
  background: var(--paper);
  min-height: 200px;
  resize: vertical;
  outline: none;
  white-space: pre-wrap;
}
footer { text-align: center; color: #7a7694; font-size: 14px; padding: 24px 20px; }
@media (max-width: 640px) {
  h1 { font-size: 27px; }
  .results-head { flex-direction: column; align-items: flex-start; }
}
