:root {
  --bg: #13161b;
  --surface: #1a1e25;
  --raised: #232831;
  --line: #2f3641;
  --text: #ece8e1;
  --muted: #9aa1ad;
  --accent: #f2b544;
  --accent-ink: #1d1503;
  --cool: #7cc0d2;
  --danger: #ef7b67;
  --r-s: 6px;
  --r-m: 10px;
  --display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
body[data-screen="app"] { display: flex; flex-direction: column; height: 100dvh; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wordmark {
  font: 700 26px/1 var(--display);
  letter-spacing: -0.02em;
}

/* Kadraj köşeleri: panelin imzası. Görselin sınırlarının korunacağını söyler. */
.corner { position: absolute; width: 16px; height: 16px; border: 2px solid var(--accent); pointer-events: none; }
.corner.tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.corner.tr { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.corner.br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.drop .corner { z-index: 2; }
.drop .corner.tl, .drop .corner.tr { top: 0; }
.drop .corner.bl, .drop .corner.br { bottom: 0; }
.drop .corner.tl, .drop .corner.bl { left: 0; }
.drop .corner.tr, .drop .corner.br { right: 0; }

/* ---------- Düğmeler ---------- */
.btn {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--raised);
  font-weight: 600;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: #46505f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #f7c466; border-color: #f7c466; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.large { min-height: 52px; font-size: 17px; width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; min-width: 44px; padding: 0 12px; justify-content: center;
  background: none; border: 0; border-radius: var(--r-s); color: var(--muted); font-weight: 500; font-size: 15px;
  transition: color .15s, background-color .15s;
}
.icon-btn:hover { color: var(--text); background: var(--raised); }

/* ---------- Form öğeleri ---------- */
label, legend { font-size: 14px; font-weight: 500; color: var(--muted); }
input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 11px 12px;
  transition: border-color .15s;
}
select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px; background-size: 5px 5px; background-repeat: no-repeat; }
input:hover, select:hover, textarea:hover { border-color: #46505f; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 104px; line-height: 1.5; }
::placeholder { color: #6d7582; }
.hint, small { font-size: 13px; color: var(--muted); }
.form-error { color: var(--danger); font-size: 14px; font-weight: 500; }

/* ---------- Giriş ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-frame { position: relative; width: min(400px, 100%); padding: 40px 32px; border: 1px solid var(--line); background: var(--surface); }
.gate-lead { color: var(--muted); margin: 10px 0 28px; }
.gate form { display: grid; gap: 8px; }
.gate .btn { margin-top: 12px; }

/* ---------- Üst çubuk ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; border-bottom: 1px solid var(--line); }
.bar nav { display: flex; gap: 4px; }
.bar { gap: 16px; }
.brandbar { display: flex; align-items: center; gap: 8px; margin-right: auto; margin-left: 12px; min-width: 0; }
.brandbar select { width: auto; min-width: 180px; max-width: 280px; padding-top: 7px; padding-bottom: 7px; background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px; background-color: var(--surface); font-weight: 600; }
.btn.danger { color: var(--danger); margin-right: auto; }
.btn.danger:hover { border-color: var(--danger); }

/* ---------- Marka hafızası ---------- */
.memory { display: grid; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); }
.memory h3 { font: 500 17px/1.3 var(--display); }
.memory-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.mem { position: relative; aspect-ratio: 1; }
.mem .use { width: 100%; height: 100%; padding: 0; border: 1px solid var(--line); background: #0e1014; overflow: hidden; display: block; }
.mem .use:hover { border-color: var(--accent); }
.mem img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mem .remove { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; display: none; place-items: center; border: 0; border-radius: 50%; background: var(--text); color: var(--bg); }
.mem:hover .remove, .mem:focus-within .remove { display: grid; }
.mem .remove svg { width: 13px; height: 13px; }
.mem-add { aspect-ratio: 1; display: grid; place-items: center; border: 1px dashed #46505f; background: none; color: var(--accent); }
.mem-add:hover { border-color: var(--accent); }
.prompt-foot { display: flex; justify-content: space-between; align-items: center; min-height: 24px; margin-top: -4px; }
.prompt-foot .count { margin: 0 0 0 auto; }
.prompt-foot .link { margin-left: -8px; min-height: 30px; color: var(--accent); }
.saved-prompt { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.saved-prompt p { flex: 1; overflow-wrap: anywhere; }
.notice { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; padding: 12px 24px; background: #2a2414; border-bottom: 1px solid #4b3d17; font-size: 15px; }
.notice strong { color: var(--accent); }

/* ---------- Yerleşim ---------- */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); }
.composer { display: grid; gap: 20px; padding: 24px; padding-bottom: 0; border-right: 1px solid var(--line); align-content: start; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.library { padding: 24px 28px 48px; min-width: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ---------- Mod seçimi ---------- */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); }
.seg button { min-height: 40px; border: 0; background: none; border-radius: var(--r-s); color: var(--muted); font-weight: 600; font-size: 15px; transition: background-color .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button[aria-selected="true"] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.mode-help { font-size: 14px; color: var(--muted); margin-top: -8px; }

/* ---------- Görsel alanı ---------- */
.frames { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 12px; align-items: stretch; }
.frames.single { grid-template-columns: 1fr; }
.drop {
  position: relative; min-height: 220px; display: grid; place-items: center;
  background: var(--surface); border: 1px dashed #46505f; cursor: pointer; overflow: hidden;
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #1e222a; }
.drop.filled { min-height: 0; border-style: solid; border-color: var(--line); cursor: default; background: #0e1014; }
.drop-empty { display: grid; justify-items: center; gap: 6px; padding: 20px; text-align: center; color: var(--muted); font-size: 14px; }
.drop-empty strong { color: var(--text); font-size: 16px; font-weight: 600; }
.drop-empty svg { width: 30px; height: 30px; color: var(--accent); margin-bottom: 4px; }
.drop.mini { min-height: 0; border-radius: 0; }
.drop.mini .drop-empty { padding: 8px; font-size: 12.5px; line-height: 1.35; }
.drop.mini .drop-empty svg { width: 20px; height: 20px; color: var(--muted); }
.drop img { display: block; width: 100%; max-height: 360px; object-fit: contain; }
.drop.mini img { height: 100%; object-fit: cover; }
.drop .remove, .ref .remove {
  position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(15, 17, 21, .82); color: var(--text);
}
.drop .remove:hover, .ref .remove:hover { background: var(--danger); color: #1b0b07; }
.drop .tag { position: absolute; left: 8px; bottom: 8px; padding: 3px 8px; background: rgba(15, 17, 21, .82); font-size: 12.5px; font-weight: 500; border-radius: 4px; }
.drop.busy::after, .ref.busy::after { content: ""; position: absolute; inset: 0; background: rgba(19, 22, 27, .7) linear-gradient(100deg, transparent 30%, rgba(242, 181, 68, .18) 50%, transparent 70%) 0 0 / 200% 100%; animation: sweep 1.2s linear infinite; }
.drop.mini .remove { width: 28px; height: 28px; top: 4px; right: 4px; }
.drop.mini .remove svg { width: 15px; height: 15px; }

.ref-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ref { position: relative; aspect-ratio: 1; background: #0e1014; border: 1px solid var(--line); overflow: hidden; }
.ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref .num { position: absolute; left: 6px; top: 6px; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; border-radius: 4px; }
.ref .remove { width: 30px; height: 30px; top: 5px; right: 5px; }
.ref .remove svg { width: 16px; height: 16px; }
.ref-add { aspect-ratio: 1; display: grid; place-items: center; align-content: center; gap: 4px; border: 1px dashed #46505f; background: var(--surface); color: var(--muted); font-size: 13px; }
.ref-add:hover, .ref-add.over { border-color: var(--accent); color: var(--text); }
.ref-add svg { color: var(--accent); }

/* ---------- Metin ---------- */
.prompt { display: grid; gap: 8px; position: relative; }
.prompt label { font: 500 18px/1.3 var(--display); color: var(--text); letter-spacing: -0.01em; }
.count { justify-self: end; font-size: 12.5px; color: var(--muted); margin-top: -4px; font-variant-numeric: tabular-nums; }

.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { padding: 0; margin-bottom: 10px; }
.chips button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); font-size: 14px; font-weight: 500; transition: border-color .15s, color .15s, background-color .15s; }
.chips button:hover { color: var(--text); border-color: #46505f; }
.chips button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

/* ---------- Anahtar (switch) ---------- */
.switch { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { flex: none; width: 42px; height: 24px; border-radius: 999px; background: #3a424f; position: relative; transition: background-color .18s; margin-top: 1px; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text); transition: transform .18s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--accent-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text { display: grid; gap: 2px; }
.switch-text strong { font-weight: 600; font-size: 15px; color: var(--text); }
.switch.compact { align-items: center; padding: 0 12px; min-height: 46px; align-self: end; }

/* ---------- Ayarlar ızgarası ---------- */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { display: flex; justify-content: space-between; }
.field output { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 44px; margin: 0; background: none; accent-color: var(--accent); }

.go { display: grid; gap: 8px; position: sticky; bottom: 0; z-index: 5; padding: 22px 0 16px; background: linear-gradient(to top, var(--bg) 82%, transparent); }
.cost { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); }
.cost span { font-size: 14px; color: var(--muted); }
.cost strong { font: 700 26px/1 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--accent); }
.cost small { grid-column: 1 / -1; margin-top: 4px; }

/* ---------- Video ızgarası ---------- */
.library-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 8px; }
.library-head h2 { margin-bottom: 4px; }
.spend { display: flex; margin: 0; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.spend div { padding: 10px 18px; min-width: 96px; }
.spend div + div { border-left: 1px solid var(--line); }
.spend dt { font-size: 13px; color: var(--muted); }
.spend dd { margin: 2px 0 0; font: 700 20px/1.1 var(--display); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.spend-note { font-size: 13px; color: var(--muted); margin-bottom: 20px; min-height: 20px; text-align: right; }
.library-head h2 { font: 700 30px/1.1 var(--display); letter-spacing: -0.025em; }
.library-head p { color: var(--muted); font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 28px 20px; }

.card { display: grid; gap: 10px; align-content: start; min-width: 0; }
.shot { position: relative; aspect-ratio: 16 / 10; background: #0e1014; border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; width: 100%; padding: 0; color: inherit; }
button.shot:hover { border-color: #56606f; }
.shot video, .shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.shot img.dim { opacity: .28; filter: saturate(.6); object-fit: cover; }
.shot .state { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 6px; padding: 16px; text-align: center; }
.shot .state strong { font: 500 17px/1.2 var(--display); }
.shot .state span { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shot .state.error strong { color: var(--danger); }
.shot .state.error span { color: var(--text); max-width: 32ch; }
.shot.working::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent) 0 0 / 50% 100% no-repeat; animation: run 1.6s ease-in-out infinite; }
.shot .badge { position: absolute; left: 8px; top: 8px; padding: 3px 8px; border-radius: 4px; background: rgba(15, 17, 21, .85); font-size: 12.5px; font-weight: 600; color: var(--accent); }
.card-text { font-size: 14.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-text.none { color: var(--muted); }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.card-actions { display: flex; gap: 2px; flex-basis: 100%; margin: -2px 0 0 -8px; }
.link { background: none; border: 0; padding: 0 8px; min-height: 36px; color: var(--muted); font-size: 13.5px; font-weight: 500; border-radius: 4px; text-decoration: none; display: inline-flex; align-items: center; }
.link:hover { color: var(--text); background: var(--raised); }
.link.danger:hover { color: var(--danger); }

.empty { position: relative; max-width: 520px; margin: 8vh auto 0; padding: 44px 36px; border: 1px solid var(--line); text-align: center; }
.empty h3 { font: 700 24px/1.2 var(--display); letter-spacing: -0.02em; margin-bottom: 10px; }
.empty p { color: var(--muted); }

/* ---------- Pencereler ---------- */
dialog { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 0; border-radius: var(--r-m); max-width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(8, 9, 12, .78); }
.sheet { width: 480px; }
.sheet form { display: grid; gap: 8px; padding: 24px; }
.sheet header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sheet h2 { font: 700 24px/1.2 var(--display); letter-spacing: -0.02em; }
.sheet h3 { font-size: 16px; font-weight: 600; margin-top: 14px; }
.sheet .hint { margin-bottom: 6px; }
.sheet footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.viewer { width: min(1180px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: hidden; }
.viewer[open] { display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.viewer-media { background: #0b0c0f; display: grid; place-items: center; min-height: 320px; }
.viewer-media video { width: 100%; max-height: calc(100dvh - 34px); display: block; }
.viewer-info { padding: 56px 24px 24px; display: grid; gap: 18px; align-content: start; overflow-y: auto; max-height: calc(100dvh - 34px); }
.viewer-info h3 { font-size: 13.5px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.viewer-info p { font-size: 15px; overflow-wrap: anywhere; }
.viewer-info dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14.5px; }
.viewer-info dt { color: var(--muted); }
.viewer-info dd { margin: 0; text-align: right; }
.viewer-info .thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.viewer-info .thumbs img { width: 56px; height: 56px; object-fit: cover; border: 1px solid var(--line); }
.viewer-info .btn { text-decoration: none; display: grid; place-items: center; }
.viewer .close, .sheet .close { color: var(--text); }
.viewer .close { position: absolute; top: 8px; right: 8px; z-index: 2; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px); padding: 12px 18px; background: var(--text); color: var(--bg); border-radius: var(--r-s); font-weight: 500; font-size: 15px; }
.toast.error { background: var(--danger); color: #1b0b07; }

@keyframes sweep { to { background-position: -200% 0; } }
@keyframes run { 0% { background-position: -50% 0; } 100% { background-position: 150% 0; } }

/* ---------- Dar ekran ---------- */
@media (max-width: 900px) {
  body[data-screen="app"] { display: block; height: auto; }
  .layout { grid-template-columns: 1fr; }
  .composer { border-right: 0; border-bottom: 1px solid var(--line); padding: 20px 16px; overflow: visible; }
  .library { padding: 24px 16px 48px; overflow: visible; }
  .bar, .notice { padding-left: 16px; padding-right: 16px; }
  .icon-btn span { display: none; }
  .bar { flex-wrap: wrap; }
  .brandbar { order: 3; flex-basis: 100%; margin: 0; }
  .brandbar label { display: none; }
  .brandbar select { flex: 1; min-width: 0; max-width: none; }
  .spend { width: 100%; }
  .spend div { flex: 1; min-width: 0; padding: 10px 12px; }
  .spend-note { text-align: left; }
  .viewer[open] { grid-template-columns: 1fr; overflow-y: auto; }
  .viewer-media video { max-height: 60dvh; }
  .viewer-info { max-height: none; padding-top: 24px; }
  .go { position: static; background: none; padding: 0 0 20px; }
}
@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
  .gate-frame { padding: 32px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.card-meta .price { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.discounts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
