/* Drawing */

.drawing-list { display: grid; gap: 2px; padding-top: 8px; }
.drawing-item { margin-inline: -8px; border-radius: 10px; }
.drawing-row { display: flex; align-items: center; gap: 2px; padding-right: 4px; }
.drawing-item:hover, .drawing-item.on, .drawing-item.editing { background: var(--hover); }
.drawing-edit { display: grid; gap: 8px; padding: 2px 8px 10px; }
.drawing-edit .select select { width: 100%; max-width: none; height: 34px; }
.drawing-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 12.5px; }
.drawing-actions .confirm-text { margin-right: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  font: 500 12.5px var(--sans);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent); }
.chip-count { font-size: 11px; opacity: 0.75; font-variant-numeric: tabular-nums; }

.folder-tools { display: flex; align-items: center; gap: 12px; padding: 0 0 8px; }
.folder-tools .link-btn { margin: 0; font-size: 12.5px; }
.folder-tools input, .drawing-edit > input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 500 13.5px var(--sans);
}
.folder-tools .confirm-btn { flex: none; }
.drawing-item .icon-btn { width: 32px; height: 32px; color: var(--muted); }
.drawing-item .i { width: 17px; height: 17px; }
.drawing-open { flex: 1; min-width: 0; display: grid; padding: 8px; border: 0; background: none; text-align: left; cursor: pointer; }
.drawing-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawing-meta { font-size: 12px; color: var(--muted); }
.mark-item .drawing-row { padding-left: 8px; }
.mark-item .drawing-open { padding-left: 4px; }
.mark-chip .i { width: 14px; height: 14px; }
.mark-chip:disabled { cursor: default; }
/* Go to */

.book-grid, .chapter-grid { display: grid; gap: 4px; padding: 4px 0 10px; }
.book-grid { grid-template-columns: repeat(3, 1fr); }
.chapter-grid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }

.book-cell, .chapter-cell {
  position: relative;
  height: 34px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: var(--hover);
  font: 500 12.5px var(--sans);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.chapter-cell { font-variant-numeric: tabular-nums; }
.book-cell:hover, .chapter-cell:hover { box-shadow: inset 0 0 0 1px var(--faint); }
.book-cell.on, .chapter-cell.on { background: var(--accent); color: var(--bg); font-weight: 600; }

.book-cell.marked::after, .chapter-cell.marked::after {
  content: "";
  position: absolute;
  top: 0;
  right: 6px;
  width: 6px;
  height: 9px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 70%, 0 100%);
}

.book-cell.on.marked::after, .chapter-cell.on.marked::after { background: var(--bg); }

.book-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 6px -8px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: 600 15px var(--sans);
  color: var(--text);
  cursor: pointer;
}

.book-switch:hover { background: var(--hover); }
.book-switch .i { width: 16px; height: 16px; color: var(--muted); }

.ribbon-dot { flex: none; width: 10px; height: 16px; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.drawing-empty { margin: 4px 0 8px; font-size: 13px; color: var(--muted); }
.notice { font-size: 12.5px; color: #c2413a; }

.draw-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  margin: 8px 0 6px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}

.draw-new .i { width: 18px; height: 18px; }

.app.writing .reader { padding: 32px 40px 140px; touch-action: none; }
.writing .reader > * { max-width: none; }
.app.writing.layout-scroll .reader { padding: 12px 0 0; }
.reader:has(kore-ink[data-tool="look"]) { touch-action: pan-x pan-y; }

.ink-host { margin: -8px -8px 0; padding: 8px 8px 24px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.writing.layout-scroll .ink-host { height: calc(var(--app-h) - var(--bar-h) - var(--dock-h) - var(--ink-room, 100px)); margin: 0; padding: 8px 24px; overflow: auto; }
.ink-slides { margin-top: 20px; }
.ink-slides .focus-btn:disabled { opacity: 0.35; cursor: default; }
.ink-stage { position: relative; margin-inline: auto; }
.ink-zoom { min-width: 52px; height: 36px; padding: 0 4px; border: 0; border-radius: 10px; background: none; font: 500 13px var(--sans); font-variant-numeric: tabular-nums; color: var(--muted); cursor: pointer; }
.ink-zoom:hover { background: var(--hover); }

.ink-page {
  position: absolute;
  top: 0;
  left: 0;
  transform: scale(var(--ink-scale, 1));
  transform-origin: 0 0;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
  color: var(--text);
  font-family: var(--page-font);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.ink-page[data-font="sbl"] { --page-font: "Kore SBL", var(--hebrew); }
.ink-page[data-font="serif"] { --page-font: "Noto Serif Hebrew", "Kore SBL", var(--hebrew); }
.ink-page[data-font="sans"] { --page-font: "Noto Sans Hebrew", "Kore SBL", var(--hebrew); }
.ink-page[data-font="rashi"] { --page-font: "Noto Rashi Hebrew", "Kore SBL", var(--hebrew); }

.ink-probe { position: fixed; top: 0; left: -99999px; visibility: hidden; pointer-events: none; }

.ink-head { display: grid; align-content: start; justify-items: center; }
.ink-head h1 { margin: 0; font: 600 1.25em/1.3 var(--page-font); }
.ink-head p { margin: 4px 0 0; font: 500 12px/1.5 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.ink-line { display: flex; justify-content: space-between; column-gap: 0.3em; white-space: nowrap; }
.ink-line.last { justify-content: flex-start; }
.ink-unit { display: inline-block; flex: none; white-space: nowrap; }
.ink-v { margin-inline-end: 0.3em; font: 600 0.42em/1 var(--sans); vertical-align: 0.9em; color: var(--accent); font-variant-numeric: tabular-nums; }
.ink-n { margin-inline-end: 0.3em; font-size: 0.55em; font-weight: 600; line-height: 1; vertical-align: 0.7em; color: var(--accent); }
.ink-m { font-size: 0.7em; color: var(--faint); }
.ink-s { display: inline-block; width: 1.8em; }

.ink-page[data-layout="interlinear"] .ink-line { align-items: flex-start; }
.ink-cell { display: inline-flex; flex-direction: column; align-items: center; padding-inline: 0.12em; }
.ink-cell .ink-v, .ink-cell .ink-n { margin: 0; vertical-align: 0.4em; }
.ink-cell .ink-m { margin-inline-start: 0.25em; }
.ink-g {
  display: -webkit-box;
  max-width: 6.5em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font: 500 0.44em/1.4 var(--sans);
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

.ink-page[data-layout="scroll"] .ink-text { display: flex; align-items: stretch; }
.ink-col, .ink-rule { flex: none; }
.ink-rule { background: linear-gradient(var(--line), var(--line)) center / 1px 100% no-repeat; }

.ink-page[data-layout="focus"] .ink-line { justify-content: center; }
.ink-page[data-layout="focus"] .ink-head h1 { font-size: 0.62em; }

:is(.ink-w, .ink-v, .ink-n, .ink-cell)[data-tap] { border-radius: 6px; transition: background 0.12s, box-shadow 0.12s, color 0.12s; }
:is(.ink-w, .ink-cell).in-verse { background: var(--verse-soft); box-shadow: 0 0 0 0.06em var(--verse-soft); }
:is(.ink-w, .ink-cell).sel { background: var(--accent-soft); color: var(--accent-text); box-shadow: 0 0 0 0.06em var(--accent-soft), inset 0 0 0 1px var(--accent-line); }
.ink-cell.sel .ink-g { color: var(--accent-text); }
:is(.ink-v, .ink-n).sel { background: var(--accent); color: var(--bg); box-shadow: 0 0 0 0.25em var(--accent); }
.reader:has(kore-ink[data-tool="look"]) [data-tap] { cursor: pointer; }
@media (hover: hover) { .reader:has(kore-ink[data-tool="look"]) [data-tap]:not(.sel):hover { background: var(--hover); } }

kore-ink { position: absolute; inset: 0; display: block; touch-action: none; cursor: crosshair; }
kore-ink[data-tool="eraser"] { cursor: cell; }
kore-ink[data-tool="look"] { pointer-events: none; }
kore-ink svg { display: block; width: 100%; height: 100%; overflow: visible; }
kore-ink path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ink-c0 { stroke: var(--ink-0); }
.ink-c1 { stroke: var(--ink-1); }
.ink-c2 { stroke: var(--ink-2); }

.ink-bar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 25;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--raised);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.ink-name {
  width: 12rem;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 500 14px var(--sans);
}

.ink-group { display: flex; align-items: center; gap: 2px; }
.ink-group + .ink-group { padding-left: 10px; border-left: 1px solid var(--line); }
.ink-bar .icon-btn:disabled { opacity: 0.3; cursor: default; background: none; }
.ink-bar .icon-btn.on { background: none; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }

.ink-swatch {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, currentColor 0 9px, transparent 10px);
  cursor: pointer;
}

.ink-swatch.on { box-shadow: inset 0 0 0 2px currentColor; }

.ink-done {
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
}

.ink-bar .notice { flex-basis: 100%; text-align: center; }
.ink-hint {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--text);
  color: var(--bg);
  font: 500 12.5px var(--sans);
  white-space: nowrap;
  pointer-events: none;
  animation: fade-in 0.15s;
}

@media (min-width: 960px) {
  .writing.panel-pinned.panel-right .ink-bar { left: calc((100vw - var(--panel-w)) / 2); max-width: calc(100vw - var(--panel-w) - 24px); }
  .writing.panel-pinned.panel-left .ink-bar { left: calc((100vw + var(--panel-w)) / 2); max-width: calc(100vw - var(--panel-w) - 24px); }
  .writing.panel-pinned.panel-bottom .ink-bar { bottom: calc(var(--dock-h) + 16px); }
  .writing.panel-pinned:is(.panel-left, .panel-right) .ink-name { width: 8rem; }
  .writing.panel-floating.panel-bottom.has-selection .ink-bar { top: calc(var(--bar-h) + 12px); bottom: auto; }
  .app.writing.layout-focus.panel-floating.has-selection.panel-left .reader { padding-left: 420px; }
  .app.writing.layout-focus.panel-floating.has-selection.panel-right .reader { padding-right: 420px; }
}

@media (max-width: 959px) {
  .app.writing.has-selection .reader { padding-bottom: calc(var(--sheet-h) + 140px); }
  .writing.has-selection .ink-bar { bottom: calc(var(--sheet-h) + 12px); }
}

@media (max-width: 600px) {
  :root { --ink-room: 150px; }
  .app.writing .reader { padding: 20px 16px 170px; }
  .app.writing.layout-scroll .reader { padding: 8px 0 0; }
  .ink-name { flex: 1 1 100%; width: auto; }
  .writing.has-selection .ink-name { display: none; }
  .ink-group + .ink-group { padding-left: 0; border-left: 0; }
  .ink-bar { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .loader-bar span { width: 100%; opacity: 0.5; }
}

.pending-note { margin: 2rem 0; text-align: center; color: var(--muted); font: 15px var(--sans); }
.draw-new:disabled { opacity: 0.5; cursor: default; }
.offline-status { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
