:root {
  --bg: #FFFBEB;
  --surface: #FFFFFF;
  --ink: #1E2A1E;
  --muted: #6B7769;
  --line: #E6E2CF;
  --yellow: #FFD43B;
  --green: #B7E36B;
  --red: #E5484D;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
img, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.meta { color: var(--muted); font-size: 13px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 2px solid var(--ink); flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; }
.tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.tab { border: 2px solid transparent; background: transparent; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--yellow); border-color: var(--ink); font-weight: 700; }
.tab small { color: var(--muted); margin-left: 4px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn { border: 2px solid var(--ink); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 700; white-space: nowrap; }
.btn.primary { background: var(--yellow); }
.btn.ghost { border-color: var(--line); font-weight: 600; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.pill { background: var(--red); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; }

.banner { margin: 12px 16px 0; padding: 10px 14px; border: 2px solid #D9A400; background: #FFF1B8; border-radius: var(--radius); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.error { border-color: var(--red); background: #FFE3E0; }

.main { padding: 16px; max-width: 1200px; margin: 0 auto; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select, .toolbar input { border: 2px solid var(--line); border-radius: 10px; padding: 6px 10px; background: var(--surface); }
.toolbar input { flex: 1; min-width: 160px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row-item { display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 10px; }
.row-item.pinned { border-color: var(--ink); background: #FFFDF2; }
.thumb { width: 72px; height: 72px; border-radius: 10px; background: var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); font-size: 12px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.info { min-width: 0; }
.info .title { font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.info .title code { font-weight: 400; font-size: 12px; color: var(--muted); background: var(--bg); padding: 1px 6px; border-radius: 6px; }
.info .sub { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font-size: 12px; }
.badge.pin { background: var(--yellow); border-color: var(--ink); font-weight: 700; }
.ops { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ops label { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.ops input[type="number"] { width: 68px; border: 2px solid var(--line); border-radius: 8px; padding: 3px 6px; }
@media (max-width: 640px) {
  .row-item { grid-template-columns: 56px 1fr; }
  .thumb { width: 56px; height: 56px; }
  .ops { grid-column: 1 / -1; justify-content: flex-start; }
}

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 2px solid var(--ink); z-index: 10; overflow: auto; padding: 16px; box-shadow: -12px 0 40px rgba(0,0,0,.12); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.editor { display: flex; flex-direction: column; gap: 12px; }
.editor label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.editor label > span b { color: var(--red); }
.editor input, .editor select, .editor textarea { border: 2px solid var(--line); border-radius: 10px; padding: 7px 10px; background: var(--surface); color: var(--ink); font-size: 15px; }
.editor input[type="file"] { padding: 6px; }
.editor .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.editor .check { flex-direction: row; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); }
.editor .hint { font-size: 12px; color: var(--muted); }
.editor .preview { border: 2px dashed var(--line); border-radius: 10px; padding: 8px; display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.editor .preview img, .editor .preview video { width: 96px; height: 96px; object-fit: contain; background: var(--bg); border-radius: 8px; }
.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--green); width: 0; transition: width .2s; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.note { background: var(--bg); border-radius: 10px; padding: 8px 10px; font-size: 13px; color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(30,42,30,.45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--surface); border: 2px solid var(--ink); border-radius: 18px; padding: 18px; width: min(640px, 100%); max-height: 90vh; overflow: auto; }
.modal-card h2 { margin: 0 0 10px; font-size: 18px; }
.modal-card pre { background: var(--bg); padding: 10px; border-radius: 10px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.modal-card ul { margin: 6px 0; padding-left: 18px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 30; max-width: 90vw; font-size: 14px; }
.toast.error { background: var(--red); }

body.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
body.login .card { background: var(--surface); border: 2px solid var(--ink); border-radius: 18px; padding: 24px; width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; }
body.login h1 { margin: 0; font-size: 20px; }
body.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
body.login input { border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 16px; }
.err { color: var(--red); margin: 0; font-size: 14px; }
