/* ============================================================
   Thumbnail Studio - design system
   Dark, editorial, gradient-accented. Inter for UI, Sora for headings.
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0c13;
  --surface: #121522;
  --surface-2: #1a1e2e;
  --surface-3: #232941;
  --field: #0e1120;
  --line: #262c40;
  --line-2: #333a55;
  --text: #eef1fa;
  --muted: #98a1ba;
  --faint: #6a7390;
  --accent: #ff3d68;
  --accent-2: #ff8a3d;
  --grad: linear-gradient(120deg, #ff3d68 0%, #ff8a3d 100%);
  --blue: #4dc3ff;
  --ok: #3ddc85;
  --warn: #ffc247;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 10px;
  --shadow: 0 10px 34px rgba(0, 0, 0, .38);
  --glow: 0 8px 26px rgba(255, 61, 104, .32);
}

html { accent-color: var(--accent); }

body {
  background:
    radial-gradient(1100px 520px at 78% -12%, rgba(255, 61, 104, .07), transparent 60%),
    radial-gradient(900px 480px at -8% 8%, rgba(77, 195, 255, .05), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}

::selection { background: rgba(255, 61, 104, .35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3047; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #39415f; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #ff7a7a; margin-top: 12px; font-size: 14px; }
.req {
  color: var(--accent-2); font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; margin-left: 6px;
}

/* ---------------- brand ---------------- */

.logo-tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; font-size: 18px;
  background: var(--grad); box-shadow: var(--glow);
}
.logo-tile.big {
  width: 58px; height: 58px; border-radius: 16px; font-size: 30px;
  margin: 0 auto 18px;
}
.wordmark {
  font-family: "Sora", sans-serif; font-weight: 700; font-size: 17px;
  letter-spacing: -.01em;
}

/* ---------------- login ---------------- */

.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: rgba(18, 21, 34, .88);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 22px; padding: 44px 40px; width: 380px; text-align: center;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-family: "Sora", sans-serif; font-size: 24px; font-weight: 700;
  margin-bottom: 4px; letter-spacing: -.02em;
}
.login-card p { margin-bottom: 26px; font-size: 14px; }
.login-card input { width: 100%; margin-bottom: 12px; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* ---------------- inputs ---------------- */

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="url"], select, textarea {
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 14.5px;
  width: 100%;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 61, 104, .16);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2398a1ba' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}
textarea { resize: vertical; }

input[type="file"] {
  color: var(--muted); font-size: 13px; padding: 6px 0; width: 100%;
}
input[type="file"]::file-selector-button {
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 13px; margin-right: 10px; font-size: 13px;
  font-family: inherit; cursor: pointer; transition: border-color .15s;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); }

.field-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); margin: 16px 0 7px;
  letter-spacing: .02em;
}

input[type="range"] { padding: 0; height: 28px; border: none; background: none; box-shadow: none; }

/* ---------------- buttons ---------------- */

.btn {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 11px 18px; font-size: 14.5px; font-weight: 500;
  font-family: inherit; cursor: pointer;
  transition: transform .12s, border-color .15s, box-shadow .15s, filter .15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--grad); border: none; color: #fff; font-weight: 600;
  box-shadow: var(--glow);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.big {
  width: 100%; padding: 16px; font-size: 16px; margin-top: 26px;
  font-family: "Sora", sans-serif; font-weight: 600; letter-spacing: .01em;
  border-radius: 13px;
}
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 13px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: wait; transform: none; }

/* ---------------- header ---------------- */

header {
  position: sticky; top: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  padding: 12px 28px;
  background: rgba(10, 12, 19, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.badge {
  background: var(--warn); color: #1a1400; font-size: 10px; font-weight: 800;
  letter-spacing: .06em; border-radius: 6px; padding: 3px 8px; margin-left: 4px;
}
.header-right { display: flex; gap: 8px; align-items: center; }
.nav-pill {
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 999px;
  padding: 8px 15px; font-size: 13.5px; font-weight: 500;
  font-family: inherit; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.nav-pill:hover { color: var(--text); background: var(--surface-2); border-color: var(--line); }
.user-chip {
  color: var(--muted); font-size: 13px; padding: 7px 14px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px;
}
.user-chip:empty { display: none; }

/* ---------------- layout ---------------- */

main { max-width: 1520px; margin: 0 auto; padding: 30px 26px 60px; }

main h2 {
  font-family: "Sora", sans-serif; font-size: 17px; font-weight: 600;
  letter-spacing: -.01em; margin: 10px 0 12px;
  display: flex; align-items: center; gap: 10px;
}
main h2::before {
  content: ""; width: 18px; height: 3px; border-radius: 2px;
  background: var(--grad); flex-shrink: 0;
}

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px; margin-bottom: 18px;
}
.create-card { max-width: 940px; margin: 0 auto 30px; padding: 30px 34px; }

.row { display: flex; gap: 14px; align-items: flex-end; }
.row.wrap { flex-wrap: wrap; }
.col { flex: 1; min-width: 140px; }
.col.grow, .grow { flex: 3; }

/* ---------------- create-flow steps ---------------- */

.step { padding: 6px 0 22px; }
.step + .step { border-top: 1px solid var(--line); padding-top: 24px; }
.step-head { display: flex; align-items: center; gap: 13px; margin-bottom: 6px; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 27px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad); color: #fff;
  font-family: "Sora", sans-serif; font-weight: 700; font-size: 13px;
}
.step-title {
  font-family: "Sora", sans-serif; font-weight: 600; font-size: 15.5px;
  letter-spacing: -.01em;
}
.step-sub { color: var(--faint); font-size: 12.5px; margin-top: 1px; }

.preset-manager {
  margin: 14px 0; padding: 18px; border: 1px solid var(--line-2);
  border-radius: var(--r-md); background: var(--surface-2);
}

.ref-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 6px;
}
@media (max-width: 860px) { .ref-grid { grid-template-columns: 1fr; } }
.subcard {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 16px 18px 18px;
}
.subcard-h {
  font-family: "Sora", sans-serif; font-size: 12px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.subcard .field-label { margin-top: 14px; }
.subcard .field-label:first-of-type { margin-top: 12px; }

/* ---------------- media grids & chips ---------------- */

.person-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px; margin-top: 10px;
}
.person-grid:empty { display: none; }
.person-grid img {
  width: 100%; height: 68px; object-fit: cover; border-radius: 8px;
  cursor: pointer; border: 2px solid transparent; display: block;
  transition: border-color .12s, transform .12s;
}
.person-grid img:hover { border-color: var(--accent-2); transform: scale(1.03); }
.person-grid img.picked { border-color: var(--accent); }

.persona-chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 4px; }
.persona-chip {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px;
  background: var(--surface-3); border: 2px solid var(--line-2);
  border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: border-color .15s, transform .12s;
}
.persona-chip:hover { transform: translateY(-1px); }
.persona-chip img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.persona-chip.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 61, 104, .15); }
.persona-chip .px { margin-left: 4px; opacity: .5; cursor: pointer; font-weight: 700; }
.persona-chip .px:hover { opacity: 1; color: var(--accent); }

.ref-previews { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.ref-previews:empty { display: none; }
.ref-thumb { position: relative; }
.ref-thumb img {
  height: 76px; border-radius: 10px; border: 1px solid var(--line-2);
  display: block; box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
.ref-thumb .tag {
  position: absolute; bottom: 5px; left: 5px; background: rgba(6, 8, 14, .82);
  font-size: 9.5px; font-weight: 700; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 5px;
}
.ref-thumb .rm {
  position: absolute; top: -7px; right: -7px; background: var(--accent);
  border: none; color: #fff; width: 20px; height: 20px; border-radius: 50%;
  cursor: pointer; font-size: 12px; line-height: 1;
}

/* ---------------- switches ---------------- */

.toggles { display: flex; flex-direction: column; gap: 11px; margin-top: 18px; }
.toggles label, .checks label {
  font-size: 13.5px; color: var(--muted); display: flex; gap: 10px;
  align-items: center; cursor: pointer; transition: color .15s;
}
.toggles label:hover, .checks label:hover { color: var(--text); }

.toggles input[type="checkbox"], .checks input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 38px; height: 22px; border-radius: 999px; flex-shrink: 0;
  background: var(--surface-3); border: 1px solid var(--line-2);
  position: relative; cursor: pointer; transition: background .18s, border-color .18s;
  margin: 0;
}
.toggles input[type="checkbox"]::after, .checks input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); transition: left .18s, background .18s;
}
.toggles input[type="checkbox"]:checked, .checks input[type="checkbox"]:checked {
  background: var(--grad); border-color: transparent;
}
.toggles input[type="checkbox"]:checked::after, .checks input[type="checkbox"]:checked::after {
  left: 19px; background: #fff;
}
.checks { display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }

/* ---------------- status ---------------- */

#genStatus { margin-top: 14px; font-size: 14px; }

.spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, .25); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: -2px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- results ---------------- */

.results-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 28px; }
@media (max-width: 1000px) { .results-grid { grid-template-columns: 1fr; } }

.overlay-controls { padding: 18px 20px; }
.overlay-controls .field-label { margin-top: 10px; }

.thumb-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px; margin-bottom: 24px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.thumb-card:hover {
  transform: translateY(-2px); border-color: var(--line-2);
  box-shadow: var(--shadow);
}
.thumb-card canvas {
  width: 100%; border-radius: 10px; display: block; cursor: pointer;
}
.thumb-card .bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; gap: 8px; flex-wrap: wrap;
}

.readability {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  background: rgba(255, 194, 71, .1); border: 1px solid rgba(255, 194, 71, .3);
  color: var(--warn); font-size: 12.5px;
}

.score-panel {
  margin-top: 12px; padding: 14px; border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--surface-2);
}
.score-head { display: flex; align-items: baseline; gap: 9px; }
.score-num {
  font-family: "Sora", sans-serif; font-size: 32px; font-weight: 800;
  line-height: 1;
  background: var(--grad); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent;
}
.score-dims { display: flex; gap: 6px; flex-wrap: wrap; margin: 11px 0; }
.score-dim {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 7px; padding: 4px 9px; font-size: 12px; color: var(--muted);
  cursor: help;
}
.score-dim b { color: var(--text); }
.score-weak { margin-bottom: 11px; line-height: 1.45; }

.edit-row { display: flex; gap: 8px; margin-top: 9px; }
.edit-row input { flex: 1; font-size: 13px; padding: 9px 12px; }
.edit-hist { margin-top: 7px; font-style: italic; }

.chips { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.chips:empty { display: none; }
.chip {
  background: var(--surface-3); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 5px 14px; font-size: 12px; font-weight: 500;
  font-family: inherit; cursor: pointer; color: var(--muted);
  transition: color .15s, border-color .15s;
}
.chip:hover { color: var(--text); border-color: var(--accent); }

.swatches { display: flex; gap: 7px; padding: 2px 0; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .12); cursor: pointer;
  transition: transform .12s;
  padding: 0;
}
.swatch:hover { transform: scale(1.12); }
.swatch.selected { border-color: #fff; outline: 2px solid var(--accent); }
.swatch.same {
  background: var(--surface-3); color: var(--muted); font-weight: 700;
  font-size: 13px; line-height: 20px; text-align: center;
  border-color: var(--line-2);
}
.swatch-line { display: flex; align-items: center; gap: 9px; margin: 4px 0; }
.swatch-lbl { font-size: 11px; color: var(--faint); width: 40px; flex-shrink: 0; }

/* ---------------- packaging column ---------------- */

.pkg-col .panel { padding: 16px 18px; }
.pkg-col > p { margin-bottom: 10px; }

.title-option {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 10px;
  border-radius: 9px; cursor: pointer; font-size: 14px; line-height: 1.45;
  transition: background .12s;
}
.title-option:hover { background: var(--surface-2); }
.title-option input { width: auto; margin-top: 3px; }
.title-option .copy {
  margin-left: auto; opacity: .55; font-size: 12px; cursor: pointer;
  flex-shrink: 0; transition: opacity .12s;
}
.title-option .copy:hover { opacity: 1; color: var(--accent-2); }

#descBox {
  margin-bottom: 12px; font-size: 13px; line-height: 1.55;
  border: none; background: transparent; padding: 2px;
}
#descBox:focus { box-shadow: none; }
#tagsBox { margin-bottom: 12px; line-height: 1.9; }

/* ---------------- history ---------------- */

.history-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 18px;
}
.history-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.history-card:hover {
  transform: translateY(-3px); border-color: var(--line-2);
  box-shadow: var(--shadow);
}
.history-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.history-card .hc-body { padding: 12px 14px 13px; }
.history-card .hc-title {
  font-size: 13.5px; font-weight: 600; line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.history-card .hc-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px;
}

/* ---------------- log ---------------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th {
  color: var(--faint); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }

/* ---------------- modal ---------------- */

.modal {
  position: fixed; inset: 0; background: rgba(6, 8, 14, .72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 16px;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 20px; padding: 26px;
  width: min(560px, 94vw); max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.yt-mock { display: flex; gap: 12px; margin: 8px 0 20px; }
.search-mock img { width: min(320px, 60vw); border-radius: 12px; }
.side-mock img { width: 168px; border-radius: 8px; }
.yt-title { font-size: 15px; font-weight: 600; line-height: 1.35; }
.yt-title.small-title { font-size: 13px; }
.yt-meta { flex: 1; }

/* ---------------- responsive ---------------- */

@media (max-width: 720px) {
  main { padding: 18px 14px 50px; }
  .create-card { padding: 22px 18px; }
  .row { flex-wrap: wrap; }
  header { padding: 10px 14px; }
  .wordmark { font-size: 15px; }
}

.viewing-banner {
  display: block; margin: -4px 0 14px; padding: 9px 14px; border-radius: 9px;
  background: rgba(77,195,255,.1); border: 1px solid rgba(77,195,255,.32);
  color: #9bd9ff; font-size: 13px;
}
.viewing-banner b { color: #fff; }
.role-tag {
  font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 2px 7px;
  border-radius: 5px; background: var(--surface-3); color: var(--muted);
}
.role-tag.admin { background: var(--grad); color: #fff; }
#usersTable td .btn { margin-right: 6px; }

.auth-toggle { margin-top: 16px; font-size: 13.5px; }
.auth-toggle a { color: var(--accent-2); text-decoration: none; }
.auth-toggle a:hover { text-decoration: underline; }
.notice {
  margin-top: 14px; padding: 11px 14px; border-radius: 9px; font-size: 13.5px;
  background: rgba(61,220,133,.1); border: 1px solid rgba(61,220,133,.32);
  color: #8ef0b8; text-align: left;
}
.status-tag {
  font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 2px 7px;
  border-radius: 5px; background: rgba(61,220,133,.16); color: var(--ok);
}
.status-tag.pending { background: rgba(255,194,71,.16); color: var(--warn); }

.status-tag.paused { background: rgba(255,122,122,.16); color: #ff7a7a; }

.pending-dot {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; margin-left: 7px; padding: 0 5px;
  border-radius: 999px; background: var(--grad); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 1;
}
.pending-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 0 0 20px; padding: 14px 18px; border-radius: var(--r-md);
  background: rgba(255,194,71,.1); border: 1px solid rgba(255,194,71,.35);
  color: #ffd98a; font-size: 14px;
}
.pending-banner b { color: #fff; }
.pending-banner .btn { margin-left: auto; }

.share-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.share-list:empty { display: none; }
.share-person {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--surface-3); border: 1px solid var(--line-2);
  border-radius: 999px; font-size: 13px; cursor: pointer;
}
.share-person input { width: auto; margin: 0; }
.share-person.on { border-color: var(--accent); }
.share-note {
  margin-top: 12px; padding: 9px 13px; border-radius: 8px; font-size: 13px;
  background: rgba(77,195,255,.1); border: 1px solid rgba(77,195,255,.3);
  color: #9bd9ff;
}
