:root {
  color-scheme: light dark;
  --page: #f4f5f7;
  --surface: #ffffff;
  --raised: #eef0f3;
  --hover: #e8eaee;
  --text: #16191e;
  --muted: #68707c;
  --border: #d7dbe1;
  --border-strong: #aeb5c0;
  --viewer: #16191e;
  --accent: #adff00;
  --accent-ink: #111500;
  --danger: #b42318;
  --radius: 5px;
  --max-width: 1500px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: var(--page);
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #17191d;
    --surface: #1d2025;
    --raised: #24282e;
    --hover: #2b3037;
    --text: #f1f3f5;
    --muted: #9299a3;
    --border: #343941;
    --border-strong: #555c67;
    --viewer: #121417;
    --danger: #ff8c82;
  }
}

* { box-sizing: border-box; }
html.detail-open, html.detail-open body { overflow: hidden; }
body { min-width: 320px; min-height: 100dvh; margin: 0; background: var(--page); }
button, input { font: inherit; }
button { min-height: 34px; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 700; white-space: nowrap; }
button:hover:not(:disabled) { border-color: var(--border-strong); background: var(--hover); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, input:focus-visible, summary:focus-visible, [tabindex="0"]:focus-visible { outline: 2px solid var(--border-strong); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ui-segmented { display: inline-flex; width: max-content; max-width: 100%; align-items: center; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; background: var(--surface); }
.ui-segmented-item { display: inline-flex; min-height: 28px; align-items: center; justify-content: center; border: 0; border-radius: calc(var(--radius) - 1px); padding: 4px 10px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.ui-segmented .ui-segmented-item:hover { color: var(--text); background: var(--hover); }
.ui-segmented-item[aria-current="page"] { color: var(--text); background: var(--raised); box-shadow: inset 0 0 0 1px var(--accent); }
.ui-skill-card { display: flex; min-width: 0; min-height: 152px; flex-direction: column; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--text); background: var(--surface); }
.ui-skill-card:hover { border-color: var(--border-strong); background: var(--raised); box-shadow: inset 2px 0 var(--accent); }
.ui-skill-card-title { margin: 0; overflow-wrap: anywhere; font-size: 17px; line-height: 1.35; }
.ui-skill-card-summary { display: -webkit-box; flex: 1; overflow: hidden; margin: 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.ui-skill-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: auto; }
.ui-skill-card-actions > :is(button, a) { display: inline-flex; min-height: 30px; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 9px; color: var(--text); background: transparent; font-size: 11px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.ui-skill-card-actions > :is(button, a):hover { border-color: var(--border-strong); background: var(--hover); }

.topbar { position: sticky; z-index: 20; top: 0; display: grid; min-height: 58px; grid-template-columns: auto minmax(260px, 720px) auto; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding: 9px max(12px, calc((100vw - var(--max-width)) / 2)); background: color-mix(in srgb, var(--surface) 96%, transparent); }
.public-section-title { display: flex; align-items: center; gap: 12px; }
.public-brand { display: grid; min-width: 0; gap: 1px; color: var(--text); text-decoration: none; }
.public-brand strong, .public-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.public-brand strong { font-size: 14px; line-height: 17px; }
.public-brand span { color: var(--muted); font-size: 10px; line-height: 13px; }
.public-section-nav { flex: none; }
.search-shell { display: grid; min-width: 0; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 10px; background: var(--raised); }
.search-shell:focus-within { border-color: var(--border-strong); }
.search-shell input { min-height: 34px; min-width: 0; border: 0; padding: 0; color: var(--text); outline: 0; background: transparent; }
.search-shell input::placeholder { color: var(--muted); }
.search-mark { width: 13px; height: 13px; border: 1.5px solid var(--muted); border-radius: 50%; }
.search-mark::after { content: ""; display: block; width: 5px; height: 1.5px; margin: 10px 0 0 9px; background: var(--muted); transform: rotate(45deg); transform-origin: left center; }
.header-actions { display: flex; align-items: center; gap: 7px; }
.support-link, .privacy-link { display: inline-flex; min-height: 34px; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; color: var(--text); background: var(--surface); font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.support-link:hover, .privacy-link:hover { border-color: var(--border-strong); background: var(--hover); }
.button-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.filter-wrap, .sort-menu { position: relative; }
.menu-panel { position: absolute; z-index: 30; top: calc(100% + 7px); right: 0; display: grid; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 5px; background: var(--surface); box-shadow: 0 12px 30px color-mix(in srgb, var(--viewer) 24%, transparent); }
.menu-panel[hidden] { display: none; }
.filter-panel { width: 205px; gap: 3px; padding: 9px; }
.filter-panel strong { padding: 2px 3px 5px; font-size: 11px; }
.filter-panel label { display: flex; min-height: 31px; align-items: center; gap: 8px; font-size: 12px; }
.filter-panel input { width: 15px; min-height: 15px; accent-color: var(--accent); }
.menu-reset { margin-top: 4px; }
.sort-menu > summary { display: flex; min-width: 76px; min-height: 34px; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 700; list-style: none; white-space: nowrap; }
.sort-menu > summary:hover { border-color: var(--border-strong); background: var(--hover); }
.sort-menu > summary::-webkit-details-marker { display: none; }
.chevron { width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.sort-menu[open] .chevron { transform: translateY(2px) rotate(225deg); }
.sort-panel { width: 110px; gap: 2px; }
.sort-panel button { display: flex; min-height: 32px; align-items: center; justify-content: space-between; border: 0; padding: 5px 9px; background: transparent; text-align: left; }
.sort-panel button[aria-current="true"] { background: var(--hover); }
.sort-check { visibility: hidden; }
.sort-panel button[aria-current="true"] .sort-check { visibility: visible; }

.product-guide { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); padding: 9px max(12px, calc((100vw - var(--max-width)) / 2)); background: var(--surface); }
.product-guide p { display: flex; min-width: 0; align-items: baseline; gap: 8px; margin: 0; font-size: 12px; }
.product-guide p span { color: var(--muted); }
.product-actions { display: flex; flex: none; align-items: center; gap: 7px; }
.product-actions a { display: inline-flex; min-height: 34px; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; font-size: 12px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.product-actions .install-link { color: var(--accent-ink); border-color: var(--accent); background: var(--accent); }
.source-link { color: var(--text); background: var(--surface); }
.source-link:hover { border-color: var(--border-strong); background: var(--hover); }

.app-shell { width: calc(100% - 12px); max-width: var(--max-width); min-height: calc(100dvh - 58px); margin: 8px auto 48px; }
.site-footer { display: flex; max-width: var(--max-width); align-items: center; justify-content: space-between; gap: 12px; margin: 0 auto; border-top: 1px solid var(--border); padding: 16px 12px 24px; color: var(--muted); font-size: 11px; }
.site-footer strong { color: var(--text); }
.pack-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pack-card { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.pack-card:hover { border-color: var(--border-strong); box-shadow: 0 8px 20px color-mix(in srgb, var(--viewer) 15%, transparent); }
.pack-cover { display: block; width: 100%; aspect-ratio: 4 / 5; overflow: hidden; background: var(--viewer); }
.pack-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pack-copy { display: grid; gap: 6px; padding: 9px 10px 10px; }
.pack-copy h2 { overflow: hidden; margin: 0; font-size: 14px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.pack-meta { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.pack-meta span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pack-meta span:last-child { flex: none; }
.loading-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.loading-grid span { aspect-ratio: 4 / 5.55; border-radius: var(--radius); background: var(--raised); }
.empty-state { display: grid; min-height: 55dvh; place-items: center; color: var(--muted); font-size: 13px; }
.skill-state { align-content: center; justify-items: center; gap: 16px; padding: 32px 18px; text-align: center; }
.skill-state-copy { display: grid; max-width: 460px; gap: 7px; }
.skill-state h2, .skill-state p { margin: 0; }
.skill-state h2 { color: var(--text); font-size: 18px; line-height: 1.35; }
.skill-state p { line-height: 1.6; }
.skill-state[data-state="error"] h2 { color: var(--danger); }
.skill-state-action { display: inline-flex; min-height: 34px; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 12px; color: var(--text); background: var(--surface); font-size: 12px; font-weight: 800; text-decoration: none; }
.skill-state-action:hover { border-color: var(--border-strong); background: var(--hover); }
.public-skill-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.public-skill-card h2, .public-skill-card p { margin: 0; }
.public-skill-card-actions a { margin-left: auto; color: var(--accent-ink); border-color: var(--accent); background: var(--accent); }
.public-skill-card-actions a:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 88%, var(--surface)); }
.skill-public-dialog { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; color: var(--text); background: var(--surface); }
.public-skill-detail { display: grid; gap: 16px; padding: 28px; }
.public-skill-detail h1, .public-skill-detail p { margin: 0; }
.public-skill-detail p { color: var(--muted); line-height: 1.6; }
.public-skill-maintenance { border-top: 1px solid var(--border); padding-top: 12px; color: var(--muted); font-size: 11px; }
.public-skill-maintenance summary { width: max-content; cursor: pointer; color: var(--text); font-weight: 750; }
.public-skill-maintenance-copy { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-top: 10px; }
.public-skill-download { justify-self: start; border-radius: var(--radius); padding: 9px 12px; color: var(--accent-ink); background: var(--accent); font-size: 12px; font-weight: 800; text-decoration: none; }

.detail-dialog { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; padding: 0; color: var(--text); background: var(--page); }
.detail-dialog::backdrop { background: rgb(4 6 9 / .84); }
.detail-dialog:focus { outline: 0; }
.dialog-close { position: fixed; z-index: 50; top: 11px; right: 12px; width: 36px; padding: 0; font-size: 22px; line-height: 1; }
.detail-surface { min-height: 100dvh; padding-bottom: 40px; }
.detail-hero { display: grid; height: min(70dvh, 680px); min-height: 460px; grid-template-columns: minmax(0, 1fr) clamp(360px, 31vw, 450px); border-bottom: 1px solid var(--border); background: var(--surface); }
.detail-cover { min-height: 380px; overflow: hidden; background: var(--viewer); }
.detail-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail-info { display: grid; align-content: center; gap: 16px; padding: 42px 24px 34px; }
.detail-info h1 { display: -webkit-box; overflow: hidden; margin: 0; font-size: clamp(24px, 3vw, 40px); line-height: 1.12; letter-spacing: -.035em; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.detail-meta { display: flex; min-width: 0; overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; }
.detail-meta span { display: inline-flex; align-items: center; white-space: nowrap; }
.detail-meta span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.detail-meta span + span { border-left: 1px solid var(--border-strong); margin-left: 10px; padding-left: 10px; }
.detail-actions { display: flex; align-items: center; gap: 7px; }
.detail-actions a { display: inline-flex; min-height: 34px; align-items: center; border-radius: var(--radius); padding: 7px 11px; color: var(--accent-ink); background: var(--accent); font-size: 12px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.follow-action.is-active { color: var(--accent); border-color: var(--border-strong); }
.case-section { width: calc(100% - 16px); max-width: var(--max-width); margin: 18px auto 0; }
.case-section > h2 { display: flex; align-items: baseline; gap: 7px; margin: 0 2px 9px; font-size: 14px; }
.case-section > h2 span { color: var(--muted); font-size: 11px; font-weight: 500; }
.case-list { position: relative; width: 100%; overflow-anchor: none; --masonry-card-min-width: 270px; --masonry-gap: 8px; }
.case-card { position: absolute; display: block; min-width: 0; margin: 0; overflow: hidden; border: 0; border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.case-card:hover { box-shadow: 0 8px 20px color-mix(in srgb, var(--viewer) 15%, transparent); }
.case-image-wrap { position: relative; width: 100%; min-height: 110px; overflow: hidden; background: var(--viewer); }
.case-visual { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--viewer); }
.case-video-preview { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.case-image-wrap.is-video-playing .case-video-badge { opacity: 0; }
.case-video-badge { position: absolute; right: 8px; bottom: 8px; display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; color: white; background: rgba(5,7,11,.7); font-size: 10px; }
.case-load-sentinel { height: 2px; }
.case-loading { min-height: 160px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--raised); }
.preview-failure { display: flex; min-height: 160px; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); background: var(--raised); font-size: 13px; }
.preview-failure button { min-height: 30px; }
.toast { position: fixed; z-index: 90; right: 18px; bottom: 18px; max-width: min(360px, calc(100vw - 36px)); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 9px 12px; color: var(--text); background: var(--surface); box-shadow: 0 12px 30px color-mix(in srgb, var(--viewer) 24%, transparent); font-size: 11px; font-weight: 700; }

.case-detail-backdrop { position: fixed; z-index: 70; inset: 0; background: rgba(0,0,0,.76); }
.case-detail-backdrop[hidden] { display: none; }
.case-detail-drawer { position: fixed; z-index: 71; inset: 0; width: 100vw; height: 100dvh; overflow: hidden; visibility: hidden; background: var(--viewer); opacity: 0; pointer-events: none; transform: scale(.992); }
.case-detail-drawer.open { visibility: visible; opacity: 1; pointer-events: auto; transform: scale(1); }
.case-detail-toolbar { position: fixed; z-index: 73; top: 12px; right: 12px; display: flex; gap: 6px; }
.case-detail-toolbar button { width: 36px; min-width: 36px; padding: 0; background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: 0 8px 22px rgba(0,0,0,.24); font-size: 22px; line-height: 1; }
.case-detail-content { width: 100%; height: 100%; overflow: auto; }
.case-detail-layout { display: grid; min-height: 100dvh; grid-template-columns: minmax(0, 1fr) clamp(380px, 34vw, 480px); }
.case-detail-figure { position: relative; display: grid; min-width: 0; min-height: 100dvh; margin: 0; place-items: center; overflow: hidden; background: var(--viewer); }
.case-detail-figure img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100dvh; object-fit: contain; }
.case-detail-video-wrap { position: relative; display: block; width: 100%; height: 100dvh; }
.case-detail-video { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--viewer); }
.case-video-error { position: absolute; inset: auto 14px 14px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid rgba(255,255,255,.2); border-radius: var(--radius); padding: 7px 9px; color: rgba(255,255,255,.9); background: rgba(5,7,11,.78); font-size: 11px; }
.case-video-error[hidden] { display: none; }
.case-detail-video-label { position: absolute; right: 14px; bottom: 14px; border-radius: var(--radius); padding: 6px 9px; color: rgba(255,255,255,.86); background: rgba(5,7,11,.72); font-size: 11px; }
.case-detail-body { display: grid; min-width: 0; min-height: 100dvh; align-content: start; grid-template-rows: auto minmax(0, 1fr) auto auto; border-left: 1px solid var(--border); background: var(--surface); }
.case-detail-heading { padding: 68px 22px 17px; border-bottom: 1px solid var(--border); }
.case-detail-heading h2 { margin: 0; font-size: 18px; line-height: 1.35; }
.case-detail-heading p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.case-detail-section { min-height: 0; padding: 18px 22px; }
.case-detail-section h3 { margin: 0 0 10px; font-size: 11px; }
.case-detail-prompt { max-height: calc(100dvh - 290px); overflow: auto; margin: 0; border-radius: var(--radius); padding: 13px; color: var(--text); background: var(--raised); font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.case-detail-source { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); padding: 12px 22px; color: var(--muted); font-size: 11px; }
.case-detail-source a { color: var(--text); font-weight: 700; text-decoration: none; }
.case-detail-actions { position: sticky; bottom: 0; border-top: 1px solid var(--border); padding: 12px 22px 16px; background: var(--surface); }
.case-detail-actions button { width: 100%; }
.case-detail-actions .is-success { color: var(--accent); border-color: var(--border-strong); background: var(--raised); }

@media (max-width: 1050px) {
  .pack-grid, .loading-grid, .public-skill-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .case-list { --masonry-card-min-width: 220px; }
}

@media (max-width: 760px) {
  .topbar { grid-template-columns: auto 1fr; padding: 8px 10px; }
  .header-actions { justify-self: end; }
  .search-shell { grid-column: 1 / -1; grid-row: 2; }
  .product-guide { align-items: flex-start; padding: 9px 10px; }
  .product-guide p { display: grid; gap: 2px; }
  .app-shell { width: min(100% - 8px, var(--max-width)); }
  .pack-grid, .loading-grid, .public-skill-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .case-list { --masonry-card-min-width: 155px; --masonry-gap: 6px; }
  .detail-hero { height: auto; min-height: 0; grid-template-columns: 1fr; }
  .detail-cover { min-height: 46dvh; max-height: 56dvh; }
  .detail-info { padding: 24px 14px; }
  .detail-info h1 { font-size: 24px; }
  .case-section { width: calc(100vw - 16px); }
  .case-detail-layout { grid-template-columns: 1fr; }
  .case-detail-figure { min-height: 54dvh; }
  .case-detail-figure img { max-height: 54dvh; }
  .case-detail-video-wrap { height: 54dvh; }
  .case-detail-body { min-height: 46dvh; border-top: 1px solid var(--border); border-left: 0; }
  .case-detail-heading { padding: 18px 14px 14px; }
  .case-detail-section { padding: 16px 14px; }
  .case-detail-prompt { max-height: none; }
  .case-detail-source { padding: 12px 14px; }
  .case-detail-actions { padding: 10px 14px 14px; }
}

@media (max-width: 460px) {
  .product-guide { flex-direction: column; }
  .product-actions { width: 100%; }
  .product-actions a { flex: 1; justify-content: center; }
  .detail-info { gap: 12px; }
  .detail-actions { flex-wrap: wrap; }
  .case-detail-toolbar { top: 8px; right: 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  button, input, summary, .pack-card, .case-card, .case-detail-drawer { transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 120ms ease, opacity 140ms ease; }
}
