:root {
  --ink: #1c1c1e;
  --muted: #6b6b70;
  --line: #d4d4d8;
  --panel: #f6f6f7;
  --desk: #e4e4e7;
  --accent: #1f4fd8;
  --text_edge: #ababab;      /* The top edge of a text block being edited: 67% grey. */
  --text_handle: #ababab;    /* Its squares: the same. */
  font-family: system-ui, sans-serif;
  font-size: 15px;
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

[hidden] { display: none !important; }

button, input { font: inherit; color: inherit; }

button {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  cursor: pointer;
}

button:hover { border-color: var(--muted); }

button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

input[type="text"], select.notebook_pick {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font: inherit;
  color: inherit;
}

h2 {
  margin: 1.4rem 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Start screen */

#start {
  max-width: 28rem;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

#start h1 { margin: 0 0 1.5rem; font-size: 1.6rem; }
#start label { display: block; margin: 1rem 0 0.3rem; }
#start section { margin-top: 1.5rem; }
#start section p { margin: 0 0 0.6rem; color: var(--muted); }
#start section button { margin-top: 0.6rem; }

.message { min-height: 1.4em; margin-top: 1.5rem; color: #b42318; }

.note { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.note.problem { color: #b42318; }
.file { margin: 0; overflow-wrap: anywhere; }

/* Session */

#session {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.group { display: flex; align-items: center; gap: 0.35rem; }

.swatch {
  width: 1.5rem;
  height: 1.5rem;
  padding: 3px;
  border-radius: 50%;
  background: var(--swatch);
  background-clip: content-box;
}

/* The same height as the buttons, so the toolbar does not change height. */
.toolbar button:not(.swatch), #text_size, #text_font {
  box-sizing: border-box;
  height: 2rem;
  padding-top: 0;
  padding-bottom: 0;
}

#text_size, #text_font {
  margin: 0;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font: inherit;
}

#text_size { width: 3.6rem; }
#text_font { padding-right: 0.3rem; }

/* The palette that "+" opens: no system dialog, which crashes Firefox on
   Linux (Hollis, 2026-10-04). */
.palette {
  position: absolute;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(8, 1.5rem);
  gap: 0.3rem;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}

.palette .swatch { width: 1.5rem; height: 1.5rem; }

.swatch.more {
  --swatch: white;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
}

.width_choice {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 1.9rem;
  padding: 0;
}

.width_choice span {
  display: block;
  width: 1.4rem;
  border-radius: 99px;
  background: var(--ink);
}

#zoom_in, #zoom_out {
  width: 2.2rem;
  padding: 0.1rem 0;
  font-size: 1.35rem;
  line-height: 1;
}

/* What concerns the page and the view, not the tool: it never moves. */
.toolbar_right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
}

.page_number { color: var(--muted); }
.status { min-width: 6.5rem; text-align: right; color: var(--muted); }
.status.problem { color: #b42318; }

.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.desk {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 1.25rem;
  background: var(--desk);
}

.page {
  position: relative;
  margin: 0 auto;
  background: white;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}

.page canvas, .page_image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Text being edited */

.text_field {
  position: absolute;
  z-index: 2;
  box-sizing: content-box;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  resize: none;
  overflow: hidden;
  outline: none;
}

.text_handle {
  position: absolute;
  z-index: 3;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border: 1px solid white;
  border-radius: 2px;
  background: var(--text_handle);
  cursor: move;
}

.text_handle.end { cursor: ew-resize; }

.text_edge {
  position: absolute;
  z-index: 3;
  height: 0;
  margin-top: -1px;
  border-top: 2px solid var(--text_edge);
  cursor: move;
}

.text_edge::before, .text_edge::after {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 8px;
  border-left: 2px solid var(--text_edge);
}

.text_edge::before { left: 0; }
.text_edge::after { right: 0; }

/* The top edge of a new block, while it is being dragged out. */
.text_preview {
  position: absolute;
  z-index: 3;
  height: 0;
  margin-top: -1px;
  border-top: 2px solid var(--text_edge);
  pointer-events: none;
}


.panel {
  width: 16rem;
  padding: 0 1rem 1rem;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.panel ul { margin: 0; padding: 0; list-style: none; }

.panel li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
}

.panel li.absent { color: var(--muted); }
.panel li label { flex: 1; }
.panel li .role { font-size: 0.8rem; color: var(--muted); }
.panel li .allow { order: 1; padding: 0.1rem 0.4rem; font-size: 0.75rem; }

.panel button { margin-top: 0.4rem; }

/* The notebook chooser */

.chooser {
  width: min(56rem, 90vw);
  height: min(36rem, 85vh);
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.25);
}

.chooser::backdrop { background: rgb(0 0 0 / 0.3); }

.chooser header { display: flex; align-items: center; }
.chooser header h2 { flex: 1; margin: 0; }
.chooser header button { width: 2rem; padding: 0.2rem 0; font-size: 1.1rem; line-height: 1; }

.chooser_body {
  display: flex;
  gap: 1rem;
  height: calc(100% - 4rem);
  margin-top: 0.75rem;
}

.chooser_notebooks {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 12rem;
  overflow: auto;
}

.chooser_notebooks button { text-align: left; }

.chooser_pages {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.75rem;
  align-content: start;
  overflow: auto;
}

.page_card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem;
}

.page_card img {
  width: 100%;
  aspect-ratio: 210 / 297;
  object-fit: contain;
  background: var(--desk);
}

.page_card span { font-size: 0.8rem; }

/* The file chooser */

#file_chooser[open] { display: flex; flex-direction: column; }

.files_place, .files_save {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.files_place input, .files_save input { flex: 1; min-width: 0; }

/* Directories down the left, one to a line; the files beside them.  Each
   scrolls by itself, as in the notebook chooser. */
.files_body {
  display: flex;
  flex: 1;
  gap: 1rem;
  min-height: 0;
  margin-top: 0.75rem;
}

.files_directories {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 0.3rem;
  width: 12rem;
  overflow: auto;
}

.files_directories button { text-align: left; overflow-wrap: anywhere; }

.files_entries {
  flex: 1;
  overflow: auto;
}

.files_shrink { display: block; margin-top: 0.75rem; font-size: 0.9rem; }

.files_existing {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.files_images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.75rem;
  align-content: start;
}

.file_card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem;
}

.file_card canvas {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--desk);
}

.file_card span { font-size: 0.8rem; overflow-wrap: anywhere; }

.tooltip {
  position: fixed;
  z-index: 10;
  max-width: 20rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-size: 0.85rem;
  line-height: 1.35;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.25);
  pointer-events: none;
}

.report {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
