:root {
  --bg: #f5f3ff;
  --bg-soft: #eef7ff;
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.78);
  --ink: #1f2440;
  --muted: #667085;
  --line: #e5e7f1;
  --primary: #6d5dfc;
  --primary-dark: #4436d8;
  --success: #13a67c;
  --danger: #e34b67;
  --shadow: 0 18px 45px rgba(70, 64, 140, 0.14);
  --radius: 8px;
  --sidebar-width: 220px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 197, 112, 0.18), transparent 28%),
    radial-gradient(circle at 82% 4%, rgba(109, 93, 252, 0.18), transparent 26%),
    linear-gradient(135deg, #f7f8ff 0%, #f1ecff 44%, #edf9ff 100%);
  font-family:
    "Inter",
    "PingFang SC",
    "Microsoft YaHei",
    Arial,
    sans-serif;
  letter-spacing: 0;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid rgba(213, 216, 232, 0.8);
  box-shadow: 10px 0 35px rgba(68, 63, 132, 0.08);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, #6d5dfc, #14b8a6);
  border-radius: var(--radius);
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand small {
  display: block;
  max-width: 138px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.sidebar-nav {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
}

.menu-group {
  margin: 0 0 18px;
}

.menu-group p {
  margin: 0 0 8px;
  padding: 0 8px;
  color: #98a0b4;
  font-size: 12px;
  font-weight: 700;
}

.menu-link {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 4px;
  padding: 8px 10px;
  color: #4b556f;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.2;
}

.menu-link:hover,
.menu-link.is-active {
  color: var(--primary-dark);
  background: #f1efff;
}

.sidebar-account {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: linear-gradient(135deg, #f7f5ff, #eefafa);
  border: 1px solid #e4e5f3;
  border-radius: var(--radius);
}

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

.sidebar-account strong {
  font-size: 14px;
}

.mobile-menu-toggle {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  width: 42px;
  height: 42px;
  display: none;
  place-items: center;
  padding: 11px 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.mobile-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 2px 0;
  background: var(--ink);
  border-radius: 99px;
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(20, 24, 42, 0.32);
}

.main-console {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 26px 88px 56px 28px;
}

.welcome-panel,
.favorite-section,
.tools-section,
.tool-panel,
.materials-section,
.account-section,
.tutorial-section {
  width: min(100%, 1280px);
  margin: 0 auto 18px;
}

.welcome-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 26px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 244, 255, 0.88)),
    linear-gradient(90deg, rgba(109, 93, 252, 0.08), rgba(20, 184, 166, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.welcome-copy h1 {
  margin: 12px 0 8px;
  font-size: 34px;
  line-height: 1.16;
  font-weight: 800;
  letter-spacing: 0;
}

.welcome-copy p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.pill-label,
.section-kicker,
.tool-count,
.output-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 5px 12px;
  color: var(--primary-dark);
  background: #f0eeff;
  border: 1px solid #dfdcff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.section-kicker {
  min-height: auto;
  padding: 0;
  color: #8c93aa;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.tool-count,
.output-status {
  color: #607083;
  background: #f4f6fb;
  border-color: #e4e9f4;
}

.welcome-actions,
.output-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.soft-button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, #6d5dfc, #5146d8);
  box-shadow: 0 12px 24px rgba(88, 73, 221, 0.22);
}

.primary-button:hover {
  filter: brightness(1.04);
}

.ghost-button,
.soft-button {
  color: #48516a;
  background: #ffffff;
  border-color: var(--line);
}

.ghost-button:hover,
.soft-button:hover {
  color: var(--primary-dark);
  border-color: #cfc9ff;
}

.full-button {
  width: 100%;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title h2 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.2;
}

.favorite-section,
.tools-section,
.tool-panel,
.materials-section,
.account-section,
.tutorial-section {
  padding: 18px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  box-shadow: 0 14px 35px rgba(81, 78, 140, 0.08);
}

.favorite-grid {
  min-height: 96px;
}

.favorite-empty {
  display: grid;
  place-items: center;
  min-height: 116px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: rgba(247, 248, 252, 0.88);
  border: 1px dashed #d6daea;
  border-radius: var(--radius);
}

.favorite-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 16px;
}

.favorite-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.favorite-card {
  min-height: 92px;
  padding: 13px;
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.favorite-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.favorite-card strong {
  display: block;
  margin-bottom: 6px;
}

.favorite-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.tool-card {
  position: relative;
  min-height: 268px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  color: #ffffff;
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 18px 30px rgba(63, 62, 122, 0.18);
}

.tool-card::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -48px;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
}

.theme-purple {
  background: linear-gradient(135deg, #8b5cf6 0%, #5b52df 100%);
}

.theme-orange {
  background: linear-gradient(135deg, #ff9f43 0%, #ff6b6b 100%);
}

.theme-blue {
  background: linear-gradient(135deg, #3aa7ff 0%, #3867d6 100%);
}

.theme-indigo {
  background: linear-gradient(135deg, #293a8f 0%, #121c54 100%);
}

.theme-teal {
  background: linear-gradient(135deg, #17c3b2 0%, #118ab2 100%);
}

.theme-pink {
  background: linear-gradient(135deg, #ff6aa2 0%, #a855f7 100%);
}

.theme-green {
  background: linear-gradient(135deg, #22c55e 0%, #0f9f8f 100%);
}

.theme-cyan {
  background: linear-gradient(135deg, #00b4d8 0%, #006d77 100%);
}

.theme-rose {
  background: linear-gradient(135deg, #fb7185 0%, #be185d 100%);
}

.theme-slate {
  background: linear-gradient(135deg, #64748b 0%, #334155 100%);
}

.star-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  font-size: 19px;
  line-height: 1;
}

.star-button.is-favorited {
  color: #ffe082;
  background: rgba(31, 36, 64, 0.22);
}

.card-badge {
  position: relative;
  z-index: 1;
  width: fit-content;
  margin-bottom: 12px;
  padding: 5px 9px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.tool-tag {
  position: relative;
  z-index: 1;
  width: fit-content;
  padding: 4px 8px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.tool-card h3 {
  position: relative;
  z-index: 1;
  margin: 12px 0 8px;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.tool-card p {
  position: relative;
  z-index: 1;
  flex: 1;
  margin: 0 0 14px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.tool-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.tool-actions button,
.use-tool-button {
  min-height: 28px;
  padding: 0 10px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.use-tool-button {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 36px;
  margin-top: auto;
  color: #2b3151;
  background: rgba(255, 255, 255, 0.9);
}

.tool-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.tool-panel h2 {
  margin: 10px 0 8px;
  font-size: 24px;
}

.tool-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.72;
}

.favorite-tool-button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--primary-dark);
  background: #f3f1ff;
  border: 1px solid #ded9ff;
  border-radius: 999px;
  font-weight: 800;
  white-space: nowrap;
}

.favorite-tool-button.is-favorited {
  color: #9a6400;
  background: #fff5cc;
  border-color: #ffe08a;
}

.tool-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(340px, 1.25fr);
  gap: 16px;
}

.tool-form,
.output-card,
.account-card {
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tool-form label,
.stack-form label {
  display: grid;
  gap: 8px;
  color: #3f465c;
  font-weight: 800;
}

.tool-form textarea,
.tool-form select,
.stack-form input {
  width: 100%;
  padding: 12px;
  color: var(--ink);
  background: #f8f9fd;
  border: 1px solid #dfe3ef;
  border-radius: var(--radius);
  outline: none;
}

.tool-form textarea {
  resize: vertical;
  min-height: 148px;
  line-height: 1.6;
}

.tool-form textarea:focus,
.tool-form select:focus,
.stack-form input:focus {
  border-color: #a9a2ff;
  box-shadow: 0 0 0 3px rgba(109, 93, 252, 0.12);
}

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

.credit-rule {
  margin-bottom: 14px !important;
  padding: 10px 12px;
  color: #576079 !important;
  background: #f6f8ff;
  border: 1px solid #e2e7f5;
  border-radius: var(--radius);
  font-size: 13px;
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.output-head h3 {
  margin: 4px 0 0;
}

.tool-output {
  min-height: 304px;
  padding: 14px;
  color: #3c445c;
  background: #f8f9fd;
  border: 1px solid #e3e7f1;
  border-radius: var(--radius);
  overflow: auto;
  overflow-wrap: anywhere;
}

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

.output-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.result-block {
  display: grid;
  gap: 12px;
}

.result-block h4 {
  margin: 0 0 4px;
  color: var(--ink);
}

.result-block ul,
.result-block ol {
  margin: 0;
  padding-left: 20px;
}

.result-block li {
  margin: 8px 0;
  line-height: 1.55;
}

.result-chip-row,
.material-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-chip,
.material-type-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  color: #3c4465;
  background: #ffffff;
  border: 1px solid #e1e5f0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.risk-low {
  color: #087f5b;
}

.risk-mid {
  color: #b46900;
}

.risk-high {
  color: #d6334f;
}

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

.generated-card {
  padding: 12px;
  background: #ffffff;
  border: 1px solid #e2e6f2;
  border-radius: var(--radius);
}

.generated-card strong {
  display: block;
  margin-bottom: 6px;
}

.generated-card span {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 3px 8px;
  color: #4f46e5;
  background: #eef2ff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.generated-card p {
  color: #59617a;
  font-size: 13px;
}

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

.history-item {
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-top strong {
  display: block;
}

.history-top span {
  color: var(--muted);
  font-size: 12px;
}

.history-variants {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-variants span {
  padding: 5px 9px;
  color: #59617a;
  background: #f4f6fb;
  border-radius: 999px;
  font-size: 12px;
}

.empty-note {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background: rgba(247, 248, 252, 0.82);
  border: 1px dashed #d5d9e8;
  border-radius: var(--radius);
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) minmax(260px, 0.9fr);
  gap: 14px;
}

.account-card h3 {
  margin: 0 0 12px;
}

.auth-forms {
  display: grid;
  gap: 16px;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.account-panel {
  display: grid;
  gap: 12px;
}

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

.account-metrics span {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 12px;
  color: var(--muted);
  background: #f6f8fd;
  border: 1px solid #e4e8f2;
  border-radius: var(--radius);
  font-size: 12px;
}

.account-metrics strong {
  color: var(--ink);
  font-size: 19px;
}

.system-message {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.system-message.is-error {
  color: var(--danger);
}

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

.plan-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: #f8f9fd;
  border: 1px solid #e2e6f1;
  border-radius: var(--radius);
}

.plan-card strong {
  display: block;
  margin-bottom: 4px;
}

.plan-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.mini-button {
  min-height: 32px;
  padding: 0 12px;
  color: var(--primary-dark);
  background: #f0eeff;
  border-color: #dcd8ff;
  font-size: 12px;
}

.credit-log-list {
  display: grid;
  gap: 8px;
}

.credit-log-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  color: #4d566f;
  background: #f8f9fd;
  border: 1px solid #e3e7f2;
  border-radius: var(--radius);
  font-size: 13px;
}

.credit-log-row small {
  display: block;
  color: var(--muted);
}

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

.guide-steps article {
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.guide-steps span {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--primary-dark);
  font-weight: 900;
}

.guide-steps strong {
  display: block;
  margin-bottom: 6px;
}

.guide-steps p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.quick-bar {
  position: fixed;
  top: 156px;
  right: 16px;
  z-index: 18;
  display: grid;
  gap: 8px;
  width: 66px;
}

.quick-bar button {
  min-height: 54px;
  padding: 7px 6px;
  color: #4d5571;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(224, 227, 240, 0.94);
  border-radius: var(--radius);
  box-shadow: 0 10px 22px rgba(74, 70, 124, 0.1);
  font-size: 12px;
  font-weight: 800;
}

.quick-bar button:hover {
  color: var(--primary-dark);
  border-color: #cfc9ff;
}

.payment-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 24, 42, 0.44);
}

.payment-box {
  position: relative;
  width: min(420px, 100%);
  padding: 24px;
  text-align: center;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.payment-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  color: var(--ink);
  background: #f4f6fb;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 20px;
}

.qr-box {
  min-height: 180px;
  display: grid;
  place-items: center;
  margin: 16px 0;
  padding: 12px;
  background: #f8f9fd;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.qr-box svg {
  max-width: 180px;
  height: auto;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1280px) {
  .tool-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .account-grid {
    grid-template-columns: 1fr 1fr;
  }

  .account-card:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .main-console {
    padding-right: 24px;
  }

  .quick-bar {
    display: none;
  }

  .tool-grid,
  .favorite-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-workspace,
  .account-grid,
  .guide-steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .mobile-menu-toggle {
    display: grid;
  }

  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-scrim {
    display: block;
  }

  .main-console {
    margin-left: 0;
    padding: 74px 14px 32px;
  }

  .welcome-panel {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  .welcome-actions {
    width: 100%;
  }

  .welcome-actions button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .welcome-copy h1 {
    font-size: 26px;
  }

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

  .welcome-actions button {
    width: 100%;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .favorite-section,
  .tools-section,
  .tool-panel,
  .materials-section,
  .account-section,
  .tutorial-section {
    padding: 14px;
  }

  .tool-grid,
  .favorite-cards,
  .generated-grid,
  .parameter-grid,
  .account-metrics {
    grid-template-columns: 1fr;
  }

  .tool-card {
    min-height: 244px;
  }

  .tool-panel-head {
    flex-direction: column;
  }

  .output-head,
  .history-top,
  .plan-card,
  .credit-log-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .output-actions {
    justify-content: stretch;
  }

  .output-actions button {
    flex: 1;
  }
}
