:root {
  color-scheme: light;
  --bg: #f3f0ea;
  --panel: #fffdf9;
  --panel-soft: #f7f3ec;
  --ink: #181b24;
  --muted: #6f746f;
  --line: #e3ddd2;
  --line-strong: #d5ccbd;
  --blue: #315f86;
  --blue-soft: #edf5fb;
  --green: #0b7d64;
  --green-soft: #e9f8f3;
  --orange: #c86f2e;
  --red: #c23b44;
  --accent: #93613a;
  --accent-soft: #f4e7d7;
  --charcoal: #171b24;
  --shadow: 0 20px 56px rgba(50, 40, 28, 0.12);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(49, 95, 134, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #f7f3ec 0%, var(--bg) 48%, #eef3f1 100%);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    system-ui,
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label,
select,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-sprite {
  display: none;
}

.product-shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.auth-view,
.subscription-view {
  display: none;
}

body.auth-mode .auth-view,
body.subscription-mode .subscription-view {
  display: grid;
}

body.auth-mode .product-shell,
body.subscription-mode .product-shell {
  display: none;
}

.auth-view {
  min-height: 100vh;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(7, 12, 22, 0.98), rgba(16, 31, 43, 0.96)),
    repeating-linear-gradient(90deg, rgba(82, 208, 255, 0.08) 0 1px, transparent 1px 64px);
  color: #eef8ff;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 28px;
  width: min(1040px, 100%);
  align-items: stretch;
}

.auth-copy,
.auth-panel,
.subscription-panel {
  border: 1px solid rgba(132, 211, 255, 0.18);
  border-radius: 8px;
  background: rgba(11, 18, 32, 0.76);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.auth-copy {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  min-height: 560px;
  overflow: hidden;
  padding: 42px;
}

.auth-copy::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.34;
  background:
    linear-gradient(90deg, rgba(94, 234, 212, 0.12) 1px, transparent 1px),
    linear-gradient(0deg, rgba(125, 211, 252, 0.1) 1px, transparent 1px);
  background-size: 42px 42px;
}

.auth-copy > * {
  position: relative;
  z-index: 1;
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 4px;
  border: 1px solid rgba(94, 234, 212, 0.5);
  border-radius: 8px;
  background: rgba(9, 24, 36, 0.92);
  color: #7dd3fc;
  font-size: 28px;
  font-weight: 900;
}

.auth-copy h1,
.subscription-panel h1 {
  margin: 0;
  max-width: 680px;
  font-size: 44px;
  line-height: 1.08;
}

.auth-copy p:not(.eyebrow) {
  max-width: 560px;
  margin: 0;
  color: #b7c7d8;
  font-size: 16px;
  line-height: 1.7;
}

.subscription-panel > p {
  max-width: 560px;
  margin: 18px 0 0;
  color: #b7c7d8;
  font-size: 16px;
  line-height: 1.7;
}

.auth-signal {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.auth-signal span {
  border: 1px solid rgba(125, 211, 252, 0.22);
  border-radius: 8px;
  padding: 9px 12px;
  background: rgba(3, 105, 161, 0.16);
  color: #d8f4ff;
  font-size: 12px;
  font-weight: 800;
}

.auth-panel {
  padding: 24px;
}

.auth-tabs,
.method-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.35);
}

.auth-tabs button,
.method-tabs button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9fb3c8;
  cursor: pointer;
  font-weight: 900;
}

.auth-tabs button.active,
.method-tabs button.active {
  background: #e7f7ff;
  color: #0f172a;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 8px;
}

.auth-form label span {
  color: #c9d7e6;
  font-size: 13px;
  font-weight: 800;
}

.auth-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  padding: 0 13px;
}

.auth-form input::placeholder {
  color: #738297;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 0;
}

.account-bar #userBadge {
  max-width: 136px;
  overflow: hidden;
  color: #5c6472;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subscription-view {
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background: #0b1220;
  color: #eff6ff;
}

.subscription-panel {
  width: min(900px, 100%);
  padding: 30px;
}

.subscription-status-card,
.plan-row,
.record-empty,
.record-item {
  border: 1px solid rgba(125, 211, 252, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
}

.subscription-status-card {
  margin-top: 22px;
  padding: 16px;
}

.subscription-status-card span,
.record-item span,
.record-empty {
  color: #9fb3c8;
  font-size: 12px;
  font-weight: 800;
}

.subscription-status-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.subscription-status-card p {
  margin: 8px 0 0;
  color: #b7c7d8;
}

.plan-list {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.plan-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 16px;
}

.plan-row strong,
.plan-row span {
  font-size: 18px;
}

.plan-row p {
  margin: 8px 0 0;
  color: #b7c7d8;
  line-height: 1.6;
}

.subscription-actions {
  display: flex;
  margin-top: 18px;
  gap: 10px;
}

.payment-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-top: 22px;
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: #fff;
  color: #111827;
}

.payment-box img {
  width: 240px;
  height: 240px;
  object-fit: contain;
}

.payment-box p {
  margin: 0;
  color: #5d6676;
}

.subscription-records {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.record-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.record-empty {
  padding: 14px;
}

.record-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.record-item p,
.record-item small {
  display: block;
  margin: 4px 0 0;
}

.record-item p {
  color: #fff;
  font-weight: 800;
  word-break: break-all;
}

.record-item small {
  color: #9fb3c8;
  line-height: 1.5;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 14px 30px;
  border-bottom: 1px solid rgba(227, 221, 210, 0.86);
  background: rgba(255, 253, 249, 0.9);
  backdrop-filter: blur(16px);
}

.menu-button {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  padding: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 19px;
  line-height: 1.2;
}

.brand span {
  margin-top: 4px;
  color: #8a93a3;
  font-size: 12px;
}

.side-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #4b5567;
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.side-link:hover {
  background: #f1f5ff;
}

.side-link.active {
  background: #111827;
  color: #fff;
}

.sidebar-card {
  display: none;
}

.sidebar-card span,
.sidebar-card strong,
.sidebar-card small {
  display: block;
}

.sidebar-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.sidebar-card strong {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.45;
}

.sidebar-card small {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #98a2b3;
}

.server-status.ok .status-dot {
  background: var(--green);
}

.server-status.warn .status-dot {
  background: var(--orange);
}

.server-status.error .status-dot {
  background: var(--red);
}

.main {
  min-width: 0;
  padding: 30px;
}

.view {
  display: none;
  width: min(1220px, 100%);
  margin: 0 auto;
}

.view.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding: 30px 32px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.page-header.compact {
  align-items: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.15;
  letter-spacing: 0;
}

.page-header p:not(.eyebrow) {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.hero-workbench {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(480px, 1.05fr);
  gap: 22px;
  align-items: stretch;
}

.hero-copy,
.workbench-card {
  border: 1px solid rgba(227, 221, 210, 0.86);
  border-radius: 22px;
  box-shadow: var(--shadow);
  height: 100%;
}

.hero-copy {
  min-height: 560px;
  padding: 34px 34px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    var(--charcoal);
  color: #fff;
}

.hero-copy .eyebrow {
  color: #b7dbc9;
}

.hero-copy h1 {
  max-width: 650px;
  margin: 0;
  font-size: clamp(34px, 4.6vw, 58px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 620px;
  margin: 18px 0 0;
  color: #d5d9df;
  font-size: 16px;
  line-height: 1.8;
}

.hero-flow {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.hero-flow div,
.focus-note {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.hero-flow div {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 4px 12px;
  padding: 14px;
}

.hero-flow span {
  grid-row: span 2;
  color: #b7dbc9;
  font-size: 13px;
  font-weight: 900;
}

.hero-flow strong,
.hero-flow small,
.focus-note strong,
.focus-note p {
  display: block;
}

.hero-flow strong {
  font-size: 15px;
}

.hero-flow small {
  color: #b9c0ca;
  line-height: 1.5;
}

.focus-note {
  margin-top: 14px;
  padding: 16px;
}

.focus-note strong {
  color: #ffe0bb;
}

.focus-note p {
  margin: 8px 0 0;
  color: #d8dde4;
  line-height: 1.75;
}

.workbench-card {
  padding: 22px;
  background: rgba(255, 253, 249, 0.96);
}

.workbench-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.workbench-head .eyebrow {
  margin-bottom: 7px;
  color: var(--green);
}

.workbench-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.header-actions,
.composer-footer,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.task-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.composer-card,
.requirements-card,
.state-panel,
.library-card,
.history-card,
.template-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.composer-card {
  padding: 18px;
}

.source-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.source-switch.compact {
  gap: 8px;
  margin-bottom: 14px;
}

.source-card {
  display: block;
  min-height: 98px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  cursor: pointer;
}

.source-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.source-card strong,
.source-card span {
  display: block;
}

.source-card strong {
  margin-bottom: 8px;
  font-size: 15px;
}

.source-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.source-card.active {
  border-color: rgba(11, 125, 100, 0.42);
  background: var(--green-soft);
}

.source-switch.compact .source-card {
  min-height: 74px;
  padding: 12px;
}

.source-helper {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

label span,
.output-list > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 13px;
  line-height: 1.65;
}

.material-field textarea {
  min-height: 178px;
}

.small-textarea {
  min-height: 86px;
}

.style-picker {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

.style-picker > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
}

.style-picker > summary::-webkit-details-marker {
  display: none;
}

.style-picker > summary::after {
  content: "⌄";
  color: var(--muted);
  font-weight: 900;
}

.style-picker[open] > summary::after {
  transform: rotate(180deg);
}

.style-picker strong,
.style-picker small {
  display: block;
}

.style-picker small {
  color: var(--muted);
  font-size: 12px;
}

.style-groups {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.style-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.style-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  color: #344054;
  font-size: 13px;
  font-weight: 900;
  list-style: none;
}

.style-group > summary::-webkit-details-marker {
  display: none;
}

.style-group > summary::after {
  content: "⌄";
  color: var(--muted);
}

.style-group[open] > summary::after {
  transform: rotate(180deg);
}

.style-options {
  display: grid;
  gap: 6px;
  padding: 0 8px 8px;
}

.style-option {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.style-option:hover,
.style-option.active {
  border-color: rgba(56, 103, 246, 0.45);
  background: var(--blue-soft);
}

.style-option span {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.composer-footer {
  justify-content: space-between;
  margin-top: 14px;
}

.file-button,
.secondary-button,
.primary-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 900;
  white-space: nowrap;
}

.file-button,
.secondary-button,
.copy-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.file-button:hover,
.secondary-button:hover,
.copy-button:hover {
  background: var(--panel-soft);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.primary-button {
  width: 100%;
  margin-top: 16px;
  border: 1px solid #111827;
  background: #111827;
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: #242b37;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.compact-primary {
  width: auto;
  margin-top: 0;
}

.task-dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 17, 30, 0.48);
}

.task-dialog-card {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 72px rgba(15, 23, 42, 0.22);
}

.task-dialog-card h2 {
  margin: 0;
  font-size: 21px;
}

.task-dialog-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.task-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.source-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.requirements-card {
  padding: 18px;
}

.requirements-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.requirements-card label,
.two-col {
  display: block;
  margin-top: 13px;
}

.requirements-drawer {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.requirements-drawer > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.requirements-drawer > summary::-webkit-details-marker {
  display: none;
}

.requirements-drawer strong,
.requirements-drawer small {
  display: block;
}

.requirements-drawer small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.drawer-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.drawer-state::after {
  content: "⌄";
  margin-left: 6px;
  color: var(--muted);
}

.requirements-drawer[open] .drawer-state::after {
  transform: rotate(180deg);
}

.state-open,
.requirements-drawer[open] .state-closed {
  display: none;
}

.requirements-drawer[open] .state-open {
  display: inline;
}

.requirements-drawer label {
  display: block;
  margin-top: 13px;
}

.requirements-drawer > label {
  margin-right: 14px;
  margin-left: 14px;
}

.requirements-drawer > label:last-child {
  margin-bottom: 14px;
}

.requirements-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  padding: 0 14px;
}

.requirements-grid label {
  margin-top: 0;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.output-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.output-list.compact {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  background: #fff;
}

.output-list.compact > strong {
  color: var(--muted);
  font-size: 12px;
  line-height: 26px;
}

.output-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.output-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.output-chips span {
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: #344054;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.output-list input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.state-panel {
  margin-top: 18px;
  min-height: 180px;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.92);
  box-shadow: var(--shadow);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--ink);
}

.loading-state {
  display: grid;
  place-items: center;
  min-height: 190px;
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 14px;
  border: 3px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.spinner-inline {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-state {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 140px;
  padding: 18px;
  border: 1px solid #f3b4ba;
  border-radius: var(--radius);
  background: #fff4f5;
  color: #7a1d27;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.results-header h2 {
  margin: 0;
  font-size: 22px;
}

.result-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.result-document {
  display: block;
}

.result-section-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
}

.result-section-nav a {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: #344054;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.result-section-nav a:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.result-sections {
  display: grid;
  gap: 14px;
}

.result-section {
  scroll-margin-top: 74px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.result-section h3 {
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 18px;
}

.rich-output {
  color: #303846;
  font-size: 14px;
  line-height: 1.65;
}

.rich-output p {
  margin: 0 0 10px;
}

.rich-output ul,
.rich-output ol {
  margin: 8px 0 12px;
  padding-left: 20px;
}

.rich-output li {
  margin-bottom: 5px;
}

.mini-block {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.mini-block strong {
  display: block;
  margin-bottom: 7px;
}

.search-box {
  position: relative;
  width: min(360px, 100%);
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-box input {
  padding-left: 38px;
}

.library-grid,
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.library-card,
.template-card,
.history-card {
  padding: 16px;
}

.library-card strong,
.template-card strong,
.history-card strong {
  display: block;
  margin-bottom: 8px;
}

.library-label {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
}

.library-card p,
.template-card p,
.history-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.library-empty {
  max-width: 430px;
}

.library-empty .copy-button {
  margin-top: 14px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.card-tags span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.history-clickable {
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.history-clickable:hover,
.history-clickable:focus-visible {
  border-color: rgba(49, 95, 134, 0.35);
  box-shadow: 0 12px 28px rgba(50, 40, 28, 0.08);
  transform: translateY(-1px);
}

.history-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.markdown-preview {
  max-height: 520px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: #303846;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    system-ui,
    sans-serif;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.template-card {
  min-height: 168px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-copy {
    min-height: 340px;
  }

  .sidebar {
    align-items: flex-start;
    flex-wrap: wrap;
    height: auto;
    padding: 14px;
  }

  .side-nav {
    order: 3;
    width: 100%;
  }

  .sidebar-card {
    display: none;
  }

  .server-status {
    margin-left: auto;
  }

  .account-bar {
    order: 2;
  }

  .hero-workbench {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    min-height: auto;
  }

  .task-layout {
    grid-template-columns: 1fr;
  }

  .requirements-card {
    order: -1;
  }

  .library-grid,
  .template-grid,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .auth-view,
  .subscription-view {
    padding: 14px;
  }

  .auth-copy,
  .auth-panel,
  .subscription-panel {
    padding: 20px;
  }

  .auth-copy h1,
  .subscription-panel h1 {
    font-size: 31px;
  }

  .auth-copy {
    min-height: 300px;
  }

  .subscription-actions {
    flex-direction: column;
  }

  .subscription-records {
    grid-template-columns: 1fr;
  }

  .plan-row,
  .record-item {
    flex-direction: column;
  }

  .code-row {
    grid-template-columns: 1fr;
  }

  .payment-box img {
    width: 210px;
    height: 210px;
  }

  .main {
    padding: 14px;
  }

  .sidebar {
    gap: 12px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .side-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
    padding: 22px;
    border-radius: 14px;
  }

  .hero-copy,
  .workbench-card {
    border-radius: 16px;
  }

  .workbench-card {
    order: -1;
  }

  .hero-copy {
    padding: 28px 22px;
    min-height: auto;
  }

  .hero-copy h1 {
    font-size: 31px;
  }

  .hero-copy > p:not(.eyebrow) {
    font-size: 15px;
  }

  .hero-flow div {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .workbench-card {
    padding: 16px;
  }

  .workbench-head {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
  }

  .source-switch,
  .library-grid,
  .template-grid,
  .result-grid,
  .two-col,
  .requirements-grid {
    grid-template-columns: 1fr;
  }

  .source-switch.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .source-switch.compact .source-card {
    display: flex;
    align-items: center;
    min-height: 54px;
    padding: 10px;
  }

  .source-switch.compact .source-card strong {
    margin-bottom: 0;
    font-size: 13px;
  }

  .source-switch.compact .source-card span {
    display: none;
  }

  .source-helper {
    margin-bottom: 10px;
  }

  .material-field textarea {
    min-height: 136px;
  }

  .output-list.compact {
    grid-template-columns: 1fr;
  }

  .output-chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-card.wide {
    grid-column: auto;
  }

  .composer-footer,
  .history-card,
  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

  .history-actions {
    width: 100%;
  }

  .history-actions .copy-button {
    flex: 1 1 0;
  }

  .file-button,
  .secondary-button,
  .copy-button {
    width: 100%;
  }

  .task-dialog-actions {
    flex-direction: column-reverse;
  }

  .task-dialog-actions .secondary-button,
  .task-dialog-actions .compact-primary {
    width: 100%;
  }
}
