:root {
  color-scheme: light;
  --blue: #1769e0;
  --blue-weak: #eaf2ff;
  --ink: #172033;
  --muted: #6f7787;
  --line: #e4e8ef;
  --surface: #ffffff;
  --canvas: #f5f7fa;
  --green: #16845b;
  --amber: #b76806;
  --danger: #c94242;
  --shadow: 0 16px 44px rgba(29, 43, 70, .14);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; letter-spacing: 0; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px 14px; background: #fff; border-right: 1px solid var(--line); }
.brand { height: 58px; display: flex; align-items: center; gap: 11px; padding: 4px 8px; }
.brand img { width: 42px; height: 42px; object-fit: cover; object-position: 50% 31%; border-radius: 7px; }
.brand strong { display: block; font-size: 20px; line-height: 1.2; }
.brand span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.main-nav { display: grid; gap: 5px; margin-top: 24px; }
.nav-item, .help-button { width: 100%; height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; color: #50596a; }
.nav-item svg, .help-button svg { width: 19px; }
.nav-item:hover, .help-button:hover { background: #f4f6f9; color: var(--ink); }
.nav-item.active { background: var(--blue-weak); color: var(--blue); font-weight: 700; }
.sidebar-footer { margin-top: auto; display: grid; gap: 5px; }
.account-button { height: 58px; border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 7px 8px; display: flex; align-items: center; gap: 9px; cursor: pointer; text-align: left; }
.account-button:hover { border-color: #b9c5d7; }
.avatar { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #28344e; font-weight: 700; }
.account-copy { min-width: 0; flex: 1; }
.account-copy strong, .account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.account-button > svg { width: 16px; color: #929aa8; }
.workspace { min-width: 0; }
.topbar { height: 84px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 21px; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.environment { color: var(--green); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.environment > span { width: 7px; height: 7px; border-radius: 50%; background: #21a774; box-shadow: 0 0 0 3px #e1f5ed; }
.credit-pill { height: 36px; border: 1px solid #d9e3f1; background: #fff; border-radius: 18px; display: flex; align-items: center; gap: 6px; padding: 0 13px; cursor: pointer; }
.credit-pill svg { width: 17px; color: var(--amber); }

.upscale-output { display: grid; grid-template-columns: minmax(320px, 1.35fr) minmax(260px, .65fr); gap: 28px; align-items: center; padding: 28px 0 8px; border-top: 1px solid var(--line); }
.upscale-output-preview { height: 360px; background: #eef3f9; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.upscale-output-preview img { width: 100%; height: 100%; object-fit: contain; }
.upscale-output-info h2 { margin: 16px 0 8px; font-size: 24px; }
.upscale-output-info p { color: var(--muted); }
.tool-action-row { display: flex; gap: 10px; margin-top: 24px; }
.icon-text-button { min-height: 42px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 0 16px; display: inline-flex; align-items: center; gap: 8px; border-radius: 6px; cursor: pointer; }
.secondary-button { min-height: 40px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.secondary-button:hover, .icon-text-button:hover { border-color: #aebbd0; background: #f8fafc; }
.icon-text-button svg, .legal-copy button svg { width: 17px; }
.legal-copy { padding: 4px 2px 2px; }
.legal-copy h3 { margin: 0 0 10px; font-size: 16px; }
.legal-copy p { margin: 0 0 18px; color: var(--muted); line-height: 1.7; }

@media (max-width: 900px) {
  .upscale-output { grid-template-columns: 1fr; }
  .upscale-output-preview { height: 300px; }
}
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 7px; background: #fff; display: inline-grid; place-items: center; cursor: pointer; }
.icon-button svg { width: 17px; }
.icon-button:hover:not(:disabled) { color: var(--blue); border-color: #b7c9e4; }
.icon-button:disabled { opacity: .38; cursor: not-allowed; }
.view-root { padding: 22px 28px 30px; }
.design-layout { display: grid; grid-template-columns: minmax(540px, 700px) minmax(380px, 1fr); gap: 20px; max-width: 1460px; margin: 0 auto; }
.control-panel, .preview-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.control-panel { padding: 22px; }
.section-heading, .field-row { display: flex; align-items: center; justify-content: space-between; }
.section-heading h2, .preview-toolbar h2, .page-section h2 { margin: 0; font-size: 16px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.template-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 15px; }
.template-button { min-height: 67px; padding: 8px 6px; border: 1px solid var(--line); border-radius: 7px; background: #fff; display: grid; justify-items: center; align-content: center; gap: 5px; cursor: pointer; text-align: center; font-size: 12px; }
.template-button svg { width: 19px; color: #616b7d; }
.template-button:hover { border-color: #aebbd0; background: #fafcff; }
.template-button.active { color: var(--blue); border-color: var(--blue); background: var(--blue-weak); box-shadow: inset 0 0 0 1px var(--blue); font-weight: 700; }
.template-button.active svg { color: var(--blue); }
.form-section { margin-top: 22px; }
.field-label { display: block; margin-bottom: 9px; font-size: 13px; font-weight: 700; }
.optional { color: var(--muted); font-size: 11px; }
.prompt-box { border: 1px solid #d7dce5; border-radius: 7px; overflow: hidden; transition: border .2s, box-shadow .2s; }
.prompt-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,224,.1); }
.prompt-box textarea { width: 100%; height: 112px; padding: 13px; border: 0; outline: none; resize: vertical; min-height: 88px; color: var(--ink); }
.prompt-actions { height: 38px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #edf0f4; background: #fafbfc; color: var(--muted); font-size: 11px; }
.text-action { border: 0; background: transparent; color: var(--blue); padding: 5px; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.text-action svg { width: 14px; }
.upload-grid { display: flex; gap: 8px; min-height: 84px; overflow-x: auto; }
.upload-tile, .uploaded-tile { width: 86px; height: 84px; flex: 0 0 86px; border: 1px dashed #bec7d5; border-radius: 7px; background: #fafbfc; overflow: hidden; position: relative; }
.upload-tile { display: grid; place-items: center; align-content: center; gap: 3px; cursor: pointer; color: #576174; }
.upload-tile svg { width: 20px; color: var(--blue); }
.upload-tile span { font-size: 12px; }
.upload-tile small { font-size: 9px; color: #929aa8; }
.uploaded-tile img { width: 100%; height: 100%; object-fit: cover; }
.uploaded-tile button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%; color: #fff; background: rgba(12,18,28,.72); display: grid; place-items: center; cursor: pointer; }
.uploaded-tile button svg { width: 12px; }
.two-columns { display: grid; grid-template-columns: 1fr 1.35fr; gap: 14px; }
select, input[type="number"], .activation-row input { width: 100%; height: 40px; border: 1px solid #d7dce5; border-radius: 6px; background: #fff; padding: 0 10px; outline: none; }
select:focus, input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,224,.08); }
.tier-control { height: 40px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #d7dce5; border-radius: 6px; overflow: hidden; }
.tier-button { min-width: 0; border: 0; border-right: 1px solid #e1e5eb; background: #fff; cursor: pointer; font-size: 11px; line-height: 1.2; }
.tier-button:last-child { border-right: 0; }
.tier-button b { display: block; font-size: 12px; }
.tier-button.active { color: var(--blue); background: var(--blue-weak); }
.custom-ratio { margin-top: 10px; padding: 10px; display: grid; grid-template-columns: 1fr auto 1fr 74px; gap: 8px; align-items: end; background: #f6f8fb; border-radius: 6px; }
.custom-ratio[hidden] { display: none; }
.custom-ratio label { color: var(--muted); font-size: 10px; }
.custom-ratio input { display: block; margin-top: 4px; }
.custom-ratio > span { padding-bottom: 11px; }
.primary-button { border: 0; border-radius: 7px; background: var(--blue); color: #fff; cursor: pointer; font-weight: 700; }
.primary-button:hover { background: #0d5ccc; }
.generate-button { width: 100%; height: 48px; margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.generate-button svg { width: 18px; }
.generate-button small { margin-left: auto; margin-right: 16px; font-weight: 400; color: #dceaff; }
.preview-panel { min-height: 690px; display: grid; grid-template-rows: auto minmax(420px, 1fr) auto; overflow: hidden; }
.preview-toolbar { height: 65px; padding: 0 17px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.preview-toolbar h2 { margin-bottom: 4px; }
.preview-toolbar span { color: var(--muted); font-size: 11px; }
.preview-actions { display: flex; gap: 7px; }
.preview-stage { margin: 18px; min-height: 420px; height: calc(100% - 36px); padding: 22px; display: grid; place-items: center; position: relative; overflow: hidden; background-color: #eef1f5; background-image: linear-gradient(45deg,#e4e8ee 25%,transparent 25%),linear-gradient(-45deg,#e4e8ee 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#e4e8ee 75%),linear-gradient(-45deg,transparent 75%,#e4e8ee 75%); background-size: 18px 18px; background-position: 0 0,0 9px,9px -9px,-9px 0; border-radius: 6px; }
.preview-stage > img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; box-shadow: 0 8px 28px rgba(21,30,48,.2); cursor: zoom-in; }
.empty-preview, .generating { text-align: center; color: var(--muted); }
.empty-preview strong, .generating strong { display: block; color: #4c5668; margin-top: 12px; }
.empty-preview p, .generating p { margin: 6px 0 0; font-size: 12px; }
.empty-icon { width: 54px; height: 54px; margin: auto; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.88); color: #8d97a7; box-shadow: 0 2px 10px rgba(36,45,62,.08); }
.empty-icon svg { width: 23px; }
.spinner { width: 34px; height: 34px; margin: auto; display: block; border: 3px solid #cfe0f8; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-foot { height: 43px; padding: 0 17px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.preview-foot span:first-child { display: flex; align-items: center; gap: 5px; color: var(--green); }
.preview-foot svg { width: 14px; }
.page-section { max-width: 1280px; margin: 0 auto; }
.tool-hero { min-height: 146px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 24px; padding: 24px 28px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.tool-hero h2 { font-size: 20px; }
.tool-hero p { color: var(--muted); margin: 8px 0 0; }
.tool-badge { width: 68px; height: 68px; border-radius: 8px; display: grid; place-items: center; background: var(--blue-weak); color: var(--blue); }
.tool-badge svg { width: 31px; height: 31px; }
.operation-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.operation-card { min-height: 122px; padding: 17px; border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; text-align: left; }
.operation-card:hover { border-color: #abc1df; box-shadow: 0 6px 18px rgba(40,58,88,.07); }
.operation-card svg { width: 21px; color: var(--blue); }
.operation-card strong { display: block; margin-top: 14px; }
.operation-card span { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.single-tool { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.drop-area { min-height: 380px; display: grid; place-items: center; padding: 28px; border-right: 1px solid var(--line); background: #fafbfc; }
.drop-target { width: 100%; height: 100%; min-height: 300px; border: 1px dashed #b9c4d3; border-radius: 7px; display: grid; place-items: center; align-content: center; gap: 9px; cursor: pointer; color: var(--muted); }
.drop-target svg { width: 34px; color: var(--blue); }
.drop-target strong { color: var(--ink); }
.tool-settings { padding: 25px; }
.settings-list { display: grid; gap: 18px; margin: 24px 0; }
.settings-row { display: flex; align-items: center; justify-content: space-between; min-height: 42px; gap: 18px; }
.settings-row label strong { display: block; }
.settings-row label small { display: block; color: var(--muted); margin-top: 3px; }
.settings-row select { width: 190px; }
.wide-button { width: 100%; height: 44px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.stat-box { padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.stat-box span { color: var(--muted); font-size: 11px; }
.stat-box strong { display: block; margin-top: 8px; font-size: 23px; }
.data-panel { margin-top: 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.panel-heading { min-height: 58px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin: 0; font-size: 15px; }
.empty-table { min-height: 250px; display: grid; place-items: center; color: var(--muted); }
.activation-row { display: flex; gap: 9px; padding: 20px; }
.activation-row input { flex: 1; }
.activation-row button { width: 116px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid #edf0f4; white-space: nowrap; }
th { color: var(--muted); background: #fafbfc; font-size: 11px; font-weight: 600; }
td { font-size: 12px; }
.status-tag { display: inline-flex; align-items: center; height: 24px; border-radius: 12px; padding: 0 9px; color: var(--green); background: #e8f6f0; font-size: 10px; }
.status-tag.waiting { color: var(--amber); background: #fff2df; }
.modal { position: fixed; inset: 0; z-index: 50; display: none; }
.modal.open { display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(14,20,31,.58); backdrop-filter: blur(2px); }
.image-dialog { width: min(92vw, 1280px); height: min(90vh, 900px); position: relative; z-index: 1; display: grid; place-items: center; padding: 36px; background: #202733; border-radius: 8px; box-shadow: var(--shadow); }
.image-dialog img { max-width: 100%; max-height: 100%; object-fit: contain; }
.modal-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; cursor: pointer; }
.modal-close svg { width: 18px; }
.floating-download { position: absolute; right: 18px; bottom: 16px; height: 38px; border: 0; border-radius: 6px; padding: 0 14px; display: flex; align-items: center; gap: 7px; background: #fff; cursor: pointer; }
.floating-download svg { width: 16px; }
.sheet-dialog { width: min(92vw, 430px); position: relative; z-index: 1; padding: 18px; background: #fff; border-radius: 8px; box-shadow: var(--shadow); }
.auth-dialog { width: min(92vw, 410px); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 16px; background: #f1f3f6; border-radius: 7px; }
.auth-tabs button { height: 36px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.auth-tabs button.active { background: #fff; color: var(--blue); font-weight: 700; box-shadow: 0 1px 4px rgba(29,42,64,.08); }
.auth-form { display: grid; gap: 13px; }
.auth-form label { display: grid; gap: 6px; color: #4c5668; font-size: 12px; }
.auth-form input { width: 100%; height: 42px; }
.auth-form .primary-button { height: 42px; margin-top: 3px; }
.auth-hint { min-height: 18px; margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.dialog-title { display: flex; justify-content: space-between; align-items: center; padding: 2px 2px 14px; }
.dialog-title h2, .admin-header h2 { margin: 0; font-size: 18px; }
.dialog-title p, .admin-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.menu-row { width: 100%; min-height: 64px; border: 0; border-top: 1px solid var(--line); background: #fff; padding: 10px 6px; display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer; }
.menu-row > svg:first-child { width: 20px; color: var(--blue); }
.menu-row > svg:last-child { width: 16px; color: #9aa3b1; }
.menu-row span { flex: 1; }
.menu-row strong, .menu-row small { display: block; }
.menu-row small { color: var(--muted); margin-top: 4px; }
.admin-dialog { width: min(96vw, 1180px); height: min(92vh, 760px); position: relative; z-index: 1; display: grid; grid-template-rows: 68px 1fr; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.admin-header { padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.admin-header > div { display: flex; align-items: center; gap: 11px; }
.admin-mark { width: 38px; height: 38px; border-radius: 7px; display: grid; place-items: center; color: #fff; background: #25324a; }
.admin-mark svg { width: 20px; }
.admin-body { min-height: 0; display: grid; grid-template-columns: 188px 1fr; }
.admin-nav { padding: 12px; background: #f6f7f9; border-right: 1px solid var(--line); display: grid; align-content: start; gap: 4px; }
.admin-nav button { height: 41px; border: 0; border-radius: 6px; background: transparent; display: flex; align-items: center; gap: 9px; padding: 0 11px; cursor: pointer; color: #50596a; text-align: left; }
.admin-nav button svg { width: 17px; }
.admin-nav button.active { background: #fff; color: var(--blue); box-shadow: 0 1px 4px rgba(29,42,64,.08); font-weight: 700; }
.admin-content { min-width: 0; padding: 22px; overflow: auto; background: #fbfcfd; }
.admin-content h3 { margin: 0 0 16px; }
.admin-content .stats-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
.admin-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.admin-toolbar input { width: 220px; height: 36px; }
.small-primary { height: 36px; border: 0; border-radius: 6px; padding: 0 13px; color: #fff; background: var(--blue); cursor: pointer; }
.route-dot { width: 7px; height: 7px; display: inline-block; margin-right: 6px; border-radius: 50%; background: #20a372; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translate(-50%, 15px); max-width: min(90vw, 520px); padding: 11px 16px; border-radius: 7px; background: #202938; color: #fff; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1060px) {
  .app-shell { grid-template-columns: 78px minmax(0,1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding: 0; }
  .brand div, .nav-item span, .help-button span, .account-copy, .account-button > svg { display: none; }
  .nav-item, .help-button { justify-content: center; padding: 0; }
  .account-button { justify-content: center; padding: 5px; border: 0; }
  .design-layout { grid-template-columns: 1fr; }
  .preview-panel { min-height: 610px; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; left: 0; right: 0; top: auto; bottom: 0; width: 100%; height: 62px; padding: 6px 8px; border: 0; border-top: 1px solid var(--line); }
  .brand, .sidebar-footer { display: none; }
  .main-nav { margin: 0; display: grid; grid-template-columns: repeat(5,1fr); gap: 2px; }
  .nav-item { height: 49px; display: grid; justify-items: center; align-content: center; gap: 3px; font-size: 9px; }
  .nav-item span { display: block; }
  .nav-item:nth-child(6), .nav-item:nth-child(7) { display: none; }
  .topbar { height: 70px; padding: 0 14px; }
  .topbar p, .environment, #notificationsButton { display: none; }
  .view-root { padding: 12px 12px 78px; }
  .control-panel { padding: 15px; }
  .template-grid { grid-template-columns: repeat(4,1fr); }
  .template-button { font-size: 10px; }
  .two-columns, .single-tool { grid-template-columns: 1fr; }
  .drop-area { border-right: 0; border-bottom: 1px solid var(--line); min-height: 260px; }
  .operation-grid, .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .preview-panel { min-height: 520px; grid-template-rows: auto 390px auto; }
  .preview-stage { min-height: 350px; margin: 12px; }
  .admin-dialog { width: 100vw; height: 100vh; border-radius: 0; }
  .admin-body { grid-template-columns: 62px 1fr; }
  .admin-nav { padding: 8px; }
  .admin-nav button { justify-content: center; padding: 0; font-size: 0; }
  .admin-content { padding: 14px; }
  .admin-content .stats-grid { grid-template-columns: 1fr; }
}
