*, *::before, *::after { box-sizing: border-box; }

html { min-width: 320px; background: var(--background); }
body.journal-page {
  --sheet: #f6f7f9;
  --rule: #e2e7f0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--background);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* The binder tabs below replace the header class switcher on this page. */
.journal-page .class-switcher { display: none; }

button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled, input:disabled { cursor: default; opacity: .5; }
a { color: inherit; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20000;
  padding: 10px 13px;
  border-radius: 5px;
  background: #fff;
  color: var(--blue);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }
:is(button, a, input, textarea):focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.journal-main {
  width: min(1260px, 100%);
  margin: 0 auto;
  padding: 34px 32px 64px;
}
.journal-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 26px;
}
.eyebrow {
  margin-bottom: 7px;
  color: var(--blue);
  font-size: 10px !important;
  font-weight: 700;
  letter-spacing: 1.8px !important;
}
.journal-intro h1 { font: 700 clamp(38px, 5vw, 66px)/.95 'OffBit', monospace; }
.journal-intro-copy { max-width: 420px; color: var(--muted); }

/* ---------- Binder tabs ---------- */
.binder-tabs-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 0 14px;
}
.binder-tabs {
  display: flex;
  align-items: flex-end;
  min-width: 0;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.binder-tabs::-webkit-scrollbar { display: none; }
.binder-tab {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 8px;
  max-width: 220px;
  min-height: 42px;
  margin: 4px 0 0;
  padding: 8px 16px;
  border: 1px solid #c9cdd5;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #d6d9df;
  color: var(--muted);
  transition: background 150ms, color 150ms, min-height 150ms;
}
.binder-tab:hover { background: #e7e9ee; color: var(--ink); }
.binder-tab[aria-selected="true"] {
  position: relative;
  z-index: 1;
  min-height: 46px;
  margin-top: 0;
  border-color: #d0d4dc;
  background: var(--sheet);
  color: var(--blue);
  font-weight: 700;
}
/* Hide the sheet border under the selected tab so they read as one piece. */
.binder-tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--sheet);
}
.binder-tab:focus-visible { outline-offset: -3px; }
.binder-tab-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.binder-tab-badge {
  display: grid;
  place-items: center;
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ffd98a;
  color: #5b3d00;
  font: 700 12px/1 'OffBit', monospace;
}
.binder-add {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  margin-bottom: 4px;
  border: 1px dashed #a9b3c4;
  border-radius: 8px;
  color: var(--blue);
  font: 700 22px/1 'OffBit', monospace;
  text-decoration: none;
}
.binder-add:hover { border-style: solid; background: #fff; }

.binder-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  grid-template-areas: "entries memo";
  align-items: start;
  gap: 22px;
  padding: 24px;
  border: 1px solid #d0d4dc;
  border-radius: 14px;
  background: var(--sheet);
  box-shadow: 0 4px 18px #15243d08;
}

/* ---------- Pense-bête ---------- */
.memo-card {
  grid-area: memo;
  position: sticky;
  top: 18px;
  padding: 20px 18px 18px;
  border: 1px solid #ecd9a6;
  border-radius: 12px;
  background: #fff8e3;
  box-shadow: 0 3px 0 #f0e2bb;
}
.memo-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.memo-kicker {
  margin-bottom: 3px;
  color: #8a6400;
  font-size: 10px !important;
  font-weight: 700;
  letter-spacing: 1.6px !important;
  text-transform: uppercase;
}
.memo-card h2 { font: 700 24px/1.05 'OffBit', monospace; }
.memo-count {
  display: grid;
  place-items: center;
  flex: none;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 50%;
  background: #ffd98a;
  color: #5b3d00;
  font: 700 18px/1 'OffBit', monospace;
}
.memo-form { display: flex; gap: 6px; margin-top: 16px; }
.memo-form input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid #e3cf98;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
.memo-form input::placeholder { color: #9b8f72; }
.memo-form button {
  flex: none;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #17243d;
  border-radius: 7px;
  background: #17243d;
  color: #fff;
}
.memo-form button:hover:not(:disabled) { background: #000; }
.memo-error { margin-top: 8px; color: #a1281a; }
.memo-list { margin: 14px 0 0; padding: 0; list-style: none; }
.memo-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px dashed #ead9ab;
}
.memo-item label {
  display: flex;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
  gap: 9px;
  padding: 3px 0;
  cursor: pointer;
}
.memo-item input {
  flex: none;
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: var(--blue);
  cursor: pointer;
}
.memo-item span { min-width: 0; overflow-wrap: anywhere; }
.memo-item.is-done span { color: #8d8676; text-decoration: line-through; }
.memo-remove {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8d8676;
  font-size: 18px;
  line-height: 1;
}
.memo-remove:hover { background: #f6e7bd; color: #5b3d00; }
.memo-empty { margin-top: 14px; color: #7a6f55; }
.memo-clear {
  margin-top: 12px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: #6c5200;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Entries ---------- */
.entries-column { grid-area: entries; min-width: 0; }
.entries-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.new-entry-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.new-entry-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 43px;
  padding: 0 4px 0 12px;
  border: 1px solid #c7ccd6;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
}
.new-entry-date input,
.entry-date input {
  min-height: 34px;
  padding: 4px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
}
.journal-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  padding: 9px 15px;
  border: 1px solid #c7ccd6;
  border-radius: 6px;
  background: #fff;
  transition: background 150ms, border-color 150ms, transform 150ms;
}
.journal-button:hover:not(:disabled) { border-color: #8ea9d6; background: #eaf0fb; }
.journal-button:active:not(:disabled) { transform: translateY(1px); }
.journal-button-primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.journal-button-primary:hover:not(:disabled) { border-color: #003da3; background: #003da3; }
.entries-search {
  display: flex;
  align-items: center;
  flex: 0 1 290px;
  gap: 8px;
  min-width: 180px;
  min-height: 43px;
  padding: 0 12px;
  border: 1px solid #c7ccd6;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
}
.entries-search svg { flex: none; width: 15px; height: 15px; }
.entries-search input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.entries-search input:focus-visible { outline: none; }
.entries-search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px #024bc833; }
.journal-privacy-note { margin: 14px 2px 0; color: var(--muted); font-size: 13px; line-height: 19px; }
.entries-summary { min-height: 20px; margin: 14px 2px 10px; color: var(--muted); }

.entries-list { display: grid; gap: 16px; }
.journal-entry {
  position: relative;
  padding: 18px 20px 12px 34px;
  border: 1px solid #d6dae2;
  border-radius: 10px;
  background: #fff;
  scroll-margin: 20px;
}
/* Notebook margin line. */
.journal-entry::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 20px;
  width: 1px;
  background: #f1b9b1;
}
.journal-entry.is-today { border-color: #9db9ea; box-shadow: 0 0 0 3px #024bc812; }
.entry-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.entry-titles { min-width: 0; }
.entry-relative {
  margin-bottom: 3px;
  color: var(--blue);
  font-size: 10px !important;
  font-weight: 700;
  letter-spacing: 1.4px !important;
  text-transform: uppercase;
}
.journal-entry h2 { font: 700 23px/1.1 'OffBit', monospace; overflow-wrap: anywhere; }
.entry-tools { display: flex; align-items: center; flex: none; gap: 4px; }
.entry-date input { color: var(--muted); }
.entry-date input:hover { background: #f1f3f7; }
.entry-remove {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #7a818d;
}
.entry-remove svg { width: 15px; height: 15px; }
.entry-remove:hover { background: #fbe9e6; color: #a1281a; }
.entry-labels { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 6px; }
.entry-label {
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid #d5deee;
  border-radius: 999px;
  background: #f3f6fc;
  color: #2c4f8f;
  font-size: 12px !important;
}
.entry-label:hover { border-color: #9db9ea; background: #e5edfb; }
body.journal-page .entry-text {
  display: block;
  width: 100%;
  min-height: 120px;
  margin: 0;
  padding: 2px 0 0;
  overflow: hidden;
  resize: none;
  border: 0;
  border-radius: 0;
  background: transparent linear-gradient(transparent 23px, var(--rule) 23px) 0 2px / 100% 24px local;
  color: var(--ink);
  font-size: 14px !important;
  line-height: 24px !important;
  letter-spacing: .3px !important;
  white-space: pre-wrap;
}
body.journal-page .entry-text::placeholder { color: #9aa1ad; }
body.journal-page .entry-text:focus-visible { outline: none; }
.journal-entry:focus-within { border-color: #9db9ea; }
.entry-status { min-height: 20px; margin-top: 4px; color: #7a818d; font-size: 11px !important; text-align: right; }
.entries-more { width: 100%; margin-top: 16px; }

.entries-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 48px 24px;
  border: 1px dashed #b5c3dc;
  border-radius: 12px;
  background: #fff;
  text-align: center;
}
.entries-empty-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #e9effb;
  color: var(--blue);
  font-size: 22px;
}
.entries-empty strong { font: 700 25px/1.1 'OffBit', monospace; }
.entries-empty p { max-width: 420px; color: var(--muted); }
.entries-empty .journal-button { margin-top: 6px; }

.journal-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 10px 12px 10px 16px;
  border-radius: 8px;
  background: #17243d;
  color: #fff;
  box-shadow: 0 8px 24px #17243d40;
  transform: translateX(-50%);
}
.journal-toast button {
  flex: none;
  padding: 6px 10px;
  border: 1px solid #ffffff55;
  border-radius: 5px;
  background: transparent;
  color: #fff;
  font-weight: 700;
}
.journal-toast button:hover { background: #ffffff1a; }
.journal-toast button:focus-visible { outline-color: #fff; }

@media (max-width: 960px) {
  .journal-main { padding-inline: 22px; }
  .binder-sheet {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "memo" "entries";
  }
  .memo-card { position: static; }
}
@media (max-width: 760px) {
  .journal-main { padding: 25px 16px 48px; }
  .journal-intro { align-items: flex-start; flex-direction: column; gap: 12px; }
  .binder-tabs-row { padding: 0 6px; }
  .binder-sheet { padding: 14px; border-radius: 12px; }
  .entries-search { flex: 1 1 100%; }
}
@media (max-width: 480px) {
  .journal-intro h1 { font-size: 39px; }
  .new-entry-form { width: 100%; }
  .new-entry-date, .new-entry-form .journal-button { flex: 1 1 100%; }
  .new-entry-date input { flex: 1; }
  .journal-entry { padding: 14px 12px 10px 26px; }
  .journal-entry::before { left: 14px; }
  .entry-header { flex-direction: column; gap: 6px; }
  .entry-tools { align-self: stretch; justify-content: space-between; }
  .journal-toast { right: 16px; left: 16px; justify-content: space-between; transform: none; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
@media print {
  .compact-header, .binder-tabs-row, .entries-toolbar, .entry-labels, .entry-tools,
  .memo-form, .memo-clear, .memo-remove, .entries-more, .entry-status, .journal-toast { display: none !important; }
  body.journal-page { background: #fff; }
  .journal-main { padding: 0; }
  .binder-sheet { display: block; padding: 0; border: 0; box-shadow: none; background: #fff; }
  .memo-card { margin-bottom: 18px; box-shadow: none; }
  .journal-entry { break-inside: avoid; margin-bottom: 12px; }
}
