:root {
  color-scheme: light;
  --page: #f5f5f7;
  --surface: #fff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --line: #e5e5ea;
  --accent: #0071e3;
  --accent-hover: #0062c4;
  --accent-soft: #eef6ff;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(25, 35, 55, .06);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body { min-height: 100vh; margin: 0; background: var(--page); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.topbar { width: min(100% - 36px, 760px); margin: 0 auto; min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { flex: 0 0 auto; border-radius: 12px; }
.brand-copy { display: grid; gap: 2px; min-width: 0; }
.eyebrow { color: var(--faint); font-size: 10px; line-height: 1.2; font-weight: 700; letter-spacing: .11em; }
.brand-name { font-size: 16px; font-weight: 650; letter-spacing: -.025em; }
.shell { width: min(100% - 36px, 660px); margin: 30px auto 80px; }
.view { animation: appear .32s ease-out both; }
.intro { margin: 0 0 24px; }
.intro .eyebrow { color: var(--accent); }
.intro h1 { max-width: 600px; margin: 9px 0 9px; font-size: clamp(31px, 8vw, 42px); line-height: 1.06; letter-spacing: -.055em; font-weight: 720; }
.intro p { max-width: 540px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.5; }
.panel { padding: 26px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.setup-panel h2, .login-panel label { margin: 0 0 16px; font-size: 18px; letter-spacing: -.025em; }
.setup-list { margin: 0 0 24px; padding-left: 22px; color: #424247; font-size: 14px; line-height: 1.6; }
.setup-list li { padding-left: 4px; margin: 0 0 12px; }
.setup-list strong { color: var(--ink); font-weight: 650; }
code { padding: 2px 5px; border-radius: 5px; background: #f1f1f4; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; overflow-wrap: anywhere; }
.small-note { margin: 15px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.center-note { max-width: 400px; margin: 15px auto 0; text-align: center; }
.login-view { width: min(100%, 500px); margin: 7vh auto 0; }
.login-panel { display: grid; gap: 14px; }
.login-panel label { margin: 0; font-size: 14px; font-weight: 650; }
input[type="password"] { width: 100%; min-height: 52px; border: 1px solid #d2d2d7; border-radius: 12px; padding: 0 14px; color: var(--ink); background: #fff; outline: none; }
input[type="password"]:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, .15); }
.studio-panel { padding: 0 26px; }
.form-section { padding: 24px 0; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { border-bottom: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-heading > div, .settings-row > div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.step-label { flex: 0 0 auto; color: var(--faint); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
h2 { margin: 0; font-size: 17px; letter-spacing: -.03em; font-weight: 660; }
.optional { margin-left: 5px; color: var(--faint); font-size: 12px; font-weight: 450; letter-spacing: 0; }
.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-action { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px; text-align: left; color: var(--ink); background: #fafafc; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.photo-action:hover { background: #f3f8ff; border-color: #b9d7f7; }
.photo-action:active { transform: scale(.985); }
.action-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 11px; color: var(--accent); background: var(--accent-soft); font-size: 22px; }
.image-icon { font-size: 25px; }
.photo-action strong, .photo-action small { display: block; }
.photo-action strong { font-size: 13px; font-weight: 640; }
.photo-action small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.hint { display: block; color: var(--muted); font-size: 12px; line-height: 1.45; }
#photoTitle + .optional { white-space: nowrap; }
.form-section > .hint { margin: 10px 0 0; }
.source-preview { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 9px 12px 9px 9px; border: 1px solid var(--line); border-radius: 13px; background: #fafafc; min-width: 0; }
.source-preview img { width: 58px; height: 58px; object-fit: cover; border-radius: 9px; background: #e8e8ed; }
.source-info { display: grid; gap: 5px; min-width: 0; }
.source-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 620; }
.source-info span { color: var(--muted); font-size: 11px; }
.text-button { padding: 8px 2px; color: var(--accent); background: transparent; border: 0; font-size: 13px; font-weight: 550; cursor: pointer; }
.text-button:hover { color: var(--accent-hover); }
textarea { display: block; width: 100%; min-height: 140px; resize: vertical; padding: 14px; border: 1px solid #d2d2d7; border-radius: 13px; background: #fff; color: var(--ink); font-size: 15px; line-height: 1.48; outline: none; }
textarea::placeholder, input::placeholder { color: #9a9aa0; }
.textarea-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-top: 8px; }
.char-count { flex: 0 0 auto; color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.model-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.model-option { display: grid; align-content: start; gap: 8px; min-height: 103px; padding: 14px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); cursor: pointer; transition: border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.model-option.selected { border-color: var(--accent); background: #f7fbff; box-shadow: 0 0 0 1px var(--accent); }
.model-top { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.model-top strong { font-size: 15px; letter-spacing: -.02em; }
.model-tag { padding: 4px 6px; border-radius: 6px; background: #f1f1f4; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; }
.model-option.selected .model-tag { color: var(--accent); background: var(--accent-soft); }
.model-description { color: var(--muted); font-size: 11px; line-height: 1.4; }
.model-footnote { margin: 10px 0 0; color: var(--faint); font-size: 11px; line-height: 1.45; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.select-wrap select { min-width: 145px; min-height: 42px; padding: 0 34px 0 12px; color: var(--ink); background-color: #fff; border: 1px solid #d2d2d7; border-radius: 10px; outline: none; cursor: pointer; }
.submit-area { padding: 21px 0 24px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 0 18px; border: 1px solid transparent; border-radius: 12px; text-decoration: none; font-size: 14px; font-weight: 620; cursor: pointer; transition: background .16s ease, border-color .16s ease, transform .16s ease, opacity .16s ease; }
.button:active:not(:disabled) { transform: scale(.99); }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-primary:disabled { cursor: not-allowed; opacity: .48; }
.button-secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button-secondary:hover { background: #f7f7f9; }
.full-width { width: 100%; }
.button-arrow { margin-left: auto; font-size: 17px; }
.generate-button { min-height: 54px; }
.form-message { min-height: 0; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }
.form-message:not(:empty) { margin-top: 12px; }
.form-message.error { color: var(--danger); }
.form-message.success { color: #267145; }
.busy .button-arrow { display: none; }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .75s linear infinite; }
.result-section { margin-top: 30px; animation: appear .32s ease-out both; }
.result-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.result-heading .eyebrow { color: var(--accent); }
.result-heading h2 { margin-top: 5px; font-size: 23px; }
.result-frame { display: grid; place-items: center; min-height: 140px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #eeeef1; }
.result-frame img { display: block; max-width: 100%; max-height: min(72vh, 760px); object-fit: contain; }
.save-button { margin-top: 12px; }
.result-hint { margin-top: 9px; text-align: center; }
.page-footer { margin: 25px 4px 0; padding-top: 18px; border-top: 1px solid var(--line); }
.page-footer p { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.page-footer a { display: inline-block; color: var(--accent); font-size: 11px; text-decoration: none; }
.page-footer a:hover { text-decoration: underline; }
.install-hint { color: #55555b !important; }
.toast { position: fixed; z-index: 5; inset: auto 18px calc(18px + env(safe-area-inset-bottom)) 18px; width: min(520px, calc(100% - 36px)); margin: 0 auto; padding: 13px 16px; color: #fff; background: #27272a; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 13px; line-height: 1.45; text-align: center; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(0,113,227,.36); outline-offset: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 680px) {
  .topbar { width: min(100% - 28px, 760px); min-height: 72px; }
  .shell { width: min(100% - 28px, 660px); margin-top: 25px; }
  .panel { border-radius: 17px; }
}
@media (max-width: 400px) {
  .topbar { width: calc(100% - 24px); min-height: 68px; }
  .shell { width: calc(100% - 24px); margin-top: 21px; }
  .brand { gap: 9px; }
  .brand img { width: 38px; height: 38px; }
  .brand-name { font-size: 15px; }
  .panel { padding: 20px; }
  .studio-panel { padding: 0 18px; }
  .form-section { padding: 20px 0; }
  .photo-actions, .model-options { gap: 8px; }
  .photo-action { padding: 10px 9px; gap: 8px; }
  .action-icon { width: 32px; height: 32px; border-radius: 9px; font-size: 19px; }
  .photo-action strong { font-size: 12px; }
  .photo-action small { font-size: 10px; }
  .model-option { min-height: 110px; padding: 11px; }
  .model-description { font-size: 10px; }
  .textarea-meta { display: block; }
  .char-count { display: block; margin-top: 6px; text-align: right; }
  .select-wrap select { min-width: 130px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
