@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0d0b14;
  --bg-raise: #16121f;
  --sel: #221b33;
  --fg: #e4e1ee;
  --muted: #a5a1b2;
  --faint: #453f57;
  --accent: #7c3aed;
  --purple: #a78bfa;
  --line: rgba(124, 58, 237, 0.14);
  --border: rgba(124, 58, 237, 0.24);
  --pill-bg: rgba(124, 58, 237, 0.12);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --scroll-thumb: rgba(124, 58, 237, 0.45);
  --scroll-thumb-hover: rgba(167, 139, 250, 0.7);

  --border-strong: var(--purple);
  --pill-bg-hover: rgba(124, 58, 237, 0.22);
  --row-hover: rgba(124, 58, 237, 0.05);
  --mark-glow: 0 0 12px rgba(124, 58, 237, 0.3);
  --danger: #f38ba8;
  --font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-ui: var(--font);
  --r: 6px;
  --r-sm: 6px;
  --page-bg:
    radial-gradient(1100px 700px at 88% -12%, rgba(167, 139, 250, 0.05), transparent 60%),
    radial-gradient(1300px 850px at 8% 4%, rgba(124, 58, 237, 0.09), transparent 62%),
    var(--bg);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Panels carry their own display value (grid, flex), which outranks the user
   agent rule for [hidden], so the attribute has to win explicitly. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

/* Legacy scrollbar styling for browsers without standard scrollbar support. */
::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-track:vertical {
  border-left: 1px solid var(--line);
}

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: var(--r);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  background: var(--page-bg);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: clamp(14px, 12.8px + 0.16vw, 16px);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--sel);
  color: var(--fg);
}

a {
  color: var(--purple);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

a:hover {
  border-bottom-color: var(--purple);
}

:focus-visible {
  outline: 1px solid var(--purple);
  outline-offset: 3px;
}

.page {
  min-height: 100dvh;
  padding: 28px 20px 56px;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
}

/* ---- demo overview ---- */

.demo-note {
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  border-radius: var(--r);
  background: var(--bg-raise);
  padding: 10px 14px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 82ch;
}

.demo-note summary {
  color: var(--fg);
  cursor: pointer;
}

.demo-note summary span {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.demo-note[open] summary {
  margin-bottom: 12px;
}

.demo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 12px;
}

/* Two skins make links the same ink as the body text, so underline always. */
.demo-links a,
.foot a {
  border-bottom-color: currentColor;
}

/* ---- masthead ---- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 24px;
  padding-bottom: 18px;
}

/* Use one system monospace font: the web font lacks block-art glyphs,
   so mixing it with fallback glyphs misaligns the spaces. */
.mark {
  color: var(--purple);
  font-family: monospace;
  font-size: clamp(6px, 1.5vw, 6.4px);
  line-height: 1.2;
  letter-spacing: 0;
  font-variant-ligatures: none;
  text-shadow: var(--mark-glow);
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.mark-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.masthead-meta {
  color: var(--muted);
  font-size: 12.5px;
}

.masthead-meta #stat-entries,
.masthead-meta #stat-categories {
  color: var(--fg);
}

.masthead-meta .unit {
  color: var(--muted);
}

.sep::before {
  content: "/";
  color: var(--faint);
  margin: 0 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- toolbar ---- */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.find {
  position: relative;
  flex: 1 1 auto;
  max-width: 520px;
  display: flex;
  align-items: center;
}

.search {
  width: 100%;
  min-height: 44px;
  background: var(--bg-raise);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 74px 8px 14px;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}

.search::placeholder {
  color: var(--muted);
}

.clear {
  position: absolute;
  right: 6px;
  min-height: 36px;
  padding: 0 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.clear:hover {
  color: var(--purple);
}

/* ---- period filters ---- */

.rail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.12s var(--ease), border-color 0.12s var(--ease), background 0.12s var(--ease);
}

.chip:hover {
  color: var(--fg);
  border-color: var(--border);
}

.chip.on {
  background: var(--pill-bg);
  border-color: var(--border-strong);
  color: var(--fg);
}

.chip-count {
  color: var(--muted);
  font-size: 11.5px;
}

.chip.on .chip-count {
  color: var(--purple);
}

/* ---- entry modal ---- */

.entry-dialog {
  margin: auto;
  width: min(640px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  background: var(--bg-raise);
  color: var(--muted);
  border: 0;
  border-radius: var(--r);
  overflow: auto;
}

.entry-dialog::backdrop {
  background: rgb(0 0 0 / 60%);
}

body:has(.entry-dialog[open]) {
  overflow: hidden;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  background: var(--bg-raise);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin: 0;
}

.form-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-head h2 {
  color: var(--fg);
  font-size: 13px;
  font-weight: 700;
}

.icon-btn {
  min-height: 34px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--fg);
  border-color: var(--border);
}

.field.wide {
  grid-column: 1 / -1;
}

.entry-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.entry-form input,
.entry-form textarea {
  width: 100%;
  min-height: 42px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 9px 12px;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}

.entry-form input::placeholder,
.entry-form textarea::placeholder {
  color: var(--muted);
}

.entry-form input:focus,
.entry-form textarea:focus {
  border-color: var(--border-strong);
}

.entry-form textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.7;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn {
  min-height: 44px;
  background: var(--pill-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--purple);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}

.btn:hover {
  background: var(--pill-bg-hover);
  color: var(--fg);
}

.btn:active {
  transform: translateY(1px);
}

.form-error {
  color: var(--danger);
  font-size: 12px;
}

/* ---- the feed ---- */

.results-label {
  color: var(--muted);
  font-size: 12px;
  margin: 16px 0 0;
}

.results-label:empty {
  display: none;
}

.feed {
  list-style: none;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.row {
  border-bottom: 1px solid var(--line);
}

.row-main {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 16px;
  width: 100%;
  min-height: 52px;
  padding: 13px 4px;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s var(--ease), background 0.12s var(--ease);
}

.row-main:hover {
  background: var(--row-hover);
  border-left-color: var(--border);
}

.row.open .row-main {
  border-left-color: var(--accent);
}

.row-date {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-title {
  color: var(--fg);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.row.open .row-title {
  font-weight: 700;
}

.row-period {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.row-detail {
  padding: 0 4px 18px 96px;
  max-width: 82ch;
}

.row-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.row-remarks {
  margin-top: 12px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.75;
}

.row-remarks span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  list-style: none;
}

.tags li {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--muted);
  font-size: 11px;
}

.row-actions {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.row-actions button {
  min-height: 34px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.row-actions button:hover {
  color: var(--purple);
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 32px 0;
  border-top: 1px solid var(--line);
}

/* ---- footer ---- */

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}

@media (max-width: 640px) {
  .entry-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .row-main {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 6px 12px;
  }

  .row-period {
    grid-column: 2;
  }

  .row-detail {
    padding-left: 16px;
  }
}

/* ---- view tabs ---- */

.views {
  display: flex;
  gap: 6px;
  margin: 18px 0 14px;
  border-bottom: 1px solid var(--line);
}

.view-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  min-height: 44px;
  cursor: pointer;
}

.view-tab:hover {
  color: var(--purple);
}

/* Keep keyboard focus visible on form controls. */
.entry-form input:focus-visible,
.entry-form textarea:focus-visible,
.search:focus-visible {
  outline: 1px solid var(--purple);
  outline-offset: 2px;
}

.view-tab.on {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* ---- logbook ---- */

.book-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.book-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  min-height: 44px;
  cursor: pointer;
}

.book-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.book-note {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 18px;
}

.book-summary {
  display: block;
  color: var(--fg);
  margin-top: 4px;
}

.row-edit {
  display: block;
  white-space: nowrap;
  margin-top: 2px;
  /* 44px would double the height of every row, so this sits at the 24px
     minimum target size instead, which a dense table can carry. */
  padding: 6px 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.row-edit:hover {
  color: var(--purple);
}

.book-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12.5px;
}

.col-date {
  width: 16%;
  white-space: nowrap;
}
.col-work {
  width: 56%;
}
.col-remarks {
  width: 28%;
}

.book-table th,
.book-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.book-table thead th {
  color: var(--purple);
  font-size: 11.5px;
  font-weight: 700;
  background: var(--sel);
}

.book-table td {
  color: var(--muted);
}

/* The period heading spans all three columns, the way it is written by hand
   across the top of a page in the UiTM book. */
.book-table .period th {
  background: var(--bg-raise);
  color: var(--fg);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

.col-work strong {
  color: var(--fg);
  font-weight: 700;
}

.work-body {
  display: block;
  margin-top: 6px;
  line-height: 1.65;
}

.book-empty {
  margin-top: 20px;
}

/* On screen the remarks stay readable but struck through, so it is obvious
   they exist and are being withheld from the paper copy. */
body.hide-remarks .remark-text {
  text-decoration: line-through;
  text-decoration-color: var(--faint);
}

/* On a phone the three columns squeeze to a few words per line, so the table
   keeps a readable width and scrolls sideways instead. The page itself never
   scrolls sideways; only this container does. */
@media screen and (max-width: 760px) {
  .book-scroll {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--r);
  }

  .book-table {
    min-width: 640px;
    font-size: 11.5px;
  }

  .book-table th,
  .book-table td {
    padding: 7px 8px;
  }
}

/* ---- print: the page that gets handed in ---- */

@page {
  size: A4;
  margin: 18mm 14mm;
}

@media print {
  /* Everything that is screen furniture is dropped: what is left on paper is
     the three-column table and nothing else. */
  .demo-note,
  .masthead,
  .views,
  .layout,
  .book-bar,
  .book-note,
  .foot {
    display: none !important;
  }

  html,
  body,
  .page,
  .shell {
    background: #fff;
    color: #000;
    padding: 0;
    margin: 0;
    max-width: none;
  }

  .book[hidden] {
    display: block !important;
  }

  /* Chromium clips a collapsed border that sits on the page-box edge, so the
     header row loses its top rule on every page, including the repeats. The
     rule is drawn inside the cell instead, where nothing clips it. A border
     is used rather than a background so it survives with background graphics
     switched off in the print dialog. */
  .book-table thead th {
    position: relative;
  }

  .book-table thead th::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    border-top: 0.6pt solid #000;
  }

  .book-table {
    width: 100%;
    font-size: 10.5pt;
    color: #000;
  }

  .book-table thead {
    display: table-header-group;
  }

  .book-table th,
  .book-table td {
    border: 0.6pt solid #000;
    color: #000;
    background: transparent;
    padding: 3mm;
  }

  .book-table thead th,
  .book-table .period th {
    font-size: 9.5pt;
    background: transparent;
    color: #000;
  }

  .book-table tr,
  .book-table .period th {
    break-inside: avoid;
  }

  .book-table .period th {
    background: transparent;
    text-align: center;
  }

  .col-work strong {
    color: #000;
  }

  .row-edit {
    display: none;
  }

  /* Unchecked toggle: the column prints empty, sized for a handwritten note.
     visibility keeps the cell height and the border, and keeps the text out of
     the PDF text layer, which colour: transparent would not. */
  body.hide-remarks .remark-text {
    visibility: hidden;
    text-decoration: none;
  }
}
