:root {
  color-scheme: dark;
  --bg: #161819;
  --surface: #1f2223;
  --surface-2: #282c2d;
  --line: #353a3b;
  --line-soft: #2a2e2f;
  --row-alt: #232627;
  --text: #e9ecea;
  --muted: #8d9692;
  --faint: #545b58;
  --green: #4fbf87;
  --green-hi: #67d29c;
  --green-light: #93cfb0;
  --green-dark: #2c5847;
  --green-deep: #20402f;
  --head: #284e3f;
  --bad: #e5826a;
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--green); }
h1, h2 { font-weight: 600; letter-spacing: 0.02em; margin: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  max-width: 1080px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.1rem; letter-spacing: 0.06em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2);
  background-image: url("icon.svg"); background-size: cover;
}
.top nav { display: flex; align-items: center; gap: 1.1rem; font-size: 0.92rem; }
.top nav a { color: var(--muted); }
.top nav a:hover { color: var(--green); }
.top nav form { margin: 0; }

main { max-width: 1080px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }
main.narrow { max-width: 360px; padding-top: 3rem; }
main.narrow h1 { margin-bottom: 0.3rem; }
main.narrow h2 { margin: 1.4rem 0 0.6rem; color: var(--muted); font-size: 0.95rem; }

.flash { margin: 0 0 1rem; padding: 0.55rem 0.8rem; border-radius: var(--radius); background: var(--surface); border-left: 3px solid var(--green-light); }
.flash.bad { border-left-color: var(--bad); color: var(--bad); }
.flash.good { border-left-color: var(--green); }

/* forms */
input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  font: inherit;
}
input:focus { outline: none; border-color: var(--green); }
input[type="number"] { width: 4.2rem; text-align: center; }
button {
  background: var(--green);
  border: none;
  color: #0f1a14;
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--green-hi); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--green-light); outline-offset: 2px; }
button.link { background: none; color: var(--muted); padding: 0; font-weight: 400; }
button.link:hover { color: var(--green); }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); font-weight: 400; }
button.danger:hover { border-color: var(--bad); }
label { display: block; color: var(--muted); font-size: 0.85rem; }
.stack { display: flex; flex-direction: column; gap: 0.8rem; margin: 1.4rem 0 1rem; }
.stack label input { margin-top: 0.3rem; }
.stack button { margin-top: 0.4rem; }
.inline { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.3rem; }

/* week bar */
.weekbar { display: flex; align-items: center; gap: 1rem; margin: 0.4rem 0 0.8rem; flex-wrap: wrap; }
.weekname { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.step {
  display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem;
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted);
}
.step:hover { border-color: var(--green); }
.today-link { color: var(--green-light); font-size: 0.9rem; }

.legend { display: flex; gap: 1.2rem; flex-wrap: wrap; list-style: none; padding: 0; margin: 0 0 1.2rem; color: var(--muted); font-size: 0.82rem; }
.legend li { display: flex; align-items: center; gap: 0.45rem; }

/* blocks */
.block {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 1rem 1rem 1.1rem;
  margin-bottom: 1.2rem;
}
.block.mine { border-color: var(--line); }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.you { font-size: 0.72rem; color: var(--green-light); border: 1px solid var(--green-light); border-radius: 99px; padding: 0 0.45rem; margin-left: 0.3rem; vertical-align: 2px; font-weight: 400; }
.score { color: var(--muted); font-size: 0.85rem; }
.score.full { color: var(--green); }

.grid-wrap { overflow-x: auto; margin: 0 -0.25rem; padding: 0 0.25rem; }
.grid { width: 100%; border-collapse: collapse; min-width: 560px; }
.grid th {
  background: var(--head);
  color: #e3efe8;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.45rem 0.5rem;
  text-align: center;
  white-space: nowrap;
}
.grid th:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.grid th:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.grid th.task, .grid td.task { text-align: left; }
.grid th small { display: block; font-weight: 400; color: #9fc4b1; font-size: 0.72rem; }
.grid th.today { color: var(--green); }
.grid th.today small { color: var(--green); }
.grid td { padding: 0.15rem 0.4rem; border-bottom: 1px solid var(--line-soft); text-align: center; height: 2.5rem; }
.grid td { background: var(--surface); }
.grid tbody tr:nth-child(even) td { background: var(--row-alt); }
.grid td.task { padding-left: 0.6rem; min-width: 10rem; max-width: 22rem; overflow-wrap: anywhere; }
.grid td.num { color: var(--muted); font-size: 0.88rem; white-space: nowrap; }
.grid td.cell { width: 2.9rem; }
.grid tbody tr td.today { background-image: linear-gradient(rgba(79, 191, 135, 0.06), rgba(79, 191, 135, 0.06)); }
.grid td.progress.met { color: var(--green); font-weight: 700; }
.pending { color: var(--muted); font-weight: 400; }
.checkin-row td { border-bottom: none; height: 2rem; font-size: 0.85rem; }

.tick { margin: 0; }
.tick button { background: none; padding: 0.3rem; border-radius: var(--radius); display: inline-grid; place-items: center; }
.tick button:hover:not(:disabled) { background: var(--surface-2); }
.tick button:disabled { cursor: default; }

/* marks: open / claimed / confirmed */
.mark {
  display: inline-block; width: 20px; height: 20px; border-radius: 5px;
  border: 1.5px solid var(--faint); position: relative; flex: none;
}
.mark.future { border-style: dashed; border-color: var(--line); }
.mark.claimed { border-color: #4f8f70; background: var(--green-deep); }
.mark.claimed::after {
  content: ""; position: absolute; inset: 5px; border-radius: 2px; background: var(--green-light);
}
.mark.confirmed { border-color: var(--green); background: var(--green); }
.mark.confirmed::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid #0f1a14; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.tick button:hover:not(:disabled) .mark:not(.confirmed):not(.claimed) { border-color: var(--muted); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--green-light); cursor: help; }

.checkins { list-style: none; padding: 0; margin: 0.9rem 0 0; font-size: 0.88rem; }
.checkins li { display: flex; gap: 0.9rem; padding: 0.3rem 0; border-top: 1px solid var(--line-soft); }
.checkins .when { color: var(--green-light); min-width: 3.6rem; flex: none; }
.checkins .body { overflow-wrap: anywhere; white-space: pre-wrap; }

.tools { margin-top: 1rem; display: grid; gap: 0.9rem; }
.tools form { margin: 0; }
details.edit summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
details.edit summary:hover { color: var(--green); }
.edit-row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.edit-row .inline { flex: 1; margin: 0; }

@media (max-width: 560px) {
  body { font-size: 14px; }
  .top nav { gap: 0.8rem; }
  .block { padding: 0.8rem 0.7rem 0.9rem; border-radius: 8px; }
  .edit-row { flex-wrap: wrap; }
  .inline { flex-wrap: wrap; }
  .inline input:not([type="number"]) { flex: 1 1 12rem; }
  .weekname { flex-direction: column; gap: 0; }
  .weekname .muted { font-size: 0.8rem; }
  .grid { min-width: 0; }
  .grid .target { display: none; }
  .grid th.task, .grid td.task { position: sticky; left: 0; z-index: 1; min-width: 6.5rem; max-width: 8rem; padding-left: 0.4rem; }
  .grid th.task { background: var(--head); }
  .grid th, .grid td { padding-left: 0.15rem; padding-right: 0.15rem; }
  .grid td.cell { width: 2.1rem; }
  .tick button { padding: 0.15rem; }
}
