/* Un aide-mémoire: cream paper notebook, large type, calm.
   Light only on purpose: one predictable look for Jean-Paul. */
:root {
  color-scheme: light;
  --bg: #efe7d8;          /* page / header paper */
  --paper: #f8f2e7;       /* board */
  --card: #fffcf6;        /* notes */
  --line: #dccfb9;
  --ink: #26221d;
  --ink-soft: #564c42;    /* 7:1 on --paper */
  --field: #857664;       /* input borders, 3:1+ */
  --accent: #2c4d78;      /* fountain-pen blue, white text 8.9:1 */
  --accent-soft: #e4e9f1;
  --danger: #a1271c;
  --r: 14px;
  --shadow: 0 1px 2px rgb(92 70 38 / .08), 0 10px 28px rgb(92 70 38 / .10);
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 22px/1.5 var(--sans);
}
h1, h2 { font-family: var(--serif); font-weight: 600; margin: 0; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  min-height: 60px;
  padding: 0 26px;
  border: 2px solid var(--field);
  border-radius: var(--r);
  background: var(--card);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fffcf6; }
.btn:disabled { opacity: .6; cursor: progress; }
.linkish {
  min-height: 56px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 18px;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.error { color: var(--danger); font-weight: 700; margin: 0; min-height: 1.5em; }

/* ---------- Header ---------- */
.app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.top { flex: none; padding: 22px 32px 0; border-bottom: 2px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 24px; justify-content: space-between; }
.top h1 { font-size: clamp(28px, 1.2rem + 1.4vw, 42px); line-height: 1.15; }
.admin { display: flex; align-items: center; gap: 16px; flex: none; }
.save { font-size: 18px; color: var(--ink-soft); min-width: 9ch; text-align: right; }
.save:empty { display: none; }
.save.is-error { color: var(--danger); font-weight: 700; }

/* Big edit switch */
.switch {
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 0 18px 0 12px;
  border: 2px solid var(--field); border-radius: var(--r);
  background: var(--card); font-weight: 700; cursor: pointer;
}
.switch-track {
  position: relative; width: 60px; height: 34px; border-radius: 999px;
  background: #cbbda6; transition: background-color .2s ease;
}
.switch-thumb {
  position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%;
  background: #fffcf6; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s ease;
}
.switch[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.switch[aria-checked="true"] .switch-track { background: var(--accent); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(26px); }

/* Folder tabs sitting on the board */
.tabs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 20px 0 -2px; }
.tab {
  min-height: 60px; padding: 0 28px;
  border: 2px solid var(--line); border-bottom: 0;
  border-radius: var(--r) var(--r) 0 0;
  background: #e6dcca; color: var(--ink-soft);
  font-size: 23px; font-weight: 700; cursor: pointer;
}
.tab[aria-current="page"] {
  min-height: 66px;
  background: var(--paper); color: var(--ink);
  border-color: var(--line); border-bottom: 2px solid var(--paper);
}
.tab-add { background: transparent; border-style: dashed; color: var(--accent); }
.tab-tool {
  width: 56px; height: 56px; margin-bottom: 4px;
  border: 2px solid var(--line); border-radius: var(--r);
  background: var(--card); font-size: 24px; cursor: pointer;
}

/* ---------- Board ---------- */
.scroller { flex: 1; overflow: auto; background: var(--paper); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.board { position: relative; width: 3000px; height: 2000px; }
.board.editing {
  background-image: radial-gradient(#d6c8b0 1.3px, transparent 1.6px);
  background-size: 40px 40px;
}
.empty, .load-error {
  position: absolute; left: 48px; top: 40px; max-width: 34ch;
  margin: 0; color: var(--ink-soft); font-size: 24px;
}
.load-error { display: grid; gap: 18px; justify-items: start; color: var(--ink); }

/* ---------- Note ---------- */
.note {
  position: absolute;
  min-width: 240px; max-width: 1400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.note-head { padding: 22px 26px 0; display: flex; align-items: flex-start; gap: 12px; }
.note-title {
  flex: 1; font-size: 30px; line-height: 1.2;
  padding-bottom: 14px; border-bottom: 2px solid #ece2d1;
}
.note-body { padding: 18px 26px 24px; display: grid; gap: 16px; }
.note-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-media { display: block; width: 100%; height: auto; border-radius: 10px; background: #ece4d6; }
.note-frame { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; background: #ece4d6; }

/* Numbered steps look like steps */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.steps li { display: grid; grid-template-columns: 46px 1fr; gap: 16px; align-items: start; }
.step-n {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent); color: #fffcf6; font-weight: 700; font-size: 22px;
}
.steps li > span:last-child { padding-top: 5px; overflow-wrap: anywhere; }

.link-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 72px; padding: 12px 24px;
  border-radius: var(--r); background: var(--accent); color: #fffcf6;
  font-size: 24px; font-weight: 700; text-decoration: none; text-align: center;
}
.link-host { display: block; color: var(--ink-soft); font-size: 18px; text-align: center; overflow-wrap: anywhere; }

/* Edit mode note */
.board.editing .note { resize: horizontal; overflow: hidden; }
.board.editing .note-head {
  padding: 8px 8px 8px 16px; background: #f1e9db; border-bottom: 1px solid var(--line);
  align-items: center; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.board.editing .note-title { font-size: 24px; padding: 0; border: 0; }
.board.editing .note-title.untitled { color: var(--ink-soft); font-style: italic; font-weight: 500; }
.grip { color: var(--ink-soft); font-size: 26px; line-height: 1; }
.note.dragging { box-shadow: 0 2px 4px rgb(92 70 38 / .1), 0 22px 48px rgb(92 70 38 / .22); }
.note.dragging .note-head { cursor: grabbing; }
.icon-btn {
  flex: none; width: 56px; height: 56px;
  border: 2px solid var(--line); border-radius: var(--r);
  background: var(--card); font-size: 24px; cursor: pointer;
}
.icon-btn.danger:hover { border-color: var(--danger); }

.fab {
  position: fixed;
  right: max(28px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  min-height: 68px; padding: 0 30px;
  border: 0; border-radius: var(--r);
  background: var(--accent); color: #fffcf6;
  font-size: 26px; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 28px rgb(44 77 120 / .35);
}

/* ---------- Dialog ---------- */
.dlg {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 32px;
  border: 0; border-radius: var(--r);
  background: var(--card); color: var(--ink);
  box-shadow: 0 24px 64px rgb(38 34 29 / .3);
}
.dlg::backdrop { background: rgb(38 34 29 / .45); }
.dlg h2 { font-size: 32px; margin-bottom: 20px; }
.dlg form { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
.field label { font-weight: 700; font-size: 20px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 60px; padding: 12px 16px;
  border: 2px solid var(--field); border-radius: var(--r);
  background: #fff; font-size: 21px;
}
.field textarea { min-height: 180px; resize: vertical; line-height: 1.45; }
.field input[type="file"] { padding: 14px; }
.field input::placeholder { color: #7a6d5e; }
#f-error:empty { display: none; }
.help { margin: 0; font-size: 18px; color: var(--ink-soft); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(640px, 100%);
  padding: clamp(28px, 5vw, 56px);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.login-card h1 { font-size: clamp(30px, 1.3rem + 2vw, 46px); line-height: 1.15; margin-bottom: 36px; }
.login-card form { display: grid; gap: 14px; }
.login-hint { font-size: 26px; font-weight: 700; }
.login-card input {
  width: 100%; min-height: 80px; padding: 0 22px;
  border: 2px solid var(--field); border-radius: var(--r);
  background: #fff; font-size: 34px; letter-spacing: .08em;
}
.login-card input[aria-invalid="true"] { border-color: var(--danger); }
.btn.big { min-height: 76px; font-size: 28px; }

/* ---------- Smaller screens ---------- */
@media (max-width: 1100px) {
  .top { padding: 18px 20px 0; }
  .top-row { flex-wrap: wrap; }
}
@media (max-width: 700px) {
  body { font-size: 20px; }
  /* phone: page scrolls, board keeps its own two-way scroll */
  .app { height: auto; overflow: visible; }
  .top { padding: 16px 16px 0; }
  .top-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .admin { flex-wrap: wrap; }
  .save { text-align: left; min-width: 0; }
  .tab { padding: 0 18px; font-size: 20px; }
  .scroller { flex: none; height: 78dvh; }
  .fab { right: 16px; bottom: 16px; }
  .dlg { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
