/* The Oddside board: the paper look (warm off-white ground, ink type, hairline borders, mono
   micro-labels, a film grain), cut down to what an app needs. Tokens first, then layout. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --fg: #16161a;
  --muted: #6a6a72;
  --line: rgba(22, 22, 26, 0.13);
  --line-strong: rgba(22, 22, 26, 0.34);
  --surface: rgba(22, 22, 26, 0.035);
  --surface-2: rgba(22, 22, 26, 0.07);
  --card-bg: #fbfaf8;
  --nav-bg: rgba(244, 242, 238, 0.86);
  --accent: #16161a;
  --accent-ink: #fbfaf8;
  --danger: #b3261e;
  --font-body: "Inter Tight", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --r-card: 10px;
  --r-btn: 8px;
  --list-w: 300px;
  --nav-h: 58px;
  --panel-w: 480px;
  --grain-subtle: 0.17;
}

html, body { height: 100%; }
body { display: flex; flex-direction: column; }
#main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  background-image:
    linear-gradient(rgba(22, 22, 26, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 22, 26, 0.045) 1px, transparent 1px);
  background-size: 100% 46px, 46px 100%;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-btn);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: 0.88; }
.btn-ghost { border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: rgba(179, 38, 30, 0.4); }
.btn.danger:hover { background: rgba(179, 38, 30, 0.07); }
.icon-btn {
  width: 32px; height: 32px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.icon-btn:hover { background: var(--surface); color: var(--fg); }
.link {
  border: 0; background: none; padding: 0; margin-left: 8px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--fg); cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- nav ---------- */

.nav {
  position: relative;
  flex: none;
  z-index: 60;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.nav-row {
  min-height: var(--nav-h);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.nav-brand { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; text-decoration: none; color: inherit; white-space: nowrap; }
.nav-brand span { color: var(--muted); font-weight: 400; }
.nav-tools { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.search { display: flex; align-items: center; gap: 10px; }
.search input {
  width: 220px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-btn);
  background: var(--card-bg);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card-bg);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--fg)); flex: none; }
.chip.on, .chip:hover { color: var(--fg); border-color: var(--line-strong); }
.chip.on { background: var(--surface-2); }
.chip.static { cursor: default; }
.chip.static:hover { border-color: var(--line); color: var(--muted); }

.toggle { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--fg); margin: 0; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 260px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card-bg);
  box-shadow: 0 10px 30px rgba(22, 22, 26, 0.12);
  display: flex; flex-direction: column; gap: 10px;
  z-index: 70;
}
.menu-body form { display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.menu-body input { padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: #fff; }
.menu-note { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ---------- login ---------- */

.login { flex: 1 1 auto; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(380px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--card-bg);
  box-shadow: 0 1px 2px rgba(22, 22, 26, 0.05);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { font-size: 30px; font-weight: 500; letter-spacing: -0.03em; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.login-card input { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: #fff; font-size: 15px; letter-spacing: 0; text-transform: none; }
.login-error { color: var(--danger); font-size: 14px; }

/* ---------- board ---------- */

.board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 16px;
  padding: 18px 20px 24px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-start;
  scroll-snap-type: x proximity;
}
.list {
  flex: none;
  width: var(--list-w);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: rgba(251, 250, 248, 0.6);
  scroll-snap-align: start;
}
.list.over { border-color: var(--line-strong); }
.list-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 12px 14px 8px;
}
.list-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.list-head .count { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.cards {
  flex: 1 1 auto;
  min-height: 24px;
  overflow-y: auto;
  padding: 2px 10px 6px;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin;
}
.add {
  margin: 6px 10px 10px;
  padding: 8px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-btn);
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.add:hover { color: var(--fg); background: var(--surface); }

.card {
  padding: 10px 12px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  background: var(--card-bg);
  box-shadow: 0 1px 2px rgba(22, 22, 26, 0.05);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  display: flex; flex-direction: column; gap: 6px;
}
.card:hover { border-color: var(--line-strong); }
.card h3 { font-size: 14px; font-weight: 500; line-height: 1.35; letter-spacing: -0.005em; }
.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 18px; }
.card-top:empty { display: none; }
.pill {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.pill.done { color: var(--fg); border-color: var(--line-strong); }
.card.archived { opacity: 0.55; border-style: dashed; }
.card.placeholder { opacity: 0.35; border-style: dashed; background: transparent; box-shadow: none; }
.ghost {
  position: fixed; z-index: 100; pointer-events: none;
  transform-origin: 20% 20%;
  transform: rotate(1.5deg);
  box-shadow: 0 14px 34px rgba(22, 22, 26, 0.2);
  cursor: grabbing;
}
body.dragging { cursor: grabbing; user-select: none; }

/* ---------- panel ---------- */

.scrim { position: fixed; inset: 0; z-index: 79; background: rgba(22, 22, 26, 0.18); }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 80;
  width: min(var(--panel-w), 100vw);
  background: var(--card-bg);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(22, 22, 26, 0.12);
  display: flex; flex-direction: column;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px 24px; }
.panel-body { flex: 1 1 auto; overflow-y: auto; padding: 0 24px 24px; display: flex; flex-direction: column; gap: 18px; }
.card-title {
  width: 100%;
  border: 0; border-bottom: 1px solid transparent; background: transparent; resize: none;
  font-size: 22px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.25; padding: 4px 0;
}
.card-title:focus { outline: none; border-bottom-color: var(--line-strong); }
.panel-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > .eyebrow b { color: var(--fg); font-weight: 500; margin-left: 6px; }
select {
  padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: #fff; font-size: 14px;
}
.desc-edit {
  width: 100%; min-height: 160px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: #fff;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.55; resize: vertical;
}
.markdown { font-size: 14.5px; line-height: 1.55; cursor: text; min-height: 24px; }
.markdown.empty { color: var(--muted); font-style: italic; }
.markdown p + p, .markdown ul, .markdown ol, .markdown pre, .markdown blockquote, .markdown h1, .markdown h2, .markdown h3 { margin-top: 8px; }
.markdown h1, .markdown h2, .markdown h3 { font-size: 15px; font-weight: 600; }
.markdown ul, .markdown ol { padding-left: 22px; }
.markdown li.task { list-style: none; margin-left: -18px; }
.markdown code { font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.markdown pre { background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-btn); overflow-x: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { border-left: 2px solid var(--line-strong); padding-left: 12px; color: var(--muted); }
.markdown a { color: var(--fg); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.steps li { display: flex; align-items: flex-start; gap: 10px; padding: 5px 6px; border-radius: 6px; }
.steps li:hover { background: var(--surface); }
.steps input[type="checkbox"] { accent-color: var(--fg); margin: 4px 0 0; flex: none; }
.steps .step-text { flex: 1 1 auto; font-size: 14px; line-height: 1.4; }
.steps li.done .step-text { color: var(--muted); text-decoration: line-through; }
.steps .step-del { opacity: 0; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
.steps li:hover .step-del { opacity: 1; }
.step-add { display: flex; gap: 8px; }
.step-add input { flex: 1 1 auto; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: #fff; }
.panel-foot { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.spacer { flex: 1 1 auto; }
.stamp { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 110;
  padding: 10px 16px;
  border-radius: var(--r-btn);
  background: var(--accent); color: var(--accent-ink);
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(22, 22, 26, 0.2);
}

/* ---------- grain ---------- */

.fx { position: fixed; inset: 0; z-index: 90; pointer-events: none; contain: strict; }
.fx > i { position: absolute; inset: -60px; display: block; opacity: 0; }
.fx-grain {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 220px 220px;
  mix-blend-mode: multiply;
}
body[data-grain="subtle"] .fx-grain { opacity: var(--grain-subtle); }
@media (prefers-reduced-motion: no-preference) {
  body[data-grain-move="1"] .fx-grain { animation: fx-jitter 0.7s steps(1) infinite; }
}
@keyframes fx-jitter {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-13px, 8px); }
  40% { transform: translate(9px, -14px); }
  60% { transform: translate(-7px, -6px); }
  80% { transform: translate(14px, 11px); }
}

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .nav-row { padding: 8px 14px; gap: 10px; }
  .nav-brand span { display: none; }
  .nav-tools { margin-left: 0; width: 100%; gap: 10px; }
  .search input { width: 100%; }
  .search { flex: 1 1 100%; }
  .board { padding: 12px 14px 20px; gap: 12px; scroll-snap-type: x mandatory; --list-w: min(86vw, 320px); }
  .panel { width: 100vw; border-left: 0; }
  .panel-body { padding: 0 16px 20px; }
  .panel-head { padding-left: 16px; }
  .panel-row { grid-template-columns: 1fr; }
}

/* ---------- projects, filters, priorities, tags ---------- */

.projects { display: flex; gap: 2px; flex-wrap: wrap; }
.project {
  display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap;
  padding: 6px 10px; border-radius: var(--r-btn);
  font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none;
}
.project span { font-family: var(--font-mono); font-size: 11px; }
.project:hover { color: var(--fg); background: var(--surface); }
.project.on { color: var(--accent-ink); background: var(--accent); }
.project.on span { color: rgba(251, 250, 248, 0.7); }

.filter-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 0 20px 10px;
}
.filter-gap { width: 6px; }
.chip.small { padding: 1px 7px 1px 6px; font-size: 10px; }
.chip.small i { width: 6px; height: 6px; }

.pill.prio { text-transform: uppercase; letter-spacing: 0.08em; }
.pill.prio.clickable { cursor: pointer; background: var(--card-bg); }
.pill.prio.clickable:hover, .pill.prio.on { color: var(--fg); border-color: var(--line-strong); }
.pill.prio.on { background: var(--surface-2); }
.pill.prio-high { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.pill.prio-high.clickable:not(.on) { color: var(--muted); background: var(--card-bg); border-color: var(--line); }
.pill.prio-high.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.pill.prio-medium { border-color: var(--line-strong); color: var(--fg); }
.pill.prio-none { color: var(--muted); }
.card.prio-high { border-left: 3px solid var(--accent); }
.card.prio-medium { border-left: 3px solid var(--line-strong); }

.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1 1 auto; min-width: 0; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-btn); background: #fff; }

.tag-manager { display: flex; flex-direction: column; gap: 4px; }
.tag-row { display: flex; align-items: center; gap: 8px; }
.tag-row input[type="color"] { width: 22px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.tag-row .tag-name { flex: 1 1 auto; text-align: left; border: 0; background: none; padding: 3px 4px; font-family: var(--font-mono); font-size: 12px; cursor: text; border-radius: 4px; }
.tag-row .tag-name:hover { background: var(--surface); }
.tag-row .step-del { opacity: 1; }
.menu-body { width: 300px; max-height: calc(100vh - 90px); overflow-y: auto; }
.menu-body form { border-bottom: 0; padding-bottom: 0; }
.menu-body form#password-form { border-top: 1px solid var(--line); padding-top: 10px; }
.empty { color: var(--muted); padding: 20px; }
.nav-row { gap: 14px; }

@media (max-width: 720px) {
  /* brand and Menu on the first line, the search under them, the projects on a line that scrolls */
  .nav-tools { display: contents; }
  .menu { order: 2; margin-left: auto; }
  .search { order: 3; flex: 1 1 100%; }
  .projects { order: 4; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; scrollbar-width: none; }
  .filter-row { padding: 0 14px 8px; }
}
