:root {
  color-scheme: dark;
  --page: #131313;
  --panel: #1b1b1c;
  --field: #151516;
  --line: #323235;
  --text: #eef0f4;
  --muted: #a7a9b0;
  --blue: #0066ff;
  --blue-hover: #247dff;
  --radius: 16px;
  font-family: system-ui, -apple-system, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--text); min-height: 100dvh; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, .upload { -webkit-tap-highlight-color: transparent; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid #61a3ff; outline-offset: 3px; }
a { color: inherit; }
h1, h2, p { margin: 0; }
.topbar { background: #171718; border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1232px; min-height: 68px; margin: auto; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; gap: 12px; align-items: center; text-decoration: none; font-size: 15px; font-weight: 800; letter-spacing: .19em; }
.brand-accent { color: #b6d2ff; }
.mark { width: 23px; height: 23px; position: relative; }
.mark::before, .mark::after, .mark i { content: ''; position: absolute; top: 2px; height: 19px; width: 4px; background: var(--text); border-radius: 1px; }
.mark::before { left: 3px; }
.mark::after { right: 3px; }
.mark i { left: 10px; height: 22px; top: 0; transform: rotate(-37deg); background: var(--blue); z-index: 1; }
.account { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); min-width: 0; }
#account-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.main { max-width: 1232px; padding: 42px 32px 64px; margin: auto; }
.loading { color: var(--muted); }
.intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
h1 { font-size: clamp(24px, 3.2vw, 36px); letter-spacing: -.035em; line-height: 1.14; }
h2 { font-size: 18px; font-weight: 650; }
.model { border: 1px solid var(--line); color: #ccd0d8; white-space: nowrap; border-radius: 100px; padding: 8px 12px; font-size: 14px; }
.model-dot { display: inline-block; height: 7px; width: 7px; border-radius: 50%; background: #4b96ff; margin-right: 7px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.studio { display: grid; grid-template-columns: minmax(290px, 370px) minmax(0, 1fr); align-items: start; gap: 20px; }
.stack { display: grid; gap: 16px; }
.controls { padding: 20px; }
.controls > label, .stack > label, .settings > label { display: grid; gap: 8px; align-content: start; }
label, legend { font-size: 14px; font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border: 1px solid var(--line); background: var(--field); border-radius: 10px; min-height: 43px; }
.segmented label { cursor: pointer; min-width: 0; }
.segmented input, .upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.segmented span { display: grid; place-items: center; min-height: 34px; padding: 5px 8px; color: var(--muted); border-radius: 7px; white-space: nowrap; }
.segmented input:checked + span { background: #2b3038; color: var(--text); }
.segmented input:focus-visible + span { outline: 2px solid #61a3ff; outline-offset: 1px; }
.settings { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 12px; }
input:not([type="radio"]):not([type="file"]), textarea, select {
  width: 100%; color: var(--text); background: var(--field); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; min-height: 43px; font-size: 16px;
}
textarea { resize: vertical; min-height: 132px; line-height: 1.48; }
textarea::placeholder { color: #898c95; }
select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, #a7a9b0 50%), linear-gradient(135deg, #a7a9b0 50%, transparent 50%); background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
.primary, .quiet, .danger { border: 1px solid transparent; border-radius: 9px; min-height: 42px; padding: 8px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 15px; font-weight: 650; text-decoration: none; }
.primary { color: white; background: var(--blue); }
.primary:hover, .primary:focus-visible { background: var(--blue-hover); }
.primary:disabled { cursor: wait; opacity: .63; }
.quiet { background: transparent; color: var(--text); border-color: var(--line); }
.quiet:hover { background: #2b2b2e; }
.danger { background: #a62f42; color: white; }
.danger:hover { background: #c03d53; }
.generate { min-height: 48px; }
.upload { display: flex; align-items: center; gap: 11px; border: 1px dashed #505561; border-radius: 10px; padding: 14px; cursor: pointer; }
.upload:hover, .upload:focus-within { border-color: #70aaff; background: #202633; }
.upload-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 7px; background: #282f3e; color: #9dc5ff; font-size: 20px; font-weight: 400; flex: none; }
.upload strong { display: block; overflow-wrap: anywhere; }
.upload small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 3px; }
.source-preview { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.source-preview img { width: 64px; height: 48px; object-fit: cover; border-radius: 7px; }
.result { min-height: 480px; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.result-bar, .result-footer { display: flex; align-items: center; justify-content: space-between; padding: 15px 19px; gap: 12px; }
.result-bar { border-bottom: 1px solid var(--line); }
.result-footer { border-top: 1px solid var(--line); }
#result-format,.muted { color: var(--muted); }
#result-format { font-size: 13px; letter-spacing: .09em; }
.result-body { background: #171718; display: grid; place-items: center; min-height: 380px; }
.result-body img { display: block; width: 100%; max-height: 620px; object-fit: contain; }
.empty { display: grid; place-items: center; gap: 12px; text-align: center; color: var(--muted); padding: 20px; font-size: 15px; }
.empty-icon { width: 45px; height: 36px; border: 1px solid #484950; border-radius: 9px; position: relative; }
.empty-icon::before { content: ''; width: 7px; height: 7px; position: absolute; top: 7px; right: 8px; border-radius: 50%; background: #545663; }
.empty-icon::after { content: ''; width: 16px; height: 16px; position: absolute; bottom: 1px; left: 8px; border: solid #545663; border-width: 1px 0 0 1px; border-radius: 3px; transform: rotate(45deg); }
.empty-icon.busy { width: 31px; height: 31px; border-radius: 50%; border-width: 2px; border-top-color: #679eff; animation: spin .85s linear infinite; }
.empty-icon.busy::before,.empty-icon.busy::after { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .empty-icon.busy { animation: none; } }
.notice { background: #40202a; color: #ffd5dd; border: 1px solid #693545; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.signin { max-width: 430px; margin: 7vh auto 0; padding: 28px; }
.signin h1 { font-size: 29px; }
.signin > p { margin: 8px 0 24px; }
.users-panel { overflow: hidden; }
.users-panel > .notice { margin: 16px; }
.users-empty { padding: 24px; }
.users { list-style: none; margin: 0; padding: 0; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; }
.user-row + .user-row { border-top: 1px solid var(--line); }
.user-login { min-width: 0; overflow-wrap: anywhere; font-weight: 650; }
.row-actions, .dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dialog { width: min(440px, calc(100% - 28px)); color: var(--text); padding: 22px; }
.dialog::backdrop { background: #000a; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 760px) {
  .topbar-inner { min-height: 60px; padding: 0 16px; }
  .main { padding: 28px 14px 40px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 16px; }
  .studio { grid-template-columns: 1fr; gap: 14px; }
  .controls { padding: 16px; }
  .result { min-height: 320px; }
  .result-body { min-height: 250px; }
  .result-bar, .result-footer { padding: 12px 15px; }
  .signin { margin-top: 4vh; padding: 22px; }
  .user-row { padding: 13px 15px; }
}
@media (max-width: 360px) {
  .brand { letter-spacing: .12em; gap: 7px; }
  .quiet, .primary, .danger { padding-left: 10px; padding-right: 10px; font-size: 14px; }
  .user-row { align-items: flex-start; flex-direction: column; }
}
