/* SPIML Tracker — one stylesheet, no framework, no build step. */

:root {
  --paper:   #f3f5f2;
  --surface: #ffffff;
  --sunken:  #eceee9;
  --ink:     #1b201d;
  --muted:   #6a716c;
  --hair:    #d5dad3;
  --accent:  #0e6b6e;
  --accent-soft: #e2efee;
  --warn:    #9c4224;
  --good:    #2f7d4f;
  --radius:  5px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #131715;
    --surface: #191e1b;
    --sunken:  #10140f;
    --ink:     #e7eae6;
    --muted:   #99a19b;
    --hair:    #2d3531;
    --accent:  #4fc2bb;
    --accent-soft: #10302f;
    --warn:    #d98362;
    --good:    #6cc08c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; align-items: stretch; }

.side {
  width: 216px;
  flex: 0 0 216px;
  background: var(--surface);
  border-right: 1px solid var(--hair);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { font-weight: 600; letter-spacing: -0.01em; display: flex; gap: 8px; align-items: center; }
.brand .mark { color: var(--accent); }

.side-search input {
  width: 100%; padding: 7px 9px; font-size: 13px;
  border: 1px solid var(--hair); border-radius: var(--radius);
  background: var(--sunken); color: var(--ink);
}

.side nav { display: flex; flex-direction: column; gap: 1px; }
.side nav a {
  padding: 7px 9px; border-radius: var(--radius); color: var(--ink); font-size: 13.5px;
}
.side nav a:hover { background: var(--sunken); text-decoration: none; }
.side nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.side-foot { margin-top: auto; border-top: 1px solid var(--hair); padding-top: 12px; }
.who { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.who small { display: block; color: var(--muted); font-size: 11.5px; }
.avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
}

main { flex: 1; min-width: 0; padding: 26px 30px 60px; max-width: 1280px; }

/* ---------------------------------------------------------------- bits */

h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 600; margin: 26px 0 10px; }
h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; }

.page-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }

.card {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--radius); padding: 16px;
}
.grid { display: grid; gap: 14px; }
.grid.two   { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.four  { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 13px 15px; }
.stat b { display: block; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 12px; }

.flash { padding: 9px 13px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--hair); background: var(--surface); }
.flash.error { border-color: var(--warn); color: var(--warn); }
.flash.ok { border-color: var(--good); color: var(--good); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono  { font-family: var(--mono); font-size: 12.5px; }
.empty { color: var(--muted); padding: 14px 0; font-style: italic; }

/* ---------------------------------------------------------------- table */

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--hair); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: var(--sunken); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- chips */

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid var(--hair); white-space: nowrap;
}
.pill.backlog { color: var(--muted); }
.pill.todo    { color: var(--accent); border-color: var(--accent); }
.pill.doing   { color: #9a6b12; border-color: #c9a34a; }
.pill.blocked { color: var(--warn); border-color: var(--warn); }
.pill.done    { color: var(--good); border-color: var(--good); }
.pill.urgent, .pill.high { color: var(--warn); border-color: var(--warn); }

.code {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  white-space: nowrap;
}

.tag {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--sunken); padding: 1px 6px; border-radius: 3px;
}

/* ---------------------------------------------------------------- forms */

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 7px 9px; font: inherit; font-size: 13.5px;
  border: 1px solid var(--hair); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; min-height: 120px; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }

button, .btn {
  font: inherit; font-size: 13px; padding: 7px 13px; cursor: pointer;
  border: 1px solid var(--hair); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); display: inline-block;
}
button:hover, .btn:hover { background: var(--sunken); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); }
button.linkish { border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; }
button.linkish:hover { color: var(--accent); background: none; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters > div { flex: 0 0 auto; min-width: 140px; }

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

.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { flex: 0 0 258px; background: var(--sunken); border-radius: var(--radius); padding: 10px; }
.col h3 { margin: 0 0 9px; display: flex; justify-content: space-between; font-size: 12px; }
.col h3 span { color: var(--muted); font-weight: 400; }
.ticket {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--radius); padding: 9px 10px; margin-bottom: 7px; display: block; color: var(--ink);
}
.ticket:hover { text-decoration: none; border-color: var(--accent); }
.ticket .t { font-size: 13px; margin: 2px 0 5px; }
.ticket .m { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--muted); flex-wrap: wrap; }

/* ---------------------------------------------------------------- item */

.item-layout { display: grid; grid-template-columns: minmax(0,1fr) 262px; gap: 22px; align-items: start; }
@media (max-width: 900px) { .item-layout { grid-template-columns: 1fr; } }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--hair); }
.timeline li { padding: 0 0 15px 15px; position: relative; }
.timeline li::before {
  content: ''; position: absolute; left: -5px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--hair);
}
.timeline li.transition::before { background: var(--accent); }
.timeline .when { color: var(--muted); font-size: 11.5px; }
.timeline .body { background: var(--sunken); padding: 8px 10px; border-radius: var(--radius); margin-top: 5px; white-space: pre-wrap; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--hair); }
.checklist li.done label { text-decoration: line-through; color: var(--muted); }
.checklist label { margin: 0; color: var(--ink); font-size: 13px; }

/* ---------------------------------------------------------------- prose */

.prose { font-size: 14.5px; line-height: 1.68; }
.prose h1 { font-size: 20px; margin: 22px 0 8px; }
.prose h2 { font-size: 16px; margin: 22px 0 8px; }
.prose h3 { font-size: 14px; margin: 18px 0 6px; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose code { font-family: var(--mono); font-size: 12.5px; background: var(--sunken); padding: 1px 4px; border-radius: 3px; }
.prose pre { background: var(--sunken); padding: 12px; border-radius: var(--radius); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin: 0 0 12px; padding: 2px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--hair); margin: 22px 0; }
.prose li.task { list-style: none; margin-left: -20px; }
.prose table { margin-bottom: 14px; }

.wiki { border-bottom: 1px dotted var(--accent); }
.wiki.missing { color: var(--warn); border-bottom-color: var(--warn); }
.code-ref { font-family: var(--mono); font-size: 0.92em; }

/* ---------------------------------------------------------------- editor */

.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .editor { grid-template-columns: 1fr; } }
.editor textarea { min-height: 62vh; }
.preview {
  border: 1px solid var(--hair); border-radius: var(--radius);
  background: var(--surface); padding: 16px; min-height: 62vh; overflow: auto;
}
.editor-hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

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

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--hair); border-radius: 7px; padding: 24px; }

/* ---------------------------------------------------------------- misc */

.tree-folder { font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 16px 0 6px; }
.tree-file { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--hair); font-size: 13px; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side { width: auto; flex: none; height: auto; position: static; flex-direction: column; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 18px 16px 50px; }
}
