/* Black outlines on white.  Colour only where it means something: light blue
   for progress, green for done, red for overdue. */
:root {
  --ink: #000;
  --paper: #fff;
  --blue: #9fd0ff;
  --blue-light: #d6ebff;
  --green: #5cc46a;
  --green-light: #ccf0d0;
  --red: #d32f2f;
  --red-light: #ffd6d6;
  --amber: #ffd54a;
  --line: 2px solid var(--ink);
  --thin: 1px solid var(--ink);
  --dither: repeating-conic-gradient(var(--ink) 0 25%, var(--paper) 0 50%) 0 0 / 4px 4px;
  --dither-light: radial-gradient(var(--ink) 0.7px, transparent 0.8px) 0 0 / 4px 4px;
  font-family: "Computer Modern Serif", "Latin Modern Roman", Georgia, serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px 16px;
  background: var(--paper);
  font-size: 17px;
  line-height: 1.35;
}

code,
.mono {
  font-family: "Computer Modern Typewriter", "Courier New", monospace;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: bold;
}
h2 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}
h3 {
  font-size: 1.05rem;
}

a {
  color: var(--ink);
}

.hint {
  margin: 0 0 14px;
  font-style: italic;
  font-size: 0.9rem;
}

.window {
  max-width: 1200px;
  margin: 0 auto;
}

.titlebar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 4px 12px;
}
.titlebar h1 {
  font-size: 1.6rem;
}
.sync {
  font-size: 0.85rem;
  font-style: italic;
}

/* ---- Tab bar: folder tabs sitting on the panel's top edge ---- */
/* The selected tab is taller and its bottom edge covers the panel's border,
   so it reads as part of the panel. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px;
  padding: 4px 0 0 12px;
  position: relative;
  z-index: 1;
}
.tabs a {
  display: block;
  padding: 6px 18px 5px;
  border: var(--line);
  background: var(--paper);
  text-decoration: none;
  white-space: nowrap;
  margin-bottom: -2px;
}
.tabs a[aria-selected="true"] {
  font-weight: bold;
  border-bottom-color: var(--paper);
  padding-top: 9px;
}
@media (max-width: 480px) {
  .tabs {
    padding-left: 4px;
  }
  .tabs a {
    padding-left: 10px;
    padding-right: 10px;
  }
}
.tabs a:focus-visible {
  outline: 1px dotted var(--ink);
  outline-offset: -5px;
}

.panel {
  border: var(--line);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 20px;
  min-height: 60vh;
  background: var(--paper);
}

.tab-body {
  display: none;
}
.tab-body.active {
  display: block;
}
.tab-body.split.active {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
}
@media (max-width: 760px) {
  .tab-body.split.active {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 12px;
  }
}

.checklist-pane {
  border-right: var(--thin);
  padding-right: 20px;
}
@media (max-width: 760px) {
  .checklist-pane {
    border-right: none;
    padding-right: 0;
  }
}

/* ---- Checklist ---- */
details.unit {
  border: var(--thin);
  margin-bottom: 8px;
}
details.unit > summary {
  cursor: pointer;
  padding: 5px 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  list-style: none;
}
details.unit > summary::-webkit-details-marker {
  display: none;
}
details.unit > summary::before {
  content: "\25B8";
  margin-right: 6px;
}
details.unit[open] > summary::before {
  content: "\25BE";
}
details.unit[open] > summary {
  border-bottom: var(--thin);
}
details.unit > summary .t {
  flex: 1;
}
.unit-body {
  padding: 6px 12px 10px;
}
.section-name {
  font-weight: bold;
  margin: 8px 0 2px;
}
.section-name a {
  font-weight: normal;
  font-size: 0.8rem;
  margin-left: 6px;
}

ul.checks {
  list-style: none;
  margin: 0;
  padding-left: 0;
}
ul.checks ul.checks {
  padding-left: 24px;
}
ul.checks li {
  margin: 1px 0;
}
.box {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--ink);
  margin-right: 7px;
  vertical-align: -1px;
  position: relative;
  background: var(--paper);
}
.box.on::after {
  content: "";
  position: absolute;
  inset: 1.5px;
  background: var(--ink);
}
.box.part::after {
  content: "";
  position: absolute;
  inset: 1.5px;
  background: var(--blue);
}
li.done > .label {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
.count {
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ---- Progress bars ---- */
.bar {
  position: relative;
  border: var(--thin);
  height: 20px;
  background: var(--paper);
  overflow: hidden;
}
.bar > .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--blue);
  border-right: var(--thin);
}
.bar > .fill.full {
  border-right: none;
  background: var(--green);
}
.bar-row {
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr) 4.5em;
  align-items: center;
  gap: 10px;
  margin: 5px 0;
}
.bar-row .key {
  font-weight: bold;
  white-space: nowrap;
}
.bar-row .pct {
  text-align: right;
  font-size: 0.85rem;
  white-space: nowrap;
}
.bar-row .name {
  grid-column: 2 / 4;
  margin-top: -4px;
  font-size: 0.85rem;
  font-style: italic;
}
.module-group {
  margin-bottom: 20px;
}
.module-group > h3 {
  border-bottom: var(--thin);
  padding-bottom: 2px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.module-group > h3 .count {
  font-weight: normal;
}

/* ---- Tables (calendar, assignments) ---- */
table.grid {
  border-collapse: collapse;
  width: 100%;
}
table.grid th,
table.grid td {
  border: var(--thin);
  padding: 4px 8px;
  text-align: left;
  vertical-align: middle;
}
table.grid thead th {
  border-bottom: var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 1;
}
table.grid td.num,
table.grid th.num {
  text-align: right;
}
.table-wrap {
  overflow-x: auto;
}

/* Calendar */
.cal td.date {
  white-space: nowrap;
  font-family: "Computer Modern Typewriter", monospace;
  font-size: 0.9rem;
}
.cal td.dow {
  width: 3.5em;
}
.cal tr.today td.date,
.cal tr.today td.dow {
  background: var(--ink);
  color: var(--paper);
}
.cal tr.past td.date,
.cal tr.past td.dow {
  font-style: italic;
}
.cal td.break {
  text-align: center;
  font-style: italic;
  letter-spacing: 0.2em;
  background: var(--dither-light);
}
.cal td.break span {
  background: var(--paper);
  padding: 0 6px;
}
/* height: 1px lets the stack inside fill the whole (row-spanning) cell. */
.cal td.topic {
  padding: 0;
  min-width: 260px;
  height: 1px;
}
.stack {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.unit-cell {
  position: relative;
  padding: 6px 10px;
  flex: 1;
}
.unit-cell + .unit-cell {
  border-top: 1px dashed var(--ink);
}
.unit-cell > .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--blue-light);
  border-right: var(--thin);
  pointer-events: none;
}
.unit-cell > .fill.full {
  border-right: none;
  background: var(--green-light);
}
.unit-cell > .txt {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.unit-cell .lbl,
.unit-cell .count {
  background: var(--paper);
  padding: 0 4px;
}
.unit-cell .qs {
  position: relative;
  display: inline-block;
  margin-top: 3px;
  font-size: 0.8rem;
  background: var(--paper);
  padding: 0 4px;
}
.cal td.topic.plain .unit-cell {
  font-style: italic;
}

/* Status tags */
.tag {
  display: inline-block;
  border: var(--thin);
  padding: 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  font-variant: small-caps;
  white-space: nowrap;
}
.tag.overdue {
  background: var(--red);
  color: var(--paper);
}
.tag.today {
  background: var(--amber);
}
.tag.done {
  background: var(--green-light);
}
.tag.none {
  border-style: dashed;
}

/* Assignments */
.assg td.days {
  font-size: 1.4rem;
  font-weight: bold;
  white-space: nowrap;
  text-align: right;
}
.assg td.days small {
  font-size: 0.75rem;
  font-weight: normal;
}
.assg tr.overdue td.days {
  color: var(--red);
}
.assg td.prog {
  min-width: 160px;
}
.assg td.prog .count {
  display: block;
  margin-top: 2px;
}
.assg tr.next td {
  border-top: var(--line);
  border-bottom: var(--line);
}
.assg .qlist {
  font-size: 0.8rem;
  margin-top: 2px;
}
.assg .qlist .q {
  margin-right: 6px;
  white-space: nowrap;
}
.assg .qlist .q.off {
  text-decoration: line-through;
}

/* Textbooks */
.books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.book-group {
  border: var(--thin);
}
.book-group h3 {
  padding: 6px 10px;
  border-bottom: var(--thin);
}
.book-group ul {
  list-style: none;
  margin: 0;
  padding: 6px 10px 10px;
}
.book-group li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px dotted var(--ink);
}
.book-group li:last-child {
  border-bottom: none;
}
.book-group li a {
  text-decoration: none;
}
.book-group li a:hover {
  text-decoration: underline;
}

.error {
  border: var(--line);
  padding: 10px;
  margin-bottom: 12px;
  background: var(--red-light);
}
.sync.failed {
  color: var(--red);
}
