:root {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --surface-2: #f2f2f2;
  --ink: #202020;
  --muted: #666666;
  --muted-2: #888888;
  --border: #e6e6e6;
  --border-2: #e8e8e8;
  --accent: #3b82f6;
  --mark: #efefef;
  --radius: 18px;
  --radius-sm: 12px;
  --shell: 1160px;
  --nav-h: 64px;
  color: var(--ink);
  background: var(--bg);
  font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Helvetica Neue", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.65;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  padding: 0.5rem 0.85rem;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
}

.shell {
  width: min(100% - 2.5rem, var(--shell));
  margin-inline: auto;
}

/* —— Top nav —— */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.top-nav__inner {
  width: min(100% - 2.5rem, var(--shell));
  margin-inline: auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand__mark {
  display: block;
  border-radius: 8px;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__cn {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand__en {
  font-size: 0.68rem;
  color: var(--muted-2);
  letter-spacing: 0.04em;
}

.top-nav__modes {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.nav-link {
  margin: 0;
  padding: 0.45rem 0.75rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--ink);
  background: var(--surface);
}

.nav-link.is-active {
  color: var(--ink);
  font-weight: 600;
  background: var(--surface);
}

.top-nav__actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
  flex-shrink: 0;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field__icon {
  position: absolute;
  left: 0.85rem;
  color: var(--muted-2);
  pointer-events: none;
}

.search-field input {
  width: 11.5rem;
  padding: 0.5rem 0.9rem 0.5rem 2.15rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}

.search-field input::placeholder {
  color: var(--muted-2);
}

.search-field input:focus {
  border-color: #ccc;
  outline: none;
  box-shadow: 0 0 0 3px rgba(32, 32, 32, 0.06);
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  line-height: 1.2;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.btn-primary:hover:not(:disabled) {
  background: #000;
}

.btn-primary:disabled {
  background: #cfcfcf;
  border-color: #cfcfcf;
  color: #fff;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.48rem 0.95rem;
  font-size: 0.9rem;
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface);
}

/* —— Hero —— */
.hero {
  padding: 3.25rem 0 0;
  background: var(--bg);
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hero__sub {
  margin-top: 0.75rem;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1.02rem;
}

.mode-tabs {
  display: flex;
  gap: 1.5rem;
  margin-top: 2rem;
  border-bottom: 1px solid var(--border);
}

.mode-tab {
  margin: 0;
  padding: 0.85rem 0.1rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.98rem;
  cursor: pointer;
  position: relative;
}

.mode-tab:hover {
  color: var(--ink);
}

.mode-tab.is-selected {
  color: var(--ink);
  font-weight: 600;
}

.mode-tab.is-selected::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

/* —— Panels —— */
.mode-panel {
  padding: 1.75rem 0 4rem;
  min-height: 50vh;
}

.freeform-layout {
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
}

.block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.block h3,
.block label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
}

.block__meta {
  font-size: 0.82rem;
  color: var(--muted-2);
}

.optional-tag {
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--muted-2);
  margin-left: 0.35rem;
}

.prompt {
  margin-top: 0.45rem;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--ink);
  font-size: 0.95rem;
}

.prompt-card {
  margin-top: 0.55rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 4.5rem;
}

.prompt-card .prompt {
  margin-top: 0;
}

mark {
  background: var(--mark);
  color: inherit;
  padding: 0 0.12em;
  border-radius: 3px;
}

input[type="text"],
textarea {
  display: block;
  width: 100%;
  margin-top: 0.55rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  resize: vertical;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: #ccc;
  box-shadow: 0 0 0 3px rgba(32, 32, 32, 0.06);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
  max-height: 11rem;
  overflow: auto;
  padding-right: 0.15rem;
}

.chip {
  margin: 0;
  padding: 0.38rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.88rem;
  cursor: pointer;
}

.chip:hover {
  border-color: #ccc;
  background: var(--surface-2);
}

.chip.is-selected {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.callout {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.92rem;
}

.callout.tips {
  color: var(--ink);
  background: var(--surface-2);
}

.callout strong {
  font-weight: 600;
}

.inline-link {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.inline-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.hint,
.status {
  margin-top: 0.7rem;
  color: var(--muted);
  min-height: 1.4em;
  font-size: 0.9rem;
}

.status:empty {
  display: none;
}

.card .btn {
  margin-top: 0.95rem;
}


/* —— Category nav —— */
.category-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0 0 0.85rem;
  padding: 0 0.2rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.category-nav__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  margin: 0;
  padding: 0.42rem 0.65rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.category-nav__item:hover {
  background: #fff;
  color: var(--ink);
}

.category-nav__item.is-active {
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.18);
}

.category-nav__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-nav__count {
  flex: 0 0 auto;
  min-width: 1.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted-2);
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.category-nav__item.is-active .category-nav__count {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
}

.category-nav--chips {
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin: 0.85rem 0 0;
  padding: 0 0 0.85rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--border);
}

.category-nav--chips .category-nav__item {
  flex: 0 0 auto;
  width: auto;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
}

.category-nav--chips .category-nav__item:hover {
  border-color: #ccc;
  background: var(--surface-2);
}

.category-nav--chips .category-nav__item.is-active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: none;
}

.chip-group__label {
  flex: 0 0 100%;
  margin: 0.55rem 0 0.15rem;
  padding: 0 0.15rem;
  color: var(--muted-2);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chip-group__label:first-of-type {
  margin-top: 0.15rem;
}

.chip-row {
  max-height: 16rem;
}

/* —— Theme / Restyle workspace —— */
.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.style-browser {
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
  max-height: calc(100vh - var(--nav-h) - 2rem);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 0.85rem 1rem;
}

.style-browser__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.35rem 0.75rem;
}

.style-browser__head h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

.style-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.style-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 0.7rem;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0.45rem;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.style-card:hover {
  background: #fff;
  border-color: var(--border);
}

.style-card.is-selected {
  background: #fff;
  border-color: var(--ink);
}

.style-card__thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: #eaeaea;
  display: block;
}

.style-card__name {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
}

.style-card__empty {
  padding: 1.25rem 0.5rem;
  color: var(--muted-2);
  font-size: 0.88rem;
  text-align: center;
}

.detail__top h2 {
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

.detail__body {
  display: grid;
  grid-template-columns: minmax(200px, 320px) minmax(0, 1fr);
  gap: 1.15rem;
  align-items: start;
}

.reference {
  margin: 0;
  padding: 0.65rem;
  overflow: hidden;
}

.reference img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(70vh, 520px);
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
}

.composer {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.composer .card {
  margin: 0;
}

/* —— Footer —— */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 2.75rem 0 1.5rem;
}

.footer__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
}

.footer__col h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.footer__col li + li {
  margin-top: 0.35rem;
}

.footer-link {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.footer-link:hover {
  color: var(--accent);
}

.footer__note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
  max-width: 22rem;
}

/* —— Responsive —— */
@media (max-width: 980px) {
  .top-nav__modes {
    display: none;
  }

  .search-field input {
    width: 9rem;
  }

  .workspace,
  .detail__body {
    grid-template-columns: 1fr;
  }

  .style-browser {
    position: static;
    max-height: none;
  }

  .style-browser .category-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 0.75rem;
  }

  .style-browser .category-nav__item {
    flex: 0 0 auto;
    width: auto;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    white-space: nowrap;
  }

  .style-browser .category-nav__item.is-active {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.08);
    box-shadow: none;
  }


  .style-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .footer__grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 1.25rem, var(--shell));
  }

  .top-nav__inner {
    width: min(100% - 1.25rem, var(--shell));
    gap: 0.65rem;
  }

  .brand__en {
    display: none;
  }

  .nav-copy,
  #nav-copy {
    display: none;
  }

  .hero {
    padding-top: 2rem;
  }

  .mode-tabs {
    gap: 1rem;
    overflow-x: auto;
  }

  .mode-tab {
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }
}
