:root {
  color-scheme: dark;
  --font: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-family: var(--font);
  color: #f3eee4;
  background: #181815;
  --panel: #24231f;
  --edge: #3d3931;
  --muted: #b9b0a0;
  --accent: #edcc91;
  --radius: 14px;
  --surface: #24231f;
  --surface-muted: #383023;
  --border: var(--edge);
  --text: #f3eee4;
  --text-3: var(--muted);
  --radius-ctl: 9px;
  --tt-font: var(--font);
  --topbar-height: 64px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button { background: transparent; border: 0; }
button:disabled { cursor: wait; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.wrap { width: min(100% - clamp(36px, 4vw, 96px), 2360px); margin-inline: auto; }
.topbar { border-bottom: 1px solid var(--edge); }
.topbar-inner { min-height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tt-region[data-pos="top-right"] { top: calc(var(--topbar-height) + 10px); }
.brand { display: inline-flex; align-items: center; font-weight: 730; font-size: 21px; letter-spacing: -.05em; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .text-button { gap: 5px; white-space: nowrap; }
.topbar-actions .wide-label { font-size: inherit; line-height: inherit; }
.topbar-actions .support-button { border-color: #735b36; background: #3a2e1c; color: var(--accent); }
.topbar-actions .support-button:hover { background: #4a3b24; }
.brand-mark { width: 17px; height: 21px; position: relative; margin-inline: 4px 13px; transform: rotate(-13deg); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; width: 13px; height: 17px; border: 1.5px solid var(--accent); border-radius: 2px; }
.brand-mark::before { left: 0; top: 4px; opacity: .55; }
.brand-mark::after { left: 4px; top: 0; background: #29251c; }
.text-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius-ctl); background: var(--surface); font-size: 13px; font-weight: 600; padding: 0 13px; color: var(--muted); }
.text-button span { font-size: 21px; line-height: 1; }
.text-button:hover { background: #473b29; color: #ffe2ad; }
.workspace { display: grid; grid-template-columns: clamp(240px, 18vw, 382px) minmax(0, 1fr); align-items: start; gap: clamp(18px, 1.6vw, 34px); margin-block: 24px 28px; }
.library { min-width: 0; }
.library-heading { display: grid; gap: 14px; margin-bottom: 13px; }
.library-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.library-title h1 { margin: 0; font-size: 24px; line-height: 1.22; letter-spacing: -.045em; }
.library-title span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.category-filters { display: flex; align-items: start; gap: 8px; min-width: 0; }
.category-trigger { flex: none; width: auto; min-height: 42px; font-size: 13px; padding: 8px 12px; }
.category-trigger i { width: 7px; height: 7px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateY(-2px) rotate(45deg); color: var(--muted); }
.category-trigger[aria-expanded="true"] { border-color: #b38c56; }
.category-trigger[aria-expanded="true"] i { transform: translateY(2px) rotate(225deg); }
.selected-categories { display: flex; flex: 1; flex-wrap: wrap; gap: 5px; align-items: center; min-width: 0; min-height: 42px; max-height: 88px; overflow: auto; padding: 4px 3px; scrollbar-color: #6c5b44 transparent; }
.selected-category { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; min-height: 30px; padding: 3px 7px 3px 9px; background: #40321e; border: 1px solid #9a794c; border-radius: 6px; color: var(--accent); font-size: 12px; }
.selected-category > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-category:hover { background: #514025; border-color: var(--accent); }
.selected-category:focus-visible { outline-offset: 1px; }
.remove-category { flex: none; font-size: 16px; line-height: 1; }
.category-menu { position: fixed; inset: auto; min-height: 0; margin: 0; padding: 6px; overflow: hidden; border: 1px solid #51473a; border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 12px 32px #0c09077d; }
.category-menu:popover-open { display: flex; flex-direction: column; gap: 5px; }
.category-menu .category-search { flex: none; min-height: 36px; }
.category-menu .search input { min-height: 34px; }
.category-options { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-color: #6c5b44 transparent; }
.category-option { position: relative; display: flex; gap: 9px; align-items: center; min-height: 34px; padding: 6px 9px; border-radius: 7px; cursor: pointer; font-size: 13px; overflow-wrap: anywhere; }
.category-option:hover, .category-option:has(input:focus-visible) { background: var(--surface-muted); }
.category-option:has(input:checked) { color: var(--accent); }
.category-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.category-check { flex: none; width: 15px; height: 15px; display: grid; place-items: center; border: 1px solid #80705b; border-radius: 4px; }
.category-option input:checked + .category-check { border-color: var(--accent); background: var(--accent); }
.category-option input:checked + .category-check::after { content: ""; width: 4px; height: 7px; border: solid #2c2315; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.category-empty { margin: 0; padding: 10px; color: var(--muted); font-size: 12px; }
.browse-button { width: 100%; justify-content: start; color: var(--text); }
.browse-button i { width: 15px; height: 15px; border-radius: 3px; border: 1px solid currentColor; background: linear-gradient(currentColor,currentColor) center / 1px 100% no-repeat, linear-gradient(currentColor,currentColor) center / 100% 1px no-repeat; color: var(--accent); }
.browse-button span { margin-left: auto; font-size: 15px; color: var(--muted); }
.preview { min-width: 0; background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius); overflow: hidden; }
.preview-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px 22px; flex-wrap: wrap; padding: 14px clamp(16px, 1.5vw, 27px); border-bottom: 1px solid var(--edge); }
.preview-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 13px; min-width: 0; }
.preview-details { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 11px; min-width: 0; }
#preview-title { margin: 0; font: 600 clamp(27px, 3vw, 39px)/1.12 "STSong", "SimSun", "Songti SC", Georgia, serif; overflow-wrap: anywhere; }
#preview-subtitle { margin: 0; color: #d5bc94; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; overflow-wrap: anywhere; }
#preview-meta { margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
#preview-frame iframe { width: 100%; display: block; height: clamp(360px, 74vh, 940px); border: 0; }
.preview-empty { margin: 0; min-height: 270px; display: grid; place-items: center; padding: 20px; color: var(--muted); font-size: 14px; }
.art { display: block; background: #292824; position: relative; overflow: hidden; isolation: isolate; }
.art img { position: absolute; width: 100%; height: 100%; inset: 0; object-fit: cover; object-position: center; }
.art img.layer, .art img.portrait { object-fit: contain; }
.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(105px, auto); gap: 8px; }
.search-help { grid-column: 1/-1; margin: 0 2px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.search, .filters select:not(.at-sel-native) { display: flex; background: var(--surface); border: 1px solid var(--border); min-height: 42px; border-radius: var(--radius-ctl); }
.search { position: relative; align-items: center; padding-right: 5px; }
.search:focus-within, .at-sel-btn:focus-visible, .at-sel.open .at-sel-btn { outline: 0; border-color: #b38c56; box-shadow: 0 0 0 3px #edcc911b; }
.search input { appearance: none; outline: 0; background: none; border: none; width: 100%; min-width: 0; padding: 0 3px 0 32px; min-height: 40px; font-size: 13px; border-radius: var(--radius-ctl); }
.search input::-webkit-search-cancel-button { display: none; }
.search button { flex: none; width: 29px; height: 29px; display: grid; place-items: center; padding: 0; border-radius: 6px; color: var(--muted); font-size: 19px; }
.search button:hover { background: var(--surface-muted); color: var(--text); }
.search input::placeholder { color: #aaa191; }
.search i { width: 11px; height: 11px; border: 1.5px solid var(--muted); border-radius: 50%; position: absolute; left: 13px; pointer-events: none; }
.search i::after { content: ""; position: absolute; width: 6px; height: 1.5px; background: var(--muted); top: 8px; left: 7px; transform: rotate(45deg); }
.filters select:not(.at-sel-native) { padding: 0 8px; font-size: 12px; }
.filters .at-sel { min-width: 0; }
.filters .at-sel-btn { min-height: 42px; font-size: 12px; gap: 7px; padding: 8px 8px 8px 11px; }
.at-sel-btn:hover { border-color: #8c7351; }
.at-sel-menu { font-size: 12px; }
.at-opt { min-height: 34px; }
.at-opt.sel { color: var(--accent); }
.card-grid { display: grid; gap: 10px; }
.card-grid:has(> .card:nth-child(2)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; width: 100%; min-width: 0; padding: 8px; text-align: left; border-radius: 11px; border: 1px solid var(--edge); background: #211f1b; }
.card:hover { border-color: #8c7351; }
.card[aria-pressed="true"] { border-color: #ba965d; background: #342b20; }
.card-art { aspect-ratio: 16 / 9; border-radius: 6px; }
.card-caption { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 4px 4px; }
.card-caption strong, .card-caption small, .card-tag { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-caption strong { flex: 0 1 auto; max-width: 52%; color: #f0d39d; font-size: 16px; font-weight: 700; }
.card-caption small { flex: 1 1 0; font-size: 12px; color: var(--muted); }
.card-tag { width: fit-content; max-width: 100%; padding: 2px 7px; border: 1px solid #65533a; border-radius: 5px; background: #352c20; color: #e4c796; font-size: 11px; font-weight: 600; line-height: 1.35; }
.card-caption .card-tag { flex: 0 1 auto; max-width: 39%; }
.card[aria-pressed="true"] .card-caption strong { color: #ffe0a8; }
.card[aria-pressed="true"] .card-tag { border-color: #9a794c; background: #46371f; color: #f6d69f; }
.empty { border: 1px dashed var(--edge); margin: 0; padding: 29px 19px; border-radius: 10px; color: var(--muted); font-size: 14px; }
body:has(.catalog[open], .community-dialog[open]) { overflow: hidden; }
.catalog { width: min(1560px, calc(100% - 64px)); height: min(840px, calc(100dvh - clamp(36px, 9dvh, 96px))); max-width: none; border: 1px solid #51473a; border-radius: 16px; color: var(--text); background: #1e1d19; padding: 0; box-shadow: 0 25px 85px #0c0907b0; overflow: hidden; }
.catalog::backdrop, .community-dialog::backdrop { background: #0c0b09b8; }
.community-dialog { width: min(560px, calc(100% - 28px)); max-height: calc(100dvh - 28px); padding: 0; border: 1px solid #51473a; border-radius: 16px; background: #1e1d19; color: var(--text); box-shadow: 0 25px 72px #0c0907a0; }
.community-content { padding: 17px 24px 24px; }
.community-content > p { margin: 0 0 17px; color: var(--muted); font-size: 13px; }
.community-codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(152px, 100%), 1fr)); gap: 12px; }
.community-codes:has(> figure:only-child) { grid-template-columns: minmax(0, min(350px, 100%)); justify-content: center; }
.community-codes figure { min-width: 0; margin: 0; padding: 10px; border-radius: 11px; border: 1px solid var(--edge); background: var(--panel); }
.community-codes img { width: 100%; max-height: 280px; object-fit: contain; display: block; border-radius: 5px; background: #fff; }
.community-codes figure:only-child img { max-height: min(510px, max(220px, calc(100dvh - 180px))); }
.community-codes figcaption { margin-top: 9px; text-align: center; font-size: 12px; color: var(--muted); }
.catalog-layout { display: grid; grid-template-rows: auto auto minmax(0, 1fr); height: 100%; }
.catalog-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 18px 24px; border-bottom: 1px solid var(--edge); }
.catalog-heading > div { display: flex; align-items: baseline; gap: 12px; }
.catalog-heading h2 { margin: 0; font-size: 23px; }
#catalog-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.catalog-close { width: 38px; min-height: 38px; padding: 0; font-size: 23px; line-height: 1; }
.catalog-tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 420px); align-items: start; gap: 14px 20px; padding: 16px 24px; }
.catalog-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-color: #6c5b44 transparent; padding: 4px 24px 24px; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 15px; }
.catalog-grid .card { align-content: start; }
.catalog-grid .card-caption strong { font-size: 15px; }
.at-tip[data-kind="card"] { --ink: #332b21; width: min(286px, calc(100vw - 16px)); max-width: none; padding: 13px 15px; border: 1px solid #6e563a; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.at-tip[data-kind="card"] b { color: var(--accent); font-size: 15px; margin-bottom: 5px; }
.at-tip[data-kind="card"] > span { display: block; white-space: pre-line; color: #dfd3bf; }
@media (max-width: 900px) {
  .wrap { width: calc(100% - 36px); }
  :root { --topbar-height: 55px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 15px; margin-block: 17px 29px; }
  .library-heading { gap: 8px; margin-bottom: 7px; }
  .library-title h1 { font-size: 19px; }
  .search input { font-size: 16px; }
  .search input::placeholder { font-size: 12px; }
  .card-grid, .card-grid:has(> .card:nth-child(2)) { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: clamp(169px, 49vw, 228px); justify-content: start; overflow: auto hidden; padding: 4px; margin: -4px; scrollbar-color: #6c5b44 transparent; }
  .card-grid .card { grid-template-columns: 58px minmax(0, 1fr); align-items: center; gap: 7px; padding: 6px; }
  .card-grid .card-caption { padding: 0; gap: 5px; }
  .card-grid .card-caption strong { font-size: 14px; }
  .card-grid .card-caption small { font-size: 10px; }
  .card-grid .card-tag { font-size: 10px; padding-inline: 5px; }
  .preview-heading { padding: 12px 13px; gap: 6px 12px; }
}
@media (max-width: 660px) {
  .catalog { width: calc(100% - 18px); height: calc(100dvh - 22px); border-radius: 12px; }
  .catalog-heading { padding: 11px 13px; }
  .catalog-heading h2 { font-size: 19px; }
  .catalog-tools { grid-template-columns: minmax(0, 1fr); gap: 9px; padding: 12px 13px; }
  .selected-categories { max-height: 74px; }
  .catalog-scroll { padding: 4px 13px 14px; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .catalog-grid .card { padding: 5px; }
  .catalog-grid .card-caption { padding-inline: 2px; gap: 5px; }
  .catalog-grid .card-caption small { font-size: 10px; }
}
@media (max-width: 374px) {
  .wrap { width: calc(100% - 28px); }
  .text-button { padding-inline: 5px; }
}
@media (max-width: 520px) {
  .brand { font-size: 18px; }
  .brand-mark { margin-right: 9px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .text-button { min-width: 34px; min-height: 36px; padding-inline: 7px; font-size: 12px; }
  .topbar-actions .wide-label { display: none; }
  .community-content { padding: 14px 14px 17px; }
}
@media (max-width: 360px) {
  .topbar-inner { gap: 8px; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .text-button { min-width: 30px; padding-inline: 6px; }
}
