:root {
    --ink: #1c1914;
    --muted: #6f675c;
    --paper: #f5f5f3;
    --card: #ffffff;
    --line: #e6e6e6;
    --pine: #1f1f1f;
    --rust: #d0121a;
    --ok: #215c38;
    --bad: #8d2d2d;
    --warn: #8a5a12;
    --shadow: 0 18px 40px rgba(48, 34, 18, 0.08);
    color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background: #f5f5f3;
    color: var(--ink);
    font-family: "Microsoft JhengHei", "微軟正黑體", "PingFang TC", "Noto Sans TC", "Heiti TC", sans-serif;
    line-height: 1.6;
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

.top {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 5vw;
    background: #fff;
    color: #1a1a1a;
    border-bottom: 1px solid #ececec;
}
.admin-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 5vw;
    background: #1f1f1f;
    color: #f7f7f7;
}
.mark {
    font-family: inherit;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-decoration: none;
}
.top nav, .admin-bar nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 18px;
}
.top a, .admin-bar a { text-decoration: none; }
.admin-bar strong { font-weight: 560; letter-spacing: 0.08em; }
.admin-bar form { margin: 0; }
.admin-bar button, .ops button, .thumb, .link-box button, [data-move], [data-remove-image] {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
}
.admin-bar button { color: #f6f0e6; }

main { min-height: calc(100vh - 150px); }
.hero, .catalog, .empty, .detail, .pager {
    width: min(1120px, calc(100% - 10vw));
    margin-left: auto;
    margin-right: auto;
}
.hero { padding: 36px 0 18px; }
.kicker {
    margin: 0 0 8px;
    color: #888;
    letter-spacing: 0.08em;
    font-size: 13px;
}
.hero h1 { margin: 0; font-size: 32px; line-height: 1.25; }
.lede { max-width: 40rem; color: #666; font-size: 15px; }

.catalog {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    padding-bottom: 36px;
}
.card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
    border: 1px solid #ececec;
    text-decoration: none;
}
.card-media, .stage {
    position: relative;
    background: #f3f3f3;
    overflow: hidden;
}
.card-media { aspect-ratio: 1 / 1; }
.stage {
    aspect-ratio: 1 / 1;
    max-height: 640px;
    border: 1px solid #ececec;
}
.card-media img, .stage img, .card-media .ph, .stage .ph {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card.feature .card-media {
    aspect-ratio: 1 / 1;
    height: auto;
    min-height: 0;
}
.card-body { padding: 10px 12px 14px; }
.code {
    margin: 0 0 4px;
    font-family: Consolas, "Cascadia Mono", monospace;
    letter-spacing: 0.08em;
    font-size: 12px;
    color: #999;
}
.card h2, .detail h1 { margin: 0 0 6px; }
.card h2 {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
}
.summary {
    margin: 0 0 8px;
    color: #777;
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.price { margin: 0; color: #d0121a; font-weight: 700; font-size: 16px; }
.ph {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: #666;
    font-size: 42px;
}
.ph.big { font-size: 96px; }

.detail { padding: 36px 0 64px; }
.back { margin: 0 0 18px; }
.back a { color: var(--muted); }
.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.85fr);
    gap: 36px;
    align-items: start;
}
.stage img { object-fit: cover; }
.thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.thumb {
    width: 72px;
    height: 72px;
    padding: 0;
    border: 1px solid transparent;
    background: #e8dece;
}
.thumb.is-on { border-color: var(--ink); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.detail h1 { font-size: 28px; line-height: 1.3; }
.detail .price { font-size: 22px; margin-bottom: 12px; }
.prose p { margin: 0 0 14px; }
.link-box {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.link-box code {
    font-family: Consolas, "Cascadia Mono", monospace;
    font-size: 13px;
    word-break: break-all;
}
.link-box button, .ops button, [data-move], [data-remove-image] { text-decoration: underline; text-underline-offset: 3px; }
.link-box.inline { margin: 0 0 18px; }

.empty, .gate {
    padding: 72px 0;
    max-width: 640px;
}
.empty.slim { padding: 12px 0 40px; }
.button, button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    background: var(--ink);
    color: #f6f0e6;
    text-decoration: none;
    border: 0;
    cursor: pointer;
}
.pager {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 8px 0 48px;
}
.pager a { color: var(--rust); }
.foot {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    width: min(1120px, calc(100% - 10vw));
    margin: 0 auto;
    padding: 22px 0 32px;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.admin .wrap { width: min(1040px, calc(100% - 8vw)); margin: 0 auto; padding: 32px 0 64px; }
.admin-head, .form-actions, .split { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; }
.admin h1 { margin: 0; font-size: 42px; }
.banner { padding: 12px 14px; border: 1px solid var(--line); background: var(--card); }
.banner.ok { color: var(--ok); }
.banner.bad { color: var(--bad); }
.banner.warn { color: var(--warn); background: #fff6e8; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--card); }
.sheet { width: 100%; border-collapse: collapse; }
.sheet th, .sheet td { padding: 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.sheet th { font-size: 12px; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.sheet small, .editor small, .hint { display: block; color: var(--muted); }
.tiny { width: 56px; height: 72px; object-fit: cover; background: #e8dece; }
span.tiny { display: grid; place-items: center; font-family: Palatino, serif; font-size: 22px; }
.ops { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.ops form { margin: 0; }
.editor, .stack { display: grid; gap: 16px; }
.editor { max-width: 760px; }
label span, fieldset legend { display: block; margin-bottom: 6px; }
input, textarea, select {
    width: 100%;
    padding: 12px 12px;
    border: 1px solid #d4c6b2;
    background: #fffdf9;
}
textarea { resize: vertical; }
.split label { flex: 1; }
.shots { margin: 0; padding: 12px; border: 1px solid var(--line); display: grid; gap: 12px; }
.shot { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: center; }
.shot img { width: 72px; height: 72px; object-fit: cover; }
.shot-actions { display: flex; gap: 14px; justify-content: flex-end; }
.admin-bar button, .ops button, .thumb, .link-box button, [data-move], [data-remove-image] {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
}
[data-remove-image] { color: #d0121a; }
.field-label { display: block; margin-bottom: 6px; }
.file-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
}
.file-btn input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.check { display: flex; gap: 6px; align-items: center; }
.check input { width: auto; }
.preview { display: flex; gap: 8px; flex-wrap: wrap; }
.preview img { width: 84px; height: 108px; object-fit: cover; }
.gate { margin: 8vh auto; }
.hint { margin-top: 8px; }

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

@media (max-width: 980px) {
    .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: 1fr; }
    .stage { max-height: 420px; }
}
@media (max-width: 680px) {
    .top, .admin-bar { padding: 14px 16px; }
    .top nav, .admin-bar nav { gap: 12px; }
    .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero { padding-top: 24px; }
    .hero h1 { font-size: 26px; }
    .split, .admin-head, .foot { display: grid; }
    .shot { grid-template-columns: 72px 1fr; }
}
