:root {
  --bg: #06111f;
  --panel: #0b1929;
  --panel-2: #0e2033;
  --line: #203b52;
  --text: #f4f8fb;
  --muted: #9aabba;
  --cyan: #4bd6d0;
  --blue: #3977ef;
  --danger: #ff7f7f;
  --radius: 18px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: linear-gradient(180deg, #071422 0%, var(--bg) 48%, #08131e 100%); min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button, select, input[type="file"] { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.topbar { min-height: 76px; padding: 10px clamp(22px, 4vw, 72px); display: grid; grid-template-columns: minmax(190px, 1fr) auto minmax(260px, 1fr); align-items: center; gap: 20px; border-bottom: 1px solid var(--line); background: rgba(6, 17, 31, .97); position: sticky; top: 0; z-index: 20; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 24px; letter-spacing: .03em; justify-self: start; }
.brand small { font-size: 18px; }
.brand-mark { color: var(--cyan); width: 34px; height: 34px; border: 2px solid currentColor; border-radius: 50%; display: grid; place-items: center; }
.topbar nav { display: flex; gap: clamp(24px, 4vw, 56px); align-self: stretch; align-items: center; }
.topbar nav a, .nav-button { color: var(--muted); align-self: stretch; display: grid; place-items: center; border: 0; border-bottom: 3px solid transparent; min-width: 82px; background: transparent; padding: 0 8px; }
.topbar nav a:hover, .topbar nav a.active, .nav-button:hover, .nav-button[aria-expanded="true"] { color: var(--text); border-bottom-color: var(--cyan); }
.account-area { justify-self: end; display: flex; align-items: center; justify-content: flex-end; gap: 9px; min-width: 0; }
.account-copy { display: grid; text-align: right; min-width: 0; }
.account-copy strong { color: #dffcf7; font-size: 16px; white-space: nowrap; }
.account-copy small { color: var(--muted); font-size: 11px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid #31516a; color: var(--cyan); background: #102438; font-size: 20px; }

main { width: min(1640px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 80px; }
.intro { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 24px; }
.eyebrow { color: var(--cyan); font-size: 13px; font-weight: 700; letter-spacing: .18em; margin: 0 0 8px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(32px, 4vw, 52px); margin-bottom: 10px; }
h2 { font-size: 24px; margin-bottom: 8px; }
.intro > div > p:last-child, .works-heading p { color: var(--muted); margin-bottom: 0; }
.service-state { color: #c8e8d1; font-size: 14px; padding-bottom: 6px; }
.service-state span { display: inline-block; width: 9px; height: 9px; background: #57d98b; border-radius: 50%; margin-right: 6px; }

.studio-grid { display: grid; grid-template-columns: minmax(470px, 46%) minmax(0, 54%); gap: 16px; align-items: stretch; }
.control-panel, .preview-panel, .works-section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 18px 55px rgba(0, 0, 0, .18); }
.control-panel { padding: clamp(20px, 2.2vw, 34px); display: flex; flex-direction: column; }
.field-heading { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 10px; gap: 16px; }
.field-heading label { font-size: 18px; font-weight: 700; }
.field-heading label small, .field-heading > span, .field-tools > span { color: var(--muted); font-size: 13px; font-weight: 400; }
.field-tools { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-width: 0; }
.inline-guide-button { border: 0; background: transparent; color: var(--cyan); font-size: 13px; padding: 4px 0; white-space: nowrap; }
.inline-guide-button:hover { color: #8df3ed; text-decoration: underline; text-underline-offset: 3px; }
textarea, input[type="password"], input[type="text"], select { color: var(--text); background: #091522; border: 1px solid #2b475e; border-radius: 12px; outline: none; }
textarea:focus, input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(75, 214, 208, .12); }
textarea { width: 100%; min-height: 230px; resize: vertical; padding: 16px; line-height: 1.65; font-size: 16px; margin-bottom: 10px; }
.content-policy-note { margin: 0 0 24px; color: #aebdca; font-size: 13px; line-height: 1.65; }

.upload-zone { min-height: 250px; border: 1px dashed #4b687e; background: #091522; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 24px; text-align: center; transition: border-color .2s, background .2s; }
.upload-zone:hover, .upload-zone.dragging { border-color: var(--cyan); background: #0c1c2b; }
.upload-icon { font-size: 44px; color: var(--cyan); }
.upload-zone strong { font-size: 16px; }
.upload-zone small, .upload-note { color: var(--muted); }
.upload-note { font-size: 12px; }
.reference-thumbnails { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; margin-top: 12px; }
.reference-card { position: relative; border: 1px solid #2c4a61; border-radius: 11px; overflow: hidden; background: #081522; min-width: 0; }
.reference-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #020810; }
.reference-info { padding: 8px; display: grid; gap: 3px; }
.reference-info strong, .reference-info small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-info strong { font-size: 11px; }
.reference-info small { color: var(--muted); font-size: 10px; }
.reference-remove { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,.32); background: rgba(3,10,18,.82); color: #fff; }

.parameter-area { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(180px, .75fr); gap: 12px; margin-top: 20px; }
.settings-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.settings-row label { color: var(--muted); font-size: 12px; }
.settings-row select { display: block; width: 100%; height: 48px; padding: 0 12px; color: var(--text); margin-top: 6px; }
.estimate-card { border: 1px solid #2a4b61; background: #0c1d2d; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; justify-content: center; gap: 5px; }
.estimate-card span, .estimate-card small { color: var(--muted); font-size: 11px; }
.estimate-card strong { font-size: 15px; color: #d9fbf6; line-height: 1.35; }
.constraint-message { min-height: 22px; padding-top: 8px; color: #ffcf87; font-size: 13px; }

.primary-button, .secondary-button, .text-button, .danger-button { border-radius: 11px; color: var(--text); font-weight: 700; }
.primary-button { border: 0; min-height: 54px; background: linear-gradient(100deg, #3dbea8, var(--blue)); padding: 0 24px; font-size: 17px; }
.primary-button:hover { filter: brightness(1.08); }
.primary-button:disabled { cursor: wait; opacity: .62; }
.secondary-button { background: #142b3d; border: 1px solid #31516a; min-height: 44px; padding: 0 18px; }
.text-button { border: 0; background: transparent; color: var(--cyan); padding: 8px; }
.danger-button { border: 0; background: #43262d; color: #ffb6b6; padding: 10px 14px; }
.message { min-height: 24px; color: var(--muted); margin: 8px 0; font-size: 14px; }
.message.error { color: var(--danger); }
.message.success { color: #77dfa5; }

.preview-panel { padding: clamp(18px, 2vw, 30px); display: flex; flex-direction: column; min-width: 0; }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 14px; }
.panel-title h2 { margin: 0; }
.badge { border: 1px solid #31516a; background: #102539; color: #d3e4ed; border-radius: 999px; padding: 8px 14px; font-size: 13px; white-space: nowrap; }
.preview-stage { flex: 1; min-height: 500px; border-radius: 13px; overflow: hidden; background: #020810; border: 1px solid #29475e; display: grid; place-items: center; position: relative; }
.preview-stage > img, .preview-stage > video { width: 100%; height: 100%; object-fit: contain; background: #020810; }
.preview-placeholder { position: absolute; inset: 0; background: rgba(3, 11, 20, .88); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.preview-placeholder small { color: var(--muted); }
.spinner { width: 38px; height: 38px; border: 3px solid #2a4658; border-top-color: var(--cyan); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-area { margin-top: 18px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: 14px; }
.progress-track { height: 7px; background: #183147; border-radius: 999px; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--cyan), #72a84f); transition: width .35s ease; }

.works-section { margin-top: 20px; padding: clamp(22px, 3vw, 38px); }
.works-heading { display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.works-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.work-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.work-card video, .work-placeholder { width: 100%; aspect-ratio: 16 / 9; background: #030a12; display: grid; place-items: center; color: var(--muted); padding: 18px; text-align: center; }
.work-card-content { padding: 16px; }
.work-card h3 { font-size: 16px; line-height: 1.5; margin: 0 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.work-meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 14px; }
.work-actions { display: flex; gap: 8px; }
.work-actions a { display: inline-grid; place-items: center; }
.empty-state { color: var(--muted); border: 1px dashed #33516a; border-radius: 14px; padding: 34px; text-align: center; }

.login-gate { position: fixed; inset: 0; z-index: 100; background: rgba(2, 8, 15, .94); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 20px; }
.login-gate[hidden] { display: none; }
.login-card { width: 100%; max-width: 520px; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 38px; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); }
.login-brand { margin-bottom: 28px; }
.login-card > p:not(.eyebrow) { color: var(--muted); }
.login-card > label { display: block; margin: 22px 0 8px; font-weight: 700; }
.key-input-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.key-input-row input { width: 100%; height: 54px; padding: 0 14px; min-width: 0; }
.key-input-row .secondary-button { min-height: 54px; }
.key-status { color: var(--muted); font-size: 12px; margin-top: 8px; }
.login-card > .primary-button { width: 100%; }

body.guide-open { overflow: hidden; }
.guide-backdrop { position: fixed; inset: 0; z-index: 48; background: rgba(1, 7, 13, .72); backdrop-filter: blur(4px); }
.creation-guide { position: fixed; inset: 0 0 0 auto; z-index: 50; width: min(680px, 100%); height: 100dvh; display: flex; flex-direction: column; color: var(--text); background: #081727; border-left: 1px solid #2b4b62; box-shadow: -24px 0 70px rgba(0, 0, 0, .48); }
.guide-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding: 28px 30px 22px; border-bottom: 1px solid var(--line); background: #0a1a2a; }
.guide-header h2 { font-size: 26px; margin-bottom: 8px; }
.guide-header p:last-child { color: var(--muted); margin-bottom: 0; line-height: 1.6; }
.guide-close { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 11px; border: 1px solid #31516a; color: var(--text); background: #102438; font-size: 28px; line-height: 1; }
.guide-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 30px; border-bottom: 1px solid var(--line); background: #0a1a2a; }
.guide-tab { min-height: 44px; border: 1px solid transparent; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 700; }
.guide-tab:hover { color: var(--text); background: #102438; }
.guide-tab.active { color: #dffcf7; border-color: #347c82; background: rgba(75, 214, 208, .1); }
.guide-body { flex: 1; min-height: 0; overflow-y: auto; padding: 26px 30px 38px; }
.guide-panel { display: grid; gap: 22px; }
.guide-callout { display: grid; gap: 6px; border-left: 3px solid var(--cyan); border-radius: 0 12px 12px 0; background: #0d2233; padding: 16px 18px; line-height: 1.55; }
.guide-callout span, .guide-section-heading small { color: var(--muted); }
.guide-section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.guide-section-heading > span { font-size: 17px; font-weight: 700; }
.guide-section-heading small { font-size: 12px; text-align: right; }
.role-grid { list-style: none; margin: -10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-grid li { min-height: 78px; display: grid; place-content: center; justify-items: center; gap: 6px; border: 1px solid #29475e; border-radius: 11px; background: #0b1c2c; text-align: center; }
.role-grid b { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; color: #05131f; background: var(--cyan); font-size: 12px; }
.role-grid span { font-size: 13px; }
.guide-tool { display: grid; gap: 14px; border: 1px solid #29475e; border-radius: 15px; background: #091522; padding: 18px; }
.nine-grid-picker { width: 100%; min-height: 76px; display: grid; place-content: center; gap: 4px; border: 1px dashed #4b687e; border-radius: 11px; color: var(--text); text-align: center; background: #0b1a29; }
.nine-grid-picker:hover { border-color: var(--cyan); background: #0d2030; }
.nine-grid-picker span { color: var(--muted); font-size: 12px; }
.nine-grid-preview { width: min(100%, 480px); aspect-ratio: 1; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 6px; padding: 6px; border: 1px solid #2b4a61; border-radius: 13px; background: #06111f; overflow: hidden; }
.nine-grid-preview > span { min-width: 0; min-height: 0; display: grid; place-items: center; color: #577084; background: #102438; font-weight: 700; overflow: hidden; }
.nine-grid-preview img { width: 100%; height: 100%; display: block; object-fit: contain; background: #0a1826; }
.guide-actions { display: grid; grid-template-columns: minmax(120px, .75fr) minmax(220px, 1.35fr); gap: 10px; }
.guide-actions .primary-button, .guide-actions .secondary-button { width: 100%; }
.guide-warning { border: 1px solid #5e4a31; border-radius: 12px; color: #e5d5bd; background: #241d16; padding: 14px 16px; line-height: 1.65; }
.prompt-formula { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.prompt-formula span { border: 1px solid #31516a; border-radius: 999px; color: #dcf6f3; background: #102438; padding: 8px 12px; font-size: 13px; }
.prompt-formula i { color: var(--cyan); font-style: normal; }
.guide-example, .preflight-card { border: 1px solid #29475e; border-radius: 15px; background: #091522; padding: 20px; }
.guide-example h3, .preflight-card h3 { margin: 0 0 16px; font-size: 17px; }
.guide-example p { margin: 0 0 10px; color: #c6d2dc; line-height: 1.6; }
.guide-example p:last-child { margin-bottom: 0; }
.guide-example b { color: #eaf9f7; }
.guide-wide-button { width: 100%; }
.consistency-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.consistency-list li { display: grid; grid-template-columns: 110px 1fr; gap: 14px; border: 1px solid #29475e; border-radius: 12px; background: #0b1c2c; padding: 15px 16px; line-height: 1.55; }
.consistency-list b { color: #dffcf7; }
.consistency-list span { color: var(--muted); }
.preflight-card { display: grid; gap: 12px; }
.preflight-card label { display: flex; gap: 10px; align-items: flex-start; color: #c6d2dc; line-height: 1.5; }
.preflight-card input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--cyan); }
.guide-close:focus-visible, .guide-tab:focus-visible, .nav-button:focus-visible, .inline-guide-button:focus-visible, .nine-grid-picker:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

[hidden] { display: none !important; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .account-copy small { max-width: 150px; }
  .studio-grid { grid-template-columns: 1fr; }
  .preview-stage { min-height: 420px; }
}

@media (max-width: 760px) {
  .topbar { position: static; grid-template-columns: 1fr auto; padding: 12px 18px 0; gap: 10px 14px; }
  .brand { font-size: 20px; }
  .brand small { font-size: 15px; }
  .account-area { max-width: 58vw; }
  .account-copy strong { font-size: 14px; }
  .account-copy small { white-space: normal; max-width: 150px; line-height: 1.25; }
  .account-area .text-button { display: inline-flex; font-size: 12px; padding: 4px; }
  .topbar nav { grid-column: 1 / -1; width: 100%; justify-content: space-around; gap: 8px; height: 48px; }
  .topbar nav a, .nav-button { min-width: 88px; }
  main { width: min(100% - 28px, 1640px); padding-top: 28px; }
  .intro { align-items: start; flex-direction: column; }
  .service-state { display: none; }
  .parameter-area { grid-template-columns: 1fr; }
  .settings-row { grid-template-columns: 1fr; }
  .upload-zone { min-height: 260px; }
  .reference-thumbnails { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-stage { min-height: 280px; }
  .works-heading { align-items: start; flex-direction: column; }
  .works-grid { grid-template-columns: 1fr; }
  .control-panel, .preview-panel, .works-section { border-radius: 14px; }
  .login-card { width: calc(100vw - 40px); max-width: calc(100vw - 40px); padding: 28px 22px; }
  .key-input-row { grid-template-columns: minmax(0, 1fr) 72px; }
  .key-input-row .secondary-button { padding: 0 10px; }
  .creation-guide { width: 100%; border-left: 0; }
  .guide-header { padding: 22px 18px 18px; }
  .guide-header h2 { font-size: 22px; }
  .guide-tabs { padding: 10px 14px; }
  .guide-body { padding: 20px 16px 30px; }
  .guide-section-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .guide-section-heading small { text-align: left; }
  .role-grid li { min-height: 68px; }
  .guide-actions { grid-template-columns: 1fr; }
  .consistency-list li { grid-template-columns: 1fr; gap: 5px; }
  .field-tools { gap: 8px; }
  .inline-guide-button { font-size: 12px; }
}
/* Shared AIbox navigation and interaction polish */
.brand { color: var(--text); transition: color .18s ease, transform .18s ease, filter .18s ease; }
.brand:hover { color: #ffffff; transform: translateY(-1px); filter: drop-shadow(0 0 10px rgba(75, 214, 208, .22)); }
.topbar nav .home-link { min-width: 70px; min-height: 34px; padding: 0 13px; border: 1px solid #31516a; border-bottom-width: 1px; border-radius: 9px; color: #c2d9eb; background: rgba(12, 33, 52, .78); }
.topbar nav .home-link:hover, .topbar nav .home-link:focus-visible { border-color: var(--cyan); color: #effffc; background: rgba(25, 74, 84, .72); box-shadow: 0 0 18px rgba(75, 214, 208, .16); }
.topbar nav a:focus-visible, .nav-button:focus-visible, .icon-button:focus-visible, .text-button:focus-visible, .primary-button:focus-visible, .secondary-button:focus-visible, .danger-button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.primary-button, .secondary-button, .text-button, .danger-button, .icon-button { transition: transform .18s ease, filter .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease; }
.primary-button:hover, .secondary-button:hover, .icon-button:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 10px 24px rgba(25, 131, 191, .2); }
.primary-button:active, .secondary-button:active, .icon-button:active { transform: translateY(0) scale(.98); }
.primary-button { background: linear-gradient(100deg, #42c8b3 0%, #3d91ef 52%, #416ff1 100%); background-size: 180% 100%; }
.primary-button:hover { background-position: 100% 0; filter: brightness(1.08); }
.danger-button:hover { background: #5a2d36; transform: translateY(-1px); }
