/* ==========================================================
   NextNotes - styles.css
   1. Colours (colour themes, light + dark)   2. Base   3. Layout
   4. Sidebar   5. Main page and journal   6. Small screens
   ========================================================== */

/* 1. Colour themes. Each one is only a few numbers (the Themes button in the menu picks one):
     --h   the colour itself, a number from 0 to 360 (green 166, blue 255, red 27 ...)
     --c   how strong the colour is in the menu and on buttons
     --cb  how strong the light shade of it is (used in dark mode)
     --l   how light the menu is (a light colour like orange needs a little more)
   To add a theme: copy a line, change the name and the numbers, then add a matching
   button in index.html (class "swatch", data-palette="name"). */
:root,
[data-palette="green"]  { --h: 166; --c: 0.071; --cb: 0.094; --l: 0.482; }
[data-palette="blue"]   { --h: 255; --c: 0.135; --cb: 0.105; --l: 0.50; }
[data-palette="purple"] { --h: 300; --c: 0.135; --cb: 0.12;  --l: 0.48; }
[data-palette="pink"]   { --h: 355; --c: 0.14;  --cb: 0.12;  --l: 0.52; }
[data-palette="red"]    { --h: 27;  --c: 0.14;  --cb: 0.115; --l: 0.50; }
[data-palette="orange"] { --h: 55;  --c: 0.12;  --cb: 0.13;  --l: 0.53; }
[data-palette="mono"]   { --h: 85;  --c: 0.004; --cb: 0.012; --l: 0.24; }

/* Light colours, made from the numbers above: change a number there and the whole site updates */
:root {
  --brand: oklch(var(--l) var(--c) var(--h));             /* the menu */
  --brand-ink: oklch(var(--l) var(--c) var(--h));         /* the same colour, kept in dark mode too */
  --brand-bright: oklch(0.778 var(--cb) var(--h));        /* a light shade for the dark menu */
  --brand-soft: oklch(0.935 min(var(--c) * 0.338, 0.03) var(--h));
  --brand-deep: oklch(0.374 calc(var(--c) * 0.775) var(--h));
  --on-brand: oklch(0.968 min(var(--c) * 0.169, 0.014) var(--h));   /* text on the menu */
  --on-brand-muted: oklch(max(0.813, calc(0.813 + (var(--l) - 0.482) * 1.4)) calc(var(--c) * 0.59) var(--h));   /* a lighter menu gets lighter small text */
  --accent: var(--brand);                                 /* links and buttons on the page */
  --page: #ffffff;
  --text: oklch(0.273 calc(var(--c) * 0.24) var(--h));
  --text-muted: oklch(0.548 calc(var(--c) * 0.3) var(--h));
  --line: oklch(0.934 calc(var(--c) * 0.127) var(--h));
  --input-line: oklch(0.874 calc(var(--c) * 0.21) var(--h));
  --field-bg: #ffffff;
  --notice-bg: oklch(0.966 min(var(--c) * 0.155, 0.015) var(--h));
  --notice-line: oklch(0.898 min(var(--c) * 0.366, 0.045) var(--h));
  --paper: oklch(0.975 min(var(--c) * 0.13, 0.012) var(--h));      /* the pages of the journal */
  --todo: #e0a43a;
  --progress: #4a90d9;
  --done: #4caf7d;
  --danger: #b8433a;
  --danger-bg: #fbf1f0;
  --sidebar-width: 300px;
  --slide: 0.4s;                                          /* how long the menu takes to slide */
  --slide-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --font: "Figtree", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

/* Dark theme: only the values that change (switched by js/theme.js) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: oklch(0.357 calc(var(--c) * 0.634) var(--h));
  --accent: var(--brand-bright);
  --page: oklch(0.205 calc(var(--c) * 0.155) var(--h));
  --text: oklch(0.938 calc(var(--c) * 0.169) var(--h));
  --text-muted: oklch(0.74 calc(var(--c) * 0.352) var(--h));
  --line: oklch(0.31 calc(var(--c) * 0.31) var(--h));
  --input-line: oklch(0.377 calc(var(--c) * 0.366) var(--h));
  --field-bg: oklch(0.238 calc(var(--c) * 0.197) var(--h));
  --notice-bg: oklch(0.269 calc(var(--c) * 0.338) var(--h));
  --notice-line: oklch(0.363 calc(var(--c) * 0.493) var(--h));
  --paper: oklch(0.26 calc(var(--c) * 0.25) var(--h));
  --danger: #ef8f86;
  --danger-bg: #2a1e1d;
}

/* Black and white: a near black menu and, instead of pure white, a warm white with a little cream in it.
   (The other themes are built from their few numbers; this one also sets its whites by hand.) */
:root[data-palette="mono"] {
  --on-brand: oklch(0.965 0.01 85);
  --on-brand-muted: oklch(0.8 0.012 85);
}
:root[data-palette="mono"]:not([data-theme="dark"]) {
  --page: oklch(0.968 0.013 85);
  --field-bg: oklch(0.985 0.009 85);
  --paper: oklch(0.985 0.01 85);
  --text: oklch(0.24 0.008 85);
  --text-muted: oklch(0.5 0.01 85);
  --line: oklch(0.905 0.012 85);
  --input-line: oklch(0.845 0.014 85);
  --notice-bg: oklch(0.94 0.014 85);
  --notice-line: oklch(0.875 0.016 85);
}
:root[data-palette="mono"][data-theme="dark"] {
  --brand: oklch(0.33 0.006 85);
  --page: oklch(0.2 0.006 85);
  --field-bg: oklch(0.235 0.007 85);
  --paper: oklch(0.26 0.008 85);
  --text: oklch(0.935 0.012 85);
  --text-muted: oklch(0.74 0.012 85);
  --line: oklch(0.31 0.008 85);
  --input-line: oklch(0.38 0.009 85);
  --notice-bg: oklch(0.265 0.008 85);
  --notice-line: oklch(0.36 0.01 85);
}

/* 2. Base */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--page);
  line-height: 1.6;
}

h1, h2, h3, p, ul { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }

/* 3. Layout: sidebar on the left, page on the right */
.layout { display: flex; min-height: 100vh; }

.content {
  flex: 1;
  min-width: 0;
  max-width: 760px;
  padding: 72px clamp(24px, 6vw, 72px);
}

/* The main page is wider: the journal sits next to the list of pages */
.content.wide { max-width: 1240px; }

/* 4. Sidebar (the menu). The wrapper makes room for it and slides it away when it is
   closed; the menu inside keeps its width, so nothing in it gets squashed. */
.sidebar-wrap {
  position: sticky;
  top: 0;
  align-self: flex-start;
  flex-shrink: 0;
  width: calc(var(--sidebar-width) - var(--pull, 0px)); /* --pull: how far the edge was dragged past the narrowest width */
  height: 100vh;
  overflow: hidden;
  transition: width var(--slide) var(--slide-ease);
}
.menu-closed .sidebar-wrap { width: 0; }

.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100%;
  overflow-y: auto;
  padding: 28px 20px 20px;
  background: var(--brand);
  color: var(--on-brand);
  translate: calc(var(--pull, 0px) * -1) 0;
  transition: translate var(--slide) var(--slide-ease), width var(--slide) var(--slide-ease), opacity 0.2s;
}
.menu-closed .sidebar {
  translate: calc(var(--sidebar-width) * -1) 0;
  visibility: hidden; /* so its buttons cannot be reached with the Tab key while it is away */
  transition: translate var(--slide) var(--slide-ease), visibility 0s linear var(--slide);
}

/* While you drag the edge, the menu follows the mouse at once instead of sliding */
.menu-dragging .sidebar-wrap, .menu-dragging .resizer { transition: none; }
.menu-dragging .sidebar { transition: opacity 0.2s; }
.menu-will-close .sidebar { opacity: 0.5; } /* dragged far enough: letting go now closes the menu */
.menu-dragging, .menu-dragging * { cursor: col-resize !important; user-select: none; }

/* Logo on the left, the button that closes the menu on the right */
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 32px; }

/* The two buttons that close and open the menu */
.side-btn, .menu-open {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.side-btn svg, .menu-open svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-btn { width: 34px; height: 34px; border-radius: 8px; background: transparent; color: var(--on-brand-muted); }
.side-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.side-btn:focus-visible { outline: 2px solid #fff; }

/* The open button waits at the left edge of the page, half hidden, and only shows while the menu is
   closed. Point at it and it pops out; click it and the menu comes back. */
.menu-open {
  position: fixed;
  top: 16px;
  left: 0;
  z-index: 5;
  width: 44px;
  height: 40px;
  border-radius: 0 10px 10px 0;
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  visibility: hidden;
  translate: -100% 0;                 /* the menu is open: the button waits off the screen */
  transition: translate 0.3s var(--slide-ease), visibility 0s linear 0.3s, filter 0.15s;
}
.menu-open svg { translate: 11px 0; transition: translate 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); } /* the icon stays in the half you can see */
.menu-closed .menu-open {
  visibility: visible;
  translate: -22px 0;                 /* half of the button peeks out */
  transition: translate 0.4s 0.1s var(--slide-ease), visibility 0s, filter 0.15s;
}
.menu-closed .menu-open:hover, .menu-closed .menu-open:focus-visible {
  translate: 0 0;                     /* pointed at: it pops out fully */
  transition: translate 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s, filter 0.15s;
}
.menu-closed .menu-open:hover svg, .menu-closed .menu-open:focus-visible svg { translate: 0 0; }
.menu-open:hover { filter: brightness(1.15); }
.menu-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The edge of the menu: drag it to make the menu a little wider or narrower (sidebar.js). Drag it past
   the narrowest width, keep going and let go, and the menu closes. There is nothing drawn on the edge:
   the mouse pointer just changes into the arrows when you are on it. */
.resizer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: calc(var(--sidebar-width) - var(--pull, 0px) - 6px);
  z-index: 4;
  width: 12px;
  cursor: col-resize;
  touch-action: none;
  transition: left var(--slide) var(--slide-ease);
}
.menu-closed .resizer {
  left: -12px;
  visibility: hidden;
  transition: left var(--slide) var(--slide-ease), visibility 0s linear var(--slide);
}
.resizer:focus-visible { outline: none; background: color-mix(in oklch, var(--brand-bright) 55%, transparent); } /* shows for keyboard users only */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  border-radius: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}
.brand:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #fff;
  color: var(--brand-ink);
  font-size: 1.05rem;
  transition: scale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), rotate 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* The logo reacts to you: it tilts when you point at it (mouse only, a touch
   screen would leave it tilted), squeezes while you press and bounces on click. */
@media (hover: hover) { .brand:hover .brand-mark { scale: 1.1; rotate: -6deg; } }
.brand:active .brand-mark { scale: 0.88; rotate: 0deg; transition-duration: 0.1s; }
.brand-mark.pop { animation: logo-pop 0.55s; }
@keyframes logo-pop {
  0%   { transform: none; animation-timing-function: ease-out; }
  45%  { transform: scale(1.18) rotate(8deg); animation-timing-function: ease-in-out; }
  75%  { transform: scale(0.97) rotate(-4deg); animation-timing-function: ease-in-out; }
  100% { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .brand-mark { transition: none; }
  .brand-mark.pop { animation: none; }
}

/* While the name is being typed (see typeName in app.js) a cursor blinks behind the last letter */
.brand-text.typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 3px;
  background: currentColor;
  vertical-align: -0.12em;
  animation: caret 0.7s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.nav, .nav-secondary { display: flex; flex-direction: column; gap: 4px; }
.nav-secondary { margin-top: auto; padding-top: 28px; }

.nav-item, .nav-link, .theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-item { color: var(--on-brand); font-weight: 500; }
.nav-item.active { background: rgba(255, 255, 255, 0.2); font-weight: 600; }

/* Quieter links: smaller and muted */
.nav-link, .theme-toggle { color: var(--on-brand-muted); font-size: 0.875rem; }
.nav-link.active { color: #fff; }

.nav-item:hover, .nav-link:hover, .theme-toggle:hover { background: rgba(255, 255, 255, 0.1); }
.nav-item:focus-visible, .nav-link:focus-visible, .theme-toggle:focus-visible { outline: 2px solid #fff; }

.badge {
  margin-left: auto;
  min-width: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
}

.chevron {
  width: 7px;
  height: 7px;
  margin: 0 4px 0 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
[aria-expanded="true"] .chevron { transform: rotate(45deg); }

/* Tickets (opens under the Tickets item) */
.tickets-panel { padding: 8px 0 8px 12px; }
.ticket-form { display: flex; gap: 8px; margin-bottom: 12px; }

.ticket-form input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.ticket-form input::placeholder { color: var(--on-brand-muted); }
.ticket-form input:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); }

.ticket-form button {
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--brand-ink);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.ticket-form button:hover { background: var(--brand-soft); }
.ticket-form button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.ticket-list { display: flex; flex-direction: column; gap: 2px; list-style: none; }

.ticket-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--on-brand);
  font-size: 0.925rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.ticket-item:hover { background: rgba(255, 255, 255, 0.1); }
.ticket-item.active { background: rgba(255, 255, 255, 0.2); }
.ticket-item:focus-visible { outline: 2px solid #fff; }

.ticket-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { color: var(--on-brand-muted); font-size: 0.8rem; }
.empty { padding: 6px 4px; color: var(--on-brand-muted); font-size: 0.9rem; }

/* Round bubble with the initials of the person working on a ticket */
.bubble {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--page);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}
.bubble.empty { background: transparent; border: 1.5px dashed currentColor; color: var(--text-muted); font-weight: 500; }
.sidebar .bubble { background: var(--brand-soft); color: var(--brand-deep); }
.sidebar .bubble.empty { background: transparent; border-color: rgba(255, 255, 255, 0.5); color: var(--on-brand-muted); }

/* Done and Bin folders under the ticket list */
.folders {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/* Dark mode and Themes sit at the very bottom */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/* Dark mode switch */
.theme-toggle { justify-content: space-between; }

.switch {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.theme-toggle[aria-pressed="true"] .switch { background: var(--brand-bright); }
.theme-toggle[aria-pressed="true"] .switch::after { transform: translateX(14px); }

/* Themes: the button shows the colour you have now and opens a row of colours under it */
.palette-dot {
  width: 14px;
  height: 14px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--brand-bright);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.palette-panel {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 0.35s var(--slide-ease), visibility 0s linear 0.35s;
}
.palette-panel.open { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows 0.35s var(--slide-ease), visibility 0s; }
.palette-inner { min-height: 0; overflow: hidden; }
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); justify-items: center; gap: 12px 2px; padding: 10px 4px 6px; }

/* Each colour button is painted with its own theme numbers (see the list at the top) */
.swatch {
  position: relative;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: oklch(0.778 var(--cb) var(--h));
  cursor: pointer;
  transition: scale 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
@media (hover: hover) { .swatch:hover { scale: 1.12; } }
.swatch:active { scale: 0.92; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--brand), 0 0 0 3.5px #fff; }
.swatch:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.swatch::after { /* a tick on the colour that is chosen */
  content: "";
  position: absolute;
  top: 46%;
  left: 50%;
  width: 6px;
  height: 11px;
  border: solid rgba(0, 0, 0, 0.6);
  border-width: 0 2.5px 2.5px 0;
  rotate: 45deg;
  translate: -50% -50%;
  scale: 0;
  transition: scale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.swatch[aria-pressed="true"]::after { scale: 1; }

/* Black and white shows as a button that is half black, half warm white */
.swatch[data-palette="mono"], :root[data-palette="mono"] .palette-dot { background: linear-gradient(135deg, #1b1a18 50%, #f3efe6 50%); }

/* Status dots */
.dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; }
.sidebar .dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9); }
.dot.todo { background: var(--todo); }
.dot.progress { background: var(--progress); }
.dot.done { background: var(--done); }

/* 5. Main page */
h1 {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.lead { margin-top: 14px; max-width: 60ch; color: var(--text-muted); font-size: 1.1rem; }
.subtitle { margin-top: 48px; font-size: 1.05rem; font-weight: 600; }

/* "You are on the main page" message, with a cross to close it */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 28px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--notice-line);
  border-radius: 8px;
  background: var(--notice-bg);
  font-size: 0.95rem;
}

.notice-close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.notice-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.notice-close:hover { background: var(--notice-line); color: var(--text); }
.notice-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.notice.pop { animation: pop 0.5s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* The rest of the main page rises in each time you arrive on it (the logo brings you here) */
#view-main.enter > :not(.notice) { animation: rise 0.45s ease-out backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .notice.pop, #view-main.enter > :not(.notice) { animation: none; } }

.page-links, .progress-list {
  max-width: 480px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  list-style: none;
}

.page-links button {
  display: block;
  width: 100%;
  padding: 14px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.page-links strong { display: block; color: var(--accent); font-weight: 600; }
.page-links span { display: block; color: var(--text-muted); font-size: 0.95rem; }
.page-links button:hover strong { text-decoration: underline; }
.page-links button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.progress-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.progress-list strong { margin-left: auto; font-weight: 600; }

/* Main page: the list of pages on the left, the journal on the right.
   When there is not enough room they stack and the journal goes below. */
.main-split { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 48px; }
.main-left { flex: 1 1 240px; max-width: 400px; }
.main-right { flex: 2 1 480px; min-width: 0; container: journal / inline-size; }

/* Journal: a book with bookmarks on its right edge. A click on a bookmark turns the
   pages to that one (journal.js). To add a page, add a bookmark and a page in index.html. */
.journal {
  --turn: 0.75s;                                /* how long one page takes to turn */
  --ease: cubic-bezier(0.5, 0.05, 0.2, 1);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 16px;
}

.book {
  position: relative;
  z-index: 1;                                   /* above the bookmarks, so they come out from behind the pages */
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);   /* the spine, then the pages */
  min-height: 330px;
  border: 1px solid var(--line);
  border-radius: 8px 18px 18px 8px;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 18px 32px -18px rgba(0, 0, 0, 0.35);
}

.book::before { /* the spine, with a line of stitches */
  content: "";
  border-radius: 7px 0 0 7px;
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.5) 0 7px, transparent 7px 14px) 50% 0 / 2px 100% no-repeat,
    linear-gradient(90deg, color-mix(in oklch, var(--brand) 82%, black), var(--brand));
}

.leaves { position: relative; display: grid; perspective: 3000px; counter-reset: page; }

/* One page. All pages lie on top of each other; the first one is on top. */
.leaf {
  position: relative;
  grid-area: 1 / 1;
  z-index: calc(10 - var(--i));
  counter-increment: page;
  padding: 28px 34px 44px 30px;
  border-radius: 0 17px 17px 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.08), transparent 30px), var(--paper);
  transform-origin: 0 50%;                      /* pages turn around their left edge, the spine */
  backface-visibility: hidden;
  transition: transform var(--turn) var(--ease) var(--wait, 0s), box-shadow var(--turn) var(--ease) var(--wait, 0s);
}

/* A page that has been turned over: it lies on edge at the spine, out of sight.
   (--wait lets several pages turn one after the other when you jump ahead.) */
.leaf.turned {
  transform: rotateY(-90deg);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  visibility: hidden;
  transition: transform var(--turn) var(--ease) var(--wait, 0s), box-shadow var(--turn) var(--ease) var(--wait, 0s),
    visibility 0s linear calc(var(--turn) + var(--wait, 0s));
}

.leaf::before { /* page number */
  content: counter(page);
  position: absolute;
  right: 24px;
  bottom: 14px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.leaf::after { /* the page darkens while it turns away */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.45));
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--turn) var(--ease) var(--wait, 0s);
}
.leaf.turned::after { opacity: 1; }

.leaf h3 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.leaf h3::after { content: ""; display: block; width: 36px; height: 3px; margin: 10px 0 14px; border-radius: 3px; background: var(--accent); }
.leaf p { font-size: 0.975rem; line-height: 1.65; }
.leaf p + p, .leaf ul + p { margin-top: 12px; }
.leaf ul { display: grid; gap: 10px; list-style: none; }
.leaf li { display: flex; gap: 12px; font-size: 0.975rem; line-height: 1.65; }
.leaf li .dot { margin-top: 8px; }

/* The bookmarks stick out of the right edge of the book; the open one slides out further */
.bookmarks {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  margin-left: -12px;                           /* tucked under the edge of the book */
  padding: 26px 16px 26px 0;                    /* room on the right for the open bookmark to slide out */
}

.bookmark {
  min-width: 132px;
  padding: 11px 16px 11px 28px;
  border: 1px solid color-mix(in oklch, var(--accent) 35%, var(--line));
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: color-mix(in oklch, var(--accent) 16%, var(--page));
  color: var(--text);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: translate 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), scale 0.15s, background 0.25s, color 0.25s, border-color 0.25s, box-shadow 0.25s;
}
@media (hover: hover) { .bookmark:hover { translate: 5px 0; } }
.bookmark:active { scale: 0.97; }
.bookmark[aria-current="true"] {
  translate: 14px 0;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--page);
  box-shadow: 0 8px 18px -8px color-mix(in oklch, var(--accent) 80%, black);
}
.bookmark:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* A narrow journal (a phone, or a wide menu): the bookmarks move above the book, like index tabs */
@container journal (max-width: 460px) {
  .journal { grid-template-columns: minmax(0, 1fr); }
  .bookmarks { order: -1; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 6px; margin: 0 0 -1px; padding: 0 0 0 22px; }
  .bookmark { min-width: 0; padding: 8px 14px; border: 1px solid color-mix(in oklch, var(--accent) 35%, var(--line)); border-bottom: 0; border-radius: 10px 10px 0 0; }
  .bookmark[aria-current="true"] { translate: 0 -4px; border-color: var(--accent); }
  .leaf { padding: 22px 22px 44px 20px; }
}
@media (hover: hover) {
  @container journal (max-width: 460px) {
    .bookmark:hover { translate: 0 -2px; }
    .bookmark[aria-current="true"]:hover { translate: 0 -4px; }
  }
}

/* Ticket view */
.back {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.back:hover { text-decoration: underline; }

.ticket-code { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
#edit-form { margin-top: 20px; }
.meta { margin: 6px 0 32px; color: var(--text-muted); font-size: 0.9rem; }

.field { margin-bottom: 24px; }
.field label, .field-label { display: block; margin-bottom: 6px; font-size: 0.95rem; font-weight: 600; }

.field input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--input-line);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--text);
}
select { max-width: 240px; }
.field input { max-width: 320px; }
#edit-title { max-width: 480px; }
textarea { min-height: 180px; line-height: 1.5; resize: vertical; }
.field input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Ticket page: back link on the left, view / edit / bin icons on the right */
.ticket-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.tools { display: flex; align-items: center; gap: 20px; }

/* View mode: status, who is on it, notes */
.facts { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.9rem; }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.95rem; }
.who strong { color: var(--text); font-weight: 600; }
#read-notes { max-width: 60ch; margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.muted { color: var(--text-muted); }

/* Icon buttons: eye, pencil, bin */
.mode-toggle { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--input-line); border-radius: 10px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:hover { background: var(--notice-bg); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--accent); color: var(--page); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The bin stays quiet until you point at it */
.icon-btn.subtle { height: 34px; opacity: 0.7; }
.icon-btn.subtle:hover { background: var(--danger-bg); color: var(--danger); opacity: 1; }

/* Save changes: faded until something has changed */
.primary {
  padding: 10px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--page);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, filter 0.15s;
}
.primary:disabled { opacity: 0.35; cursor: not-allowed; }
.primary:not(:disabled):hover { filter: brightness(1.1); }
.primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hint { margin-top: 6px; color: var(--text-muted); font-size: 0.9rem; }

/* Lists on the Done and Bin pages */
.rows { max-width: 560px; margin-top: 12px; border-top: 1px solid var(--line); list-style: none; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; border-bottom: 1px solid var(--line); }
.row-main { flex: 1; min-width: 0; padding: 14px 2px; border: 0; background: none; color: var(--text); text-align: left; }
.row-main strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row-main span { display: block; color: var(--text-muted); font-size: 0.9rem; }
button.row-main { cursor: pointer; }
button.row-main:hover strong { color: var(--accent); text-decoration: underline; }
button.row-main:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row-actions { display: flex; gap: 8px; }
.empty-note { padding: 14px 2px; border-bottom: 1px solid var(--line); color: var(--text-muted); }

.small-btn {
  padding: 6px 12px;
  border: 1px solid var(--input-line);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
.small-btn:hover { background: var(--notice-bg); }
.small-btn.danger-text { color: var(--danger); }
.small-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Pop-up message ("Changes have been saved!"): bottom right corner. It is only
   for reading, so the mouse goes straight through it. Change 3s in .toast-bar
   to keep it on screen longer. */
.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 10; pointer-events: none; }

.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 12px 18px 14px 14px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.hide { opacity: 0; transform: translateY(8px); }

.toast svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--brand-bright);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The timer bar: runs down from full to empty */
.toast-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 4px;
  background: var(--brand-bright);
  transform-origin: left;
  animation: toast-timer 3s linear forwards;
}

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-timer { to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .toast.hide { transform: none; }
}

/* ==========================================================
   Gallery: a page full of posts (gallery.js). The buttons are in the top right corner.
   ========================================================== */
.gallery-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 18px 32px; }
.gallery-intro { flex: 1 1 360px; min-width: 0; }
.gallery-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: auto; padding-top: 6px; }
.gallery-stage { margin-top: 30px; }

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid var(--input-line);
  border-radius: 999px;
  background: var(--field-bg);
  color: var(--text);
  font-size: 0.925rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, scale 0.15s, filter 0.2s;
}
.tool-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: rotate 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.tool-btn:hover { background: var(--notice-bg); }
.tool-btn:active { scale: 0.96; }
.tool-btn[aria-pressed="true"], .tool-btn.add { border-color: var(--accent); background: var(--accent); color: var(--page); }
.tool-btn[aria-pressed="true"]:hover, .tool-btn.add:hover { background: var(--accent); filter: brightness(1.12); }
.tool-btn.add:hover svg { rotate: 90deg; }
.tool-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill { min-width: 22px; padding: 0 7px; border-radius: 999px; background: color-mix(in oklch, currentColor 18%, transparent); font-size: 0.8rem; text-align: center; }

/* The stage holds the posts, or only the photos, or the bin. Changing between them fades and slides. */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 22px; }
.gallery-stage > .leaving { animation: stage-out 0.22s ease-in forwards; }
@keyframes stage-out { to { opacity: 0; transform: scale(0.97); } }
.enter .post-card, .enter .wall-tile { animation: card-in 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes card-in { from { opacity: 0; transform: translateY(22px) scale(0.96); } }

/* One post */
.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 24px -16px rgba(0, 0, 0, 0.3);
  transition: translate 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s, border-color 0.3s;
}
@media (hover: hover) {
  .post-card:hover {
    translate: 0 -5px;
    border-color: color-mix(in oklch, var(--accent) 40%, var(--line));
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 22px 36px -18px rgba(0, 0, 0, 0.4);
  }
}
.post-card:has(.post-open:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }

.post-photo { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 17px 17px 0 0; background: linear-gradient(135deg, var(--notice-bg), var(--line)); }
.post-photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: scale 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
@media (hover: hover) { .post-card:hover .post-photo img { scale: 1.06; } }
.post-noimg { position: absolute; inset: 0; display: grid; place-items: center; font-size: 4rem; }

.post-symbol {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--page);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  font-size: 1.3rem;
  line-height: 1;
}
@media (hover: hover) { .post-card:hover .post-symbol { animation: wiggle 0.6s ease-in-out; } }
@keyframes wiggle { 25% { rotate: -14deg; scale: 1.12; } 60% { rotate: 10deg; scale: 1.12; } }

.photo-count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
}
.photo-count svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.post-body { display: flex; flex: 1; flex-direction: column; gap: 6px; padding: 14px 16px 16px; }
.post-title { font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.post-open {
  display: -webkit-box;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  cursor: pointer;
}
.post-open::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* the whole card opens the post */
.post-card .post-text {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.925rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.post-meta { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 8px; color: var(--text-muted); font-size: 0.8rem; }
.post-meta .bubble { width: 22px; height: 22px; font-size: 0.62rem; }

/* Eye, pencil and bin on a card: the same buttons as on a ticket */
.card-actions { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; gap: 6px; opacity: 0; translate: 0 -6px; transition: opacity 0.2s, translate 0.25s; }
.post-card:hover .card-actions, .post-card:focus-within .card-actions { opacity: 1; translate: 0 0; }
@media (hover: none) { .card-actions { opacity: 1; translate: 0 0; } }
.card-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in oklch, var(--page) 92%, transparent);
  color: var(--text);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, scale 0.15s;
}
.card-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card-btn:hover { background: var(--accent); color: var(--page); scale: 1.1; }
.card-btn.danger:hover { background: var(--danger); color: #fff; }
.card-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* In the bin the cards are quiet and have Restore and Delete permanently under them */
.post-card.in-bin .post-photo img { filter: grayscale(0.7); opacity: 0.75; }
.bin-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; }

/* A post that has just been published pops up with a glow; one that goes to the bin shrinks away */
.post-card.fresh { animation: card-pop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), card-glow 1.8s ease-out; }
@keyframes card-pop { from { opacity: 0; scale: 0.8; rotate: -2deg; } }
@keyframes card-glow { 0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 30px transparent; } }
.post-card.leaving { animation: card-out 0.3s ease-in forwards; pointer-events: none; }
@keyframes card-out { to { opacity: 0; scale: 0.8; rotate: -3deg; } }

/* Only the photos: a wall of pictures, each at its own shape */
.photo-wall { columns: 4 220px; column-gap: 12px; }
.wall-tile { margin: 0 0 12px; overflow: hidden; border-radius: 14px; background: var(--line); break-inside: avoid; }
.wall-tile img { display: block; width: 100%; height: auto; transition: scale 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
@media (hover: hover) { .wall-tile:hover img { scale: 1.05; } }

/* Nothing here yet */
.gallery-empty { display: grid; grid-column: 1 / -1; justify-items: center; gap: 8px; padding: 56px 20px; border: 2px dashed var(--input-line); border-radius: 22px; color: var(--text-muted); text-align: center; column-span: all; }
.gallery-empty h2 { color: var(--text); font-size: 1.3rem; }
.gallery-empty .tool-btn { margin-top: 10px; }
.empty-symbol { font-size: 3.2rem; line-height: 1.2; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 -10px; } }

/* One post: the page */
.post-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 26px; }
.post-photos img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 16px; animation: card-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; animation-delay: calc(var(--i, 0) * 70ms); }
.post-photos:not(.single) img:last-child:nth-child(odd) { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
.post-photos.single img { grid-column: 1 / -1; aspect-ratio: auto; max-height: 560px; object-fit: contain; background: var(--line); }
.post-heading { display: flex; align-items: center; gap: 14px; }
.symbol-badge { display: grid; flex-shrink: 0; place-items: center; width: 48px; height: 48px; border: 1px solid var(--notice-line); border-radius: 50%; background: var(--notice-bg); font-size: 1.6rem; line-height: 1; }
#post-meta .bubble { width: 22px; height: 22px; margin-right: 6px; font-size: 0.62rem; vertical-align: middle; }
#post-text { max-width: 60ch; white-space: pre-wrap; overflow-wrap: anywhere; }
.form-title { margin-bottom: 24px; }

/* Writing a post: the box for photos, the small pictures, the symbols */
.field .dropzone { /* (.field label would make it a plain block, so this is a little more specific) */
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0;
  padding: 30px 20px;
  font-size: 1rem;
  font-weight: 400;
  border: 2px dashed var(--input-line);
  border-radius: 18px;
  background: var(--field-bg);
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, scale 0.2s;
}
.dropzone svg { width: 38px; height: 38px; margin-bottom: 4px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dropzone strong { color: var(--text); font-size: 1.05rem; }
.dropzone span { font-size: 0.9rem; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--notice-bg); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.over { scale: 1.015; }
.dropzone.over svg { animation: bob 0.7s ease-in-out infinite; }
.dropzone.busy { cursor: progress; opacity: 0.7; }
.dropzone.busy svg { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { scale: 1.2; opacity: 0.5; } }
.field .dropzone input { position: absolute; inset: 0; width: 100%; max-width: none; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.field .dropzone input:focus-visible { outline: none; }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; list-style: none; }
.thumb { position: relative; width: 104px; height: 104px; overflow: hidden; border-radius: 14px; background: var(--line); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb.new { animation: thumb-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) backwards; }
@keyframes thumb-in { from { opacity: 0; scale: 0.5; } }
.thumb.leaving { animation: thumb-out 0.25s ease-in forwards; }
@keyframes thumb-out { to { opacity: 0; scale: 0.5; } }
.cover-tag { position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 0.72rem; font-weight: 600; }
.thumb-x { position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; cursor: pointer; transition: background 0.15s, scale 0.15s; }
.thumb-x svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.thumb-x:hover { background: var(--danger); scale: 1.1; }
.thumb-x:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.symbols { display: flex; flex-wrap: wrap; gap: 8px; }
.symbol-btn { display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border: 2px solid var(--input-line); border-radius: 14px; background: var(--field-bg); font-size: 1.5rem; line-height: 1; cursor: pointer; transition: border-color 0.15s, background 0.15s, scale 0.15s; }
.symbol-btn:hover { border-color: var(--accent); scale: 1.1; }
.symbol-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--notice-bg); animation: symbol-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes symbol-pop { 0% { scale: 0.8; } 60% { scale: 1.2; } }
.symbol-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* A pop-up message about a problem stays a little longer and is amber */
.toast.warn svg { stroke: var(--todo); }
.toast.warn .toast-bar { background: var(--todo); animation-duration: 5s; }

@media (max-width: 520px) {
  .gallery-tools .tool-btn:not(.add) > span:not(.pill) { display: none; } /* icons only on a phone */
  .photo-wall { columns: 2 140px; }
}

@media (prefers-reduced-motion: reduce) {
  .enter .post-card, .enter .wall-tile, .post-card.fresh, .post-card.leaving, .post-card:hover .post-symbol, .post-photos img,
  .thumb.new, .thumb.leaving, .empty-symbol, .dropzone.over svg, .dropzone.busy svg, .symbol-btn[aria-pressed="true"],
  .gallery-stage > .leaving { animation: none; }
  .post-card, .post-photo img, .wall-tile img, .card-actions, .card-btn, .tool-btn, .tool-btn svg, .dropzone, .symbol-btn, .thumb-x { transition: none; }
}

/* ==========================================================
   Accounts: who may see what, the Log in / Sign up text, the log in window, the team page
   ========================================================== */
/* Pages and buttons for the team only show for the team. (The database checks it too: this is just tidiness.) */
html:not(.is-dev) .dev-only { display: none !important; }
html:not(.is-owner) .owner-only { display: none !important; }

/* Plain text that can be pressed */
.text-link { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-underline-offset: 3px; cursor: pointer; transition: color 0.15s; }
.text-link:hover { color: var(--text); text-decoration: underline; }
.text-link.strong { color: var(--accent); font-weight: 600; }
.text-link.strong:hover { color: var(--accent); }
.text-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.text-link:disabled { color: var(--text-muted); opacity: 0.6; cursor: default; text-decoration: none; }

/* Log in · Sign up: small and quiet, in the top right corner of the page */
.layout { position: relative; }
.account { position: absolute; top: 22px; right: 30px; z-index: 6; color: var(--text-muted); font-size: 0.9rem; }
.account > span { display: inline-flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: 4px 10px; }
#account-name { color: var(--text); font-weight: 600; }
.role-tag { padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.75rem; line-height: 1.6; }

/* The log in window */
.auth-dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 22px; background: var(--page); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); }
.auth-dialog::backdrop { background: rgba(10, 14, 12, 0.5); backdrop-filter: blur(5px); }
.auth-dialog[open] { animation: auth-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
.auth-dialog[open]::backdrop { animation: backdrop-in 0.25s ease-out; }
@keyframes auth-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
@keyframes backdrop-in { from { opacity: 0; } }
.auth-card { position: relative; padding: 32px 30px 26px; }
.auth-card h2 { font-size: 1.5rem; font-weight: 700; }
.auth-intro, .auth-sent { margin-top: 8px; color: var(--text-muted); font-size: 0.95rem; }
.auth-card .field { margin: 18px 0 0; }
.auth-card .field input { max-width: none; }
.auth-card .primary { width: 100%; margin-top: 20px; }
.auth-close { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; transition: background 0.15s, color 0.15s; }
.auth-close:hover { background: var(--notice-bg); color: var(--text); }
.auth-close:focus-visible { outline: 2px solid var(--accent); }
.auth-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.auth-captcha { margin-top: 16px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; margin-top: 16px; color: var(--text-muted); font-size: 0.92rem; }
.auth-error { margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: 0.92rem; }
.auth-switch { margin-top: 20px; color: var(--text-muted); font-size: 0.92rem; text-align: center; }
#auth-code { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; }

/* The page people see when a team page is not for them, and the team page itself */
.locked-actions { margin-top: 20px; font-size: 1.05rem; }
.team-form { display: flex; flex-wrap: wrap; gap: 10px; max-width: 540px; margin-top: 28px; }
.team-form input { flex: 1 1 240px; min-width: 0; padding: 10px 12px; border: 1px solid var(--input-line); border-radius: 8px; background: var(--field-bg); color: var(--text); }
.team-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.team-list { max-width: 640px; margin-top: 24px; }
.team-list .row-main .role-tag { display: inline-block; margin-left: 8px; color: var(--text-muted); font-size: 0.75rem; font-weight: 500; vertical-align: 2px; }
.team-list .row-main span { overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .account { position: static; padding: 14px 20px 0; text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-dialog[open], .auth-dialog[open]::backdrop { animation: none; }
}

/* Changing the colours: the new look spreads out from the button you pressed (theme.js).
   The browser would normally fade from the old look to the new one, so that is switched off. */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* Browsers that cannot spread the colours fade them instead (theme.js adds this class for a moment) */
.theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after {
  transition: background-color 0.45s, border-color 0.45s, color 0.45s, fill 0.45s, stroke 0.45s !important;
}

/* For people who asked their device for less movement: everything just switches */
@media (prefers-reduced-motion: reduce) {
  .sidebar-wrap, .sidebar, .resizer, .menu-open, .menu-open svg, .palette-panel, .swatch, .swatch::after,
  .leaf, .leaf.turned, .leaf::after, .bookmark { transition: none; }
}

/* 6. Small screens: the menu moves above the page (and slides up when you close it) */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar-wrap { position: static; width: 100%; height: auto; max-height: 75vh; transition: max-height var(--slide) var(--slide-ease); }
  .menu-closed .sidebar-wrap { width: 100%; max-height: 0; }
  .sidebar { width: 100%; height: auto; max-height: 75vh; }
  .menu-closed .sidebar { translate: none; }
  .resizer { display: none; }
  .content { max-width: none; padding: 40px 20px; }
  h1 { font-size: 1.8rem; }
  .row-actions { padding-bottom: 12px; }
}
