:root {
  --bg: #000;
  --panel: #0a0a0b;
  --panel-2: #111113;
  --line: #1e1e21;
  --line-2: #2a2a2e;
  --text: #ededed;
  --muted: #8b8b90;
  --dim: #5c5c62;
  --accent: #3b6bff;
  --rail: 56px;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, "Noto Sans TC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* rail */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  border-right: 1px solid var(--line); background: var(--bg);
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 12px; z-index: 20;
}
.logo {
  width: 28px; height: 28px; border-radius: 7px; margin-bottom: 18px;
  display: grid; place-items: center; font-weight: 600; font-size: 15px;
  background: var(--text); color: var(--bg);
}
.rail-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--muted);
}
.rail-btn:hover { color: var(--text); background: var(--panel-2); }
.rail-btn.on { color: var(--text); background: var(--panel-2); }

.main { margin-left: var(--rail); min-height: 100vh; display: flex; flex-direction: column; }

/* top */
.top {
  position: sticky; top: 0; z-index: 10; height: 52px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(0,0,0,.8); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 6px 12px; border-radius: 7px; color: var(--muted); font-size: 13px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); background: var(--panel-2); }
.count { color: var(--dim); font-size: 12px; white-space: nowrap; padding-left: 12px; }

/* hero */
.hero {
  position: relative; overflow: hidden; border-bottom: 1px solid var(--line);
  padding: 56px 24px 52px; text-align: center;
  background: radial-gradient(90% 120% at 50% 130%, #0a2b9e 0%, #03123f 45%, #01040f 80%);
}
#dots { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-in { position: relative; }
.eyebrow { margin: 0 0 14px; font-size: 12px; color: #c9d3ff; }
.hero h1 {
  margin: 0; font-size: clamp(26px, 4vw, 38px); line-height: 1.25; font-weight: 500; letter-spacing: .01em;
  text-shadow: 0 2px 24px rgba(0,0,0,.6);
}
.sub { margin: 12px 0 24px; color: #aab3cc; font-size: 14px; }
.search {
  margin: 0 auto; max-width: 420px; height: 44px; padding: 0 10px 0 14px;
  display: flex; align-items: center; gap: 10px; cursor: text;
  background: rgba(16,16,20,.85); border: 1px solid var(--line-2); border-radius: 10px;
  color: var(--muted);
}
.search:focus-within { border-color: #4a5fa8; }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
  color: var(--text); font: inherit;
}
.search input::-webkit-search-cancel-button { filter: invert(1) opacity(.5); }
kbd {
  font: 11px Inter, sans-serif; color: var(--dim); padding: 2px 6px;
  border: 1px solid var(--line-2); border-radius: 5px;
}

/* sections */
#view { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 8px 24px 40px; }
.sec { padding-top: 40px; }
.sec-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sec-h h2 { margin: 0; font-size: 16px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.sec-h h2 svg { width: 16px; height: 16px; color: var(--accent); }
.sec-h .n { color: var(--dim); font-size: 12px; font-weight: 400; }
.more { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.more:hover { color: var(--text); }
.more svg { width: 14px; height: 14px; }

/* featured cards */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px 16px; }
.card .shot {
  aspect-ratio: 1200 / 630; border-radius: 6px; overflow: hidden; background: var(--panel-2);
  border: 1px solid var(--line); position: relative;
}
.card .shot > img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; transition: transform .4s ease; }
.card .shot .ph { position: absolute; inset: 0; display: grid; place-items: center; }
.card .shot .ph img { width: 40px; height: 40px; object-fit: contain; opacity: .9; }
.card .shot > img.ss { object-position: top; }
.card:hover .shot > img { transform: scale(1.03); }
.card .meta { margin-top: 10px; display: flex; align-items: center; gap: 6px; font-size: 13px; min-width: 0; }
.card .meta b { font-weight: 500; white-space: nowrap; }
.card .meta span { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* compact list */
.list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 16px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 8px; margin: 0 -8px; border-radius: 8px; min-width: 0;
}
.row:hover { background: var(--panel-2); }
.ico {
  flex: none; width: 36px; height: 36px; border-radius: 8px; background: #fff;
  display: grid; place-items: center; overflow: hidden;
}
.ico img { width: 22px; height: 22px; }
.row .txt { min-width: 0; flex: 1; }
.row .name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .desc { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .price { color: var(--muted); font-size: 11px; white-space: nowrap; align-self: flex-start; padding-top: 2px; }

/* category tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile {
  display: flex; align-items: center; gap: 12px; padding: 18px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.tile:hover { border-color: var(--line-2); background: var(--panel-2); }
.stack { display: flex; }
.stack .ico { width: 26px; height: 26px; border-radius: 6px; border: 2px solid var(--panel); margin-left: -8px; }
.stack .ico:first-child { margin-left: 0; }
.stack .ico img { width: 15px; height: 15px; }
.tile b { font-weight: 500; flex: 1; }
.tile .n { color: var(--dim); font-size: 12px; }
.tile svg { width: 14px; height: 14px; color: var(--dim); }

.empty { padding: 60px 0; text-align: center; color: var(--dim); }

.foot { border-top: 1px solid var(--line); padding: 20px 24px; color: var(--dim); font-size: 12px; text-align: center; }

@media (max-width: 1100px) {
  .cards, .list, .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .cards, .list, .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  :root { --rail: 0px; }
  .rail { display: none; }
  .top, #view { padding-left: 16px; padding-right: 16px; }
  .hero { padding: 56px 16px 48px; }
  .list, .tiles { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; gap: 16px 12px; }
  .count { display: none; }
}

/* ---------- admin ---------- */
.admin-only { display: none !important; }
body.admin .admin-only { display: inline-flex !important; }
body.admin .rail-btn.admin-only { display: grid !important; }
.rail-gap { flex: 1; }
.rail { padding-bottom: 12px; }
.top-r { display: flex; align-items: center; gap: 8px; }

.btn {
  height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font: 500 13px Inter, "Noto Sans TC", sans-serif;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: #3a3a40; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--text); color: #000; border-color: var(--text); }
.btn.primary:hover { background: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: #ff6b6b; border-color: #4a1f22; }
.btn.danger:hover { background: #2a1214; }
.btn.sq { width: 32px; padding: 0; }
.link { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }

.item { position: relative; min-width: 0; }
.edit {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line-2);
  background: rgba(10,10,12,.85); color: var(--text); cursor: pointer;
  display: grid; place-items: center; opacity: 0; transition: opacity .15s;
}
.edit svg { width: 15px; height: 15px; }
.item:hover .edit, .edit:focus-visible { opacity: 1; }
.list .edit { top: 50%; right: -4px; transform: translateY(-50%); }
.list .item:hover .price { visibility: hidden; }
@media (hover: none) { .edit { opacity: .9; } .list .item .price { display: none; } }

/* dialogs */
.dlg {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-2); border-radius: 14px;
  background: var(--panel); color: var(--text); box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.dlg::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.dlg-in { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg h3 { margin: 0 0 2px; font-size: 16px; font-weight: 500; }
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > span { font-size: 12px; color: var(--muted); }
.fld input, .cat-list input {
  height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2);
  background: #050506; color: var(--text); font: inherit; outline: 0; width: 100%; min-width: 0;
}
.fld input:focus, .cat-list input:focus { border-color: #4a5fa8; }
.with-btn { display: flex; gap: 8px; }
.with-btn .btn { height: 38px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.chk { display: flex; align-items: center; gap: 8px; height: 38px; font-size: 13px; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }
.hint { margin: -8px 0 0; font-size: 12px; color: var(--dim); }
.err { margin: 0; font-size: 12px; color: #ff6b6b; min-height: 0; }
.err:empty { display: none; }
.preview { border-radius: 8px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 1200 / 630; background: var(--panel-2); }
.preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.acts { display: flex; gap: 8px; margin-top: 4px; }
.acts .sp { flex: 1; }
.acts:not(:has(.sp)) { justify-content: flex-end; }
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow: auto; }
.cat-list li { display: flex; align-items: center; gap: 8px; }
.cat-list .n { color: var(--dim); font-size: 12px; width: 24px; text-align: right; flex: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 100;
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: #000; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #ff6b6b; }

@media (max-width: 560px) {
  .two { grid-template-columns: 1fr; }
  .top-r .btn.ghost { display: none !important; }
}
