/* Desk styles.
 *
 * The first block is copied verbatim from the mindalike design system
 * (docs/design/_ds/…/_ds_bundle.css), only the classes Desk uses. Keep it in
 * sync by hand if mindalike's look changes. Desk's own styles follow. */

/* ---- mindalike classes */

.app-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 44px;
  background: var(--color-brand);
  color: #fff;
  flex-shrink: 0;
  position: relative;
  z-index: 400;
}
.app-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}
.app-title {
  text-decoration: none;
  color: inherit;
}
.app-nav {
  display: flex;
  gap: 4px;
}
.nav-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  padding: 6px 14px;
  font-size: var(--font-size);
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.nav-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-btn.active { color: #fff; background: rgba(255,255,255,0.14); }
.ctrl-btn {
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: var(--color-text-muted);
}
.ctrl-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
.ctrl-btn.active { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.ctrl-btn.active:hover { opacity: 0.88; }
.control-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 12px;
}
.settings-section {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.settings-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}
.admin-input {
  display: block;
  width: 100%;
  max-width: 400px;
  padding: 6px 10px;
  margin-top: 4px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: var(--font-size);
}
.btn-primary {
  padding: 8px 20px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: var(--font-size);
  cursor: pointer;
  font-weight: 500;
}
.btn-primary:hover { opacity: 0.9; }
.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
  border: none;
}
.btn-danger {
  background: var(--color-today);
  color: #fff;
}
.btn-danger:hover { opacity: 0.85; }

/* ---- page */

/* Caveat (SIL OFL), bundled in web/fonts: handwriting that stays readable,
   for what is written on things (project names on washi tape). */
@font-face {
  font-family: 'Desk Hand'; font-weight: 600; font-display: swap;
  src: url(../fonts/caveat-600-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: 'Desk Hand'; font-weight: 600; font-display: swap;
  src: url(../fonts/caveat-600-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
:root { --font-hand: 'Desk Hand', 'Bradley Hand', 'Segoe Print', cursive; }


html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: var(--font-size);
  color: var(--color-text);
  background: var(--color-bg);
}
a { color: var(--color-accent); }
a:hover { color: var(--color-brand); }
textarea:focus, input:focus { outline: none; }
[hidden] { display: none !important; }

.shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- header */

.app-header { gap: 16px; flex-wrap: nowrap; min-width: 0; }
.app-nav { flex-shrink: 0; }
.app-nav .nav-btn { display: flex; align-items: center; gap: 6px; }
.nav-badge { font-size: 10px; font-weight: 700; opacity: .6; }
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  min-width: 0;
  flex: 0 1 auto;
}
.header-right > .nav-btn { white-space: nowrap; }
.match-count { color: rgba(255,255,255,.75); font-size: 12px; white-space: nowrap; }
.search { position: relative; display: flex; align-items: center; min-width: 0; flex: 1 1 300px; }
.search-input {
  width: 100%;
  min-width: 140px;
  max-width: 300px;
  height: 30px;
  border: none;
  border-radius: 6px;
  padding: 0 30px 0 10px;
  background: #fff;
  color: var(--color-text);
  font: inherit;
  box-sizing: border-box;
}
.search-key {
  position: absolute;
  right: 8px;
  font-size: 11px;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 16px;
  pointer-events: none; /* clicks reach the input underneath */
}

/* ---- desk */

.main { flex: 1; position: relative; display: flex; min-height: 0; }
/* The desk and whatever covers it (the editor); a sidebar sits beside it. */
.desk-area { flex: 1; position: relative; display: flex; min-width: 0; }
.desk {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background-color: var(--color-header-bg);
  background-image: radial-gradient(var(--color-weekend-bg) 1.4px, transparent 1.4px);
  background-size: 24px 24px;
}

/* The world layer holds everything in desk coordinates; desk.js moves and
   scales it. Objects sit in it at their world position and size. */
.world { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; }
.zones { position: absolute; left: 0; top: 0; pointer-events: none; }

/* ---- objects */

.obj {
  --shadow: 0 1px 2px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.08);
  position: absolute;
  box-sizing: border-box;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform: rotate(var(--rot, 0deg));
  transition: left .5s cubic-bezier(.2,.8,.2,1), top .5s cubic-bezier(.2,.8,.2,1), transform .3s, opacity .2s;
}
.obj.dragging {
  --shadow: 0 6px 10px rgba(0,0,0,.10), 0 22px 44px rgba(0,0,0,.20);
  transform: rotate(var(--rot, 0deg)) scale(1.04);
  transition: transform .2s, opacity .2s;
  z-index: 100000 !important;
}
.obj.selected::after {
  content: ''; position: absolute; inset: -7px; border-radius: 6px;
  border: 2px solid var(--color-accent); pointer-events: none;
}
.obj.drop::after {
  content: ''; position: absolute; inset: -12px; border-radius: 10px;
  border: 2px dashed var(--color-accent);
  background: color-mix(in oklch, var(--color-accent) 12%, transparent);
  pointer-events: none;
}

.face { position: absolute; inset: 0; box-sizing: border-box; overflow: hidden; box-shadow: var(--shadow); }
.f-title { font-size: 14px; font-weight: 700; line-height: 1.25; }
.f-body { white-space: pre-wrap; }
.f-meta { font-size: 11px; color: var(--color-text-muted); }

.face.postit {
  padding: 18px 16px; font-size: 17px; line-height: 1.3; font-weight: 500;
  white-space: pre-wrap; text-wrap: pretty;
}
.pdot {
  position: absolute; right: 10px; bottom: 10px; width: 10px; height: 10px;
  border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.8);
}

.face.paper { background: #fff; padding: 28px 20px 16px; display: flex; flex-direction: column; gap: 10px; }
.paper .f-body { font-size: 12px; line-height: 1.65; }

.face.notebook {
  background: var(--color-brand); border-radius: 4px 10px 10px 4px;
  box-shadow: var(--shadow), inset 14px 0 0 rgba(0,0,0,.32);
}
.notebook .band { position: absolute; top: 0; bottom: 0; right: 22px; width: 9px; }
.notebook .label {
  position: absolute; left: 34px; right: 46px; top: 60px; background: #fff;
  padding: 12px 12px 10px; display: flex; flex-direction: column; gap: 4px; border-radius: 2px;
}

.face.photo { background: #fff; padding: 10px 10px 0; display: flex; flex-direction: column; }
.ph-img {
  height: 150px; flex-shrink: 0;
  background: repeating-linear-gradient(135deg, var(--color-header-bg) 0 10px, var(--color-weekend-bg) 10px 20px);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted); font-size: 11px; font-family: ui-monospace, monospace;
}
.ph-cap { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12px; padding: 0 4px; line-height: 1.3; }

.face.pdf { background: #fff; padding: 26px 16px 16px; display: flex; flex-direction: column; gap: 7px; }
.pdf .corner {
  position: absolute; top: 0; right: 0; width: 24px; height: 24px;
  background: linear-gradient(225deg, var(--color-header-bg) 0 50%, var(--color-weekend-bg) 50%);
}
.pdf .tag { align-self: flex-start; background: var(--color-today); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px; }
.pdf .f-title { font-size: 12.5px; line-height: 1.3; margin-bottom: 6px; }
.pdf .line { height: 6px; flex-shrink: 0; background: var(--color-header-bg); }
.pdf .figure { height: 38px; flex-shrink: 0; background: var(--color-row-odd); border: 1px solid var(--color-border); margin-top: 6px; }
.pdf .f-meta { position: absolute; left: 16px; bottom: 12px; }

.face.todo { background: #fff; padding: 28px 18px 14px; display: flex; flex-direction: column; gap: 6px; }
.todo .f-title { margin-bottom: 4px; }
.task { display: flex; align-items: center; gap: 9px; min-height: 26px; font-size: 12.5px; }
.task .box {
  width: 16px; height: 16px; flex-shrink: 0; box-sizing: border-box;
  border: 1.5px solid var(--color-text); border-radius: 3px; background: #fff;
  color: #fff; font-size: 11px; line-height: 13px; text-align: center; cursor: pointer;
}
.task.done .box { background: var(--color-text); }
.task.done span:last-child { text-decoration: line-through; color: var(--color-text-muted); }

.face.index { background: #fff; display: flex; flex-direction: column; }
.index .f-title { font-size: 13px; padding: 16px 16px 6px; border-bottom: 2px solid var(--color-open); }
.index .f-body {
  flex: 1; font-size: 12px; line-height: 22px; padding: 0 16px;
  background-image: repeating-linear-gradient(to bottom, transparent 0 21px, color-mix(in oklch, var(--color-accent) 25%, white) 21px 22px);
}

.face.sketch {
  background: #fff;
  background-image: radial-gradient(var(--color-border) 1.2px, transparent 1.2px);
  background-size: 16px 16px;
}
.sketch .f-title { position: absolute; left: 10px; bottom: 8px; font-size: 11px; font-weight: 600; background: #fff; padding: 1px 4px; }

.ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ink path { fill: none; stroke-width: 1.6px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* Washi tape: the project's colour across the top, its name written on it.
   The colour is see-through, the writing is not. Torn ends via clip-path. */
.tape {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%) rotate(var(--tilt, -3deg));
  min-width: 72px; max-width: calc(100% - 24px); height: 22px; padding: 0 12px; box-sizing: border-box;
  background: color-mix(in oklch, var(--tape) 82%, transparent); color: var(--tape-ink);
  font: 600 18px/22px var(--font-hand); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 25%, 100% 50%, calc(100% - 4px) 75%, 100% 100%,
    0 100%, 4px 75%, 0 50%, 4px 25%);
}

/* ---- piles */

.sheet { position: absolute; inset: 0; background: #fff; border: 1px solid var(--color-border); box-shadow: 0 1px 3px rgba(0,0,0,.10); }
.sheet-a { transform: rotate(-5deg) translate(-9px, 7px); }
.sheet-b { transform: rotate(3.5deg) translate(8px, 4px); }
.badge {
  position: absolute; top: -11px; right: -11px; min-width: 26px; height: 26px; padding: 0 6px;
  box-sizing: border-box; border-radius: 13px; background: var(--color-brand); color: #fff;
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.pile-title {
  position: absolute; top: 100%; left: -20px; right: -20px; margin-top: 16px;
  text-align: center; font-size: 13px; font-weight: 700; color: var(--color-text-muted);
}

.frame {
  position: absolute; box-sizing: border-box; border: 2px dashed var(--color-dep);
  border-radius: 14px; background: rgba(255,255,255,.35);
}
.frame-head {
  position: absolute; left: 16px; top: -19px; display: flex; gap: 8px; align-items: center;
  background: var(--color-header-bg); padding: 0 8px;
}
.frame, .frame-head { cursor: grab; }
.world.moving-pile .obj { transition: none; }
.frame-title { cursor: text; font: inherit; font-size: 15px; font-weight: 700; border: none; background: transparent; width: 150px; color: var(--color-text); }
.frame-count { color: var(--color-text-muted); }
.frame-head .ctrl-btn { height: 32px; }

/* ---- tidy zones */

.zone { position: absolute; border-top: 2px solid var(--color-border); }
.zone-head { display: flex; align-items: center; gap: 10px; padding-top: 14px; font-size: 22px; font-weight: 700; white-space: nowrap; }
.zone-dot { width: 12px; height: 12px; border-radius: 50%; }
.zone-count { font-weight: 400; color: var(--color-text-muted); font-size: 15px; }

/* ---- context bar, toast, toolbar */

.ctxbar {
  position: absolute; z-index: 40; display: flex; align-items: center; gap: 2px;
  background: #fff; border: 1px solid var(--color-border); border-radius: 10px; padding: 4px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); white-space: nowrap;
}
.ctxbar .ctrl-btn { height: 36px; }
.ctx-sep { width: 1px; height: 24px; background: var(--color-border); margin: 0 4px; }
.ctx-proj {
  height: 36px; min-width: 36px; padding: 0 8px; border-radius: 8px; border: none; background: transparent;
  display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  font: inherit; color: var(--color-text);
}
.ctx-proj.active { background: var(--color-header-bg); }
.ctx-dot { width: 14px; height: 14px; border-radius: 50%; }

.toast {
  /* Above the editor (60) and dialogs (80), so Undo stays reachable. */
  position: absolute; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 12px;
  background: var(--color-brand); color: #fff; padding: 8px 14px; border-radius: 8px;
  font-size: 13px; white-space: nowrap; pointer-events: none;
}
/* A toast with Undo catches clicks: a near miss must not fall through to
   whatever lies under it (a dialog's backdrop would close the dialog). */
.toast.has-undo { pointer-events: auto; }
.toast-undo {
  border: none; background: none; color: #fff; font: inherit; font-weight: 700;
  text-decoration: underline; cursor: pointer; padding: 8px 10px; margin: -8px -10px;
}

.toolbar {
  /* Clear of the iPad's home indicator when installed. */
  position: absolute; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--color-border); border-radius: 12px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
  width: max-content; max-width: calc(100% - 32px); box-sizing: border-box;
}
.toolbar .ctrl-btn, .ctxbar button { touch-action: manipulation; }
.toolbar .ctrl-btn { height: 38px; }
.toolbar .sq { width: 38px; padding: 0; }
.toolbar .control-label { padding: 0 6px; }
.tb-sep { width: 1px; height: 26px; background: var(--color-border); margin: 0 6px; }
.zoom-pct { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; color: var(--color-text-muted); }

/* ---- editor */

.ed-scrim {
  position: absolute; inset: 0; z-index: 60; background: rgba(26,26,46,.28);
  display: flex; align-items: center; justify-content: center;
}
.ed-card {
  background: #fff; width: min(680px, calc(100% - 32px)); max-height: calc(100% - 32px);
  border-radius: 10px; box-shadow: 0 24px 64px rgba(0,0,0,.25);
  display: flex; flex-direction: column; overflow: hidden;
}
.ed-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.ed-type { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); font-weight: 600; white-space: nowrap; }
.ed-title { flex: 1; min-width: 0; border: none; font: inherit; font-size: 18px; font-weight: 600; color: var(--color-text); background: transparent; }
.ed-head .ctrl-btn { height: 34px; }

.ed-projects { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; align-items: center; }
.ed-projects .control-label { margin-right: 4px; }
.ed-chips { display: contents; }
.ed-chip {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 16px;
  border: 1px solid var(--color-border); background: #fff; font: inherit; cursor: pointer; color: var(--color-text);
}
.ed-chip.active { border-color: var(--color-text); background: var(--color-header-bg); }
.ed-chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.ed-newproj {
  height: 32px; width: 140px; padding: 0 12px; border-radius: 16px; border: 1px dashed var(--color-border);
  background: #fff; font: inherit; color: var(--color-text); box-sizing: border-box;
}

.ed-tools {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 16px;
  border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); background: var(--color-row-odd);
}
.ed-tools .ctrl-btn { height: 34px; touch-action: manipulation; }
.ink-dot {
  width: 24px; height: 24px; margin: 0 3px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 0 0 2px transparent;
}
.ink-dot.active { box-shadow: 0 0 0 2px var(--color-text-muted); }
.ed-spacer { flex: 1; }
.ed-mic { display: flex; align-items: center; gap: 6px; }
.ed-mic:disabled { opacity: .5; cursor: not-allowed; }
.ed-mic:not(.active) .rec-dot { display: none; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-today); animation: deskpulse 1s infinite; }
@keyframes deskpulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.ed-pages { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--color-border); }
.ed-pages .ctrl-btn { height: 30px; }
.ed-body { flex: 1; min-height: 0; overflow: auto; padding: 20px; background: var(--color-bg); }
.ed-hint { padding: 9px 16px; font-size: 12px; color: var(--color-text-muted); border-top: 1px solid var(--color-border); }

/* A page is laid out at 600 units wide (.page) and scaled to the width its
   .surface gets, so text and ink keep their places at any size. */
.surface {
  position: relative; margin: 0 auto; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.08);
  -webkit-user-select: none; -webkit-touch-callout: none;
}
.surface.pen { cursor: crosshair; }
.page { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; }
.pg-paper, .pg-notebook, .pg-index {
  background-image: repeating-linear-gradient(to bottom, transparent 0 calc(var(--line) - 1px), var(--color-border) calc(var(--line) - 1px) var(--line));
}
.pg-sketch { background-image: radial-gradient(var(--color-border) 1.3px, transparent 1.3px); background-size: 20px 20px; }
.pg-text {
  position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box; resize: none;
  border: none; background: transparent; font-family: var(--font); color: var(--color-text);
  -webkit-user-select: text;
}
.surface.pen .pg-text { pointer-events: none; }
.page .ink path { stroke-width: 2.5px; }
.pg-photo {
  position: absolute; inset: 15px;
  background: repeating-linear-gradient(135deg, var(--color-header-bg) 0 14px, var(--color-weekend-bg) 14px 28px);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted); font-family: ui-monospace, monospace; font-size: 13px;
}
.pg-pdf { position: absolute; inset: 0; padding: 53px 49px; display: flex; flex-direction: column; gap: 13px; box-sizing: border-box; }
.pg-pdf .tag { align-self: flex-start; background: var(--color-today); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 3px; }
.pg-pdf-title { font-size: 22px; font-weight: 700; }
.pg-pdf .line { height: 10px; flex-shrink: 0; background: var(--color-header-bg); }
.pg-pdf .figure { height: 133px; flex-shrink: 0; margin-top: 11px; background: var(--color-row-odd); border: 1px solid var(--color-border); }
.ed-caption {
  display: block; width: 100%; margin: 12px auto 0; height: 40px; padding: 0 12px; box-sizing: border-box;
  border: 1px solid var(--color-border); border-radius: 6px; font: inherit; font-size: 14px; background: #fff; color: var(--color-text);
}

.todo-sheet {
  max-width: 520px; margin: 0 auto; background: #fff; padding: 12px 24px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.08); display: flex; flex-direction: column;
}
.todo-row { display: flex; align-items: center; gap: 12px; min-height: 46px; border-bottom: 1px solid var(--color-border); }
.todo-box {
  width: 24px; height: 24px; flex-shrink: 0; padding: 0; border-radius: 4px; cursor: pointer;
  border: 1.5px solid var(--color-text); background: #fff; color: #fff; font-size: 14px;
}
.todo-row.done .todo-box { background: var(--color-text); }
.todo-text { flex: 1; min-width: 0; border: none; font: inherit; font-size: 16px; color: var(--color-text); background: transparent; }
.todo-row.done .todo-text { text-decoration: line-through; color: var(--color-text-muted); }
.todo-x { width: 36px; height: 36px; border: none; background: none; color: var(--color-text-muted); cursor: pointer; font-size: 18px; }
.todo-draft { color: var(--color-text-muted); font-size: 16px; }
.todo-draft .rec-dot { margin: 0 8px; }
.todo-new { height: 48px; border: none; font: inherit; font-size: 16px; background: transparent; color: var(--color-text); }

/* ---- search: matches get a ring, everything else dims */

.obj.dim { opacity: .2; }
.obj.hl::before {
  content: ''; position: absolute; inset: -6px; border-radius: 6px; pointer-events: none;
  box-shadow: 0 0 0 3px var(--color-accent), 0 0 0 9px color-mix(in oklch, var(--color-accent) 22%, transparent);
}

.cmd-menu {
  position: absolute; top: 36px; right: 0; width: min(360px, 90vw); z-index: 100;
  display: flex; flex-direction: column; padding: 6px;
  background: #fff; border: 1px solid var(--color-border); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18); color: var(--color-text);
}
.cmd-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); padding: 8px 10px 4px; }
.cmd-row {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px;
  border: none; border-radius: 6px; background: transparent; font: inherit; color: var(--color-text);
  cursor: pointer; text-align: left;
}
.cmd-row.active { background: var(--color-header-bg); }
.cmd-sq { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.cmd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-extra { color: var(--color-text-muted); }
.cmd-foot { font-size: 11px; color: var(--color-text-muted); padding: 8px 10px 4px; border-top: 1px solid var(--color-border); margin-top: 4px; }

/* ---- Drawers sidebar */

.sidebar {
  width: 240px; flex-shrink: 0; box-sizing: border-box; overflow: auto;
  display: flex; flex-direction: column; gap: 24px; padding: 16px 10px;
  background: #fff; border-right: 1px solid var(--color-border);
}
.sb-group { display: flex; flex-direction: column; gap: 2px; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 6px; }
.sb-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); }
.sb-link { border: none; background: none; font: inherit; font-size: 12px; color: var(--color-accent); cursor: pointer; padding: 4px; }
.sb-row {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 10px;
  border: none; border-radius: 6px; background: transparent; font: inherit; color: var(--color-text);
  cursor: pointer; text-align: left;
}
.sb-row.active { background: var(--color-header-bg); font-weight: 600; }
.sb-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.sb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-count { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.sb-empty { padding: 0 10px; color: var(--color-text-muted); font-size: 12px; text-wrap: pretty; }
.sb-keys {
  margin-top: auto; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center;
  padding: 0 10px; font-size: 12px; color: var(--color-text-muted);
}
.sb-keys .sb-label { grid-column: 1 / -1; padding-bottom: 2px; }
.sb-key { padding: 1px 6px; text-align: center; cursor: default; }

/* ---- dialogs: project manager, settings */

.md-scrim {
  position: absolute; inset: 0; z-index: 80; background: rgba(26,26,46,.28);
  display: flex; align-items: center; justify-content: center;
}
.md-card {
  width: min(480px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; margin: 0;
  box-sizing: border-box; display: flex; flex-direction: column; gap: 14px;
  border-radius: 10px; box-shadow: 0 24px 64px rgba(0,0,0,.25); padding: 20px;
}
.md-head { display: flex; align-items: center; justify-content: space-between; }
.md-head h3 { margin: 0; font-size: 16px; }
.md-head .ctrl-btn { height: 34px; }
.md-body { display: flex; flex-direction: column; gap: 14px; }
.md-body .settings-hint { margin-bottom: 0; }

.pm-rows { display: flex; flex-direction: column; }
.pm-row { display: flex; align-items: center; gap: 10px; min-height: 48px; border-bottom: 1px solid var(--color-border); }
.pm-color {
  width: 28px; height: 28px; flex-shrink: 0; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--color-border);
}
.pm-name {
  flex: 1; min-width: 0; height: 36px; padding: 0 8px; box-sizing: border-box;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  font: inherit; font-size: 14px; color: var(--color-text);
}
.pm-name:focus { border-color: var(--color-border); }
.pm-count { color: var(--color-text-muted); font-size: 12px; white-space: nowrap; }
.pm-empty { padding: 12px 0; color: var(--color-text-muted); }
.pm-add { display: flex; gap: 8px; }
.pm-add .admin-input { flex: 1; min-width: 0; height: 36px; box-sizing: border-box; margin: 0; max-width: none; }
.pm-add .btn-primary { height: 36px; }

.st-row { display: flex; align-items: center; gap: 12px; }
.st-label { font-weight: 600; min-width: 80px; }
.st-range { flex: 1; }
.st-value { min-width: 80px; text-align: right; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

.ed-manage { border: none; background: none; font: inherit; font-size: 12px; color: var(--color-accent); cursor: pointer; padding: 4px 6px; }

/* ---- sign-in page, sync status, account settings */

.login-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--color-header-bg); }
.login-card { width: min(360px, 100%); box-sizing: border-box; display: flex; flex-direction: column; gap: 12px; margin: 0; border-radius: 10px; }
.login-card h3 { margin: 0 0 4px; font-size: 16px; }
.login-card label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--color-text-muted); }
.login-card .admin-input { max-width: none; height: 36px; box-sizing: border-box; font-size: 14px; color: var(--color-text); }
.login-card .btn-primary { height: 38px; margin-top: 4px; }
.login-error { color: var(--color-today); font-size: 13px; }

.sync-status {
  font-size: 11px; font-weight: 700; color: var(--color-brand); background: var(--color-in-progress);
  border-radius: 10px; padding: 2px 8px; white-space: nowrap; cursor: help;
}

.st-section { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--color-border); }
.st-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--color-text-muted); }
.st-logout { height: 32px; }
.st-password { display: flex; flex-wrap: wrap; gap: 8px; }
.st-password .admin-input { flex: 1 1 140px; margin: 0; height: 34px; box-sizing: border-box; max-width: none; }
.st-password .btn-primary { height: 34px; }
.st-usage { color: var(--color-text-muted); }

/* ---- real photos and PDFs */

.desk.drop-files { box-shadow: inset 0 0 0 3px var(--color-accent); }
.ph-img img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* A stored PDF shows its first page, stretched to the card as its ink is. */
.face.pdf.has-page { padding: 0; display: block; }
.face.pdf.has-page > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.pdf-band {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: rgba(255,255,255,.92); border-top: 1px solid var(--color-border);
}
.pdf-band .f-title { flex: 1; min-width: 0; margin: 0; font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pdf .pdf-band .f-meta { position: static; white-space: nowrap; }

.pg-photo:has(img) { background: var(--color-row-odd); }
.pg-photo img { width: 100%; height: 100%; object-fit: contain; }
.pg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---- minimap */

.minimap {
  position: absolute; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30; width: 200px; height: 130px;
  background: rgba(255,255,255,.92); border: 1px solid var(--color-border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10); overflow: hidden; cursor: pointer; touch-action: none;
}
.minimap.left { right: auto; left: 16px; }
.minimap canvas { display: block; width: 200px; height: 130px; }
.st-minimap, .st-offline { font: inherit; height: 32px; padding: 0 8px; border: 1px solid var(--color-border); border-radius: 6px; background: #fff; }

/* ---- a stored PDF in the editor: its pages to scroll and zoom (pdfview.js) */

.ed-card.wide { width: min(900px, calc(100% - 32px)); height: calc(100% - 32px); }
.ed-body:focus { outline: none; }
/* The view pinches itself; the browser must not zoom the whole app. */
.ed-body.pdf-view { touch-action: pan-x pan-y; }
/* At least as wide as the view (pages centred), wider once zoomed in (scrolls sideways). */
.pdf-pages { width: max-content; min-width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.pdf-pages .surface { margin: 0; flex-shrink: 0; }
.ed-pageno { font-size: 12px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; margin-right: 6px; }
.ed-zoom { display: flex; align-items: center; gap: 4px; }
.ed-zoom .sq { width: 34px; padding: 0; }
.ed-zoom-pct { min-width: 42px; text-align: center; font-size: 12px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
