:root {
  --bg: #f6f3ea;
  --card: #fffdf8;
  --ink: #1a1a1a;
  --muted: #666;
  --accent: #0f2744;
  --gold: #c9a227;
  --border: #e2d6a8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  direction: rtl;
  text-align: right;
  line-height: 1.5;
}
header, main { max-width: 960px; margin: 0 auto; padding: 16px; }
header h1 { margin: 0 0 4px; color: var(--accent); }
.muted { color: var(--muted); }
nav a { margin-left: 12px; color: var(--accent); }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
label { display: block; margin: 10px 0; font-weight: 600; }
input, textarea, button {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  font: inherit;
  border-radius: 8px;
  border: 1px solid #ccc;
}
button {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  margin-top: 14px;
  width: auto;
  min-width: 160px;
}
button.secondary { background: #5a6a7a; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid #e5e5e5; padding: 8px; text-align: right; vertical-align: top; }
.badge {
  display: inline-block;
  background: #eef3f9;
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.result {
  background: #111;
  color: #d6ffd6;
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
  direction: ltr;
  text-align: left;
  min-height: 2em;
}
.error { border-color: #c44; background: #fff5f5; }
.hits li { margin-bottom: 12px; }
textarea#project { font-family: Consolas, monospace; direction: ltr; text-align: left; }

.style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
@media (max-width: 700px) {
  .style-grid { grid-template-columns: 1fr; }
}
.style-grid label { font-weight: 600; }
.style-grid input[type="range"] {
  width: 100%;
  padding: 0;
  margin-top: 8px;
}
.style-grid .val {
  display: inline-block;
  min-width: 2.5em;
  color: var(--muted);
  font-weight: 400;
  margin-right: 6px;
}
.style-grid select { margin-top: 6px; }

.caption-preview {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}
.caption-preview .phone {
  position: relative;
  width: 180px;
  height: 320px;
  background: #222;
  border-radius: 16px;
  border: 2px solid #444;
  overflow: hidden;
}
.caption-preview .cap {
  position: absolute;
  left: 8px;
  right: 8px;
  text-align: center;
  color: #fff;
  font-weight: 700;
  line-height: 1.25;
  pointer-events: none;
}

.preview-stage {
  position: relative;
  width: min(420px, 100%);
  margin: 0 auto;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 9 / 16;
  isolation: isolate;
}
.preview-stage video#preview {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  display: block;
  background: #000;
  border-radius: 0;
}
.live-cap {
  position: absolute;
  left: 6%;
  right: 6%;
  z-index: 3;
  pointer-events: none;
  color: #fff;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  will-change: font-size, bottom, color, background, padding;
  /* no heavy transition on size — feels laggy while dragging */
  transition: color 80ms linear, background 80ms linear;
}
.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin-top: 10px;
}
.inline-check input { width: auto; margin: 0; }

.style-under-video {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.style-under-video h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}
.editor-preview-card .preview-stage {
  width: min(480px, 100%);
}

.favorites-box {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.favorites-box h3 { margin: 0 0 6px; }
.fav-row { align-items: flex-end; }
.fav-row input { flex: 1; min-width: 180px; }
.fav-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}
.fav-list li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}
.fav-name { font-weight: 700; margin-left: 10px; }

video#preview {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 8px;
}

button.linkish {
  display: inline;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  border: none;
  border-radius: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
td.actions { white-space: nowrap; }

.modal.hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.modal-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.modal-head h3 { margin: 0; font-size: 1rem; }
.modal-head button {
  margin: 0;
  min-width: 0;
  padding: 6px 12px;
}
.modal-card video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 8px;
  aspect-ratio: 9 / 16;
  object-fit: contain;
}
.modal-actions {
  margin-top: 10px;
  justify-content: flex-start;
}
.modal-actions a { color: var(--accent); font-weight: 600; }
