:root {
  --bg: #f4efe8;
  --panel: #fffaf4;
  --ink: #1d1a17;
  --muted: #7a7068;
  --line: #e6ddd2;
  --accent: #e8572a;
  --accent-ink: #fff;
  --ok: #2f8f5b;
  --bad: #c0392b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Noto Sans Georgian', system-ui, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.logo { font-weight: 800; font-size: 22px; letter-spacing: -0.5px; display: flex; align-items: center; gap: 8px; }
.logo .dot { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); transform: rotate(45deg); }
.head-right { display: flex; align-items: center; gap: 10px; }
.balance { background: var(--ink); color: #fff; padding: 7px 12px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 9px 16px; border-radius: 10px; }
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn-primary:hover { filter: brightness(1.05); border-color: var(--accent); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-small { padding: 5px 10px; font-size: 13px; }

.banner { background: #fff3cd; color: #7a5b00; padding: 8px 24px; font-size: 14px; text-align: center; }

main { display: grid; grid-template-columns: 380px 1fr; gap: 24px; padding: 24px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; padding: 16px; } header { padding: 12px 16px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.form-panel { align-self: start; position: sticky; top: 84px; }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

.models { display: grid; gap: 8px; }
.model { text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; }
.model.active { border-color: var(--accent); box-shadow: 0 0 0 3px #e8572a22; }
.model b { display: block; font-size: 14px; }
.model span { font-size: 12px; color: var(--muted); }

textarea { width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
textarea:focus, input:focus { outline: 2px solid #e8572a55; border-color: var(--accent); }
.count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.chip.active { border-color: var(--ink); background: var(--ink); color: #fff; }

.cost { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 12px; font-size: 14px; color: var(--muted); }
.cost b { color: var(--ink); font-size: 16px; }
#generateBtn { width: 100%; padding: 13px; font-size: 16px; }
.msg { font-size: 14px; margin-top: 10px; min-height: 20px; }
.msg.err { color: var(--bad); }

.gallery-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.gallery-head h2 { margin: 0; }
.gallery { align-items: start; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card .media { aspect-ratio: 16/9; background: #e9e1d6; display: grid; place-items: center; color: var(--muted); font-size: 14px; position: relative; max-height: 440px; width: 100%; }
.card video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.card .body { padding: 12px; font-size: 13px; display: grid; gap: 6px; }
.card .prompt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card .err { color: var(--bad); }
.spinner { width: 28px; height: 28px; border: 3px solid #d5c9bb; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }

/* modal */
.overlay { position: fixed; inset: 0; background: #1d1a1799; display: none; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.overlay.open { display: flex; }
.modal { background: var(--panel); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 420px; max-height: 90vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.modal input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 10px; }
.modal .switch { font-size: 14px; color: var(--muted); margin-top: 12px; text-align: center; }
.modal .switch a { cursor: pointer; }
.packages { display: grid; gap: 10px; }
.pkg { display: flex; justify-content: space-between; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; text-align: left; }
.pkg:hover { border-color: var(--accent); }
.pkg b { font-size: 16px; }
.pkg .price { font-weight: 800; color: var(--accent); }
.payinfo { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 14px; line-height: 1.6; white-space: pre-line; }
.code { font-family: ui-monospace, monospace; font-size: 20px; font-weight: 800; letter-spacing: 1px; color: var(--accent); }
.close-x { float: right; background: none; border: none; font-size: 22px; line-height: 1; color: var(--muted); }

/* admin */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 24px; margin-top: 4px; }
.status-pending { color: #b7791f; font-weight: 600; }
.status-paid { color: var(--ok); font-weight: 600; }
.status-cancelled { color: var(--muted); }
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 24px; display: grid; gap: 20px; }
.table-scroll { overflow-x: auto; }

/* footer */
.site-footer { max-width: 1400px; margin: 8px auto 0; padding: 20px 24px 32px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: grid; gap: 8px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

/* legal page */
.legal { max-width: 820px; margin: 0 auto; padding: 24px 16px 48px; line-height: 1.7; font-size: 15px; }
.legal section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 18px; scroll-margin-top: 90px; }
.legal h1 { font-size: 26px; margin: 8px 0 18px; }
.legal h2 { font-size: 19px; margin: 0 0 10px; }
.legal h3 { font-size: 15px; margin: 16px 0 4px; }
.legal p, .legal li { color: #3b352f; }
.legal .toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.legal .toc a { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; text-decoration: none; color: var(--ink); background: var(--panel); font-size: 14px; }
.legal .muted { color: var(--muted); font-size: 13px; }

/* language switch */
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: #fff; margin-right: 4px; }
.lang button { border: 0; background: none; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.lang button.active { background: var(--ink); color: #fff; }
.card .translated { color: var(--muted); font-size: 12px; font-style: italic; }
@media (max-width: 640px) { header { flex-wrap: wrap; } .head-right { flex-wrap: wrap; gap: 6px; } .btn { padding: 7px 11px; } }

/* tabs, upload, avatar */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: #efe7dc; border-radius: 12px; padding: 4px; margin-bottom: 4px; }
.tabs button { border: 0; background: none; padding: 9px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.tabs button.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px #0001; }
.drop { display: grid; place-items: center; gap: 8px; min-height: 130px; border: 2px dashed var(--line); border-radius: 12px; background: #fff; padding: 12px; text-align: center; font-size: 13px; color: var(--muted); cursor: pointer; }
.drop.over, .drop:hover { border-color: var(--accent); }
.drop img { max-width: 100%; max-height: 220px; border-radius: 8px; object-fit: contain; }
.text-input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.rule { font-size: 12px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.card .media.auto { aspect-ratio: auto; min-height: 160px; }
.card .media.auto video { height: auto; max-height: 440px; }
.chip small { opacity: .7; margin-left: 4px; }
.lang button { padding: 5px 8px; }

.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 6px; display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.preset img, .preset .ph { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; background: #efe7dc; display: grid; place-items: center; font-size: 28px; }
.preset.active { border-color: var(--accent); box-shadow: 0 0 0 3px #e8572a22; }

.card-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.del { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 2px 0; }
.del:hover { color: var(--bad); }

.drop.small { min-height: 90px; }
.drop.small img { max-height: 140px; }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 12px; padding: 0; margin-left: 6px; text-decoration: underline; }

/* მობილურზე ფორმა არ უნდა "მიეწებოს" — თორემ ვიდეოები მას ფარავს */
@media (max-width: 900px) {
  .form-panel { position: static; top: auto; }
  header { position: static; }
}

/* გრძელი შეცდომის ტექსტი ბარათს არ უნდა აფართოებდეს */
.gallery > * { min-width: 0; }
.card .err, .card .prompt, .card .translated { overflow-wrap: anywhere; word-break: break-word; }

/* referral + social */
.ref-link { display: flex; gap: 8px; margin: 12px 0; }
.ref-link input { flex: 1; min-width: 0; margin: 0 !important; font-size: 13px; }
.share { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.share a { text-decoration: none; color: var(--ink); }
.ref-stats { grid-template-columns: repeat(3, 1fr); margin: 0; }
.ref-stats .stat { padding: 10px; } .ref-stats .stat b { font-size: 20px; }
.social { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.social a { color: var(--ink); font-weight: 600; }
