:root {
  color-scheme: dark;
  --bg: #0a0c0b;
  --panel: rgba(20, 23, 21, 0.86);
  --panel-strong: #171a18;
  --line: rgba(235, 229, 211, 0.11);
  --line-strong: rgba(235, 229, 211, 0.2);
  --text: #f3efe4;
  --muted: #979b93;
  --accent: #c8ff6b;
  --accent-dark: #1d2d13;
  --warm: #f0a86b;
  --danger: #ff857d;
  --radius: 22px;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 45% -10%, #17211a 0, transparent 34%), var(--bg); overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.ambient { position: fixed; pointer-events: none; filter: blur(2px); opacity: .25; z-index: 0; }
.ambient-a { width: 420px; height: 420px; right: -240px; top: 20%; border: 1px solid rgba(200,255,107,.22); border-radius: 50%; box-shadow: 0 0 80px rgba(200,255,107,.08); }
.ambient-b { width: 240px; height: 760px; left: 33%; bottom: -500px; background: linear-gradient(180deg, transparent, rgba(240,168,107,.15)); transform: rotate(38deg); }

.topbar { height: 82px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); position: relative; z-index: 2; backdrop-filter: blur(18px); }
.brand { display: flex; gap: 13px; align-items: center; color: var(--text); text-decoration: none; }
.brand strong { display: block; font-family: Georgia, "Noto Serif SC", serif; font-size: 22px; letter-spacing: .18em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .2em; }
.brand-mark { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; gap: 3px; border: 1px solid var(--line-strong); border-radius: 50%; }
.brand-mark i { width: 2px; display: block; background: var(--accent); border-radius: 4px; }
.brand-mark i:nth-child(1), .brand-mark i:nth-child(5) { height: 8px; opacity: .5; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { height: 17px; }
.brand-mark i:nth-child(3) { height: 25px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.status-pill { padding: 9px 12px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; }
.status-pill i { width: 7px; height: 7px; background: #d8ad65; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.status-pill.ready i { background: var(--accent); }
.status-pill.error i { background: var(--danger); }

.app-shell { max-width: 1740px; min-height: calc(100vh - 136px); margin: 0 auto; display: grid; grid-template-columns: minmax(290px, .82fr) minmax(480px, 1.55fr) minmax(340px, 1fr); position: relative; z-index: 1; }
.mode-panel, .workspace, .result-panel { min-width: 0; padding: 44px 34px; }
.mode-panel, .workspace { border-right: 1px solid var(--line); }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .23em; text-transform: uppercase; }
.mode-panel h1 { margin: 20px 0 18px; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(31px, 3vw, 49px); line-height: 1.18; font-weight: 500; letter-spacing: -.04em; }
.intro { max-width: 360px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.mode-list { margin-top: 34px; display: grid; gap: 9px; }
.mode-card { width: 100%; padding: 15px 14px; border: 1px solid transparent; border-radius: 15px; background: transparent; display: flex; align-items: center; gap: 15px; text-align: left; cursor: pointer; transition: .22s ease; }
.mode-card:hover { background: rgba(255,255,255,.025); border-color: var(--line); }
.mode-card.active { background: linear-gradient(120deg, rgba(200,255,107,.11), rgba(200,255,107,.025)); border-color: rgba(200,255,107,.22); }
.mode-index { color: #656a63; font-family: Georgia, serif; font-size: 11px; }
.mode-card.active .mode-index { color: var(--accent); }
.mode-card strong { display: block; font-size: 14px; font-weight: 600; }
.mode-card small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }

.workspace { padding-inline: clamp(32px, 4.2vw, 74px); }
.workspace-head, .result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.result-head-actions { display: flex; align-items: center; gap: 14px; }
.workspace h2, .result-panel h2, dialog h2 { margin: 10px 0 0; font-family: Georgia, "Noto Serif SC", serif; font-size: 27px; font-weight: 500; }
#generatorForm { margin-top: 40px; }
.field { margin-bottom: 25px; }
.field label { display: flex; justify-content: space-between; margin-bottom: 10px; color: #d9d5c9; font-size: 12px; font-weight: 650; letter-spacing: .04em; }
.field label span { color: var(--muted); font-weight: 400; }
textarea, input, select { width: 100%; border: 1px solid var(--line); border-radius: 15px; outline: 0; color: var(--text); background: rgba(0,0,0,.22); transition: border-color .2s, box-shadow .2s; }
textarea { min-height: 150px; padding: 18px; line-height: 1.75; resize: vertical; }
input, select { height: 48px; padding: 0 14px; }
textarea:focus, input:focus, select:focus { border-color: rgba(200,255,107,.54); box-shadow: 0 0 0 4px rgba(200,255,107,.055); }
textarea::placeholder, input::placeholder { color: #5e625c; }
.field-meta { margin-top: 9px; display: flex; justify-content: space-between; gap: 18px; color: #747972; font-size: 10px; line-height: 1.5; }
.field-meta b { color: #aaa; font-weight: 500; }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compact { margin-bottom: 0; }
.switch-row { grid-column: 1/-1; padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--line); border-radius: 15px; cursor: pointer; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 12px; }
.switch-row small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { width: 40px; height: 22px; position: relative; background: #30342f; border-radius: 999px; transition: .2s; }
.switch-row i::after { content: ""; width: 16px; height: 16px; position: absolute; left: 3px; top: 3px; background: #9a9e98; border-radius: 50%; transition: .2s; }
.switch-row input:checked + i { background: var(--accent); }
.switch-row input:checked + i::after { left: 21px; background: #111; }
.submit-row { margin-top: 31px; padding-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-top: 1px solid var(--line); }
.submit-row p { margin: 0; max-width: 340px; color: var(--muted); font-size: 10px; line-height: 1.6; }

.primary-button, .primary-link, .ghost-button, .text-button, .icon-button { border: 0; cursor: pointer; text-decoration: none; transition: .2s; }
.primary-button, .primary-link { min-height: 47px; padding: 0 20px; display: inline-flex; align-items: center; justify-content: center; gap: 24px; border-radius: 999px; color: #10130e; background: var(--accent); font-size: 12px; font-weight: 750; }
.primary-button:hover, .primary-link:hover { background: #d8ff98; transform: translateY(-1px); }
.primary-button:disabled { opacity: .5; cursor: wait; transform: none; }
.ghost-button { min-height: 38px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 999px; color: #d8d4c9; background: rgba(255,255,255,.025); font-size: 11px; }
.ghost-button:hover { border-color: rgba(200,255,107,.4); color: var(--accent); }
.text-button { padding: 6px 0; color: var(--muted); background: transparent; font-size: 11px; border-bottom: 1px solid var(--line-strong); }
.text-button:hover { color: var(--accent); }
.icon-button { width: 34px; height: 34px; border-radius: 50%; color: var(--muted); background: rgba(255,255,255,.04); font-size: 19px; }
.icon-button:hover { color: var(--text); background: rgba(255,255,255,.08); }

.result-panel { display: flex; flex-direction: column; }
.empty-state, .loading-state { min-height: 470px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-state strong, .loading-state strong { margin-top: 26px; font-family: Georgia, "Noto Serif SC", serif; font-size: 18px; font-weight: 500; }
.empty-state p, .loading-state p { max-width: 270px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.record-visual { width: 128px; height: 128px; position: relative; border: 1px solid var(--line); border-radius: 50%; background: repeating-radial-gradient(circle, transparent 0 8px, rgba(255,255,255,.035) 9px 10px); }
.record-visual span { width: 34px; height: 34px; position: absolute; inset: 0; margin: auto; border: 8px solid #222722; border-radius: 50%; background: var(--accent); }
.record-visual i { width: 1px; height: 105px; position: absolute; right: -4px; top: -10px; background: linear-gradient(var(--warm), transparent); transform: rotate(25deg); transform-origin: top; }
.wave-loader { height: 70px; display: flex; align-items: center; gap: 7px; }
.wave-loader i { width: 4px; height: 18px; border-radius: 6px; background: var(--accent); animation: wave 1s ease-in-out infinite; }
.wave-loader i:nth-child(2), .wave-loader i:nth-child(4) { animation-delay: -.15s; }
.wave-loader i:nth-child(3) { animation-delay: -.3s; }
@keyframes wave { 50% { height: 58px; } }
.result-content { margin-top: 38px; }
.result-badge { display: inline-flex; padding: 6px 9px; border: 1px solid rgba(200,255,107,.25); border-radius: 999px; color: var(--accent); background: rgba(200,255,107,.06); font-size: 9px; letter-spacing: .15em; }
.result-content h3 { margin: 20px 0 8px; font-family: Georgia, "Noto Serif SC", serif; font-size: 27px; font-weight: 500; }
.style-tags { margin: 0 0 25px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.lyrics-result { max-height: 470px; margin: 0; padding: 20px; overflow: auto; white-space: pre-wrap; border: 1px solid var(--line); border-radius: 16px; color: #ddd8ca; background: rgba(0,0,0,.19); font-family: Georgia, "Noto Serif SC", serif; font-size: 13px; line-height: 1.9; }
.album-art { aspect-ratio: 1; margin-bottom: 17px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 18px; background: radial-gradient(circle at 30% 25%, rgba(200,255,107,.28), transparent 20%), linear-gradient(135deg, #252e24, #131614 60%, #392a23); overflow: hidden; }
.album-art::before, .album-art::after { content: ""; width: 70%; height: 1px; position: absolute; background: linear-gradient(90deg, transparent, rgba(255,255,255,.2), transparent); transform: rotate(-25deg); }
.album-art::after { transform: rotate(35deg); }
.album-art span { z-index: 1; font-family: Georgia, "Noto Serif SC", serif; font-size: 56px; color: rgba(255,255,255,.78); }
.audio-result { position: relative; }
.audio-result audio { width: 100%; height: 44px; }
.audio-meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 10px; }
.audio-meta span { padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; }
.billing-result { margin-top: 16px; padding: 15px; border: 1px solid rgba(200,255,107,.18); border-radius: 15px; background: linear-gradient(120deg, rgba(200,255,107,.07), transparent); }
.billing-title { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; }
.billing-title span { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.billing-title strong { color: var(--accent); font-family: Georgia, "Noto Serif SC", serif; font-size: 17px; font-weight: 500; text-align: right; }
.billing-changes { margin-top: 10px; display: grid; gap: 6px; }
.billing-change { padding-top: 7px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; border-top: 1px solid var(--line); font-size: 9px; }
.billing-change span { overflow: hidden; color: #a6aaa3; text-overflow: ellipsis; white-space: nowrap; }
.billing-change b { color: #e1ddcf; font-weight: 500; }
.billing-result > p { margin: 10px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.result-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 9px; }
.tech-details { margin-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.tech-details summary { padding: 15px 0; cursor: pointer; }
.tech-details pre { max-height: 180px; overflow: auto; white-space: pre-wrap; }
.error-state { margin-top: 30px; padding: 16px; display: flex; align-items: flex-start; gap: 13px; border: 1px solid rgba(255,133,125,.25); border-radius: 15px; background: rgba(255,133,125,.06); }
.error-state > span { width: 24px; height: 24px; display: grid; place-items: center; flex: none; border-radius: 50%; color: #161010; background: var(--danger); font-weight: 800; }
.error-state strong { font-size: 12px; }
.error-state p { margin: 5px 0 0; color: #d6aaa7; font-size: 11px; line-height: 1.55; }

footer { min-height: 54px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: #626760; font-size: 9px; letter-spacing: .06em; position: relative; z-index: 1; }
.hidden { display: none !important; }

dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 22px; color: var(--text); background: #171a18; box-shadow: 0 30px 120px #000; }
dialog::backdrop { background: rgba(2,4,3,.78); backdrop-filter: blur(8px); }
.dialog-card { padding: 28px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-card > p { color: var(--muted); font-size: 11px; line-height: 1.7; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 65px; }
.password-wrap button { position: absolute; right: 8px; top: 8px; height: 32px; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; }
.notice { margin: 18px 0; padding: 14px; border-left: 2px solid var(--warm); background: rgba(240,168,107,.06); }
.notice strong { font-size: 11px; }
.notice p { margin: 5px 0 0; color: #b5a596; font-size: 10px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.history-card { max-height: min(760px, calc(100vh - 40px)); overflow: auto; }
.history-list { margin: 22px 0; display: grid; gap: 9px; }
.history-item { width: 100%; padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: rgba(0,0,0,.16); text-align: left; cursor: pointer; }
.history-item:hover { border-color: rgba(200,255,107,.35); background: rgba(200,255,107,.035); }
.history-item strong, .history-item small { display: block; }
.history-item strong { font-family: Georgia, "Noto Serif SC", serif; font-size: 14px; font-weight: 500; }
.history-item small { margin-top: 5px; color: var(--muted); font-size: 9px; }
.history-kind { flex: none; padding: 5px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--accent); font-size: 8px; letter-spacing: .1em; }
.history-empty { padding: 34px 15px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; font-size: 11px; }
#accountDialog { width: min(650px, calc(100vw - 32px)); }
.account-card { max-height: min(820px, calc(100vh - 40px)); overflow: auto; }
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0 12px; }
.capability-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.metric-card, .capability-card, .quota-section, .cash-section { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(0,0,0,.14); }
.metric-card span, .quota-head span, .cash-section span { display: block; color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.capability-card span { color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.capability-card strong { display: block; margin: 8px 0 5px; font-size: 13px; }
.capability-card strong.ok { color: var(--accent); }
.capability-card strong.bad { color: var(--danger); }
.capability-card small { color: #7c817a; font-size: 9px; line-height: 1.5; }
.metric-card strong { display: block; margin: 9px 0 5px; font-family: Georgia, "Noto Serif SC", serif; font-size: 19px; font-weight: 500; }
.metric-card strong.ok { color: var(--accent); }
.metric-card strong.bad { color: var(--danger); }
.metric-card small { color: #70756e; font-size: 9px; line-height: 1.5; }
.quota-section, .cash-section { margin-bottom: 12px; }
.quota-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.quota-head strong, .cash-section strong { display: block; margin-top: 6px; font-size: 12px; font-weight: 600; }
.quota-rows { margin-top: 14px; display: grid; gap: 8px; }
.quota-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 15px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 10px; }
.quota-row span { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.quota-row b { color: #e2ded3; font-weight: 500; }
.cash-section p { margin: 8px 0 13px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.inline-link { display: inline-flex; align-items: center; }
.account-loading { min-height: 260px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 11px; }
.mini-spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
code { color: var(--accent); }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 280px 1fr; }
  .result-panel { grid-column: 1/-1; min-height: 520px; border-top: 1px solid var(--line); }
  .result-panel .empty-state, .result-panel .loading-state { min-height: 330px; }
  .result-content { max-width: 720px; }
}
@media (max-width: 760px) {
  .topbar { height: 70px; padding: 0 18px; }
  .status-pill { display: none; }
  .top-actions { gap: 6px; }
  .top-actions .ghost-button { padding: 0 10px; font-size: 9px; }
  .app-shell { display: block; }
  .mode-panel, .workspace, .result-panel { padding: 30px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .mode-panel h1 { font-size: 34px; }
  .mode-list { display: flex; margin-inline: -20px; padding: 0 20px 8px; overflow-x: auto; }
  .mode-card { min-width: 225px; }
  .options-grid { grid-template-columns: 1fr; }
  .switch-row { grid-column: auto; }
  .submit-row { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
  .account-grid { grid-template-columns: 1fr; }
  .capability-grid { grid-template-columns: 1fr; }
  footer { padding: 15px 20px; align-items: flex-start; flex-direction: column; gap: 7px; }
}
