@font-face {
  font-family: "kkyyyllll Mark";
  src: url("/static/fonts/big-shoulders-mark.woff") format("woff");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono-regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono-medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #12110e;
  --ink-2: #2a2722;
  --paper: #e8dcc8;
  --paper-2: #f1e7d4;
  --rule: #12110e;
  --muted: #6d675c;
  --red: #d31c0d;
  --red-deep: #a81409;
  --pad: max(20px, env(safe-area-inset-left));
  --font-mark: "kkyyyllll Mark", "Big Shoulders Display", Impact, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --font-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: "Noto Sans CJK SC", "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  min-height: 100%;
  background: var(--ink);
  color: var(--ink);
  font: 16px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100dvh; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--red); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* 2-3-4 identity bars */
.mark-234 {
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  width: 22px;
  height: 16px;
  flex-shrink: 0;
}
.mark-234 i {
  display: block;
  height: 3px;
  background: currentColor;
}
.mark-234 i:nth-child(1) { width: 40%; }
.mark-234 i:nth-child(2) { width: 70%; }
.mark-234 i:nth-child(3) { width: 100%; }

/* ---------- Login: split poster + desk ---------- */
.login-grid {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}

.poster {
  background: var(--ink);
  color: var(--paper);
  padding: 28px var(--pad) 36px;
  padding-top: max(28px, env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  min-height: 40dvh;
  position: relative;
  overflow: hidden;
}
.poster-top {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--paper);
}
.poster .mark-234 { color: var(--red); }
.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper);
}
.lockup {
  font-family: var(--font-mark);
  font-weight: 800;
  font-style: normal;
  line-height: 0.86;
  letter-spacing: -0.04em;
  font-size: clamp(4.6rem, 26vw, 8.2rem);
  margin-top: 28px;
  text-transform: lowercase;
  color: var(--paper);
}
.lockup span { display: block; }
.poster-note {
  margin-top: auto;
  padding-top: 28px;
  font-family: var(--font-serif);
  font-size: 15px;
  color: #cfc4af;
  max-width: 16em;
}

.desk {
  background: var(--paper);
  color: var(--ink);
  padding: 36px var(--pad) 40px;
  padding-bottom: max(40px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 54dvh;
}
.desk-index,
.page-head .desk-index {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--red);
  margin-bottom: 10px;
}
.desk-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 28px;
  line-height: 1.15;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  flex: 0 0 auto;
}
.login-form label,
.dialog-card label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
}
.login-form input,
.dialog-card input {
  appearance: none;
  width: 100%;
  height: 48px;
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  padding: 8px 0;
  font-size: 18px;
  font-family: var(--font-mono);
  outline: none;
}
.login-form input:focus,
.dialog-card input:focus {
  border-bottom-color: var(--red);
}
.login-form button[type="submit"] {
  appearance: none;
  margin-top: 18px;
  align-self: stretch;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 0;
  padding: 14px 18px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
}
.login-form button[type="submit"]:hover { background: var(--red); }
.err {
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 12px;
  min-height: 1.2em;
}
.desk-drop {
  display: inline-block;
  margin-top: 28px;
  font-family: var(--font-serif);
  font-size: 16px;
  border-bottom: 1px solid var(--ink);
  width: max-content;
}
.desk-drop:hover { color: var(--red); border-bottom-color: var(--red); }
.desk-foot {
  margin-top: auto;
  padding-top: 36px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

@media (min-width: 900px) {
  .login-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
    min-height: 100dvh;
  }
  .poster, .desk { min-height: 100dvh; }
  .poster { padding: 40px 48px 48px; }
  .lockup { font-size: clamp(7rem, 13.5vw, 13rem); margin-top: auto; line-height: 0.86; }
  .desk { padding: 56px 56px 48px; }
  .desk-title { font-size: 40px; margin-bottom: 40px; }
  .login-form button[type="submit"] { align-self: start; min-width: 200px; }
}

/* ---------- App chrome ---------- */
.mast {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  background: var(--ink);
  color: var(--paper);
  padding: 18px var(--pad) 16px;
  padding-top: max(18px, env(safe-area-inset-top));
  border-bottom: 6px solid var(--red);
  position: sticky;
  top: 0;
  z-index: 8;
}
.mast-brand {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  color: var(--paper);
  min-width: 0;
}
.mast-brand:hover { color: var(--paper); }
.mast-brand .mark-234 { color: var(--red); width: 18px; height: 14px; margin-bottom: 6px; }
.mast-word {
  font-family: var(--font-mark);
  font-weight: 800;
  font-size: clamp(28px, 8vw, 44px);
  line-height: 0.8;
  letter-spacing: -0.015em;
}
.mast-sec {
  font-family: var(--font-serif);
  font-size: 16px;
  letter-spacing: 0.08em;
  padding-bottom: 1px;
  color: #cfc4af;
}
.mast-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  padding-bottom: 2px;
}
.mast-nav a, .text-btn {
  color: var(--paper);
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  padding: 6px 0;
}
.mast-nav a:hover, .text-btn:hover { color: var(--red); }

.sheet {
  background: var(--paper);
  color: var(--ink);
  min-height: calc(100dvh - 72px);
  padding: 22px var(--pad) 96px;
  padding-bottom: max(96px, calc(env(safe-area-inset-bottom) + 64px));
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 16px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--ink);
  margin-bottom: 0;
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 2px;
  font-family: var(--font-mono);
  font-size: 13px;
  min-width: 0;
}
.crumbs a { color: var(--ink); border-bottom: 1px solid transparent; }
.crumbs a:hover { color: var(--red); border-bottom-color: var(--red); }
.crumbs .here { font-weight: 500; }
.crumbs .sep { color: var(--muted); padding: 0 6px; }

.actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  padding: 10px 16px;
  font: 600 13px/1 var(--font-sans);
  letter-spacing: 0.08em;
  cursor: pointer;
  border: 2px solid var(--ink);
  min-height: 42px;
  background: transparent;
  color: var(--ink);
}
.btn.line:hover { background: var(--ink); color: var(--paper); }
.btn.red {
  background: var(--red);
  border-color: var(--red);
  color: #fff8ee;
}
.btn.red:hover { background: var(--red-deep); border-color: var(--red-deep); }
.btn.danger { color: var(--red); border-color: var(--red); }

.prog {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 4px;
  height: 22px;
}
.prog i {
  flex: 1;
  display: block;
  height: 4px;
  background: #cfc3ad;
  position: relative;
  overflow: hidden;
}
.prog i::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--p, 0%);
  background: var(--red);
  transition: width .18s ease;
}
.prog span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* Catalog / ledger */
.catalog { width: 100%; }
.catalog-head {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  gap: 10px;
  padding: 10px 0 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--ink);
}
.catalog-head .c-kind,
.catalog-head .c-meta,
.catalog-head .c-acts { display: none; }

.row {
  display: grid;
  grid-template-columns: 2.4rem auto 1fr;
  grid-template-areas:
    "idx ico name"
    "idx ico sub"
    ".   .   acts";
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 16px 0 14px;
  border-bottom: 1px solid #c9bba3;
}
.row .idx {
  grid-area: idx;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  align-self: start;
  padding-top: 6px;
}
.row .ico {
  grid-area: ico;
  width: 22px;
  height: 22px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.row .ico svg { width: 20px; height: 20px; display: block; }
.row .name {
  grid-area: name;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
  line-height: 1.25;
}
.row .name:hover { color: var(--red); }
.row .name.static { cursor: default; font-family: var(--font-serif); }
.row .name.static:hover { color: var(--ink); }
.row .meta, .row .kind {
  display: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.row .sub {
  grid-area: sub;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.row .acts {
  grid-area: acts;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
}
.row .acts button,
.row .acts a,
.row .acts .status {
  color: var(--ink);
  background: none;
  border: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: none;
  letter-spacing: 0.04em;
}
.row .acts button:hover,
.row .acts a:hover { color: var(--red); }
.row .acts .danger:hover { color: var(--red); }
.status.ok { color: var(--ink); cursor: default; }
.status.bad { color: var(--red); cursor: default; }

.empty {
  padding: 48px 0 24px;
  font-family: var(--font-serif);
  font-size: 22px;
}

/* Drop page */
.drop-sheet { padding-top: 28px; }
.page-head { max-width: 36rem; margin-bottom: 28px; }
.page-title {
  font-family: var(--font-serif);
  font-size: clamp(40px, 12vw, 72px);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  margin: 0 0 16px;
}
.lead {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink-2);
}

.dock {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  min-height: 240px;
  padding: 28px 24px;
  border: 3px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 5px;
  background: var(--paper-2);
  cursor: pointer;
  margin-bottom: 8px;
}
.dock:hover,
.dock.on {
  border-color: var(--red);
  outline-color: var(--red);
  background: #f6ebe0;
}
.dock-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--red);
}
.dock-title {
  font-family: var(--font-serif);
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.dock-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: clamp(28px, 6vw, 48px);
  letter-spacing: 0.08em;
  border: 8px solid var(--red);
  pointer-events: none;
}

.dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(18, 17, 14, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.dialog-card {
  width: 100%;
  background: var(--paper);
  padding: 28px 22px 24px;
  border-top: 6px solid var(--red);
}
.dialog-card h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 14px;
}
.dialog-msg {
  font-size: 15px;
  margin-bottom: 16px;
  line-height: 1.7;
}
.dialog-card input { margin-bottom: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--ink);
  color: var(--paper);
  padding: 14px 20px max(14px, env(safe-area-inset-bottom));
  font-family: var(--font-mono);
  font-size: 13px;
}

@media (min-width: 800px) {
  .mast { padding: 22px 40px 18px; }
  .sheet { padding: 28px 40px 80px; }
  .catalog-head {
    grid-template-columns: 3rem 1fr 6.5rem 8.5rem auto;
  }
  .catalog-head .c-kind,
  .catalog-head .c-meta,
  .catalog-head .c-acts { display: block; }
  .row {
    grid-template-columns: 3rem auto 1fr 6.5rem 8.5rem auto;
    grid-template-areas: "idx ico name kind meta acts";
    align-items: center;
    padding: 18px 0;
  }
  .row .kind, .row .meta { display: block; }
  .row .sub { display: none; }
  .row .acts { margin-top: 0; justify-content: flex-end; }
  .row .name { font-size: 20px; }
  .dialog {
    align-items: center;
    padding: 32px;
  }
  .dialog-card {
    width: min(440px, 100%);
    border: 2px solid var(--ink);
    border-top-width: 8px;
    padding: 28px 28px 22px;
  }
  .dock { min-height: 320px; padding: 36px; }
  .actions .btn { min-width: 120px; }
}

@media (max-width: 799px) {
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
  .mast-sec { display: none; }
}
