*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0f1115;
  --bg2: #161922;
  --panel: #1a1e28;
  --line: #2a2f3c;
  --text: #dde0e6;
  --muted: #858c9c;
  --accent: #8bd5ca;
  --accent-ink: #0f1115;
  --star: #eed49f;
  --danger: #ed8796;
  --code-bg: #0c0e13;
  --radius: 10px;
  --mono: ui-monospace, "JetBrains Mono", "Fira Code", "Cascadia Code", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f5f1;
    --bg2: #eeece6;
    --panel: #ffffff;
    --line: #dedbd2;
    --text: #1d1f24;
    --muted: #686c75;
    --accent: #1b7a6e;
    --accent-ink: #ffffff;
    --star: #a86b12;
    --danger: #b83a3a;
    --code-bg: #fbfaf7;
    color-scheme: light;
  }
}

html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
code, pre { font-family: var(--mono); }
h1, h2, h3 { font-family: var(--mono); font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; margin: 0; }
[hidden] { display: none !important; }
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 20px; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 20px; min-height: 60px; }
.logo { font: 700 18px var(--mono); color: var(--text); white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo .tilde { color: var(--accent); }
.cursor { color: var(--star); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }
.search { flex: 1; max-width: 420px; }
.nav { display: flex; align-items: center; gap: 16px; margin-left: auto; font: 14px var(--mono); }
.nav a:not(.btn), .nav .linkbtn { color: var(--muted); }
.nav a:not(.btn):hover, .nav .linkbtn:hover { color: var(--text); text-decoration: none; }
@media (max-width: 720px) {
  .top-in { flex-wrap: wrap; gap: 10px 14px; padding-block: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .nav { gap: 12px; }
  .hide-sm { display: none; }
}

/* form controls */
input, textarea, select { font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=file] { padding: 8px; background: transparent; border-style: dashed; }
textarea { font-family: var(--mono); font-size: 13px; line-height: 1.5; resize: vertical; tab-size: 4; }
label { display: block; font: 600 13px var(--mono); color: var(--muted); }
label > input, label > textarea { margin-top: 6px; font-weight: 400; }
label small, .hint { display: block; font: 400 12px var(--sans); color: var(--muted); margin: 4px 0 0; }
.hint code { color: var(--text); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; font: 600 13px var(--mono); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { border-color: var(--muted); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-lg { padding: 11px 20px; font-size: 14px; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
.linkbtn:hover { color: var(--text); }
.linkbtn.danger:hover { color: var(--danger); }
form.inline { display: inline; }
.star.on { color: var(--star); border-color: color-mix(in srgb, var(--star) 55%, var(--line)); }
.star.static { cursor: default; }
.star.static:hover { border-color: var(--line); }

.flash { margin: 18px 0 0; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 8px; font: 14px var(--mono); }

/* home */
.hero { padding: 56px 0 24px; max-width: 760px; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); }
.hero p { color: var(--muted); font-size: 17px; margin: 16px 0 24px; max-width: 600px; }
.hero .btn { margin-right: 6px; }

.filters { padding: 24px 0 4px; display: grid; gap: 12px; }
.sorts { display: flex; gap: 4px; font: 14px var(--mono); border-bottom: 1px solid var(--line); overflow-x: auto; }
.sorts a { color: var(--muted); padding: 8px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.sorts a:hover { color: var(--text); text-decoration: none; }
.sorts a.on { color: var(--text); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips-label { font: 600 12px var(--mono); color: var(--muted); width: 40px; }
.chip { display: inline-flex; gap: 6px; align-items: center; font: 13px var(--mono); color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.chip small { color: var(--muted); font-size: 11px; }
.chip:hover { text-decoration: none; border-color: var(--muted); }
.chip.on { border-color: var(--accent); color: var(--accent); }
.active-filters { margin: 0; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 20px; padding: 18px 0 32px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform 0.15s, border-color 0.15s; }
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
@media (prefers-reduced-motion: reduce) { .card, .card:hover { transition: none; transform: none; } }
.card-shot { display: block; aspect-ratio: 16 / 10; background: var(--bg2); overflow: hidden; }
.card-shot img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.card-body { padding: 12px 14px 14px; }
.card h3 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card h3 a { color: var(--text); }
.meta { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.meta a { color: var(--muted); }
.meta a:hover { color: var(--accent); }
.stats { display: flex; gap: 14px; margin: 10px 0 0; font: 12px var(--mono); color: var(--muted); }
.stats .stars { color: var(--star); }

.empty { padding: 60px 0; text-align: center; color: var(--muted); }
.prompt { font-family: var(--mono); color: var(--accent); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 40px; font: 14px var(--mono); }

/* rice page */
.rice { padding: 28px 0 48px; }
.rice > .flash { margin: 0 0 18px; }
.rice-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.rice-head h1 { font-size: clamp(24px, 3.5vw, 34px); overflow-wrap: anywhere; }
.rice-actions { display: flex; gap: 8px; align-items: center; }
.rice-top { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .rice-top { grid-template-columns: 1fr; } }
.gallery-main { display: block; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg2); }
.gallery-main img { width: 100%; height: auto; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
.thumbs a { flex: 0 0 110px; aspect-ratio: 16 / 10; border: 2px solid transparent; border-radius: 6px; overflow: hidden; opacity: 0.6; }
.thumbs a.active, .thumbs a:hover { border-color: var(--accent); opacity: 1; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.specs { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 18px; }
.specs dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: 14px; }
.specs dt { font: 12px var(--mono); color: var(--muted); padding-top: 2px; }
.specs dd { margin: 0; overflow-wrap: anywhere; }
.specs h3 { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 28px; height: 28px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--text) 18%, transparent); cursor: pointer; padding: 0; transition: transform 0.1s; }
.sw:hover { transform: scale(1.12); }
.sw.copied { outline: 2px solid var(--accent); outline-offset: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.repo { margin: 0; font: 13px var(--mono); overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; font-size: 14px; border-top: 1px solid var(--line); padding-top: 14px; overflow-wrap: anywhere; }

.dots { margin-top: 40px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2, .comments h2 { font-size: 20px; }
.count { font: 600 12px var(--mono); color: var(--muted); background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; vertical-align: middle; margin-left: 6px; }
.install { display: flex; align-items: center; gap: 10px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 6px 6px 14px; margin-bottom: 14px; }
.install code { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow-x: auto; color: var(--muted); padding-block: 4px; }
.install code::before { content: "$ "; color: var(--accent); }

.dots-body { display: grid; grid-template-columns: 280px minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); min-height: 420px; }
.tree { border-right: 1px solid var(--line); overflow: auto; max-height: 640px; padding: 6px 0; font: 13px var(--mono); }
.tree a { display: flex; padding: 5px 14px; color: var(--text); white-space: nowrap; border-left: 2px solid transparent; }
.tree a:hover { background: var(--bg2); text-decoration: none; }
.tree a.active { background: var(--bg2); border-left-color: var(--accent); }
.tree .dir { color: var(--muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tree b { font-weight: 600; flex-shrink: 0; }
.viewer { display: flex; flex-direction: column; min-width: 0; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); font: 13px var(--mono); }
.viewer-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.viewer-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.code { margin: 0; padding: 12px 0; background: var(--code-bg); overflow: auto; max-height: 640px; flex: 1; font-size: 13px; line-height: 1.55; tab-size: 4; }
.code code { counter-reset: l; display: block; min-width: max-content; }
.l { counter-increment: l; padding-right: 16px; }
.l::before { content: counter(l); display: inline-block; width: 3.2em; padding-right: 1.2em; text-align: right; color: var(--muted); opacity: 0.55; user-select: none; }
@media (max-width: 800px) {
  .dots-body { grid-template-columns: 1fr; }
  .tree { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--line); }
  .viewer-size { display: none; }
}

.comments { margin-top: 44px; max-width: 760px; }
.comment { padding: 14px 0; border-bottom: 1px solid var(--line); }
.comment-body { white-space: pre-wrap; margin-top: 6px; overflow-wrap: anywhere; }
.op { font: 700 10px var(--mono); color: var(--accent-ink); background: var(--accent); border-radius: 4px; padding: 1px 5px; text-transform: uppercase; }
.comment-form { display: grid; gap: 10px; margin-top: 16px; justify-items: start; }
.comment-form textarea { font: 14px/1.5 var(--sans); }

/* forms */
.form-page { max-width: 880px; padding: 32px 0 60px; }
.form-page h1 { font-size: 28px; margin-bottom: 20px; overflow-wrap: anywhere; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 20px; margin: 0 0 20px; display: grid; gap: 16px; min-width: 0; }
legend { font: 700 15px var(--mono); padding: 0 8px; color: var(--text); }
legend span:first-child { color: var(--accent); margin-right: 4px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 14px; }
.errors { border: 1px solid var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 14px; }
.errors ul { margin: 6px 0 4px; padding-left: 20px; }
.errors small { color: var(--muted); }
.form-error { color: var(--danger); font-size: 14px; margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-label { display: flex; align-items: center; gap: 8px; }
.inline-label input { margin: 0; width: 170px; font: 13px var(--mono); padding: 7px 10px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
#entries { display: grid; gap: 12px; }
.entry { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg2); }
.entry-head { display: flex; gap: 8px; align-items: center; padding: 4px 12px 4px 4px; border-bottom: 1px solid var(--line); }
.entry-head input { border: 0; background: transparent; font: 600 13px var(--mono); padding: 6px 8px; }
.entry textarea { border: 0; border-radius: 0; background: var(--code-bg); display: block; min-height: 110px; }
.archive summary { cursor: pointer; font: 600 13px var(--mono); color: var(--muted); }
.archive-in { display: grid; gap: 12px; margin-top: 12px; }
.check { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 10px; }
.check input { margin: 0; }
.shot-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.shot-item img { aspect-ratio: 16 / 10; object-fit: cover; width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.shot-item span { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-weight: 400; }
.shot-item:has(input:checked) img { opacity: 0.35; outline: 2px solid var(--danger); }
.shot-preview { display: flex; gap: 8px; flex-wrap: wrap; }
.shot-preview:empty { display: none; }
.shot-preview img { height: 84px; width: auto; border-radius: 6px; border: 1px solid var(--line); }
.submit-row { display: flex; align-items: center; gap: 16px; }

.auth { max-width: 400px; margin: 56px auto; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 16px; }
.auth h1 { font-size: 22px; }
.auth form { display: grid; gap: 14px; }
.auth .alt { font-size: 14px; color: var(--muted); margin: 0; }
.settings { max-width: 560px; padding: 32px 0 60px; display: grid; gap: 4px; }
.settings h1 { font-size: 28px; margin-bottom: 16px; }

.profile { display: flex; gap: 20px; align-items: center; padding: 36px 0 4px; flex-wrap: wrap; }
.avatar { width: 72px; height: 72px; border-radius: 16px; display: grid; place-items: center; font: 700 32px var(--mono); color: #111; background: hsl(var(--h) 55% 72%); }
.profile h1 { font-size: 26px; }
.profile .bio { margin: 6px 0 0; white-space: pre-wrap; max-width: 600px; }
.profile-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font: 13px var(--mono); color: var(--muted); }
.profile-stats b { color: var(--text); }
.edit-profile { margin-left: auto; }

.error-page { padding: 80px 0; text-align: center; }
.error-page h1 { font-size: 80px; color: var(--accent); }
.error-page .prompt { overflow-wrap: anywhere; }

.foot { border-top: 1px solid var(--line); padding-block: 24px 40px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 24px; }
