:root {
  color-scheme: light;
  --bg: #f6f7fa;
  --panel: #fff;
  --subtle: #f1f3f7;
  --line: #e4e7ee;
  --ink: #172033;
  --body: #4c5870;
  --muted: #607089;
  --accent: #5149d8;
  --accent-hover: #423abf;
  --accent-soft: #eeedff;
  --glass: #ffffffde;
  --ease: cubic-bezier(.22, .75, .22, 1);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 14px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151820;
  --panel: #1d222d;
  --subtle: #252a38;
  --line: #32394a;
  --ink: #f3f4fb;
  --body: #c2c9da;
  --muted: #a3aec5;
  --accent: #b7b1ff;
  --accent-hover: #d0ccff;
  --accent-soft: #302b54;
  --glass: #1d222dde;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); min-width: 280px; }
body:has(dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
button, select, input, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
a { color: inherit; text-decoration: none; }
button, a { transition: background-color .18s, color .18s, box-shadow .18s, transform .18s var(--ease); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.lucide { width: 18px; height: 18px; flex: none; stroke-width: 1.85; }
.skip { position: fixed; left: 12px; top: -80px; padding: 12px; z-index: 15; background: var(--panel); }
.skip:focus { top: 12px; }

.sidebar, .button.header-publish, .breadcrumb { display: none; }
.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(145%);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; flex: none; }
.brand strong { display: block; font-weight: 750; font-size: 19px; line-height: 1.25; }
.brand small { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 35px;
  height: 35px;
  background: #554bdf;
  color: white;
  border-radius: 9px;
  box-shadow: 0 3px 7px #534bd238, inset 0 1px 0 #ffffff43;
}
.brand-mark .lucide { width: 21px; height: 21px; }
.header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 7px; min-width: 0; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--subtle);
  color: var(--muted);
}
.search-box:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; }
.search-box input::placeholder { color: var(--muted); }
.search-box .lucide { width: 16px; height: 16px; }
.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 650;
  line-height: 1.35;
}
.button:active, .icon-button:active, .mobile-nav button:active { transform: scale(.96); }
.button:disabled { cursor: wait; opacity: .64; }
.primary { background: #5149d8; color: white; }
.secondary { background: var(--subtle); color: var(--ink); border: 1px solid var(--line); }
.icon-button { width: 44px; padding: 0; flex: none; background: transparent; color: var(--muted); }
.admin-authenticated .admin-entry { color: var(--accent); background: var(--accent-soft); }

.main { width: 100%; max-width: 1390px; margin: 0 auto; padding: 23px 15px 25px; outline: none; }
.admin-authenticated .main { padding-bottom: 85px; }
.intro { margin-bottom: 20px; }
.intro h1 { font-size: 29px; line-height: 1.2; font-weight: 780; }
.intro p { margin-top: 8px; color: var(--body); line-height: 1.55; }
.featured {
  display: grid;
  align-items: center;
  min-height: 218px;
  margin-bottom: 25px;
  isolation: isolate;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  color: white;
  background: #183638 url('/coast.jpg') center 62% / cover no-repeat;
}
.featured::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background: linear-gradient(90deg, #0b2526f5, #102d2cc7 45%, #16303512);
}
.featured-inner { padding: 21px 18px; }
.featured-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.5;
  color: #e3fff5;
  padding: 4px 8px;
  background: #ffffff24;
  border: 1px solid #ffffff32;
  border-radius: 5px;
  backdrop-filter: blur(9px);
}
.featured-tag .lucide { width: 13px; height: 13px; }
.featured h2 { margin-top: 9px; font-size: 24px; line-height: 1.22; font-weight: 760; }
.featured p { margin-top: 7px; color: #effbf8; font-size: 13px; line-height: 1.6; }
.featured-link { margin-top: 12px; padding: 0 11px; background: #f5fffa; color: #192d29; }
.featured-link .lucide { width: 16px; height: 16px; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { font-size: 21px; line-height: 1.3; }
.section-heading p { color: var(--muted); margin-top: 4px; font-size: 12px; }
.sort-box {
  display: flex;
  align-items: center;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--body);
}
.sort-box select { min-height: 42px; padding: 0 29px 0 32px; border: 0; border-radius: inherit; background: transparent; appearance: none; font-size: 12px; }
.sort-box option { background: var(--panel); }
.sort-box .lucide { position: absolute; pointer-events: none; width: 15px; height: 15px; left: 10px; }
.sort-box .lucide:last-child { left: auto; right: 8px; }
.category-filters { display: flex; gap: 6px; margin: 14px -15px 15px; padding: 3px 15px; overflow-x: auto; scrollbar-width: thin; }
.category-filters button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--body);
  font-size: 12px;
}
.category-filters button .lucide { width: 15px; height: 15px; }
.category-filters .active { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 720; }
.game-platforms { display: flex; flex-wrap: wrap; gap: 5px; margin: -6px 0 14px; }
.game-platforms button, .publish-modes button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding-inline: 11px;
  background: var(--subtle);
  color: var(--body);
  border-radius: 7px;
  font-size: 12px;
}
.game-platforms button .lucide, .publish-modes button .lucide { width: 15px; height: 15px; }
.game-platforms button.active, .publish-modes button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 720;
}
.resource-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.resource-card {
  position: relative;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 2px 4px #15243a06;
  transition: border-color .2s, box-shadow .2s, transform .2s var(--ease);
}
.resource-card:focus-within { border-color: var(--accent); }
.resource-cover {
  height: 122px;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  border-radius: 7px 7px 0 0;
  background: #ece9ff;
}
.cover-icons { background: #edeaff; }
.cover-tools { background: #dcefe6; }
.cover-code { background: #f8eadf; }
.cover-board { background: #e0edfb; }
.cover-dev { background: #f2e1eb; }
.cover-game-pc { background: #dcebf9; color: #315a87; }
.cover-game-android { background: #def0e3; color: #35694e; }
.cover-photo { background: #183638 url('/coast.jpg') center 52% / cover no-repeat; }
.uploaded-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-art { transition: transform .3s var(--ease); }
.game-art { position: relative; display: grid; place-items: center; width: 115px; height: 80px; transform: rotate(-7deg); }
.game-art .lucide:first-child { width: 69px; height: 69px; stroke-width: 1.25; }
.game-art .lucide:nth-child(2) { position: absolute; right: 2px; bottom: 3px; width: 39px; height: 39px; fill: #ffffffdb; }
.glyphs { display: grid; grid-template-columns: repeat(3, 38px); gap: 6px; transform: rotate(-7deg); }
.glyphs span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 35px;
  border-radius: 7px;
  background: #ffffff9e;
  color: #6251bb;
  border: 1px solid #cbbcfa;
  box-shadow: 0 3px 6px #6247a512;
}
.glyphs .lucide { width: 20px; height: 20px; }
.drawing { display: flex; align-items: center; position: relative; transform: rotate(-7deg); }
.drawing-node { display: grid; place-items: center; width: 43px; height: 37px; background: #fbfffc; color: #236850; border: 1px solid #6fba9f; border-radius: 6px; }
.drawing-node.second { transform: translateY(-10px) rotate(9deg); background: #a9e0c8; }
.connection { margin: 0 3px; width: 34px; border-top: 2px dashed #70aa97; transform: rotate(-13deg); }
.drawing-pointer { position: absolute; right: -19px; bottom: -13px; color: #2b6a54; }
.drawing-pointer .lucide { fill: #b3ebd3; }
.terminal { min-width: 153px; background: #252234; color: #f4cdb0; border-radius: 6px; box-shadow: 0 5px 12px #45223631; transform: rotate(-6deg); }
.terminal-top { display: flex; align-items: center; gap: 4px; min-height: 18px; padding: 0 9px; background: #383348; border-radius: 6px 6px 0 0; }
.terminal-top span { width: 5px; height: 5px; border-radius: 50%; background: #f4a98f; }
.terminal-top span:nth-child(2) { background: #e8c383; }
.terminal-top span:nth-child(3) { background: #9bd4be; }
.terminal-top b { color: #e2dbea; font: 8px ui-monospace, monospace; margin-left: 7px; }
.terminal-lines { display: grid; gap: 3px; padding: 8px 10px; font: 9px ui-monospace, monospace; }
.terminal-lines b { color: #ffaf93; font-weight: 500; }
.terminal-lines em { color: #bde5cb; font-style: normal; }
.board { width: 150px; background: #fbfdff; border: 1px solid #aecaf0; border-radius: 7px; padding: 8px; transform: rotate(-6deg); box-shadow: 0 5px 12px #37649725; }
.board-title { display: flex; align-items: center; font-size: 9px; font-weight: 700; color: #243e65; gap: 5px; }
.board-title .lucide { width: 12px; height: 12px; }
.board-columns { display: flex; gap: 4px; margin-top: 6px; }
.board-columns span { flex: 1; background: #e4effd; border-radius: 3px; padding: 4px; }
.board-columns b, .board-columns i { height: 5px; display: block; background: #9cbdf2; border-radius: 2px; margin-bottom: 3px; }
.board-columns i { background: #fff; margin-bottom: 2px; }
.branches { display: flex; gap: 14px; align-items: center; position: relative; transform: rotate(-9deg); }
.branches span { display: grid; place-items: center; z-index: 1; width: 31px; height: 31px; background: #fff5fa; color: #935681; border: 1px solid #cda8c5; border-radius: 7px; }
.branches span:nth-last-child(2) { transform: translateY(-12px); }
.branch-line { position: absolute; left: 15px; right: 14px; border-top: 2px solid #cda8c5; }
.branch-line.side { left: 34px; right: 34px; transform: translateY(-9px); }
.resource-info { padding: 13px 12px 15px; }
.resource-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.resource-meta time, .source { color: var(--muted); font-size: 11px; }
.category-tag { flex: none; display: inline-block; padding: 4px 7px; border-radius: 4px; line-height: 1.25; font-size: 11px; font-weight: 700; }
.lilac { color: #503ac2; background: #efebff; }
.mint { color: #176544; background: #e5f4e9; }
.peach { color: #8f431b; background: #fdf0e7; }
.sky { color: #2559a0; background: #e8f1ff; }
.rose { color: #8b3e70; background: #f7eaf3; }
.resource-info h3 { margin: 8px 0 5px; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: 8px; }
.resource-info p { color: var(--body); line-height: 1.55; font-size: 12px; overflow-wrap: anywhere; }
.empty { border: 1px dashed var(--line); border-radius: 8px; min-height: 215px; display: grid; place-items: center; place-content: center; gap: 12px; color: var(--body); }
.empty > .lucide { width: 27px; height: 27px; color: var(--accent); }
.empty h3 { font-size: 15px; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 23px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

.mobile-nav {
  position: fixed;
  z-index: 4;
  right: 12px;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--glass);
  backdrop-filter: blur(19px) saturate(145%);
  box-shadow: 0 7px 26px #14233a23;
}
.mobile-nav button { min-height: 46px; display: grid; place-items: center; place-content: center; gap: 3px; background: transparent; color: var(--body); border-radius: 8px; font-size: 11px; }
.mobile-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.mobile-nav button[data-action="publish"] { color: var(--accent); }

dialog {
  width: min(100% - 18px, 510px);
  max-height: min(92dvh, 710px);
  padding: 0;
  margin: auto auto max(8px, env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 22px 90px #101b3a43;
}
dialog[open] { animation: dialog-in .28s var(--ease) both; }
dialog::backdrop { background: #121b3b65; backdrop-filter: blur(5px); }
.dialog-content { padding: 16px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.dialog-heading h2 { font-size: 21px; }
.dialog-content .resource-cover { border-radius: 8px; height: 138px; margin-bottom: 15px; }
.detail-photo { display: grid; place-items: center; background: var(--subtle); border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.detail-photo img { display: block; width: 100%; height: min(280px, 38dvh); object-fit: contain; }
.detail-thumbs { display: flex; gap: 7px; padding: 3px 3px 10px; }
.detail-thumbs button { width: 56px; height: 48px; padding: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.detail-thumbs button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.detail-thumbs img { display: block; width: 100%; height: 100%; border-radius: 4px; object-fit: cover; }
#detail-title { font-size: 23px; line-height: 1.3; overflow-wrap: anywhere; }
.detail-summary { margin: 9px 0 11px; color: var(--body); line-height: 1.65; overflow-wrap: anywhere; }
.source { display: flex; align-items: center; flex-wrap: wrap; column-gap: 6px; overflow-wrap: anywhere; }
.source .lucide { width: 14px; height: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.dialog-actions .button { padding: 0 10px; font-size: 12px; }
form { display: grid; gap: 12px; }
form label { display: grid; gap: 6px; color: var(--body); font-size: 13px; font-weight: 650; }
form input, form select, form textarea, .share-link {
  min-height: 44px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-weight: 400;
  font-size: 16px;
}
form textarea { resize: vertical; }
form .dialog-actions { margin-top: 4px; }
.form-error { color: #b52f3c; font-size: 13px; }
#admin-error { margin-top: 10px; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.photo-picker { display: grid; gap: 7px; }
.photo-picker input { font-size: 13px; }
.photo-picker input::file-selector-button { margin-right: 8px; border: 0; border-radius: 4px; padding: 4px 7px; background: var(--accent-soft); color: var(--accent); cursor: pointer; }
.photo-picker-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.photo-picker-actions .button { flex: none; padding-inline: 8px; font-size: 12px; }
.photo-picker-actions .button:disabled { cursor: default; }
.photo-previews { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
.photo-previews figure { flex: 0 0 65px; min-width: 0; margin: 0; }
.photo-previews img { display: block; width: 65px; height: 47px; object-fit: cover; background: var(--subtle); border: 1px solid var(--line); border-radius: 4px; }
.photo-previews figcaption { color: var(--muted); margin-top: 3px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.publish-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-bottom: 14px; }
[data-theme="dark"] .form-error { color: #ff9d9f; }
.share-link { margin-top: 12px; }
.toast {
  position: fixed;
  right: 15px;
  bottom: 75px;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  padding: 10px 15px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--panel);
  font-size: 13px;
  box-shadow: 0 5px 20px #13203729;
  transition: transform .22s var(--ease), opacity .18s;
}
.toast.visible { transform: translateY(0); opacity: 1; }
dialog .toast {
  position: sticky;
  float: right;
  bottom: 6px;
  right: auto;
  margin: -44px 8px 6px 8px;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(18px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (hover: hover) {
  .icon-button:hover, .secondary:hover { background: var(--subtle); color: var(--accent); }
  .primary:hover { background: #423abf; }
  .featured-link:hover { background: #d7f4e9; }
  .category-filters button:not(.active):hover { background: var(--subtle); color: var(--accent); }
  .resource-card:hover { transform: translateY(-2px); border-color: var(--muted); box-shadow: 0 8px 24px #18273c13; }
  .resource-card:hover .cover-art { transform: rotate(0); }
}

@media (min-width: 768px) {
  .main { padding: 29px 24px 25px; }
  .admin-authenticated .main { padding-bottom: 92px; }
  .topbar { padding-inline: 24px; gap: 20px; }
  .header-actions { gap: 12px; }
  .search-box { width: 240px; }
  .featured { min-height: 222px; margin-bottom: 27px; }
  .featured-inner { padding: 24px 29px; }
  .featured h2 { font-size: 31px; }
  .featured p { font-size: 14px; }
  .category-filters { margin-inline: -2px; padding-inline: 2px; }
  .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
  .mobile-nav { width: 320px; margin-inline: auto; }
  dialog { margin: auto; }
  .dialog-content { padding: 22px; }
}

@media (min-width: 1024px) {
  body { display: grid; grid-template-columns: 206px minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 18px 13px 13px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    overflow-y: auto;
  }
  .sidebar .brand { margin: 0 7px 25px; }
  .sidebar .brand-mark { width: 38px; height: 38px; }
  .brand strong { font-size: 21px; }
  .navigation { display: grid; gap: 3px; }
  .nav-label { color: var(--muted); font-size: 11px; font-weight: 700; padding: 0 9px 4px; }
  .category-label { padding-top: 17px; }
  #sidebar-categories { display: grid; gap: 2px; }
  .navigation button, .theme-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 9px;
    border-radius: 7px;
    background: transparent;
    color: var(--body);
    text-align: left;
    font-size: 13px;
  }
  .navigation button.active { background: var(--accent-soft); color: var(--accent); font-weight: 750; }
  .navigation button:not(.active):hover, .theme-button:hover { background: var(--subtle); color: var(--accent); }
  .sidebar-platforms { display: grid; gap: 2px; padding-left: 14px; }
  .sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
  .mobile-brand, .mobile-theme, .mobile-nav { display: none; }
  .breadcrumb { display: inline; color: var(--body); font-size: 13px; font-weight: 650; }
  .button.header-publish { display: inline-flex; white-space: nowrap; }
  .search-box input { font-size: 14px; }
  .topbar { padding-inline: 31px; }
  .main, .admin-authenticated .main { padding: 26px 31px 25px; }
  .intro { margin-bottom: 18px; }
  .intro h1 { font-size: 33px; }
  .featured { min-height: 205px; margin-bottom: 24px; }
  .featured-inner { padding-inline: 26px; }
  .category-filters { gap: 7px; margin-top: 12px; margin-bottom: 13px; }
  .category-filters button { min-height: 37px; padding-inline: 11px; }
  .game-platforms button { min-height: 36px; }
  .resource-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .toast { right: 24px; bottom: 23px; }
}

@media (min-width: 1280px) {
  body { grid-template-columns: 218px minmax(0, 1fr); }
  .topbar { padding-inline: 36px; }
  .main, .admin-authenticated .main { padding-inline: 36px; }
  .resource-cover { height: 132px; }
  .resource-info { padding-inline: 15px; }
  .resource-info h3 { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
