:root {
  --bg: #ffffff;          /* pure white */
  --card: #ffffff;
  --ink: #000000;         /* black */
  --muted: #666666;       /* neutral gray for secondary text */
  --line: #dddddd;        /* neutral light divider */
  --accent: #000000;
  --canvas-bg: #ffffff;
  --hand: Georgia, "Times New Roman", Times, serif;  /* clean NYT-style reading serif */
  --maxw: 600px;
  /* a wonky, hand-drawn rounded-rectangle radius */
  --doodle: 16px 10px 18px 11px / 11px 18px 10px 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--hand);
  font-size: 16px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: 16px; }

/* ---------- header ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
}
.logo svg { display: block; }
.logo img { height: 40px; width: auto; display: block; }
.logo span { display: inline-block; }
.nav { display: flex; align-items: center; gap: 14px; }
.nav .who { color: var(--muted); font-size: 13px; }

.btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn.small { padding: 5px 11px; font-size: 12px; }
.newbtn { background: none; border: none; padding: 0 2px; cursor: pointer; display: inline-flex; align-items: center; }
.newbtn img { height: 42px; width: auto; display: block; }
.newbtn:hover { opacity: 0.6; }
.btn:disabled { opacity: 0.45; cursor: default; }
.linkish {
  background: none; border: none; color: var(--muted);
  font-size: 13px; padding: 0;
}
.linkish:hover { color: var(--ink); }

/* ---------- layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 20px 16px 80px; }
.view { display: none; }
.view.active { display: block; }

/* ---------- feed cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 22px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 12px 16px 10px;
}
.card-head .user { font-weight: 600; }
.card-head .time { color: var(--muted); font-size: 12px; }
.card-canvas-wrap {
  background: var(--canvas-bg);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: center;
}
.card-canvas-wrap canvas { width: 100%; height: auto; display: block; touch-action: pan-y; }
.card-caption { padding: 12px 16px 4px; }
.card-foot { padding: 4px 16px 14px; display: flex; align-items: center; gap: 16px; }
.gif-btn { background: none; border: none; color: var(--muted); font-size: 13px; padding: 6px 0; cursor: pointer; }
.gif-btn:hover { color: var(--ink); }
.gif-btn:disabled { opacity: 0.6; cursor: default; }
.del-btn { margin-left: auto; }
.toggle-comments {
  background: none; border: none; color: var(--muted);
  font-size: 13px; padding: 6px 0;
}
.toggle-comments:hover { color: var(--ink); }

/* ---------- comments ---------- */
.comments { border-top: 1px solid var(--line); padding: 10px 16px 14px; display: none; }
.comments.open { display: block; }
.comment { padding: 6px 0; font-size: 14px; }
.comment .u { font-weight: 600; margin-right: 6px; }
.comment .t { color: var(--muted); font-size: 11px; margin-left: 6px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input {
  flex: 1; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; background: var(--bg);
}
.comment-empty { color: var(--muted); font-size: 13px; padding: 4px 0; }

/* ---------- composer ---------- */
.composer h2, .auth h2 { font-size: 18px; margin: 4px 0 16px; }
.draw-stage {
  background: var(--canvas-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 14px;
}
#padCanvas { width: 100%; height: auto; display: block; touch-action: none; cursor: crosshair; }
.tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.swatches { display: flex; gap: 7px; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
  padding: 0; cursor: pointer;
}
.swatch.active { box-shadow: 0 0 0 2px var(--ink); transform: scale(1.08); }
.tool-group { display: flex; align-items: center; gap: 8px; }
.tool-group label { font-size: 12px; color: var(--muted); }
input[type=range] { accent-color: var(--ink); }
.composer-actions { display: flex; gap: 10px; align-items: center; }
.caption-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 14px; background: var(--bg);
}
.preview-note { font-size: 12px; color: var(--muted); margin-left: auto; }

/* ---------- auth ---------- */
.auth { max-width: 340px; margin: 30px auto; }
.auth input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; margin-bottom: 11px; background: var(--card);
}
.auth .btn { width: 100%; padding: 11px; font-size: 14px; }
.auth .switch { text-align: center; margin-top: 14px; color: var(--muted); font-size: 13px; }
.auth .switch button { color: var(--ink); font-weight: 600; }

.msg { font-size: 13px; padding: 8px 0; min-height: 18px; }
.msg.err { color: #c0392b; }
.msg.ok { color: #2e7d32; }

.empty-feed { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty-feed .big { font-size: 17px; color: var(--ink); margin-bottom: 8px; }

footer.tiny { text-align: center; color: var(--muted); font-size: 12px; padding: 30px 0 10px; }
footer.tiny a { color: var(--ink); text-decoration: underline; }

/* ---------- tagline ---------- */
.logo .tag {
  font-weight: 400; font-size: 12px; color: var(--muted);
  letter-spacing: 0; margin-left: 6px;
}
@media (max-width: 460px) { .logo .tag { display: none; } }

/* ---------- feed tabs ---------- */
.tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.tab {
  background: none; border: none; padding: 9px 14px;
  font-size: 14px; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab { padding: 8px 18px; }
.tab svg { width: 27px; height: 27px; display: block; }
.tab.active svg { transform: scale(1.04); }

/* ---------- card book label ---------- */
.card-head .in-book { color: var(--muted); font-size: 12px; }
.card-head .in-book b { color: var(--ink); font-weight: 600; cursor: pointer; }
.card-head .in-book b:hover { text-decoration: underline; }
.card-head .user { cursor: pointer; }
.card-head .user:hover { text-decoration: underline; }

/* ---------- composer: sketchbook picker ---------- */
.book-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.book-row label { font-size: 13px; color: var(--muted); }
.book-row select {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  background: var(--card); font-size: 14px; max-width: 220px;
}
.newbook { display: none; gap: 8px; align-items: center; margin-bottom: 12px; }
.newbook.open { display: flex; }
.newbook input {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
  background: var(--bg); flex: 1; min-width: 140px;
}

/* ---------- profile ---------- */
.profile-head { margin-bottom: 16px; }
.profile-head .name { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.profile-head .stats { color: var(--muted); font-size: 13px; margin-top: 4px; }
.profile-head .stats b { color: var(--ink); font-weight: 600; }
.profile-head .actions { margin-top: 12px; }
.fav-btn {
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.fav-btn.on { background: transparent; color: var(--ink); }

.book-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 6px 13px; border-radius: 999px; font-size: 13px;
}
.chip .n { color: var(--muted); margin-left: 5px; }
.chip.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.chip.active .n { color: rgba(255,255,255,0.7); }

/* book color dot on chips + cards */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.chip .dot { box-shadow: 0 0 0 1px rgba(0,0,0,0.08); }
.chip.active .dot { box-shadow: 0 0 0 1px rgba(255,255,255,0.5); }

/* ---------- wobble segmented control ---------- */
.wobble-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.wobble-row label { font-size: 13px; color: var(--muted); }
.bg-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.bg-row label { font-size: 13px; color: var(--muted); }
.bg-picker .c { width: 22px; height: 22px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button {
  background: var(--card); border: none; padding: 7px 15px; font-size: 13px;
  color: var(--muted); font-weight: 600; border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--ink); color: #fff; }

/* ---------- visual sketchbook picker ---------- */
.picker-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.book-tiles { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.book-tile {
  display: flex; align-items: center; gap: 9px;
  border: 2px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 10px 14px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.book-tile .swatch-dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.book-tile .cnt { color: var(--muted); font-weight: 400; font-size: 12px; }
.book-tile.active { border-color: var(--ink); }
.book-tile.add { color: var(--muted); border-style: dashed; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-picker .c {
  width: 24px; height: 24px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.color-picker .c.sel { box-shadow: 0 0 0 2px var(--ink); transform: scale(1.08); }
.newbook { display: none; flex-direction: column; gap: 10px; margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.newbook.open { display: flex; }
.newbook input { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--card); }
.newbook-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- sketchbook editor (on your own profile) ---------- */
.book-editor { display: none; gap: 10px; flex-direction: column; margin-bottom: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.book-editor.open { display: flex; }
.book-editor input { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--bg); }
.chip .edit { margin-left: 8px; cursor: pointer; opacity: 0.6; }
.chip .edit:hover { opacity: 1; }

/* ============================================================
   Ink-on-paper theme: black & white UI with hand-drawn edges.
   (Drawings + sketchbook color dots intentionally keep color.)
   ============================================================ */
header { border-bottom: 2px solid var(--ink); }
.logo { font-size: 24px; }
h2 { font-size: 22px; }

/* the in-canvas hand-drawn frame is the drawing's border now */
.card { border: 1px solid var(--line); border-radius: var(--doodle); }
.card-canvas-wrap { border: none; background: transparent; }

/* wonky hand-drawn outlines on interactive bits */
.btn,
.fav-btn,
.chip,
.book-tile,
.caption-input,
.auth input,
.newbook input,
.newbook,
.comment-form input,
.book-editor,
.book-editor input {
  border: 2px solid var(--ink);
  border-radius: var(--doodle);
}
.btn.small { border-radius: 13px 8px 14px 9px / 9px 14px 8px 13px; }
.seg { border: 2px solid var(--ink); border-radius: 15px 19px 14px 18px / 18px 14px 19px 15px; }
.book-tile.add { border-style: dashed; }
.book-tile.active { box-shadow: 1.5px 1.5px 0 var(--ink); }
.tabs { border-bottom: 2px solid var(--ink); }

/* keep stroke swatches + background-fill swatches perfectly round */
.swatch, .color-picker .c { border-radius: 50% !important; }

/* messages in ink, not color */
.msg.err { color: var(--ink); font-style: italic; }
.msg.ok { color: var(--ink); }

.profile-head .name { font-size: 27px; }

/* ============================================================
   Declutter: remove the straight boxes/dividers around sections
   and the header/content break. Only the animated wiggle frames
   around the drawings remain as outlines.
   ============================================================ */
header { border-bottom: none; }
.card { border: none; }
.card-canvas-wrap { border: none; }
.tabs { border-bottom: none; }
.comments { border-top: none; }

/* quick add-friend (+) shown next to other people's names */
.add-friend {
  background: none; border: none; font: inherit;
  font-weight: 700; font-size: 18px; line-height: 1;
  color: var(--ink); cursor: pointer; padding: 0 3px;
}
.add-friend.on { color: var(--muted); font-weight: 400; }
.add-friend:hover { opacity: 0.55; }

/* date stamp next to each drawing */
.card-head .date { color: var(--muted); font-size: 12px; margin-left: auto; }
