/* ============================================================
   DROCHILA — design system
   ============================================================ */
:root {
  --bg: #08090d;
  --bg-2: #0d0f15;
  --surface: #14161f;
  --surface-2: #1a1d28;
  --surface-3: #222634;
  --border: #262b3a;
  --border-soft: #1e2230;
  --text: #eef0f6;
  --muted: #8b93a8;
  --dim: #5c6478;
  --accent: #7c5cff;
  --accent-2: #ff4d8d;
  --accent-3: #3ba7ff;
  --ok: #3ddc97;
  --warn: #ffb347;
  --danger: #ff5470;
  --grad: linear-gradient(135deg, #7c5cff 0%, #b44bff 50%, #ff4d8d 100%);
  --grad-soft: linear-gradient(135deg, rgba(124,92,255,.16), rgba(255,77,141,.12));
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, .4);
  --rail: 78px;
  --ease: cubic-bezier(.22, .8, .3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
/* baseline size so an icon is never rendered at the 300×150 SVG default */
svg { width: 18px; height: 18px; flex: 0 0 auto; }
a { color: var(--accent-3); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.grow { flex: 1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3040; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #353d51; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Shell
   ============================================================ */
#app { display: flex; height: 100%; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--bg-2);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 12px;
  gap: 6px;
  z-index: 30;
}

.rail-logo {
  width: 44px; height: 44px;
  border-radius: 13px;
  background: var(--grad);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 19px;
  color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 6px 22px rgba(124, 92, 255, .45);
  cursor: pointer;
  transition: transform .2s var(--ease);
}
.rail-logo:hover { transform: scale(1.06) rotate(-4deg); }

.rail-btn {
  width: 54px;
  padding: 9px 0 7px;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .2px;
  transition: color .16s, background .16s;
  position: relative;
}
.rail-btn svg { width: 21px; height: 21px; stroke-width: 1.7; }
.rail-btn:hover { color: var(--text); background: var(--surface); }
.rail-btn.active { color: var(--text); background: var(--surface-2); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -12px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0;
  background: var(--grad);
}

.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }

.balance-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ok);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .16s;
}
.balance-chip:hover { border-color: var(--ok); }
.balance-chip.empty { color: var(--dim); }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  text-transform: uppercase;
  cursor: pointer;
}
.avatar:hover { border-color: var(--accent); }

main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  height: 58px;
  flex: 0 0 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(13, 15, 21, .8);
  backdrop-filter: blur(14px);
  z-index: 12;
}
.topbar h1 { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.topbar .sub { font-size: 12px; color: var(--dim); }

.seg {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background .16s, color .16s;
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-3); color: var(--text); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  padding: 9px 16px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: #333a4d; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn.primary {
  background: var(--grad);
  border: none;
  color: #fff;
  box-shadow: 0 6px 22px rgba(124, 92, 255, .35);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface); }
.btn.danger { color: var(--danger); border-color: rgba(255, 84, 112, .3); }
.btn.danger:hover:not(:disabled) { background: rgba(255, 84, 112, .12); border-color: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 12px; border-radius: 9px; }
.btn.icon { padding: 8px; width: 34px; height: 34px; }
.btn.icon svg { width: 17px; height: 17px; }
.btn.block { width: 100%; }

/* ============================================================
   Inputs
   ============================================================ */
.input, textarea.input, select.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  transition: border-color .15s, background .15s;
  outline: none;
}
.input:focus { border-color: var(--accent); background: var(--surface-2); }
.input::placeholder { color: var(--dim); }
select.input { cursor: pointer; appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b93a8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 15px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .2px; }

/* range */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 3px;
  background: var(--surface-3);
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
  cursor: grab;
}
input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.15); }

/* toggle */
.toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .track {
  width: 36px; height: 20px; border-radius: 20px;
  background: var(--surface-3); border: 1px solid var(--border);
  position: relative; transition: background .18s, border-color .18s; flex: 0 0 auto;
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: transform .18s var(--ease), background .18s;
}
.toggle input:checked + .track { background: rgba(124, 92, 255, .3); border-color: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(16px); background: var(--accent); }
.toggle .label { font-size: 12.5px; font-weight: 500; }

/* ============================================================
   Studio: feed + composer
   ============================================================ */
.studio-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 22px 260px; }

.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  aspect-ratio: 1;
  transition: transform .22s var(--ease), border-color .18s, box-shadow .22s;
}
.card:hover { transform: translateY(-3px); border-color: #39405a; box-shadow: var(--shadow-sm); }
.card img, .card video { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-veil {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .82) 0%, rgba(0, 0, 0, .25) 38%, transparent 62%);
  opacity: 0; transition: opacity .2s;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 11px 12px;
}
.card:hover .card-veil { opacity: 1; }
.card-prompt {
  font-size: 11.5px; line-height: 1.35; color: #e8eaf2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 10.5px; color: #a9b0c4; }

.card-actions { position: absolute; top: 9px; right: 9px; display: flex; gap: 5px; opacity: 0; transition: opacity .2s; }
.card:hover .card-actions { opacity: 1; }
.mini-btn {
  width: 29px; height: 29px; border-radius: 9px;
  background: rgba(10, 11, 15, .78);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(8px);
  display: grid; place-items: center; color: #fff;
  transition: background .15s, transform .12s;
}
.mini-btn:hover { background: var(--accent); transform: scale(1.08); }
.mini-btn svg { width: 15px; height: 15px; }

.badge {
  position: absolute; top: 9px; left: 9px;
  padding: 3px 8px; border-radius: 7px;
  background: rgba(10, 11, 15, .78);
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(8px);
  font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  display: flex; align-items: center; gap: 4px;
}
.badge svg { width: 11px; height: 11px; }

/* generating placeholder */
.card.pending { cursor: default; display: grid; place-items: center; background: var(--surface); }
.card.pending::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(124, 92, 255, .13) 50%, transparent 80%);
  background-size: 220% 100%;
  animation: sheen 1.5s linear infinite;
}
@keyframes sheen { to { background-position: -220% 0; } }
.pending-inner { position: relative; text-align: center; padding: 16px; }
.pending-cancel {
  position: absolute; top: 9px; right: 9px; z-index: 3;
  width: 27px; height: 27px; border-radius: 9px;
  background: rgba(10, 11, 15, .8);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(8px);
  color: #fff;
  display: grid; place-items: center;
  transition: background .15s, transform .12s;
}
.pending-cancel svg { width: 14px; height: 14px; }
.pending-cancel:hover { background: var(--danger); transform: scale(1.08); }
.pending-inner .stage { font-size: 12px; color: var(--muted); margin-top: 10px; }
.pending-inner .el { font-size: 11px; color: var(--dim); margin-top: 3px; }
.card.pending.failed::before { animation: none; background: rgba(255, 84, 112, .07); }

.ring { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto;
  border: 3px solid var(--surface-3); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 70px 20px; color: var(--dim); }
.empty-state .big { font-size: 42px; margin-bottom: 12px; opacity: .5; }
.empty-state h3 { font-size: 16px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }

/* ============================================================
   Composer
   ============================================================ */
.composer {
  position: absolute;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  width: min(880px, calc(100% - 44px));
  background: rgba(20, 22, 31, .93);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  z-index: 20;
  overflow: hidden;
  transition: box-shadow .2s;
}
.composer:focus-within { border-color: #3a4160; }

.composer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px 0;
}

.model-scroll { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; flex: 1; scrollbar-width: none; }
.model-scroll::-webkit-scrollbar { display: none; }

.model-chip {
  padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--muted);
  white-space: nowrap;
  transition: all .16s;
}
.model-chip:hover { color: var(--text); border-color: #39405a; }
.model-chip.active {
  color: #fff; border-color: transparent;
  background: var(--grad);
  box-shadow: 0 3px 14px rgba(124, 92, 255, .4);
}

.composer-prompt { padding: 10px 16px 0; }
#promptBox {
  width: 100%;
  background: none; border: none; outline: none;
  resize: none;
  font-size: 15px; line-height: 1.5;
  min-height: 26px; max-height: 260px;
  overflow-y: auto;
}
#promptBox::placeholder { color: var(--dim); }

.ref-strip { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px 0; }

.ref-slot { display: flex; align-items: center; gap: 7px; }
.ref-slot-label {
  font-size: 10.5px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: .5px;
  writing-mode: horizontal-tb;
}

/* no overflow clipping here — the remove badge hangs outside the corner */
.thumb {
  position: relative;
  width: 46px; height: 46px;
  flex: 0 0 auto;
  cursor: grab;
}
.thumb img, .thumb video, .thumb .kind-ic {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-3);
}
.thumb .kind-ic { display: grid; place-items: center; color: var(--muted); }
.thumb .x {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff;
  display: grid; place-items: center;
  font-size: 10px; line-height: 1; font-weight: 700;
  border: 2px solid var(--surface); z-index: 3;
  opacity: 0; transform: scale(.7);
  transition: opacity .15s, transform .15s;
}
.thumb:hover .x { opacity: 1; transform: none; }
.thumb .x:hover { filter: brightness(1.15); }
/* drag-to-reorder */
.thumb.dragging { opacity: .35; cursor: grabbing; }
.thumb.drop-left::before, .thumb.drop-right::before {
  content: ""; position: absolute; top: -2px; bottom: -2px; width: 3px;
  border-radius: 3px; background: var(--accent); box-shadow: 0 0 8px var(--accent);
}
.thumb.drop-left::before { left: -6px; }
.thumb.drop-right::before { right: -6px; }
.thumb .ord {
  position: absolute; left: 3px; bottom: 3px;
  min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 5px; background: rgba(8, 9, 13, .8);
  font-size: 9.5px; font-weight: 700; line-height: 15px; text-align: center;
  color: #cfd4e2; pointer-events: none;
}
.thumb-add {
  width: 46px; height: 46px; border-radius: 10px;
  border: 1.5px dashed #333a4d; color: var(--dim);
  display: grid; place-items: center;
  transition: border-color .16s, color .16s, background .16s;
  flex: 0 0 auto;
}
.thumb-add:hover, .thumb-add.drag { border-color: var(--accent); color: var(--accent); background: rgba(124, 92, 255, .08); }
.thumb-add svg { width: 17px; height: 17px; }

.params-row {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 12px 16px 0;
}

.param {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 12px;
}
.param > .cap { color: var(--dim); font-size: 11px; font-weight: 600; white-space: nowrap; }
.param select {
  background: none; border: none; outline: none;
  font-size: 12px; font-weight: 600; cursor: pointer; padding-right: 2px;
}
.param select option { background: var(--surface-2); }
.param input[type="number"] { background: none; border: none; outline: none; width: 54px; font-size: 12px; font-weight: 600; }
/* the param box already provides the chrome — the dropdown sits flush inside it */
.param > .dd-btn { background: none; border: none; padding: 0; border-radius: 6px; }
.param > .dd-btn:hover, .param > .dd-btn.open { background: none; color: var(--accent); }
.param.slider { min-width: 190px; }
.param.slider input[type="range"] { width: 96px; }
.param .val { font-weight: 700; min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }

.composer-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 13px 16px;
}
.cost {
  font-size: 12.5px; font-weight: 700;
  padding: 6px 11px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--warn);
}
.cost .approx { color: var(--dim); font-weight: 500; font-size: 11px; }

/* ============================================================
   Detail drawer
   ============================================================ */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0, 0, 0, .55);
  z-index: 60;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s var(--ease);
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft);
}
.drawer-head h3 { font-size: 14px; font-weight: 700; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }

.detail-media {
  width: 100%; border-radius: var(--r); overflow: hidden;
  background: #000; border: 1px solid var(--border-soft); margin-bottom: 16px;
}
.detail-media img, .detail-media video { width: 100%; display: block; max-height: 46vh; object-fit: contain; }

.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.spec {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r-sm); padding: 9px 11px;
}
.spec .k { font-size: 10.5px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.spec .v { font-size: 13px; font-weight: 700; margin-top: 2px; word-break: break-word; }
.spec.wide { grid-column: 1 / -1; }

.prompt-box {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r-sm); padding: 11px 12px;
  font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  max-height: 190px; overflow-y: auto;
}
.section-title {
  font-size: 11px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: .6px; margin: 0 0 8px;
}
.drawer-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.drawer-actions .split { display: flex; gap: 8px; }
.drawer-actions .split > * { flex: 1; }

/* ============================================================
   Library pages (presets / references)
   ============================================================ */
.page-body { flex: 1; overflow-y: auto; padding: 22px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 13px; }

.preset-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r); overflow: hidden;
  cursor: pointer; transition: transform .2s var(--ease), border-color .18s;
  display: flex; flex-direction: column;
}
.preset-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.preset-card .pv { aspect-ratio: 16/10; background: var(--surface-3); overflow: hidden; position: relative; }
.preset-card .pv img { width: 100%; height: 100%; object-fit: cover; }
.preset-card .pv.blank { display: grid; place-items: center; background: var(--grad-soft); font-size: 26px; }
.preset-card .info { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.preset-card .nm { font-size: 13px; font-weight: 700; }
.preset-card .pr {
  font-size: 11.5px; color: var(--muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.preset-card .row { display: flex; gap: 6px; padding: 0 10px 10px; }

.ref-card {
  position: relative; aspect-ratio: 1;
  border-radius: var(--r); overflow: hidden;
  border: 1px solid var(--border-soft); background: var(--surface);
  transition: transform .2s var(--ease), border-color .18s;
}
.ref-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.ref-card .card-actions { opacity: 0; }
.ref-card:hover .card-actions { opacity: 1; }
.ref-card img, .ref-card video { width: 100%; height: 100%; object-fit: cover; }
.ref-card .placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--dim); }
.ref-card .placeholder svg { width: 32px; height: 32px; }
.ref-card .nm {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 16px 9px 7px; font-size: 10.5px;
  background: linear-gradient(to top, rgba(0, 0, 0, .85), transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dropzone {
  border: 2px dashed #2c3346; border-radius: var(--r-lg);
  padding: 38px; text-align: center; color: var(--muted);
  transition: border-color .18s, background .18s; cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(124, 92, 255, .06); }
.dropzone .big { font-size: 34px; margin-bottom: 10px; opacity: .6; }

/* ============================================================
   Modal
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(4, 5, 8, .74);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .18s var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.modal {
  width: min(560px, 100%);
  max-height: 86vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop .22s var(--ease);
}
.modal.wide { width: min(900px, 100%); }
@keyframes pop { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { font-size: 15px; font-weight: 700; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border-soft); display: flex; gap: 9px; justify-content: flex-end; }

/* picker grid inside modal */
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.picker-item {
  position: relative; aspect-ratio: 1; border-radius: 11px; overflow: hidden;
  border: 2px solid transparent; background: var(--surface-2); cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.picker-item:hover { transform: scale(1.04); border-color: #3a4160; }
.picker-item.selected { border-color: var(--accent); }
.picker-item img, .picker-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker-item .placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--dim); }
.picker-item .placeholder svg { width: 22px; height: 22px; }
.picker-item .tick {
  position: absolute; top: 5px; right: 5px;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  opacity: 0; transform: scale(.6);
  transition: opacity .15s var(--ease), transform .15s var(--ease);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.picker-item .tick svg { width: 11px; height: 11px; stroke-width: 3.5; }
.picker-item.selected .tick { opacity: 1; transform: none; }
.picker-item .ord {
  position: absolute; left: 5px; bottom: 5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 6px; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
  display: none;
}
.picker-item.selected .ord { display: block; }

/* ============================================================
   Dropdown (custom select)
   ============================================================ */
.dd-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 9px 6px 11px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px; font-weight: 600;
  transition: border-color .15s, background .15s;
  white-space: nowrap;
}
.dd-btn:hover { border-color: #3a4160; background: var(--surface-3); }
.dd-btn.open { border-color: var(--accent); background: var(--surface-3); }
.dd-chev { width: 13px; height: 13px; color: var(--dim); transition: transform .2s var(--ease); }
.dd-btn.open .dd-chev { transform: rotate(180deg); color: var(--accent); }
.dd-val { overflow: hidden; text-overflow: ellipsis; }

.dd-btn.block { width: 100%; justify-content: space-between; padding: 9px 11px 9px 13px; font-size: 13px; border-radius: var(--r-sm); }

.dd-panel {
  position: fixed; z-index: 300;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 5px;
  box-shadow: var(--shadow);
  max-height: 320px; overflow-y: auto;
  overscroll-behavior: contain;   /* don't chain to the page and close the panel */
  animation: ddIn .16s var(--ease);
  display: flex; flex-direction: column; gap: 1px;
}
@keyframes ddIn { from { opacity: 0; transform: translateY(-5px) scale(.98); } }

.dd-option {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 12.5px; font-weight: 500;
  color: var(--muted);
  text-align: left;
  transition: background .12s, color .12s;
}
.dd-option:hover { background: var(--surface-3); color: var(--text); }
.dd-option.selected { color: var(--text); font-weight: 700; background: rgba(124, 92, 255, .13); }
.dd-label { flex: 1; }
.dd-tick { width: 13px; height: 13px; stroke-width: 3.5; color: var(--accent); opacity: 0; }
.dd-option.selected .dd-tick { opacity: 1; }

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox {
  position: fixed; inset: 0; z-index: 140;
  background: rgba(4, 5, 8, .93);
  backdrop-filter: blur(12px);
  display: grid; place-items: center;
  padding: 46px;
  cursor: zoom-out;
  animation: fade .18s var(--ease);
}
.lightbox img, .lightbox video {
  /* sized against the viewport, not the grid row: an auto-sized row grows to the
     image's natural height, which would make max-height:100% a no-op */
  max-width: calc(100vw - 92px);
  max-height: calc(100vh - 92px);
  width: auto; height: auto;
  object-fit: contain;
  border-radius: var(--r);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .7);
  cursor: default;
  animation: pop .24s var(--ease);
}
.lb-close {
  position: absolute; top: 20px; right: 22px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(30, 34, 48, .85);
  border: 1px solid var(--border);
  color: #fff;
  display: grid; place-items: center;
  transition: background .15s, transform .12s;
}
.lb-close:hover { background: var(--danger); transform: scale(1.08); }
.detail-media { cursor: zoom-in; position: relative; }
.detail-media .expand { position: absolute; top: 8px; right: 8px; z-index: 2; }

/* ============================================================
   Styled file input
   ============================================================ */
.file-pick { display: flex; align-items: center; gap: 10px; }
.file-pick input[type="file"] { display: none; }
.file-name { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   Auth
   ============================================================ */
#auth {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(900px 500px at 50% 0%, #16182a 0%, var(--bg) 62%);
  padding: 20px;
}
.auth-card {
  width: min(390px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 30px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo {
  width: 58px; height: 58px; border-radius: 17px; margin: 0 auto 16px;
  background: var(--grad); display: grid; place-items: center;
  font-size: 25px; font-weight: 800; color: #fff;
  box-shadow: 0 10px 30px rgba(124, 92, 255, .45);
}
.auth-card h2 { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin: 6px 0 22px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-switch { margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.auth-switch button { color: var(--accent-3); font-weight: 600; }
.auth-err {
  background: rgba(255, 84, 112, .1); border: 1px solid rgba(255, 84, 112, .3);
  color: #ff8fa3; border-radius: var(--r-sm); padding: 9px 12px; font-size: 12.5px;
}

/* ============================================================
   Toast
   ============================================================ */
#toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 16px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-sm); max-width: 72vw;
  animation: toastIn .22s var(--ease);
}
.toast.err { border-color: rgba(255, 84, 112, .45); color: #ff9db0; }
.toast.ok { border-color: rgba(61, 220, 151, .4); color: var(--ok); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* ============================================================
   Settings
   ============================================================ */
.settings-wrap { max-width: 620px; display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r); padding: 17px 18px;
}
.panel h4 { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.panel .hint { font-size: 12px; color: var(--muted); margin-bottom: 13px; line-height: 1.5; }
.price-table { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.price-table th { text-align: left; color: var(--dim); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .4px; padding-bottom: 7px; }
.price-table td { padding: 7px 0; border-top: 1px solid var(--border-soft); }
.price-table td:last-child { text-align: right; font-weight: 700; color: var(--warn); font-variant-numeric: tabular-nums; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .drawer { width: 100%; }
  .composer { width: calc(100% - 24px); bottom: 12px; }
  .studio-body { padding: 16px 14px 300px; }
}
