/* ============================================================
   Make Something — premium editorial UI
   Muted "dirty" gold + dusty steel-blue on warm ink.
   ============================================================ */
:root {
  --bg: #0e0f11;
  --bg-soft: #14151a;
  --ink: #101216;

  --surface: rgba(255, 250, 240, 0.035);
  --surface-2: rgba(255, 250, 240, 0.065);
  --border: rgba(236, 231, 221, 0.10);
  --border-strong: rgba(236, 231, 221, 0.18);

  --text: #ece7dd;        /* warm cream */
  --muted: #9b968c;       /* warm gray */
  --faint: #6c6860;

  --gold: #b8934e;        /* dirty antique brass */
  --gold-hover: #caa564;
  --gold-ink: #191408;    /* text on gold */

  --blue: #587d97;        /* dusty steel blue */
  --blue-hover: #6b91ab;
  --blue-ink: #f2f5f7;    /* text on blue */

  --danger: #c9785e;      /* muted terracotta */

  --radius: 15px;
  --radius-sm: 11px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  --ring: 0 0 0 3px rgba(184, 147, 78, 0.32);

  /* Solid "page" material shared by the active tab and its panel so they merge
     seamlessly (a translucent surface would let the seam/border show through). */
  --panel-bg: #17181e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
.hidden { display: none !important; }

/* ---------- Scrollbars (themed, everywhere) ----------
   Applies to the page, textareas, the gallery, dropdown menus — every scroll. */
* {
  scrollbar-width: thin;                              /* Firefox + modern Chromium */
  scrollbar-color: rgba(184, 147, 78, 0.55) transparent;
}
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(184, 147, 78, 0.45);               /* muted gold — clearly themed */
  border: 3px solid transparent;                      /* slim, floating thumb */
  border-radius: 999px;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 147, 78, 0.72);               /* brighter gold on hover */
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner { background: transparent; }

/* Duotone backdrop: a faint warm glow up top, a cool one below. Subtle. */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(760px 420px at 18% -8%, rgba(184, 147, 78, 0.12), transparent 70%),
    radial-gradient(680px 460px at 92% 108%, rgba(88, 125, 151, 0.13), transparent 72%),
    linear-gradient(180deg, var(--bg-soft), var(--bg));
}

/* ---------- Layout ---------- */
.screen {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 30px clamp(16px, 4vw, 24px) 48px;
}
.center { display: flex; align-items: center; justify-content: center; }

/* The signed-in app spans the whole page: a full-width top bar, then a wide
   centered column that sits vertically in the middle so the page feels full. */
#app-screen {
  max-width: none;
  padding: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.content {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(12px, 2.5vh, 28px) clamp(16px, 4vw, 28px) 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3.5vw, 28px);
}

/* ---------- Wordmark (editorial serif) ---------- */
.wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: 24px;
  letter-spacing: 0.01em;
}
.wordmark .mark { color: var(--gold); }
.wordmark .mark-img {
  display: inline-block;
  flex: none;
  width: 42px; height: 40px;
  background-image: url(/logo.png);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}
.wordmark.sm { font-size: 19px; justify-content: flex-start; }
.wordmark.sm .mark-img { width: 32px; height: 30px; }

/* ---------- Lock screen ---------- */
.lock-card { width: 100%; max-width: 400px; text-align: center; }
.lock-card .wordmark { font-size: 18px; margin-bottom: 10px; flex-wrap: wrap; }
.lock-card .wordmark .mark-img { width: 30px; height: 28px; }
.subtitle { color: var(--muted); margin: 0 0 22px; font-size: 15px; }

/* ---------- Inputs ---------- */
.input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--gold); box-shadow: var(--ring); }
.pin-input { text-align: center; letter-spacing: 3px; font-size: 17px; margin-bottom: 14px; }
.prompt-box { min-height: 104px; resize: vertical; font-size: 16.5px; line-height: 1.5; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font: inherit;
  font-weight: 650;
  font-size: 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  letter-spacing: 0.01em;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn svg { flex: none; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-block { width: 100%; }

/* Gold = image / primary actions */
.btn-primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn-primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); }

/* Blue = video */
.btn-secondary { background: var(--blue); color: var(--blue-ink); border-color: var(--blue); }
.btn-secondary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }

.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn[disabled] { opacity: 0.45; pointer-events: none; }

.error { color: var(--danger); margin: 12px 0 0; font-size: 14px; }

/* ---------- App header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 20px;
}
.header-actions { display: flex; gap: 8px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Greeting ---------- */
.greeting {
  margin: 4px 2px 14px;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 21px;
  color: var(--text);
}

/* ---------- Folder-style tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  padding: 0 6px;
  margin-bottom: -1px;      /* the active tab sits on top of the panel edge */
  position: relative;
  z-index: 2;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.02);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 13px 13px 0 0;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tab svg { flex: none; opacity: 0.85; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab:focus-visible { outline: none; box-shadow: var(--ring); }
.tab.active {
  color: var(--text);
  background: var(--panel-bg);          /* same solid material as the panel */
  border-color: var(--border);
  border-top: 2px solid var(--gold);    /* the "bump" cue on the active page */
  padding-top: 11px;
}
.tab.active svg { opacity: 1; color: var(--gold); }

/* Each tool's page is one solid sheet; the active tab overlaps its top border
   by 1px (via .tabs margin) and, being the same opaque color, hides the seam. */
.panel { position: relative; z-index: 1; }
.panel .card { background: var(--panel-bg); }
/* First card joins the tabs: squared top-left, and no stray top margin so it
   sits flush under the tab row (the .gallery card had a leftover margin-top). */
.panel > .card:first-child { border-top-left-radius: 4px; margin-top: 0; }

/* ---------- Prompt field (dim when not needed) ---------- */
.prompt-field { transition: opacity 0.15s; }
.prompt-field.dimmed { opacity: 0.45; }
.prompt-box:disabled { cursor: not-allowed; background: rgba(0, 0, 0, 0.18); }

/* ---------- Aspect ratio (segmented) ---------- */
.seg-label { margin-top: 18px; }
.segmented {
  display: flex;
  gap: 8px;
}
.seg {
  flex: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.seg:hover { border-color: var(--border-strong); color: var(--text); }
.seg:focus-visible { outline: none; box-shadow: var(--ring); }
.seg.active { color: var(--text); border-color: var(--gold); background: rgba(184, 147, 78, 0.10); }
.seg-ico {
  display: block;
  border: 2px solid currentColor;
  border-radius: 3px;
  color: var(--faint);
}
.seg.active .seg-ico { color: var(--gold); }
.seg-square { width: 22px; height: 22px; }
.seg-portrait { width: 17px; height: 23px; }
.seg-landscape { width: 26px; height: 18px; }

/* ---------- Secondary "choose from gallery" button ---------- */
.subtle-btn { margin-top: 12px; font-size: 14.5px; padding: 12px 16px; }

/* ---------- Gallery pick banner ---------- */
.pick-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 15px;
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  background: rgba(184, 147, 78, 0.10);
  color: var(--text);
  font-size: 14.5px;
}
.pick-banner .btn { padding: 9px 14px; font-size: 14px; }
.tile-pick { cursor: pointer; }
.tile-pick:hover { outline: 2px solid var(--gold); outline-offset: 2px; }
.tile-disabled { opacity: 0.4; }

/* ---------- Gallery sub-tabs (Images / Videos) ---------- */
.subtabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.subtab {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 8px 18px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.subtab:hover { color: var(--text); }
.subtab.active { background: var(--surface-2); color: var(--text); }
.subtab:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Gallery ---------- */
.gallery { margin-top: 16px; }
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.gallery-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 22px;
  margin: 0;
}
.gallery-empty { color: var(--muted); text-align: center; padding: 14px 0 20px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile-media { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-dl {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s;
}
.tile:hover .tile-dl, .tile:focus-within .tile-dl { opacity: 1; }
.tile-error { color: var(--danger); font-size: 22px; }

/* ---------- Studio ---------- */
.studio { padding: clamp(16px, 2.2vw, 24px); }
.field-label {
  display: block;
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 500;
}

/* ---------- Dropzone ---------- */
.dropzone {
  margin-top: 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 20px 20px;
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(255, 250, 240, 0.012);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--gold); background: rgba(184, 147, 78, 0.06); outline: none; }
.dropzone.dragover { border-color: var(--gold); background: rgba(184, 147, 78, 0.12); }
.dropzone-empty { display: flex; flex-direction: column; align-items: center; gap: 9px; color: var(--muted); text-align: center; }
.dropzone-empty svg { color: var(--faint); flex: none; width: 30px; height: 30px; }
.dz-text { display: flex; flex-direction: column; gap: 3px; line-height: 1.35; }
.dz-text strong { font-size: 16px; font-weight: 600; color: var(--text); }
.dz-text span { color: var(--muted); font-size: 14px; }
.dropzone-preview { position: relative; display: flex; justify-content: center; }
.dropzone-preview img { max-height: 190px; border-radius: 10px; border: 1px solid var(--border); }
.chip-remove {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px;
  border-radius: 8px; border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 13px; cursor: pointer;
}
.chip-remove:hover { background: rgba(0, 0, 0, 0.85); }

/* ---------- Loop toggle ---------- */
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 4px;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 250, 240, 0.012);
  cursor: pointer;
}
.switch { position: relative; flex: none; margin-top: 2px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.track {
  display: block;
  width: 40px; height: 23px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  transition: background 0.18s, border-color 0.18s;
}
.thumb {
  position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s, background 0.18s;
}
.switch input:checked + .track { background: var(--blue); border-color: var(--blue); }
.switch input:checked + .track .thumb { transform: translateX(17px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.switch-label { display: flex; flex-direction: column; line-height: 1.35; }
.switch-label strong { font-size: 14px; font-weight: 600; }
.switch-label span { font-size: 13px; color: var(--muted); }

/* ---------- Hint ---------- */
.hint { margin: 14px 2px 0; color: var(--muted); font-size: 13.5px; text-align: center; }

/* ---------- Video length ---------- */
.length-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.length-row .field-label { margin-bottom: 0; }

/* Custom themed dropdown (replaces the OS-default <select> popup) */
.cselect { position: relative; width: auto; min-width: 172px; }
.cselect-native { display: none; }
.cselect-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cselect-trigger:hover { border-color: var(--border-strong); }
.cselect-trigger:focus-visible { border-color: var(--gold); box-shadow: var(--ring); }
.cselect-caret { color: var(--muted); flex: none; transition: transform 0.18s; }
.cselect.open .cselect-trigger { border-color: var(--gold); box-shadow: var(--ring); }
.cselect.open .cselect-caret { transform: rotate(180deg); }

.cselect-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.cselect-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
}
.cselect-option:hover { background: var(--surface-2); }
.cselect-option[aria-selected="true"] { color: var(--gold); }
.cselect-option[aria-selected="true"]::after { content: "✓"; font-size: 13px; }

/* ---------- Actions ---------- */
.actions { display: flex; gap: 12px; margin-top: 16px; }
.actions .btn { flex: 1; padding: 15px 20px; font-size: 16.5px; }
.actions.single .btn { width: 100%; }

/* ---------- Result ---------- */
.result { margin-top: 16px; }
.loading { text-align: center; padding: 26px 0; }
.spinner {
  display: inline-block;
  width: 30px; height: 30px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 15px; font-weight: 600; margin: 0; }
.loading-sub { color: var(--muted); margin: 5px 0 0; font-size: 13px; }
.progress {
  width: 100%;
  max-width: 320px;
  height: 8px;
  margin: 16px auto 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--gold);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.output { text-align: center; }
.result-media {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
}
.result-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.prompt-details { margin-top: 14px; color: var(--muted); font-size: 13px; text-align: left; }
.prompt-details summary { cursor: pointer; color: var(--muted); }
.prompt-details summary:hover { color: var(--text); }
.prompt-details p { margin: 8px 0 0; line-height: 1.55; color: var(--muted); }

.error-box { text-align: center; padding: 16px 0; }
#error-text { color: var(--danger); font-size: 15px; margin: 0 0 16px; }

/* ---------- Footer ---------- */
.app-footer { text-align: center; color: var(--faint); font-size: 12.5px; margin-top: 24px; }

/* ---------- Motion / accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .btn, .track, .thumb, .dropzone { transition: none; }
}
@media (max-width: 460px) {
  .actions { flex-direction: column; }
}
