:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d1d1b; --muted: #6d6a63; --line: #e4e1d8;
  --accent: #2f5d50; --accent-soft: #e3ece8; --danger: #a8402f; --danger-soft: #f6e4df;
  --warn-soft: #f7eed6; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151614; --panel: #1e201d; --ink: #ecebe6; --muted: #9c9a92; --line: #2f322d;
    --accent: #7fb8a4; --accent-soft: #23342e; --danger: #e08a78; --danger-soft: #3a2420;
    --warn-soft: #3a3322; --shadow: none; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code, pre { font-family: var(--mono); font-size: .85rem; }

/* layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 1.5rem 1rem;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: .25rem; }
.brand { font-weight: 700; font-size: 1.05rem; padding: 0 .75rem 1.25rem; }
.brand span { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }
.side a.nav { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem;
  border-radius: 8px; color: var(--ink); }
.side a.nav:hover { background: var(--bg); text-decoration: none; }
.side a.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .grow { flex: 1; }
.main { padding: 2rem clamp(1rem, 4vw, 3rem); max-width: 1200px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.5rem; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: .75rem;
    border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: .3rem .75rem; width: 100%; }
  .side .grow { display: none; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.cols { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.5rem; }
.stat .n { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .85rem; }
.project { display: flex; flex-direction: column; gap: .5rem; color: var(--ink); }
.project:hover { border-color: var(--accent); text-decoration: none; }
.project .t { font-weight: 600; font-size: 1.05rem; color: var(--accent); }
.meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .8rem; color: var(--muted); }
.tag { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); }
.tag.grey { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--panel); font: inherit;
  font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: .25rem .6rem; font-size: .85rem; font-weight: 500; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > input, .row > select { width: auto; flex: 1; min-width: 140px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); font-size: .85rem; }
.ico { width: 34px; height: 34px; flex: none; border-radius: 8px; display: grid; place-items: center;
  font-size: .62rem; font-weight: 700; text-transform: uppercase; background: var(--bg);
  color: var(--muted); border: 1px solid var(--line); }
.ico.pdf { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.ico.img, .ico.book { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ico.sheet { background: var(--warn-soft); color: #8a6a1c; border-color: transparent; }
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--accent-soft); color: var(--accent); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.crumbs { font-family: var(--mono); font-size: .85rem; margin-bottom: 1rem; }
.readme { line-height: 1.65; }
.readme pre, pre.file { background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 1rem; overflow-x: auto; margin: 0; }
.readme img { max-width: 100%; }
.pills { display: flex; gap: .4rem; flex-wrap: wrap; }
.pills a { padding: .3rem .75rem; border-radius: 99px; border: 1px solid var(--line); color: var(--ink);
  font-size: .85rem; background: var(--panel); }
.pills a.on { background: var(--accent); color: var(--panel); border-color: var(--accent); }
.pills a:hover { text-decoration: none; border-color: var(--accent); }

/* upload */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 2rem; text-align: center;
  background: var(--panel); transition: .15s; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { color: var(--accent); }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 1rem; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
details.edit summary { cursor: pointer; list-style: none; }
details.edit[open] { background: var(--bg); padding: .75rem; border-radius: 8px; }

/* library */
.book { display: flex; flex-direction: column; gap: .45rem; }
.book .t { font-weight: 600; color: var(--ink); font-size: 1rem; }
.book .star { background: none; border: 0; cursor: pointer; font-size: 1.15rem; color: var(--muted); padding: 0; }
.book .star.on { color: #c89b2b; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: 100%; max-width: 360px; }
