/* Kling-style UI, dark by default with a light theme: left icon rail, a creation card, a feed of result cards. No external fonts or scripts. */
:root {
  --bg: #0a0a0f; --panel: #13131b; --panel-2: #1a1a25; --line: #262634; --text: #ececf4; --muted: #8d8da3; --faint: #5e5e73;
  --accent: #6d5bff; --accent-2: #19c7ff; --ok: #35d49a; --warn: #f5b84b; --bad: #ff6b7a; --radius: 14px;
  --grad: linear-gradient(135deg, #6d5bff 0%, #19c7ff 100%);
  --rail: #0d0d14; --topbar: rgba(10,10,15,.85); --strong: #fff; --seg-on: #2a2a3b; --drop-border: #3a3a4d; --drop-bg: #12121a;
  --media: #08080c; --media-img: #000; --wait-a: #1d1b33; --wait-b: #0a0a10; --spin-track: #2b2b40; --bar: #262637; --hover-line: #3b3b52;
  --tag-bg: rgba(0,0,0,.6); --tag-text: #dcdcec; --shadow: rgba(0,0,0,.35); --shadow-lg: rgba(0,0,0,.5); --login-a: #1f1a45; --login-b: #0a0a0f;
  --banner-bg: #2a1a20; --banner-line: #5a2a35; --banner-text: #ffb3bd; --gbtn-ring: transparent;
  color-scheme: dark;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 76px 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; background: var(--rail); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0; }
.brand { width: 42px; height: 42px; border-radius: 12px; margin-bottom: 14px; box-shadow: 0 6px 18px rgba(109, 91, 255, .35); }
.brand img { width: 100%; height: 100%; display: block; }
.rail button { width: 60px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 0; border: 0; background: transparent; color: var(--muted); border-radius: 12px; font-size: 11px; }
.rail button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail button:hover { color: var(--text); background: var(--panel); }
.rail button.on { color: var(--strong); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.rail .grow { flex: 1; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--topbar); backdrop-filter: blur(10px); position: sticky; top: var(--banner-h, 0px); z-index: 5; }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 650; flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); } .dot.busy { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.who { color: var(--muted); font-size: 12px; }
.linkbtn { background: none; border: 0; color: var(--muted); font-size: 12px; padding: 4px 6px; text-decoration: underline; }
.linkbtn:hover { color: var(--text); }

.content { padding: 26px 28px 80px; width: 100%; max-width: 1180px; margin: 0 auto; }

/* ---------- creation card ---------- */
.create { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: 0 20px 60px var(--shadow); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 7px 16px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--panel-2); color: var(--strong); border-color: var(--line); }

.prompt-wrap { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; gap: 14px; align-items: flex-start; }
.prompt-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,91,255,.18); }
.prompt-wrap textarea { flex: 1; min-height: 96px; resize: vertical; background: transparent; border: 0; outline: 0; font-size: 15px; }
.prompt-wrap textarea::placeholder { color: var(--faint); }
.count { position: absolute; }
.drops { display: flex; gap: 10px; flex-wrap: wrap; }
.drop { width: 108px; height: 108px; border-radius: 12px; border: 1.5px dashed var(--drop-border); background: var(--drop-bg); display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 12px; padding: 6px; position: relative; overflow: hidden; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); }
.drop img, .drop video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.drop .x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; line-height: 1; display: none; z-index: 2; }
.drop.has .x { display: block; }
.drop small { display: block; color: var(--faint); margin-top: 2px; }
.drop .plus { font-size: 26px; line-height: 1; color: var(--faint); }

.opts { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; margin-top: 14px; }
.opt { display: flex; flex-direction: column; gap: 5px; }
.opt > label, .opt > .lab { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 600; }
.seg button.on { background: var(--seg-on); color: var(--strong); box-shadow: 0 0 0 1px var(--line); }
.seg button:hover:not(.on) { color: var(--text); }
.field { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; outline: 0; min-width: 0; }
.field:focus { border-color: var(--accent); }
input.seed { width: 118px; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); max-width: 520px; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.spacer { flex: 1; }
.est { color: var(--muted); font-size: 12px; align-self: center; }
.go { border: 0; border-radius: 12px; padding: 12px 26px; font-weight: 700; font-size: 15px; color: #fff; background: var(--grad); box-shadow: 0 8px 26px rgba(109,91,255,.35); }
.go:hover { filter: brightness(1.1); }
.go:disabled { filter: grayscale(.8) brightness(.7); cursor: not-allowed; box-shadow: none; }
.note { color: var(--muted); font-size: 12px; margin-top: 10px; }
.error { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 1em; }

/* ---------- feed ---------- */
.feed-head { display: flex; align-items: center; gap: 12px; margin: 30px 0 14px; }
.feed-head h2 { margin: 0; font-size: 16px; flex: 1; }
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 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 { position: relative; background: var(--media); aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; }
.card .media img, .card .media video { width: 100%; height: 100%; object-fit: contain; background: var(--media-img); display: block; }
.card .wait { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px; text-align: center; background: radial-gradient(circle at 50% 30%, var(--wait-a), var(--wait-b) 70%); }
.spin { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--spin-track); border-top-color: var(--accent-2); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { width: 80%; height: 6px; border-radius: 6px; background: var(--bar); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--grad); transition: width .6s ease; }
.card .wait .st { font-size: 12px; color: var(--muted); }
.card .wait .bad { color: var(--bad); font-size: 12px; max-height: 70px; overflow: auto; }
.card .meta { padding: 11px 13px 12px; display: flex; flex-direction: column; gap: 6px; }
.card .title { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { color: var(--faint); font-size: 11.5px; }
.card .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.mini { border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); border-radius: 8px; padding: 4px 10px; font-size: 12px; text-decoration: none; }
.mini:hover { color: var(--strong); border-color: var(--hover-line); }
.mini.danger:hover { color: var(--bad); border-color: var(--bad); }
.tag { position: absolute; top: 8px; left: 8px; background: var(--tag-bg); color: var(--tag-text); font-size: 11px; border-radius: 6px; padding: 2px 8px; z-index: 1; }
.empty { color: var(--faint); text-align: center; padding: 50px 10px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- users ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 220px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
td.r { text-align: right; white-space: nowrap; }
.off { opacity: .5; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 50% -10%, var(--login-a) 0%, var(--login-b) 60%); }
.login { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 30px 28px; box-shadow: 0 30px 80px var(--shadow-lg); text-align: center; }
.login .brand { margin: 0 auto 14px; width: 54px; height: 54px; font-size: 26px; border-radius: 16px; }
.login h1 { font-size: 22px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.gbtn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; border: 0; border-radius: 12px; padding: 12px; font-weight: 650; font-size: 15px; text-decoration: none; box-shadow: 0 0 0 1px var(--gbtn-ring); }
.gbtn:hover { background: #f1f1f6; }
.gbtn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.or { color: var(--faint); font-size: 12px; margin: 16px 0 10px; display: flex; align-items: center; gap: 10px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login .field { width: 100%; text-align: center; letter-spacing: .12em; text-transform: uppercase; }
.login .go { width: 100%; margin-top: 10px; }
.banner { background: var(--banner-bg); border: 1px solid var(--banner-line); color: var(--banner-text); border-radius: 10px; padding: 9px 12px; margin-bottom: 16px; font-size: 13px; }

/* ---------- light theme (theme.js sets data-theme) ---------- */
:root[data-theme="light"] {
  --bg: #f4f5fa; --panel: #ffffff; --panel-2: #eff0f8; --line: #dcdde9; --text: #17172a; --muted: #5a5a76; --faint: #85859f;
  --accent: #5b49f0; --accent-2: #0b86b8; --ok: #12925e; --warn: #a96f08; --bad: #d1344b;
  --rail: #ffffff; --topbar: rgba(244,245,250,.88); --strong: #17172a; --seg-on: #ffffff; --drop-border: #c2c3d6; --drop-bg: #f7f7fc;
  --media: #e8e9f3; --media-img: #e8e9f3; --wait-a: #e4e1ff; --wait-b: #eef0f9; --spin-track: #d5d6e6; --bar: #dcdde9; --hover-line: #b4b5cc;
  --tag-bg: rgba(255,255,255,.88); --tag-text: #17172a; --shadow: rgba(40,40,95,.12); --shadow-lg: rgba(40,40,95,.2); --login-a: #e3e0ff; --login-b: #f4f5fa;
  --banner-bg: #ffecef; --banner-line: #f0b6c0; --banner-text: #a1243a; --gbtn-ring: #dcdde9;
  color-scheme: light;
}
.iconbtn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); padding: 0; }
.iconbtn:hover { color: var(--text); border-color: var(--hover-line); }
.iconbtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn .i-moon { display: none; }
:root[data-theme="light"] .iconbtn .i-sun { display: none; }
:root[data-theme="light"] .iconbtn .i-moon { display: block; }
.iconbtn.floating { position: fixed; top: 16px; right: 16px; z-index: 30; }

/* ---------- credits and settings ---------- */
.chip.credits { color: var(--text); font-weight: 600; }
.chip.credits.low { color: var(--warn); border-color: var(--warn); }
.rail button.off { opacity: .45; }
.note.warn { color: var(--warn); }
.go small { font-weight: 600; opacity: .9; margin-left: 6px; }
input.amt { width: 76px; padding: 4px 8px; margin-right: 4px; }
input.num, select.field.num { width: 120px; }
.setting-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 22px; }
.row-check { align-items: flex-start; max-width: none; color: var(--text); }
.row-check small { display: block; color: var(--faint); font-size: 12px; }
.row-check b { font-weight: 600; }
.opt small { color: var(--faint); font-size: 12px; max-width: 280px; }
.pause-panel { border-color: var(--warn); }
.price-table td:last-child, .price-table th:last-child { text-align: right; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; padding-bottom: 66px; }
  .rail { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: 62px; flex-direction: row; justify-content: space-around; padding: 4px 6px; z-index: 20; border-right: 0; border-top: 1px solid var(--line); }
  .rail .brand, .rail .grow { display: none; }
  .content { padding: 16px 14px 90px; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
}
.mini.helper { align-self: flex-end; padding: 8px 12px; }
.viewing { position: sticky; top: 0; z-index: 8; display: flex; gap: 12px; align-items: center; justify-content: center; padding: 8px 14px; background: var(--warn); color: #1a1100; font-weight: 600; font-size: 13px; }
.viewing .mini { background: rgba(255,255,255,.55); color: #1a1100; border-color: rgba(0,0,0,.25); }
.who-link { text-decoration: underline; color: var(--accent-2); font-size: 13px; padding: 0; }

/* ---------- the viewer ---------- */
.card .media button.open { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; display: block; }
.card .media button.open img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .media button.open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.play { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(0,0,0,.55); box-shadow: 0 0 0 2px rgba(255,255,255,.75) inset; transition: transform .15s, background .15s; }
.play::after { content: ""; position: absolute; left: 20px; top: 15px; border-style: solid; border-width: 11px 0 11px 18px; border-color: transparent transparent transparent #fff; }
button.open:hover .play { transform: scale(1.08); background: rgba(0,0,0,.7); }
body.no-scroll { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 100; background: rgba(5,5,10,.88); backdrop-filter: blur(6px); display: grid; grid-template-rows: 1fr auto; padding: 18px 70px 14px; }
.viewer-stage { min-height: 0; display: grid; place-items: center; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; border-radius: 10px; background: #000; box-shadow: 0 20px 80px rgba(0,0,0,.6); }
.viewer-info { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #ececf4; max-width: 980px; width: 100%; margin: 12px auto 0; }
.viewer-title { font-size: 14px; font-weight: 600; }
.viewer-meta { font-size: 12px; color: #9a9ab2; margin-top: 2px; }
.viewer-close, .viewer-nav { position: absolute; border: 0; border-radius: 50%; width: 44px; height: 44px; background: rgba(255,255,255,.12); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0 0 3px; }
.viewer-close:hover, .viewer-nav:hover { background: rgba(255,255,255,.24); }
.viewer-close { top: 14px; right: 16px; font-size: 28px; }
.viewer-nav { top: 50%; margin-top: -22px; }
.viewer-nav.prev { left: 14px; } .viewer-nav.next { right: 14px; }
@media (max-width: 760px) { .viewer { padding: 56px 10px 12px; } .viewer-nav { top: auto; bottom: 62px; margin: 0; } .viewer-nav.prev { left: 10px; } .viewer-nav.next { right: 10px; } }
