:root {
  --bg: #f7f5f2;
  --panel: #ffffff;
  --text: #241f1a;
  --muted: #6b6259;
  --border: #e6e0d8;
  --accent: #a3491f;
  --accent-soft: #f1e3d8;
  --code: #f0ede8;
  --shadow: 0 1px 2px rgba(30,20,10,0.06), 0 8px 24px rgba(30,20,10,0.06);
  --error: #a04242;
  --sidebar-bg: #12151b;
  --sidebar-ink: #aab0bb;
  --sidebar-ink-hover: #ffffff;
  --sidebar-active-bg: #1d222b;
  --sidebar-border: #262b34;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1613;
    --panel: #231e1a;
    --text: #ece6df;
    --muted: #a89b8c;
    --border: #372f28;
    --accent: #e08a4f;
    --accent-soft: #3a2a1d;
    --code: #2a231d;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.3);
    --error: #d67a7a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}
.wrap { max-width: 780px; margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.inline-form { display: inline; margin: 0; }
.linklike {
  font: inherit; font-size: inherit; color: var(--accent); background: none;
  border: none; cursor: pointer; text-decoration: underline; padding: 0;
}

/* --- app shell / sidebar --- */
.app-shell { display: flex; min-height: 100vh; }
.app-shell-guest { flex-direction: column; }
.sidebar, .guest-header { background: var(--sidebar-bg); color: var(--sidebar-ink); }
.sidebar {
  width: 246px; flex: 0 0 246px; display: flex; flex-direction: column;
  padding: 20px 14px; overflow-y: auto; border-right: 1px solid var(--sidebar-border);
}
.app-main { flex: 1; min-width: 0; }

.sidebar .brand, .guest-header .brand {
  color: #fff; font-weight: 600; text-decoration: none; font-size: 15px;
  letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px;
}
.sidebar .brand { padding: 6px 10px 22px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.brand-mark svg { width: 15px; height: 15px; stroke: #fff; }

.nav-group { margin-bottom: 18px; }
.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: #565d6b; padding: 0 10px 6px;
}
.sidebar-links { display: flex; flex-direction: column; gap: 1px; }
.sidebar-links a, .guest-header nav a {
  display: flex; align-items: center; gap: 10px; color: var(--sidebar-ink);
  text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.sidebar-links a:hover, .guest-header nav a:hover { color: var(--sidebar-ink-hover); }
.sidebar-links svg, .guest-header nav svg { width: 16px; height: 16px; stroke: currentColor; flex: none; }
.sidebar-links a { padding: 7px 10px; border-radius: 7px; position: relative; }
.sidebar-links a:hover { background: var(--sidebar-active-bg); }
.sidebar-links a.active { color: var(--sidebar-ink-hover); background: var(--sidebar-active-bg); }
.sidebar-links a.active::before {
  content: ""; position: absolute; left: -14px; top: 50%;
  transform: translateY(-50%); width: 3px; height: 16px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}

.sidebar-spacer { flex: 1; }
.account-card {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px;
  border-radius: 9px; border: 1px solid var(--sidebar-border);
  background: var(--sidebar-active-bg);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex: none;
}
.account-name {
  font-size: 13px; font-weight: 500; color: #fff; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-card form { margin: 0; }
.logout-btn {
  width: 26px; height: 26px; border-radius: 6px; border: none; background: transparent;
  color: var(--sidebar-ink); display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex: none; padding: 0;
}
.logout-btn svg { width: 15px; height: 15px; stroke: currentColor; }
.logout-btn:hover { background: #2a2f39; color: #fff; }

.guest-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; }
.guest-header nav { display: flex; }

@media (max-width: 640px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: auto; flex: none; flex-direction: row; align-items: center;
    overflow-x: auto; overflow-y: visible; padding: 10px 12px; gap: 4px;
    border-right: none; border-bottom: 1px solid var(--sidebar-border);
  }
  .sidebar .brand { padding: 0 6px 0 0; margin-right: 4px; }
  .sidebar .brand span:last-child { display: none; }
  .brand-mark { width: 22px; height: 22px; border-radius: 5px; }
  .brand-mark svg { width: 12px; height: 12px; }
  .nav-group { margin-bottom: 0; }
  .nav-label { display: none; }
  .sidebar-links { flex-direction: row; gap: 2px; }
  .sidebar-links a { padding: 7px; }
  .sidebar-links a span { display: none; }
  .sidebar-links a.active::before {
    left: 50%; top: auto; bottom: -2px; transform: translateX(-50%);
    width: 16px; height: 3px; border-radius: 3px 3px 0 0;
  }
  .sidebar-spacer { flex: 0 0 8px; }
  .account-name { display: none; }
  .wrap { padding: 1.5rem 1rem 3rem; }
}

.crumb { font-size: 0.9rem; color: var(--muted); margin-bottom: 1.5rem; }
.crumb a { color: var(--muted); }
.source-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  margin-bottom: 0.9rem;
}
h1 { font-size: 1.9rem; margin: 0 0 0.4rem; line-height: 1.2; }
.tagline { color: var(--muted); font-size: 1.02rem; margin: 0 0 0.6rem; max-width: 60ch; }
.caveat {
  font-size: 0.88rem;
  color: var(--muted);
  font-style: italic;
  margin: 0 0 0.6rem;
}
.hero {
  margin: 0 0 1.4rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--panel);
}
.hero img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
}
.hero .credit {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--border);
}
.hero .credit a { color: var(--muted); text-decoration: underline; }
.no-photo {
  margin: 0 0 1.4rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 1.4rem;
  text-align: center;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--muted);
}
.readiness {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.6rem;
}
.readiness .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
}
.readiness select {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 1.8rem 0.35rem 0.9rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) center, calc(100% - 9px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.readiness select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.readiness select:disabled { cursor: default; opacity: 0.85; }
.owner-line { font-size: 0.85rem; color: var(--muted); margin: 0 0 1.6rem; }
.fork-note { font-size: 0.85rem; color: var(--muted); margin: -1rem 0 1.6rem; }
.linkrow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 2.2rem;
}
.linkrow .btn {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.linkrow .btn.disabled {
  color: var(--muted);
  font-style: italic;
  box-shadow: none;
}
.linkrow .btn:hover { text-decoration: none; border-color: var(--accent); }
section { margin-bottom: 2.2rem; }
h2 {
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin: 0 0 0.9rem;
}
ul.checklist { list-style: none; margin: 0; padding: 0; }
ul.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--border);
}
ul.checklist li:last-child { border-bottom: none; }
ul.checklist input[type=checkbox] {
  margin-top: 0.28rem;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: none;
}
ol.steps { margin: 0; padding-left: 1.3rem; }
ol.steps li { padding: 0.35rem 0; }
ol.steps b { color: var(--text); }
.notecard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
  font-size: 0.94rem;
  color: var(--muted);
}
footer.pagefoot {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

/* --- index / catalog --- */
.groups { display: flex; flex-direction: column; gap: 2.4rem; }
.group h2 { border: none; text-transform: none; letter-spacing: normal; font-size: 1.2rem; color: var(--text); padding-bottom: 0; margin-bottom: 0.9rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.9rem; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card.is-hidden { display: none; }
.card-link { display: block; }
.card .thumb {
  display: block;
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: var(--accent-soft);
}
.card .thumb.placeholder { background: var(--accent-soft); }
.card .name, .card .badges { padding-left: 1.1rem; padding-right: 1.1rem; }
.card .name { display: block; margin-top: 0.8rem; }
.card .badges { padding-bottom: 0.8rem; margin-top: 0.3rem; }
.card-link:hover { text-decoration: none; }
.card-link:hover .name { color: var(--accent); }
.card .name { font-weight: 600; color: var(--text); display: block; margin-bottom: 0.3rem; }
.card .user-card-name { display: flex; align-items: center; gap: 0.5rem; }
.card .badges { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.card .badge {
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.card .badge.dim { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.card-readiness {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--border);
}
.card-readiness .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.card-readiness select {
  font: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  flex: 1;
}
.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 1.1rem 0.7rem;
  font-size: 0.74rem;
  color: var(--muted);
}
.controlbar {
  display: flex;
  align-items: center;
  gap: 0.6rem 1.4rem;
  margin: 0 0 1.8rem;
  flex-wrap: wrap;
}
.controlbar .control { display: flex; align-items: center; gap: 0.6rem; }
.controlbar form.control { margin: 0; }
.controlbar label { font-size: 0.88rem; color: var(--muted); }
.controlbar select {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 1.8rem 0.35rem 0.9rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) center, calc(100% - 9px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.flat-cards { display: none; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.9rem; margin: 0 0 2.4rem; }
.group.is-hidden { display: none; }
p.intro { color: var(--muted); max-width: 62ch; }

/* --- forms --- */
.loginform, .projectform { display: flex; flex-direction: column; gap: 1rem; max-width: 480px; }
.loginform label, .projectform label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.loginform input, .projectform input, .projectform textarea {
  font: inherit; font-size: 0.95rem; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.7rem;
}
.projectform textarea { min-height: 5rem; resize: vertical; }
.btn.primary {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 8px; padding: 0.55rem 1.1rem; font-size: 0.95rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem; width: fit-content;
}
.btn.primary:hover { text-decoration: none; opacity: 0.92; }
.form-error { color: var(--error); font-size: 0.9rem; margin: 0 0 1rem; padding-left: 1.1rem; }
.save-error { color: var(--error); font-size: 0.78rem; font-style: italic; margin-left: 0.6rem; }
.projectform label .hint { display: block; font-size: 0.78rem; font-style: italic; color: var(--muted); font-weight: normal; }
.photo-upload-form { display: block; margin-top: 1.4rem; }
.photo-upload-form label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.3rem; }
.photo-upload-form input[type=file] { margin-right: 0.6rem; }
.projectform textarea { font-family: inherit; }

.tokenvalue {
  background: var(--code); border-radius: 6px; padding: 0.6rem 0.8rem;
  font-size: 0.85rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
.tokentable { width: 100%; border-collapse: collapse; margin: 1.6rem 0; font-size: 0.9rem; }
.tokentable th, .tokentable td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); }
.tokentable th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
