:root {
  --bg: #0a1022;
  --panel: rgba(14, 22, 44, .86);
  --panel-2: rgba(22, 33, 62, .9);
  --line: rgba(150, 185, 235, .18);
  --line-2: rgba(150, 185, 235, .35);
  --text: #dfe8f7;
  --muted: #8796b3;
  --accent: #8fc4ff;
  --accent-2: #5fa8ff;
  --green: #4fd1a6;
  --gold: #e6b65c;
  --red: #e36b6b;
  --radius: 4px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg) url(/img/bg.jpg) center top / cover fixed no-repeat;
  color: var(--text);
  font: 14px/1.6 "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
body > main { flex: 1; width: 100%; }
body::before { content: ""; position: fixed; inset: 0; background: rgba(6, 10, 24, .45); pointer-events: none; z-index: -1; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #fff; }
img { max-width: 100%; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* 頂部導覽 */
.topbar { background: rgba(8, 13, 30, .88); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px); }
.topbar .wrap { display: flex; align-items: center; gap: 22px; height: 60px; }
.topbar .logo img { height: 30px; display: block; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav > a, .nav .dd > span { color: var(--text); padding: 8px 12px; border-radius: var(--radius); cursor: pointer; display: block; }
.nav > a:hover, .nav .dd:hover > span, .nav a.on { background: rgba(143, 196, 255, .1); color: #fff; }
.dd { position: relative; }
.dd .menu { display: none; position: absolute; top: 100%; left: 0; min-width: 190px; background: #0f1830; border: 1px solid var(--line-2); padding: 6px; z-index: 30; }
.dd:hover .menu { display: block; }
.dd .menu a { display: block; padding: 7px 10px; color: var(--text); }
.dd .menu a:hover { background: rgba(143, 196, 255, .1); }
.dd .menu .sub { padding-left: 22px; color: var(--muted); }
.lang { color: var(--muted); border: 1px solid var(--line-2); width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.lang:hover { color: #fff; border-color: var(--accent); }
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox .quota { color: var(--muted); font-size: 12px; }
.userbox .quota b { color: var(--green); }
.rank-ico { width: 20px; height: 20px; vertical-align: -5px; }

/* 圖片按鈕（九宮格，切角不會被拉歪） */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; color: #fff; font: inherit; font-weight: 600; letter-spacing: .5px;
  border: solid transparent; border-width: 15px 17px; padding: 0 8px;
  border-image: url(/img/btn-primary-normal.png) 30 34 30 34 fill / 15px 17px stretch;
  background: none; cursor: pointer; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.btn:hover { border-image-source: url(/img/btn-primary-hover.png); color: #fff; }
.btn.dl { border-image-source: url(/img/btn-download-normal.png); }
.btn.dl:hover { border-image-source: url(/img/btn-download-hover.png); }
.btn.gold { border-image-source: url(/img/btn-gold-normal.png); color: #ffe7b5; }
.btn.gold:hover { border-image-source: url(/img/btn-gold-hover.png); }
.btn.ghost { border-image-source: url(/img/btn-ghost-normal.png); color: var(--text); font-weight: 400; }
.btn.ghost:hover { border-image-source: url(/img/btn-ghost-hover.png); }
.btn.sm { height: 32px; border-width: 11px 13px; border-image-width: 11px 13px; font-size: 13px; }
.btn.block { display: flex; width: 100%; }
.btn.big { height: 52px; font-size: 16px; }
.btn[disabled] { filter: grayscale(.8) brightness(.7); cursor: not-allowed; }

/* 橫幅 */
.banner { margin: 18px auto 0; position: relative; height: 300px; border: 1px solid var(--line-2); background: #0b1430 url(/img/banner.jpg) right center / cover no-repeat; overflow: hidden; }
@media (min-resolution: 1.5dppx) { .banner { background-image: url(/img/banner-2x.jpg); } }
.banner .inner { position: absolute; left: 40px; top: 50%; transform: translateY(-50%); width: 48%; }
.banner img.logo { width: 380px; max-width: 100%; display: block; }
.banner p { margin: 10px 0 0; color: #b9c9e6; font-size: 15px; }
.banner .stats { display: flex; gap: 22px; margin-top: 18px; color: var(--muted); font-size: 13px; }
.banner .stats b { color: #fff; font-size: 16px; margin-right: 4px; }

/* 面板（四角角飾） */
.panel { background: var(--panel); border: 1px solid var(--line); position: relative; }
.panel.deco::before, .panel.deco::after, .panel.deco > .c1, .panel.deco > .c2 { content: ""; position: absolute; width: 26px; height: 24px; background-size: contain; background-repeat: no-repeat; pointer-events: none; }
.panel.deco::before { left: -3px; top: -3px; background-image: url(/img/corner-tl.png); }
.panel.deco::after { right: -3px; top: -3px; background-image: url(/img/corner-tr.png); background-position: right top; }
.panel.deco > .c1 { left: -3px; bottom: -3px; background-image: url(/img/corner-bl.png); background-position: left bottom; }
.panel.deco > .c2 { right: -3px; bottom: -3px; background-image: url(/img/corner-br.png); background-position: right bottom; }
.panel-h { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.panel-b { padding: 16px; }
.divider { height: 14px; background: url(/img/divider.png) center / auto 100% no-repeat; margin: 14px 0; opacity: .9; }

.layout { display: grid; grid-template-columns: 270px 1fr; gap: 16px; margin: 16px auto 40px; align-items: start; }
.layout.detail { grid-template-columns: 1fr 320px; }
@media (max-width: 900px) { .layout, .layout.detail { grid-template-columns: 1fr; } .banner .inner { width: 70%; } .nav { display: none; } }

/* 側欄分類 */
.cats a { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; color: var(--text); border-left: 2px solid transparent; }
.cats a:hover { background: rgba(143, 196, 255, .07); }
.cats a.on { border-left-color: var(--accent); background: rgba(143, 196, 255, .1); color: #fff; }
.cats a.child { padding-left: 32px; color: #c5d2ea; }
.cats .ico { color: var(--accent); width: 18px; display: inline-block; }
.cats .n { font-size: 12px; color: var(--muted); background: rgba(255,255,255,.05); padding: 0 7px; border-radius: 3px; }
.side-actions { padding: 14px; display: grid; gap: 4px; }

/* 搜尋＋標籤列 */
.toolbar { display: flex; gap: 10px; padding: 12px; }
.input, .toolbar input, select, textarea {
  background: rgba(5, 10, 24, .7); border: 1px solid var(--line-2); color: var(--text); font: inherit; padding: 9px 12px; border-radius: 2px; width: 100%;
}
.input:focus, select:focus, textarea:focus, input:focus { outline: none; border-color: var(--accent); }
.tagbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 12px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 2px; color: #fff; background: var(--c, #5b7bb5); line-height: 20px; white-space: nowrap; }
.tagbar .tag { opacity: .75; }
.tagbar .tag:hover, .tagbar .tag.on { opacity: 1; box-shadow: 0 0 0 1px #fff inset; }
.tag.all { --c: #3a4766; }

/* 資源列表 */
.list-h { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.list-h .sorts a { margin-left: 12px; color: var(--muted); }
.list-h .sorts a.on { color: var(--accent); }
.item { display: grid; grid-template-columns: 64px 1fr 150px; gap: 14px; padding: 16px; border-bottom: 1px solid var(--line); align-items: start; }
.item:last-child { border-bottom: 0; }
.item:hover { background: rgba(143, 196, 255, .04); }
.thumb { width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--line-2); background: #0b1430; display: block; }
.item .t { font-size: 15px; }
.item .t a { color: #ffb366; color: var(--accent); }
.item .t a:hover { color: #fff; }
.item .ver { color: var(--muted); margin-left: 4px; }
.item .meta { color: var(--muted); font-size: 12.5px; margin: 2px 0 4px; }
.item .sum { color: #c6d1e6; font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item .side { text-align: right; font-size: 12.5px; color: var(--muted); }
.stars { color: #f5c542; letter-spacing: 1px; font-size: 14px; white-space: nowrap; }
.stars .off { color: #3b4560; }
@media (max-width: 640px) { .item { grid-template-columns: 52px 1fr; } .item .side { display: none; } .thumb { width: 52px; height: 52px; } }
.empty { padding: 50px; text-align: center; color: var(--muted); }

.pager { display: flex; gap: 4px; padding: 12px 16px; }
.pager a, .pager span { min-width: 34px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--text); }
.pager .on { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

/* 詳情頁 */
.r-head { display: flex; gap: 16px; padding: 18px; align-items: center; }
.r-head .thumb { width: 84px; height: 84px; }
.r-head h1 { margin: 0; font-size: 22px; font-weight: 600; }
.r-head h1 .ver { color: var(--muted); font-weight: 400; font-size: 18px; margin-left: 6px; }
.r-head .sum { color: #b9c6de; margin-top: 4px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 10px; }
.tabs a { padding: 12px 14px; color: var(--text); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.body { padding: 20px; font-size: 15px; line-height: 1.85; overflow-wrap: anywhere; }
.body img { max-width: 100%; height: auto; }
.body h2, .body h3 { color: #fff; margin: 1.2em 0 .5em; }
.body blockquote { border-left: 3px solid var(--accent-2); margin: 1em 0; padding: 4px 14px; color: #b9c6de; background: rgba(255,255,255,.03); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 16px 20px 0; }
.gallery img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border: 1px solid var(--line-2); cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; z-index: 99; cursor: zoom-out; }
.lightbox.on { display: flex; }
.lightbox img { max-width: 92vw; max-height: 92vh; }
.dlbox { padding: 16px; display: grid; gap: 10px; }
.quota-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); background: rgba(255,255,255,.03); padding: 8px 12px; border: 1px solid var(--line); }
.quota-row b { color: var(--green); }
.notice { font-size: 13px; color: var(--muted); text-align: center; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.stat-grid.two { grid-template-columns: 1fr 1fr; }
.stat-grid div { padding: 12px 6px; text-align: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat-grid div:last-child { border-right: 0; }
.stat-grid b { display: block; color: var(--accent); font-size: 15px; }
.stat-grid span { font-size: 12px; color: var(--muted); }
.mini-list a { display: flex; gap: 10px; align-items: center; padding: 8px 14px; color: var(--text); }
.mini-list a:hover { background: rgba(143, 196, 255, .06); }
.mini-list img { width: 34px; height: 34px; object-fit: cover; border: 1px solid var(--line); }
.update { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.update h3 { margin: 0 0 4px; font-size: 16px; }
.update .meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.review { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.review .who { font-size: 13px; color: var(--muted); }
.star-input { display: inline-flex; flex-direction: row-reverse; font-size: 26px; }
.star-input input { display: none; }
.star-input label { color: #3b4560; cursor: pointer; padding: 0 2px; }
.star-input input:checked ~ label, .star-input label:hover, .star-input label:hover ~ label { color: #f5c542; }

/* 表單 */
.form { display: grid; gap: 14px; }
.form label > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.auth { max-width: 420px; margin: 50px auto; }
.msg { padding: 10px 14px; border: 1px solid; margin-bottom: 12px; font-size: 13px; }
.msg.err { border-color: rgba(227,107,107,.5); background: rgba(227,107,107,.1); color: #ffb3b3; }
.msg.ok { border-color: rgba(79,209,166,.5); background: rgba(79,209,166,.1); color: #a8f0d6; }
.hint { font-size: 12px; color: var(--muted); }

/* 方案 */
.plans { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 20px auto 40px; }
@media (max-width: 900px) { .plans { grid-template-columns: 1fr 1fr; } }
.plan { text-align: center; padding: 26px 18px; }
.plan img { width: 72px; height: 72px; }
.plan h3 { margin: 10px 0 4px; font-size: 18px; }
.plan .q { font-size: 30px; color: #fff; font-weight: 700; margin: 10px 0; }
.plan .q small { font-size: 13px; color: var(--muted); font-weight: 400; }
.plan ul { list-style: none; padding: 0; margin: 0 0 18px; color: #b9c6de; font-size: 13px; line-height: 2; }
.plan.cur { box-shadow: 0 0 0 1px var(--accent) inset; }

/* 後台 */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 400; background: rgba(255,255,255,.02); }
.tbl tr:hover td { background: rgba(143,196,255,.03); }
.tbl .acts { white-space: nowrap; text-align: right; }
.tbl .acts a, .tbl .acts button { margin-left: 8px; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.linkbtn.danger { color: var(--red); }
.st { font-size: 12px; padding: 1px 7px; border-radius: 2px; }
.st.published { background: rgba(79,209,166,.15); color: var(--green); }
.st.draft { background: rgba(230,182,92,.15); color: var(--gold); }
.st.hidden { background: rgba(255,255,255,.08); color: var(--muted); }

/* 上傳頁 */
.steps { display: flex; gap: 8px; margin-bottom: 16px; }
.steps div { flex: 1; padding: 10px; border: 1px solid var(--line); color: var(--muted); text-align: center; font-size: 13px; }
.steps div.on { border-color: var(--accent); color: #fff; background: rgba(143,196,255,.08); }
.cat-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.cat-pick button { background: rgba(255,255,255,.03); border: 1px solid var(--line-2); color: var(--text); padding: 14px; font: inherit; cursor: pointer; text-align: left; }
.cat-pick button:hover { border-color: var(--accent); }
.cat-pick button.on { border-color: var(--accent); background: rgba(143,196,255,.14); color: #fff; }
.cat-pick .g { grid-column: 1 / -1; color: var(--muted); font-size: 12px; margin-top: 6px; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick label { cursor: pointer; }
.tag-pick input { display: none; }
.tag-pick .tag { opacity: .55; }
.tag-pick input:checked + .tag { opacity: 1; box-shadow: 0 0 0 1px #fff inset; }
.editor-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; background: rgba(5,10,24,.85); border: 1px solid var(--line-2); border-bottom: 0; }
.editor-bar button, .editor-bar select { background: transparent; border: 1px solid transparent; color: var(--text); padding: 4px 9px; cursor: pointer; font: inherit; width: auto; }
.editor-bar button:hover { border-color: var(--line-2); }
.editor-bar input[type=color] { width: 30px; height: 28px; padding: 0; border: 0; background: none; }
.editor { min-height: 320px; padding: 14px 16px; background: rgba(5,10,24,.7); border: 1px solid var(--line-2); outline: none; line-height: 1.8; overflow-wrap: anywhere; }
.editor:focus { border-color: var(--accent); }
.editor img { max-width: 100%; }
.drop { border: 1px dashed var(--line-2); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: rgba(5,10,24,.5); }
.drop:hover, .drop.over { border-color: var(--accent); color: #fff; }
.prev-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.prev-row .pv { position: relative; }
.prev-row img { width: 110px; height: 70px; object-fit: cover; border: 1px solid var(--line-2); display: block; }
.prev-row .x { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.7); color: #fff; border: 0; cursor: pointer; width: 20px; height: 20px; line-height: 18px; padding: 0; }
.progress { height: 6px; background: rgba(255,255,255,.06); margin-top: 8px; display: none; }
.progress > div { height: 100%; width: 0; background: var(--green); transition: width .2s; }
.savebar { display: flex; gap: 10px; justify-content: flex-end; align-items: center; position: sticky; bottom: 0; padding: 12px 16px; background: rgba(8,13,30,.95); border-top: 1px solid var(--line); }

.footer { border-top: 1px solid var(--line); background: rgba(6,10,24,.85); color: var(--muted); font-size: 12px; padding: 20px 0; text-align: center; }
