/* Canvas Tracker - one stylesheet, no build step, no external assets. */

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #666e7a;
  --line: #e2e5ea;
  --accent: #2f6df6;
  --alert-bg: #fdecec;
  --alert-ink: #a11b1b;

  --missing: #c62828;  --missing-bg: #fdeaea;
  --overdue: #b45309;  --overdue-bg: #fdf0dc;
  --late:    #6d28d9;  --late-bg:    #f0eafd;
  --upcoming:#1d4ed8;  --upcoming-bg:#e7eefd;
  --done:    #15803d;  --done-bg:    #e6f5ec;
  --neutral: #52606d;  --neutral-bg: #eceff3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1c1f25;
    --ink: #e8eaee;
    --muted: #9aa3af;
    --line: #2c3039;
    --accent: #6f9bff;
    --alert-bg: #3a1d1d;
    --alert-ink: #ff9c9c;

    --missing: #ff8a80;  --missing-bg: #3a1f1f;
    --overdue: #f0b072;  --overdue-bg: #382a1a;
    --late:    #c4b5fd;  --late-bg:    #272040;
    --upcoming:#9ec1ff;  --upcoming-bg:#1b2740;
    --done:    #86d9a6;  --done-bg:    #17301f;
    --neutral: #b6bec9;  --neutral-bg: #262a32;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.quiet { color: var(--muted); }

/* ---------- top bar ---------- */

.topbar {
  display: flex; flex-wrap: wrap; gap: .75rem 1.25rem;
  align-items: center; justify-content: space-between;
  padding: .75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 650; color: var(--ink); font-size: 1.05rem; }
.topbar nav { display: flex; align-items: center; gap: 1rem; }
.topbar nav a { color: var(--muted); }
.topbar nav a.on { color: var(--ink); font-weight: 600; }
.topbar form { margin: 0; }
button.link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--muted); font: inherit;
}
button.link:hover { color: var(--accent); text-decoration: underline; }

main { max-width: 60rem; margin: 0 auto; padding: 1.25rem; }
main.bare { max-width: 22rem; margin-top: 12vh; }
h1 { font-size: 1.4rem; margin: .25rem 0 1rem; }

/* ---------- status + filters ---------- */

.statusline {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  justify-content: space-between; margin-bottom: 1rem;
}
.spin::after {
  content: ""; display: inline-block; width: .7em; height: .7em; margin-left: .4em;
  border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  background: var(--alert-bg); color: var(--alert-ink);
  border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1rem;
  overflow-wrap: anywhere;
}

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.tab {
  padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: .87rem;
}
.tab:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.filters .count { margin-left: auto; font-size: .87rem; }

/* ---------- chips + pills ---------- */

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip, .pill {
  display: inline-block; border-radius: 999px; padding: .18rem .6rem;
  font-size: .78rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral);
}
.pill { min-width: 5.6rem; text-align: center; }

.missing   { background: var(--missing-bg);  color: var(--missing); }
.overdue   { background: var(--overdue-bg);  color: var(--overdue); }
.late      { background: var(--late-bg);     color: var(--late); }
.upcoming  { background: var(--upcoming-bg); color: var(--upcoming); }
.submitted, .graded, .cleared { background: var(--done-bg); color: var(--done); }
.excused, .offline, .future { background: var(--neutral-bg); color: var(--neutral); }
.new { background: var(--upcoming-bg); color: var(--upcoming); }
.changed { background: var(--late-bg); color: var(--late); }

/* ---------- cards ---------- */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.card h2 {
  font-size: 1rem; margin: 0 0 .75rem;
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline;
}
.card h2 .who { color: var(--muted); font-weight: 500; font-size: .85rem; }
.card.empty { text-align: center; color: var(--muted); }
.card.empty h2 { justify-content: center; color: var(--ink); }

ul.rows { list-style: none; margin: 0; padding: 0; }
ul.rows li {
  display: grid;
  grid-template-columns: 6.2rem 1fr auto;
  gap: .3rem .75rem; align-items: baseline;
  padding: .5rem 0; border-top: 1px solid var(--line);
}
ul.rows li:first-child { border-top: 0; }
.what a { color: var(--ink); }
.what a:hover { color: var(--accent); }
a.ext { color: var(--muted); margin-left: .3rem; text-decoration: none; }
a.ext:hover { color: var(--accent); }
.ext-icon { vertical-align: -1px; }
.detail { display: block; color: var(--muted); font-size: .82rem; font-style: normal; }
.when { color: var(--muted); font-size: .85rem; text-align: right; white-space: nowrap; }
.pts { display: block; font-size: .78rem; }
.changes h2 { font-size: .95rem; color: var(--muted); font-weight: 600; }

/* ---------- history ---------- */

table.history { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.history th { text-align: left; color: var(--muted); font-weight: 600; }
table.history th, table.history td {
  padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top;
}
table.history .tally { display: flex; flex-wrap: wrap; gap: .3rem; }

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

.login { display: flex; flex-direction: column; gap: .6rem; }
.login h1 { text-align: center; margin-bottom: .5rem; }
.login label { color: var(--muted); font-size: .85rem; }
.login input, .login button {
  font: inherit; padding: .55rem .7rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
}
.login button {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; cursor: pointer; margin-top: .4rem;
}

/* ---------- update banner ---------- */

#update-banner {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 1.25rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: .5rem 1rem; box-shadow: 0 6px 24px rgba(0,0,0,.18);
  display: flex; gap: .6rem; align-items: center; font-size: .9rem;
}
#update-banner[hidden] { display: none; }
#update-banner button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 999px;
  padding: .25rem .8rem; background: var(--accent); color: #fff;
}

@media (max-width: 34rem) {
  ul.rows li { grid-template-columns: 1fr auto; }
  ul.rows li .pill { grid-column: 1 / -1; justify-self: start; }
  .filters .count { margin-left: 0; width: 100%; }
}

/* ---------- entity layer: assignment page, statuses, account ---------- */

.done { background: var(--done-bg); color: var(--done); }
.notice {
  background: var(--done-bg); color: var(--done);
  border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1rem;
}

ul.facts { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .4rem; }
ul.facts li { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
ul.facts .quiet { min-width: 6rem; }

input:not([type]), input[type="text"], input[type="password"], input[type="time"], select, textarea {
  font: inherit; padding: .4rem .55rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
textarea { width: 100%; resize: vertical; }
button[type="submit"] {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: .4rem .9rem;
}
button.link.danger { color: var(--missing); }
label.inline { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .85rem; }

.statusform, .commentform, .stack { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.statusform label, .commentform label { color: var(--muted); font-size: .85rem; }
.commentform, .stack { flex-direction: column; align-items: stretch; }
.commentform { margin-top: 1rem; }
.commentform button, .stack button { align-self: flex-start; }
.stack input { max-width: 22rem; }
.buttons, .row { display: flex; gap: .5rem; flex-wrap: wrap; align-self: flex-start; }
.row { align-items: center; }
button.secondary { background: transparent; color: var(--accent); }
.subform { margin-top: .9rem; }

ul.timeline { list-style: none; margin: 0; padding: 0; }
ul.timeline li {
  display: grid; grid-template-columns: 11rem 1fr; gap: .3rem .9rem;
  padding: .45rem 0; border-top: 1px solid var(--line); align-items: baseline;
}
ul.timeline li:first-child { border-top: 0; }
.tl-when { font-size: .82rem; white-space: nowrap; }
.tl-body {
  display: block; margin-top: .25rem; padding: .45rem .6rem;
  background: var(--bg); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.tl-canvas .tl-what { color: var(--muted); }

ul.statuslist, ul.people { list-style: none; margin: 0; padding: 0; }
ul.statuslist li, ul.people li { padding: .5rem 0; border-top: 1px solid var(--line); }
ul.statuslist li:first-child, ul.people li:first-child { border-top: 0; }
ul.statuslist form, ul.people form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
ul.statuslist input[type="text"] { flex: 1 1 12rem; }
ul.people .what { flex: 1 1 12rem; }

@media (max-width: 34rem) {
  ul.timeline li { grid-template-columns: 1fr; }
}
