:root {
  /* Media Studio identity: indigo + teal. Deliberately unlike the Mujtaba
     site (navy + red) so the tool reads as its own thing. The variable names
     (navy/accent) are kept for brevity; the values are what matter. */
  --navy: #3730a3;        /* header / primary indigo */
  --navy-deep: #262166;
  --steel: #4f46e5;       /* secondary indigo (hovers) */
  --accent: #0d9488;      /* teal action colour */
  --accent-deep: #0f766e;
  --ink: #1f2733;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #eef1f7;
  --card: #ffffff;
  --ok: #15803d;
  --err: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 27, 75, 0.06), 0 8px 24px rgba(30, 27, 75, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: linear-gradient(120deg, var(--navy), var(--navy-deep));
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: block; border-radius: 10px; }
.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: 0.2px; }
.brand p { margin: 0; font-size: 0.8rem; color: #b9c6d6; }

.wrap { max-width: 940px; margin: 0 auto; padding: 20px 16px 120px; display: grid; gap: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.card h2 { font-size: 1.02rem; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 0.85rem; font-weight: 700;
}
.hint { color: var(--muted); font-size: 0.82rem; margin: 6px 0 14px; }

/* Presets */
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.preset {
  text-align: left; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 12px 14px; transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.preset:hover { border-color: #b9c6d6; }
.preset:active { transform: translateY(1px); }
.preset.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14); }
.preset .name { font-weight: 700; display: block; }
.preset .meta { color: var(--muted); font-size: 0.76rem; }

/* Fields */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-weight: 600; font-size: 0.85rem; }
label.inline { font-weight: 500; font-size: 0.82rem; }
input[type="number"], select, input[type="text"] {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff; color: var(--ink);
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 44px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
select:focus, input:focus { outline: 2px solid var(--steel); outline-offset: 1px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 500; }
.tag { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.logo-preview {
  margin-top: 4px; height: 54px; border: 1px dashed var(--line); border-radius: 9px;
  display: grid; place-items: center; background:
    repeating-conic-gradient(#f3f6f9 0% 25%, #e7edf3 0% 50%) 50% / 16px 16px;
}
.logo-preview img { max-height: 44px; max-width: 90%; object-fit: contain; }

.wm { border: 1px solid var(--line); border-radius: 12px; padding: 8px 16px 16px; margin-top: 18px; }
.wm legend { padding: 0 6px; }
.wm.off #wmControls { opacity: 0.4; pointer-events: none; }

.pos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; max-width: 132px; }
.pos-grid button {
  aspect-ratio: 1; border: 1px solid var(--line); background: #f7f9fb; border-radius: 6px; cursor: pointer;
}
.pos-grid button.on { background: var(--accent); border-color: var(--accent); }

.video-adv { margin-top: 16px; }
.video-adv summary { cursor: pointer; font-weight: 600; font-size: 0.88rem; }
.video-adv[open] > .grid { margin-top: 14px; }

/* Dropzone */
.drop {
  border: 2px dashed #b9c6d6; border-radius: 12px; padding: 26px; text-align: center;
  background: #f7f9fb; transition: border-color 0.15s, background 0.15s;
}
.drop.over { border-color: var(--accent); background: #e6f5f3; }
.drop p { margin: 4px 0; }
.link { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

/* File list */
.files { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.file { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.file .thumb { width: 52px; height: 52px; border-radius: 7px; object-fit: cover; background: #eef2f6; }
.file .thumb.vid { display: grid; place-items: center; font-size: 1.4rem; }
.file .info { min-width: 0; }
.file .fname { font-weight: 600; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .fmeta { font-size: 0.76rem; color: var(--muted); }
.file .status { font-size: 0.78rem; font-weight: 600; text-align: right; white-space: nowrap; }
.status.queued { color: var(--muted); }
.status.working { color: var(--steel); }
.status.done { color: var(--ok); }
.status.error { color: var(--err); }
.file .remove { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.file a.dl { color: var(--accent); font-size: 0.78rem; text-decoration: none; font-weight: 600; }

/* Action bar */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; z-index: 5;
}
.actions { display: flex; gap: 10px; margin-left: auto; }
.progress { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 420px; }
.bar { flex: 1; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
#progressText { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

button.primary, button.accent, button.ghost {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 16px; cursor: pointer; border: 1px solid transparent;
}
button.primary { background: var(--navy); color: #fff; }
button.primary:hover { background: var(--steel); }
button.accent { background: var(--accent); color: #fff; }
button.accent:hover { background: var(--accent-deep); }
button.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
button.ghost:hover { border-color: #b9c6d6; }
button.small { padding: 6px 10px; font-size: 0.8rem; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
a.ghost { color: #dbe6f1; text-decoration: none; font-size: 0.85rem; border: 1px solid rgba(255,255,255,0.25); padding: 6px 12px; border-radius: 9px; }
a.ghost:hover { background: rgba(255,255,255,0.1); }

.foot { text-align: center; color: var(--muted); font-size: 0.78rem; padding: 8px 16px 100px; }

.topbar-actions { display: flex; gap: 8px; }
.topbar-actions .ghost { color: #dbe6f1; border: 1px solid rgba(255,255,255,0.25); background: transparent; }
.topbar-actions .ghost:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.4); }

.file-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--navy), var(--navy-deep)); }
.login-wrap { width: 100%; max-width: 380px; padding: 24px; text-align: center; }
.login-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow);
  padding: 28px 26px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.login-mark { align-self: center; border-radius: 10px; background: #fff; }
.login-card h1 { text-align: center; margin: 4px 0 0; font-size: 1.2rem; }
.login-sub { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 0 0 10px; }
.login-card label { font-weight: 600; font-size: 0.82rem; margin-top: 6px; }
.login-card input { padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.login-card button { margin-top: 14px; padding: 11px; font-size: 0.95rem; }
.login-error { color: var(--err); font-size: 0.82rem; min-height: 1.1em; margin: 8px 0 0; text-align: center; }
.login-foot { color: #9fb2c6; font-size: 0.76rem; margin-top: 14px; }
/* Honeypot: kept in the DOM, out of sight and off the tab order. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Settings modal */
.modal { position: fixed; inset: 0; background: rgba(6, 22, 39, 0.55); display: grid;
  place-items: start center; padding: 24px 12px; z-index: 20; overflow-y: auto; }
.modal.hidden { display: none; }
.modal-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow);
  width: 100%; max-width: 760px; padding: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-tabs { display: flex; gap: 6px; margin: 14px 0 16px; border-bottom: 1px solid var(--line); }
.modal-tabs .tab { border: none; background: none; font: inherit; font-weight: 600; color: var(--muted);
  padding: 8px 10px; cursor: pointer; border-bottom: 2px solid transparent; }
.modal-tabs .tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabpane.hidden { display: none; }
.modal-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.saved-note { font-size: 0.82rem; color: var(--muted); }

.preset-editor { display: grid; gap: 14px; }
.pe-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.pe-head { margin-bottom: 10px; }
.pe-name { font-weight: 700; font-size: 1rem; border: none; border-bottom: 1px dashed var(--line);
  padding: 2px 0; width: 100%; }
.pe-name:focus { outline: none; border-bottom-color: var(--accent); }
.pe-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.pe-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.pe-grid input[type="number"], .pe-grid select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--ink); }
.pe-grid .pe-check { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); align-self: end; padding-bottom: 7px; }

.logo-upload { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.logo-upload input[type="text"] { flex: 1; min-width: 160px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.logo-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.logo-list li { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.logo-list img { width: 40px; height: 40px; object-fit: contain;
  background: repeating-conic-gradient(#f3f6f9 0% 25%, #e7edf3 0% 50%) 50% / 12px 12px; border-radius: 6px; }
.logo-list .ll-name { flex: 1; font-weight: 600; font-size: 0.86rem; }

@media (max-width: 560px) {
  .actionbar { flex-direction: column; align-items: stretch; }
  .actions { margin-left: 0; }
  .actions button { flex: 1; }
  .progress { max-width: none; }
}
