:root {
  color-scheme: only light;
  --navy-950: #111a2d;
  --navy-900: #17233b;
  --navy-800: #243451;
  --navy-700: #344867;
  --ink: #1d2940;
  --muted: #697386;
  --soft: #8f98a8;
  --line: #dfe3e9;
  --line-strong: #cbd1da;
  --canvas: #e9e8e3;
  --paper: #fffef9;
  --cream: #f7f5ef;
  --white: #ffffff;
  --coral: #e16652;
  --coral-dark: #bd4938;
  --mint: #dceee7;
  --success: #2f7458;
  --danger: #b43d3d;
  --visible-viewport-height: 100dvh;
  --visible-viewport-top: 0px;
  --app-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --app-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --editor-header-height: 58px;
  --shadow-soft: 0 12px 32px rgba(23, 35, 59, 0.12);
  --shadow-paper: 0 18px 48px rgba(24, 31, 43, 0.18), 0 2px 8px rgba(24, 31, 43, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--navy-950);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

button,
[role="button"],
input,
select,
textarea {
  outline: none;
}

button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: 0 0 0 3px rgba(225, 102, 82, 0.3);
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell,
.screen {
  width: 100%;
  height: 100%;
}

.screen {
  min-height: 100dvh;
}

/* Editor */

.editor-screen {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  background: var(--canvas);
}

.editor-header { grid-row: 1; }
.voice-editor,
.canvas-stage { grid-row: 2; }
.page-bar { grid-row: 3; }
.rich-format-bar { grid-row: 4; }
.tool-dock,
.rich-tool-dock { grid-row: 5; }

.editor-header {
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(72px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: calc(var(--editor-header-height) + var(--app-safe-top));
  padding: calc(8px + var(--app-safe-top)) 10px 8px;
  color: var(--white);
  background: var(--navy-900);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

.header-button,
.save-button,
.more-button,
.note-heading {
  min-height: 42px;
  color: inherit;
  background: transparent;
  border-radius: 12px;
}

.library-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 7px;
  font-size: 0.78rem;
  font-weight: 700;
}

.library-button:hover,
.library-button:active,
.more-button:hover,
.more-button:active,
.note-heading:hover,
.note-heading:active {
  background: rgba(255, 255, 255, 0.08);
}

.stack-icon {
  position: relative;
  display: block;
  width: 23px;
  height: 24px;
}

.stack-icon i {
  position: absolute;
  left: 1px;
  width: 19px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  background: var(--navy-900);
}

.stack-icon i:nth-child(1) { top: 1px; opacity: 0.45; }
.stack-icon i:nth-child(2) { top: 4px; opacity: 0.7; }
.stack-icon i:nth-child(3) { top: 7px; }

.note-heading {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 4px 8px;
  text-align: left;
}

.note-heading strong,
.note-heading span {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-heading strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.note-heading span {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.68rem;
  line-height: 1.1;
}

.header-end {
  display: flex;
  align-items: center;
  gap: 4px;
}

.save-status {
  display: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.68rem;
  white-space: nowrap;
}

.save-status.is-dirty {
  color: #ffd0c8;
}

.save-button {
  min-width: 52px;
  padding: 0 10px;
  color: var(--navy-950);
  background: var(--white);
  font-size: 0.76rem;
  font-weight: 800;
}

.save-button:active {
  transform: translateY(1px);
}

.more-button {
  width: 40px;
  padding: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
}

.canvas-stage {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  background: var(--paper);
}

.canvas-stage.is-page-carousel-moving,
.voice-editor.is-page-carousel-moving {
  z-index: 3;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.page-loop-notice {
  position: absolute;
  z-index: 8;
  top: calc(var(--editor-header-height) + var(--app-safe-top) + 12px);
  left: 50%;
  display: flex;
  max-width: calc(100% - 36px);
  align-items: center;
  gap: 7px;
  padding: 6px 11px 6px 7px;
  transform: translate(-50%, -8px) scale(0.96);
  color: rgba(23, 35, 59, 0.82);
  background: linear-gradient(135deg, rgba(255, 254, 249, 0.92), rgba(233, 232, 227, 0.84));
  border: 1px solid rgba(23, 35, 59, 0.12);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(23, 35, 59, 0.12);
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 220ms ease, transform 260ms cubic-bezier(.2,.8,.2,1);
}

.page-loop-notice.is-visible {
  transform: translate(-50%, 0) scale(1);
  opacity: 0.92;
}

.page-loop-notice.is-leaving {
  transform: translate(-50%, -3px) scale(0.99);
  opacity: 0;
}

.page-loop-glyph {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  flex: none;
  color: var(--coral-dark);
  background: rgba(201, 77, 66, 0.08);
  border: 1px solid rgba(201, 77, 66, 0.14);
  border-radius: 50%;
  font-size: 0.92rem;
  line-height: 1;
}

.paper {
  position: relative;
  flex: none;
  overflow: hidden;
  background-color: var(--paper);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  isolation: isolate;
  color-scheme: only light;
  forced-color-adjust: none;
}

.page-template-background {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: var(--paper);
  transform-origin: 0 0;
  pointer-events: none;
  will-change: transform;
}

.page-template-background::before {
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 0;
  left: clamp(30px, 10%, 62px);
  width: 1px;
  content: "";
  background: rgba(219, 100, 88, 0.2);
  pointer-events: none;
}

.paper-lined .page-template-background {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 59px,
    rgba(83, 131, 170, 0.18) 60px,
    transparent 61px
  );
}

.paper-grid .page-template-background {
  background-image:
    linear-gradient(rgba(83, 131, 170, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(83, 131, 170, 0.13) 1px, transparent 1px);
  background-size: 50px 50px;
}

.paper-dot .page-template-background {
  background-image: radial-gradient(circle, rgba(69, 93, 119, 0.28) 1px, transparent 1.25px);
  background-size: 44px 44px;
}

.paper-blank .page-template-background::before,
.paper-grid .page-template-background::before,
.paper-dot .page-template-background::before {
  display: none;
}

#noteCanvas {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  background: transparent;
  color-scheme: only light;
  forced-color-adjust: none;
}

.page-photo-background {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  pointer-events: none;
  user-select: none;
  will-change: transform;
  -webkit-user-drag: none;
  -webkit-user-select: none;
}

.paper.has-photo .page-template-background,
.paper:has(.page-photo-background:not([hidden])) .page-template-background {
  display: none;
}

.rich-object-layer {
  z-index: 1;
}

.ink-layer {
  z-index: 2;
}

.page-interaction-layer {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

.paper.is-ink-mode #noteCanvas {
  pointer-events: auto;
}

.paper.is-ink-mode .rich-artboard {
  pointer-events: none;
}

.paper.is-objects-mode #noteCanvas {
  pointer-events: none;
}

.paper.is-objects-mode .rich-artboard,
.paper.is-objects-mode .rich-object {
  pointer-events: auto;
}

.paper.is-ink-mode .rich-empty-hint,
.paper.is-ink-mode .rich-marquee,
.paper.is-ink-mode .rich-group-selection {
  display: none !important;
}

.paper.is-objects-mode .empty-hint {
  display: none;
}

.empty-hint {
  position: absolute;
  z-index: 3;
  top: 42%;
  left: 50%;
  display: flex;
  width: max-content;
  max-width: 80%;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  color: #adb3bc;
  pointer-events: none;
  text-align: center;
  transition: opacity 160ms ease;
}

.empty-hint span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 5vw, 1.7rem);
  font-style: italic;
}

.empty-hint small {
  margin-top: 8px;
  color: #bbc0c7;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.empty-hint.is-hidden {
  opacity: 0;
}

.zoom-controls {
  display: grid;
  grid-template-columns: 34px 48px 34px;
  gap: 1px;
  justify-self: end;
  padding: 2px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(23, 35, 59, 0.16);
  border-radius: 10px;
}

.zoom-controls button {
  display: flex;
  min-width: 0;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--navy-800);
  background: transparent;
  border-radius: 9px;
  font-size: 1.15rem;
  font-weight: 750;
}

.zoom-controls button:active {
  background: #eef0f3;
}

.zoom-controls button:disabled {
  color: #b9bec7;
}

.zoom-controls .zoom-fit-button {
  flex-direction: column;
  gap: 1px;
  font-size: 0.68rem;
}

.zoom-fit-button span {
  font-weight: 850;
  line-height: 1;
}

.zoom-fit-button small {
  color: var(--muted);
  font-size: 0.53rem;
  font-weight: 750;
  line-height: 1;
  text-transform: uppercase;
}

.page-bar {
  z-index: 4;
  display: grid;
  grid-template-columns: 44px minmax(62px, auto) minmax(68px, 1fr) auto 44px;
  align-items: center;
  gap: 4px;
  min-height: 46px;
  padding: 4px 10px;
  background: #f3f2ed;
  border-top: 1px solid rgba(23, 35, 59, 0.08);
}

.page-bar button {
  min-height: 36px;
  border-radius: 10px;
  background: transparent;
}

.page-arrow {
  color: var(--navy-800);
  font-family: Georgia, serif;
  font-size: 1.75rem;
  line-height: 1;
}

.page-arrow:disabled {
  color: #bdc2ca;
}

#nextPageButton {
  grid-column: 5;
}

.page-count {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 3px 8px;
  text-align: left;
}

.page-count span {
  color: var(--navy-900);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.05;
}

.page-count small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1;
}

.add-page-button {
  justify-self: start;
  padding: 0 12px;
  color: var(--navy-900);
  border: 1px solid var(--line-strong);
  font-size: 0.74rem;
  font-weight: 800;
}

.add-page-button span {
  margin-right: 2px;
  color: var(--coral-dark);
  font-size: 1rem;
}

.canvas-tool-dock {
  z-index: 5;
  display: flex;
  min-width: 0;
  align-items: stretch;
  min-height: calc(72px + var(--app-safe-bottom));
  padding: 5px 6px calc(5px + var(--app-safe-bottom));
  color: var(--white);
  background: var(--navy-900);
  box-shadow: 0 -1px 0 rgba(23, 35, 59, 0.08);
}

.canvas-tool-dock[hidden],
.canvas-tool-drawer[hidden] {
  display: none !important;
}

.canvas-mode-switch {
  display: grid;
  width: 58px;
  flex: 0 0 58px;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 2px;
  margin-right: 5px;
  padding-right: 5px;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
}

.canvas-mode-button {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 56px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 3px 1px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

.canvas-mode-button .tool-mark {
  width: 19px;
  height: 20px;
}

.canvas-mode-button small {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.54rem;
  font-weight: 850;
  line-height: 1;
  text-overflow: clip;
  white-space: nowrap;
}

.canvas-mode-button:active {
  background: rgba(255, 255, 255, 0.16);
}

.canvas-mode-triangle {
  display: block;
  width: 0;
  height: 0;
  border-right: 10px solid transparent;
  border-bottom: 18px solid currentColor;
  border-left: 10px solid transparent;
  filter: drop-shadow(0 0 0 currentColor);
}

.canvas-tool-drawer {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: stretch;
  gap: 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.canvas-tool-drawer::-webkit-scrollbar {
  display: none;
}

.ink-tool-drawer {
  align-items: center;
}

/* Keep tool groups at their natural width while the drawer scrolls on narrow phones. */
.ink-tool-drawer > * {
  flex: 0 0 auto;
}

.tool-group {
  display: flex;
  align-items: center;
}

.drawing-tools {
  min-width: 0;
  gap: 2px;
}

.tool-button,
.compact-tool,
.history-button {
  position: relative;
  min-height: 56px;
  padding: 4px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  border-radius: 12px;
}

.tool-button {
  display: flex;
  min-width: 50px;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.tool-button.is-active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
}

.tool-button.is-active::after {
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 15px;
  height: 2px;
  content: "";
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--coral);
}

.tool-button small,
.compact-tool small {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tool-mark {
  position: relative;
  display: block;
  width: 22px;
  height: 23px;
}

.pen-mark::before {
  position: absolute;
  top: 1px;
  left: 9px;
  width: 5px;
  height: 19px;
  content: "";
  transform: rotate(38deg);
  transform-origin: center;
  border: 1.5px solid currentColor;
  border-radius: 4px 4px 1px 1px;
}

.pen-mark::after {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 8px;
  height: 1.5px;
  content: "";
  transform: rotate(-8deg);
  border-radius: 999px;
  background: currentColor;
}

.eraser-mark::before {
  position: absolute;
  top: 5px;
  left: 3px;
  width: 15px;
  height: 12px;
  content: "";
  transform: rotate(-35deg);
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.eraser-mark::after {
  position: absolute;
  right: 1px;
  bottom: 3px;
  width: 12px;
  height: 1.5px;
  content: "";
  background: currentColor;
  opacity: 0.65;
}

.tool-divider {
  width: 1px;
  height: 38px;
  background: rgba(255, 255, 255, 0.12);
}

.style-tools {
  gap: 0;
}

.compact-tool {
  display: flex;
  width: 43px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.compact-tool:disabled {
  cursor: default;
}

#noteCanvas.is-panning {
  cursor: grabbing;
}

.active-color {
  display: block;
  width: 21px;
  height: 21px;
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: #172137;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
}

.active-size {
  display: block;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.92) 0 3px, transparent 3.5px);
}

.history-tools {
  gap: 0;
}

.history-button {
  width: 35px;
  font-family: Georgia, serif;
  font-size: 1.45rem;
  line-height: 1;
}

.history-button:disabled {
  color: rgba(255, 255, 255, 0.22);
}

.editor-screen.is-voice-note {
  inset: var(--visible-viewport-top) 0 auto;
  height: var(--visible-viewport-height);
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
}

.editor-screen.is-voice-note .page-bar {
  padding-bottom: calc(4px + var(--app-safe-bottom));
}

.native-android .editor-screen.is-voice-note {
  inset: var(--visible-viewport-top) 0 auto;
  height: var(--visible-viewport-height);
  min-height: 0;
}

.voice-editor {
  position: relative;
  display: grid;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  overflow: hidden;
  /* The shared page bar owns the Android bottom inset. Applying it here too
     wastes a second safe-area strip and crowds the dictation controls. */
  padding: 12px;
  background: var(--canvas);
}

.voice-editor.is-typing {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

.voice-editor.is-typing.is-formatting {
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
}

.voice-editor.is-typing .voice-photo-strip,
.voice-editor.is-typing .voice-control-bar {
  display: none;
}

.voice-document {
  display: grid;
  width: min(100%, 820px);
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  margin: 0 auto;
  padding: 15px 17px 12px;
  background: var(--paper);
  border: 1px solid #deded8;
  border-radius: 12px;
  box-shadow: var(--shadow-paper);
}

.voice-document-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 0.65rem;
  font-weight: 750;
}

.voice-document-heading-actions {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.voice-format-toggle {
  display: none;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  color: var(--navy-800);
  background: #eef1f6;
  border: 1px solid #cfd5df;
  border-radius: 9px;
  font-size: 0.66rem;
  font-weight: 850;
}

.voice-editor.is-typing .voice-format-toggle {
  display: inline-flex;
}

.voice-editor.is-formatting .voice-format-toggle {
  color: #fff;
  background: var(--navy-800);
  border-color: var(--navy-800);
}

.voice-type-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--coral-dark);
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mic-glyph {
  position: relative;
  display: inline-block;
  width: 15px;
  height: 19px;
  flex: none;
  background: linear-gradient(currentColor, currentColor) center bottom 2px / 2px 5px no-repeat;
}

.mic-glyph::before,
.mic-glyph::after {
  position: absolute;
  content: "";
}

.mic-glyph::before {
  top: 0;
  left: 4px;
  width: 7px;
  height: 11px;
  border: 2px solid currentColor;
  border-radius: 7px;
}

.mic-glyph::after {
  bottom: 4px;
  left: 1px;
  width: 13px;
  height: 8px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 9px 9px;
}

.voice-note-input {
  width: 100%;
  min-height: 0;
  padding: 14px 2px 24px;
  overflow-y: auto;
  color: var(--navy-900);
  background: transparent;
  border: 0;
  caret-color: var(--coral-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 3.8vw, 1.18rem);
  line-height: 1.68;
  scrollbar-width: none;
  user-select: text;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-user-select: text;
}

.voice-note-input::-webkit-scrollbar {
  display: none;
}

.voice-note-input:empty::before {
  content: attr(data-placeholder);
  color: #a6adb7;
  font-style: italic;
  pointer-events: none;
}

.voice-note-input[contenteditable="false"] {
  color: var(--navy-800);
}

.voice-note-input:focus {
  outline: 0;
}

.voice-editor.is-typing .voice-note-input {
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
}

.voice-note-input p,
.voice-note-input div,
.voice-note-input ul,
.voice-note-input ol {
  margin-top: 0;
  margin-bottom: 0.45em;
}

.voice-note-input ul,
.voice-note-input ol {
  padding-left: 1.6em;
  white-space: normal;
}

.voice-format-panel {
  width: min(100%, 820px);
  max-height: min(42vh, 285px);
  margin: 0 auto;
  padding: 10px;
  overflow-y: auto;
  color: var(--navy-900);
  background: rgba(247, 246, 242, 0.98);
  border: 1px solid #d2d5dc;
  border-radius: 15px 15px 8px 8px;
  box-shadow: 0 -7px 24px rgba(23, 35, 59, 0.12);
}

.voice-format-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.voice-format-panel-heading > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.voice-format-panel-heading strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
}

.voice-format-panel-heading small {
  color: var(--muted);
  font-size: 0.62rem;
}

.voice-format-tools,
.voice-format-colors {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 1px;
  scrollbar-width: none;
}

.voice-format-tools::-webkit-scrollbar,
.voice-format-colors::-webkit-scrollbar {
  display: none;
}

.voice-format-tools button {
  min-width: 38px;
  min-height: 38px;
  flex: none;
  padding: 6px 9px;
  color: var(--navy-900);
  background: #fff;
  border: 1px solid #d4d8df;
  border-radius: 9px;
  font-size: 0.73rem;
  font-weight: 800;
}

.voice-format-tools button:active,
.voice-format-tools button.is-active {
  color: #fff;
  background: var(--coral-dark);
  border-color: var(--coral-dark);
}

.voice-format-divider {
  width: 1px;
  height: 27px;
  flex: none;
  margin: 0 1px;
  background: #d9dce2;
}

.voice-font-size-label {
  min-width: 48px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  text-align: center;
}

.voice-format-alignment {
  padding-top: 2px;
}

.voice-format-colors > span:first-child {
  flex: none;
  margin-right: 2px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 850;
  text-transform: uppercase;
}

.voice-format-colors button,
.voice-custom-text-color {
  position: relative;
  display: grid;
  width: 32px;
  min-width: 32px;
  height: 32px;
  place-items: center;
  overflow: hidden;
  background: var(--voice-swatch, conic-gradient(#d22, #ed2, #2b6, #28c, #82d, #d22));
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #c7cbd3;
}

.voice-custom-text-color {
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
}

.voice-custom-text-color input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.voice-editor:not(.is-typing) .voice-note-input {
  /* Reserve horizontal touch travel for the page carousel while retaining
     normal vertical transcript scrolling. Typing mode restores browser text gestures. */
  touch-action: pan-y;
}

.voice-control-bar {
  display: grid;
  width: min(100%, 820px);
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 0 auto;
}

.voice-note-status {
  display: flex;
  min-width: 0;
  min-height: 56px;
  grid-column: 1 / -1;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--navy-700);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: 0 5px 16px rgba(23, 35, 59, 0.08);
}

.voice-note-status > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.voice-note-status strong {
  color: var(--navy-900);
  font-size: 0.71rem;
}

.voice-note-status small {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.voice-status-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border: 3px solid #c7d1cb;
  border-radius: 50%;
  background: var(--success);
  box-sizing: content-box;
}

.voice-note-status.is-listening {
  color: var(--coral-dark);
  background: #fff7f4;
  border-color: #e9b9af;
}

.voice-note-status.is-listening .voice-status-dot {
  border-color: #f1c2b9;
  background: var(--coral);
  animation: voice-pulse 1.2s ease-in-out infinite;
}

.voice-note-status.has-error .voice-status-dot {
  border-color: #ebcac6;
  background: var(--danger);
}

.voice-record-button,
.voice-stop-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  border-radius: 13px;
  font-size: 0.76rem;
  font-weight: 850;
}

.voice-record-button {
  color: var(--white);
  background: var(--navy-900);
  box-shadow: 0 6px 16px rgba(23, 35, 59, 0.18);
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

.voice-record-button.is-transcript-focused:not(:disabled) {
  background: var(--navy-800);
  box-shadow: 0 0 0 3px rgba(225, 102, 82, 0.18), 0 7px 18px rgba(23, 35, 59, 0.22);
}

.voice-stop-button {
  min-width: 82px;
  color: var(--white);
  background: var(--coral-dark);
}

.voice-record-button:disabled,
.voice-stop-button:disabled {
  color: #8d95a2;
  background: #d9dce1;
  box-shadow: none;
}

@keyframes voice-pulse {
  50% { transform: scale(1.22); opacity: 0.72; }
}

.voice-photo-strip {
  display: grid;
  width: min(100%, 820px);
  min-width: 0;
  gap: 7px;
  margin: 0 auto;
  padding: 9px 10px 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 5px 16px rgba(23, 35, 59, 0.07);
}

.voice-photo-strip-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--navy-800);
  font-size: 0.65rem;
}

.voice-photo-strip-heading strong {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.voice-photo-strip-heading span {
  color: var(--muted);
}

.voice-photo-strip-scroll {
  display: flex;
  min-width: 0;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 1px 2px 3px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.voice-photo-strip-scroll::-webkit-scrollbar {
  display: none;
}

.voice-photo-thumbnails {
  display: flex;
  flex: none;
  gap: 8px;
}

.voice-photo-thumbnails:empty {
  display: none;
}

.voice-photo-thumbnail,
.voice-photo-thumbnails > button,
.voice-photo-add-tile {
  position: relative;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  overflow: hidden;
  background: #e4e5e3;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

.voice-photo-thumbnail img,
.voice-photo-thumbnails > button img {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  pointer-events: none;
}

.voice-photo-thumbnail > span {
  position: absolute;
  right: 3px;
  bottom: 3px;
  z-index: 1;
  min-width: 17px;
  padding: 2px 4px;
  color: var(--white);
  background: rgba(23, 33, 55, 0.76);
  border-radius: 999px;
  font-size: 0.55rem;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
}

.voice-photo-thumbnail[aria-current="true"],
.voice-photo-thumbnails > button[aria-current="true"] {
  border-color: var(--coral-dark);
  box-shadow: 0 0 0 2px rgba(225, 102, 82, 0.25);
}

.voice-photo-add-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  color: var(--coral-dark);
  background: #fff7f4;
  border-style: dashed;
}

.voice-photo-add-tile span {
  font-size: 1.3rem;
  font-weight: 350;
  line-height: 1;
}

.voice-photo-add-tile small {
  font-size: 0.58rem;
  font-weight: 850;
}

.voice-photo-viewer {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 9px;
  padding: 10px 10px calc(10px + var(--app-safe-bottom));
  background: var(--canvas);
}

.voice-photo-viewer-header {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(90px, 1fr) auto minmax(90px, 1fr);
  align-items: center;
  gap: 7px;
}

.voice-photo-viewer-back,
.voice-photo-viewer-actions button {
  min-height: 40px;
  padding: 0 10px;
  color: var(--navy-800);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 0.67rem;
  font-weight: 850;
}

.voice-photo-viewer-back {
  justify-self: start;
}

.voice-photo-viewer-position {
  color: var(--navy-700);
  font-size: 0.65rem;
  font-weight: 850;
  text-align: center;
  white-space: nowrap;
}

.voice-photo-viewer-actions {
  display: flex;
  justify-self: end;
  gap: 5px;
}

.voice-photo-viewer-actions button.is-danger {
  color: var(--danger);
}

.voice-photo-viewer-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  place-items: center;
  background: #202738;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  box-shadow: var(--shadow-paper);
  touch-action: none;
}

#voicePhotoViewerImage {
  position: absolute;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  pointer-events: none;
  user-select: none;
  will-change: transform;
  -webkit-user-drag: none;
  -webkit-user-select: none;
}

.voice-photo-viewer-arrow {
  position: absolute;
  top: 50%;
  display: grid;
  width: 42px;
  height: 48px;
  place-items: center;
  transform: translateY(-50%);
  color: var(--white);
  background: rgba(17, 26, 45, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  font-family: Georgia, serif;
  font-size: 1.8rem;
  line-height: 1;
  backdrop-filter: blur(5px);
}

.voice-photo-viewer-arrow.is-previous {
  left: 9px;
}

.voice-photo-viewer-arrow.is-next {
  right: 9px;
}

.voice-photo-viewer-arrow:disabled {
  opacity: 0.3;
}

/* Rich note editor */

.editor-screen.is-rich-note {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.rich-editor {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #dfded9;
}

.rich-editor-legacy-hook {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.rich-canvas-stage {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 9px;
}

.rich-artboard {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  container-type: inline-size;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.rich-empty-hint {
  position: absolute;
  top: 44%;
  left: 50%;
  display: flex;
  width: 80%;
  flex-direction: column;
  gap: 7px;
  transform: translate(-50%, -50%);
  color: #a2a9b3;
  pointer-events: none;
  text-align: center;
  transition: opacity 150ms ease;
}

.rich-empty-hint strong {
  color: #8e97a4;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
  font-style: italic;
  font-weight: 500;
}

.rich-empty-hint span {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rich-empty-hint.is-hidden {
  opacity: 0;
}

.rich-hold-control {
  position: absolute;
  z-index: 307;
  bottom: 8px;
  left: 8px;
  display: none;
  width: 62px;
  height: 62px;
  pointer-events: none;
}

.rich-hold-control::before {
  position: absolute;
  inset: 8px;
  content: "";
  background: transparent;
  border: 2px solid rgba(23, 33, 55, 0.58);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(23, 33, 55, 0.12);
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.paper.is-objects-mode .rich-hold-control {
  display: block;
}

.rich-hold-control.is-active::before {
  background: rgba(201, 77, 66, 0.28);
  border-color: var(--coral-dark);
  transform: scale(1.04);
}

.rich-marquee {
  position: absolute;
  z-index: 306;
  pointer-events: none;
  background: rgba(201, 77, 66, 0.1);
  border: 2px dashed var(--coral-dark);
  border-radius: 3px;
}

.rich-group-selection {
  position: absolute;
  z-index: 305;
  pointer-events: none;
  outline: 2px dashed var(--coral-dark);
  outline-offset: 4px;
  transform-origin: center;
}

.rich-group-selection.is-locked {
  outline-color: var(--navy-700);
}

.rich-group-selection-label {
  position: absolute;
  top: -21px;
  left: -5px;
  padding: 2px 5px;
  color: var(--white);
  background: var(--coral-dark);
  border-radius: 4px;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-transform: uppercase;
}

.rich-group-selection.is-locked .rich-group-selection-label {
  background: var(--navy-700);
}

.rich-group-resize-handle,
.rich-group-rotate-handle {
  position: absolute;
  z-index: 2;
  display: block;
  width: 25px;
  height: 25px;
  padding: 0;
  pointer-events: auto;
  background: var(--white);
  border: 3px solid var(--coral-dark);
  border-radius: 50%;
  box-shadow: 0 2px 7px rgba(23, 35, 59, 0.28);
  touch-action: none;
}

.rich-group-resize-handle {
  right: -12px;
  bottom: -12px;
  cursor: nwse-resize;
}

.rich-group-rotate-handle {
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--coral-dark);
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: grab;
}

.rich-group-selection.is-locked .rich-group-resize-handle,
.rich-group-selection.is-locked .rich-group-rotate-handle {
  display: none;
}

.rich-object {
  position: absolute;
  min-width: 18px;
  min-height: 18px;
  cursor: move;
  transform-origin: center;
  touch-action: none;
  will-change: transform;
}

.rich-object.is-locked {
  cursor: default;
}

.rich-object-line {
  min-height: 0;
}

.rich-object-line::after {
  position: absolute;
  inset: -10px 0;
  content: "";
}

.rich-object-content {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.rich-object-text .rich-object-content,
.rich-object-line .rich-object-content {
  opacity: var(--rich-opacity, 1);
}

.rich-object-text .rich-object-content {
  color: var(--rich-color, #172137);
  font-family: Georgia, "Times New Roman", serif;
  font-size: calc(var(--rich-font-size, 32) * 0.1cqw);
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.rich-object-shape .rich-object-content {
  background: var(--rich-fill-color, var(--paper));
  border: calc(var(--rich-stroke-size, 4) * 0.1cqw) solid var(--rich-color, #172137);
}

.rich-object[data-shape="rounded"] .rich-object-content {
  border-radius: 20%;
}

.rich-object[data-shape="ellipse"] .rich-object-content {
  border-radius: 50%;
}

.rich-object[data-shape="triangle"] .rich-object-content {
  overflow: visible;
  background: none;
  border: 0;
  clip-path: none;
}

.rich-triangle-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.rich-triangle-svg polygon {
  fill: var(--rich-fill-color, var(--paper));
  stroke: var(--rich-color, #172137);
  stroke-linejoin: round;
  stroke-width: calc(var(--rich-stroke-size, 4) * 0.1cqw);
  stroke-opacity: 1;
  vector-effect: non-scaling-stroke;
}

.rich-object[data-shape="triangle"][data-borderless="true"] .rich-triangle-svg polygon {
  stroke: none;
}

.rich-line-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.rich-line-svg line {
  stroke: var(--rich-color, #172137);
  stroke-linecap: round;
  stroke-width: var(--rich-stroke-size, 4);
  vector-effect: non-scaling-stroke;
}

.rich-object.is-selected {
  outline: 2px dashed var(--coral);
  outline-offset: 4px;
}

.rich-object.is-multi-selected {
  outline: 2px dashed var(--coral);
  outline-offset: 3px;
}

.rich-object.is-selected::before {
  position: absolute;
  z-index: 4;
  top: -18px;
  left: -5px;
  padding: 2px 5px;
  content: "Move";
  color: var(--white);
  background: var(--coral-dark);
  border-radius: 4px;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transform: rotate(var(--rich-counter-rotation, 0deg));
}

.rich-object.is-selected.is-locked {
  outline-color: var(--navy-700);
}

.rich-object.is-selected.is-locked::before {
  content: "Locked";
  background: var(--navy-700);
}

.rich-resize-handle,
.rich-rotate-handle {
  position: absolute;
  z-index: 5;
  display: none;
  width: 23px;
  height: 23px;
  padding: 0;
  background: var(--white);
  border: 3px solid var(--coral-dark);
  border-radius: 50%;
  box-shadow: 0 2px 7px rgba(23, 35, 59, 0.28);
  cursor: nwse-resize;
  touch-action: none;
}

.rich-resize-handle {
  right: -11px;
  bottom: -11px;
}

.rich-resize-handle-nw {
  top: -11px;
  right: auto;
  bottom: auto;
  left: -11px;
}

.rich-resize-handle-ne {
  top: -11px;
  right: -11px;
  bottom: auto;
  left: auto;
  cursor: nesw-resize;
}

.rich-resize-handle-sw {
  top: auto;
  right: auto;
  bottom: -11px;
  left: -11px;
  cursor: nesw-resize;
}

.rich-resize-handle-se {
  top: auto;
  right: -11px;
  bottom: -11px;
  left: auto;
}

.rich-rotate-handle {
  top: -28px;
  right: auto;
  left: 50%;
  transform: translateX(-50%);
  color: var(--coral-dark);
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: grab;
}

.rich-object.is-selected .rich-resize-handle,
.rich-object.is-selected .rich-rotate-handle {
  display: block;
}

.rich-object-shape.is-selected:not(.is-locked)::before {
  display: none;
}

.rich-format-bar {
  z-index: 5;
  display: flex;
  min-width: 0;
  min-height: 49px;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  background: #f4f3ee;
  border-top: 1px solid rgba(23, 35, 59, 0.1);
}

.rich-selection-label {
  width: 55px;
  flex: none;
  color: var(--navy-700);
  font-size: 0.6rem;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
}

.rich-format-scroll {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}

.rich-format-scroll::-webkit-scrollbar {
  display: none;
}

.rich-format-scroll button,
.rich-size-label {
  display: inline-flex;
  min-width: 38px;
  min-height: 34px;
  flex: none;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  color: var(--navy-800);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 0.68rem;
  font-weight: 800;
}

.rich-format-scroll button:disabled {
  color: #abb1ba;
  background: #e7e7e4;
}

.rich-format-scroll .rich-format-toggle.is-active {
  color: var(--white);
  background: var(--navy-900);
  border-color: var(--navy-900);
}

.rich-size-label {
  min-width: 50px;
  padding: 0 6px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  font-size: 0.61rem;
}

.rich-format-scroll .rich-color-button {
  gap: 6px;
}

.rich-color-button i {
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: #172137;
  box-shadow: 0 0 0 1px rgba(23, 35, 59, 0.25);
}

.rich-format-scroll .rich-delete-button {
  color: var(--danger);
}

.rich-tool-dock {
  min-height: calc(66px + var(--app-safe-bottom));
}

.object-tool-drawer {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto;
  align-items: stretch;
  gap: 5px;
}

.rich-add-tools,
.rich-layer-tools,
.rich-history-tools {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.rich-tool-dock .canvas-tool-drawer button {
  min-width: 45px;
  min-height: 54px;
  padding: 4px 7px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border-radius: 11px;
  font-size: 0.6rem;
  font-weight: 800;
}

.rich-add-tools button {
  display: flex;
  min-width: 49px;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.rich-add-tools button > b {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.rich-add-tools small {
  font-size: 0.56rem;
  font-weight: 800;
}

.rich-shape-icon {
  width: 21px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.rich-line-icon {
  width: 24px;
  height: 2px;
  transform: rotate(-28deg);
  border-radius: 99px;
  background: currentColor;
}

.rich-layer-tools,
.rich-history-tools {
  padding-left: 4px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.rich-layer-tools button {
  width: 42px;
  padding: 4px;
}

.rich-history-tools button {
  width: 37px;
  min-width: 37px;
  padding: 0;
  font-family: Georgia, serif;
  font-size: 1.45rem;
}

.rich-tool-dock .canvas-tool-drawer button:active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
}

.rich-tool-dock .canvas-tool-drawer button:disabled {
  color: rgba(255, 255, 255, 0.22);
}

/* Library */

.library-screen {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: hidden;
  padding-top: var(--app-safe-top);
  color: var(--ink);
  background: var(--cream);
}

.library-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 10px;
}

.library-header-tools {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.library-icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: none;
  place-items: center;
  color: var(--navy-800);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 5px 14px rgba(23, 35, 59, 0.07);
}

.library-icon-button:active {
  transform: translateY(1px);
}

.library-icon-svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.library-backup-button {
  color: var(--white);
  background: var(--navy-900);
  border-color: var(--navy-900);
  box-shadow: 0 7px 16px rgba(23, 35, 59, 0.18);
}

.library-backup-button:disabled {
  color: #9299a5;
  background: #e1e3e5;
  border-color: #d9dcdf;
  box-shadow: none;
}

.library-backup-button[aria-busy="true"] .library-save-icon {
  animation: library-save-pulse 720ms ease-in-out infinite alternate;
}

@keyframes library-save-pulse {
  from { opacity: 0.45; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.voice-create-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  color: var(--coral-dark);
  background: var(--white);
  border: 1px solid #efc5bd;
  border-radius: 12px;
  box-shadow: 0 5px 14px rgba(23, 35, 59, 0.07);
  font-size: 0.74rem;
  font-weight: 850;
}

.eyebrow {
  display: block;
  color: var(--coral-dark);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  line-height: 1.2;
  text-transform: uppercase;
}

.library-header h1 {
  margin: 1px 0 0;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 10vw, 3.4rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.9;
}

.library-header .eyebrow {
  width: fit-content;
  text-decoration: none;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 850;
}

.primary-button {
  color: var(--white);
  background: var(--navy-900);
  box-shadow: 0 7px 16px rgba(23, 35, 59, 0.18);
}

.primary-button span {
  margin-right: 5px;
  color: #ffad9f;
  font-size: 1rem;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: translateY(1px);
}

.secondary-button {
  color: var(--navy-800);
  background: var(--white);
  border: 1px solid var(--line-strong);
}

.danger-button {
  color: var(--white);
  background: var(--danger);
}

.library-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 10px 18px 8px;
}

.library-controls .search-field {
  grid-column: 1 / -1;
}

.search-field {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
}

.search-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px 0 41px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 4px 14px rgba(23, 35, 59, 0.04);
  appearance: none;
}

.search-field input::placeholder {
  color: #8b94a3;
}

.search-glyph {
  position: absolute;
  z-index: 1;
  left: 15px;
  width: 14px;
  height: 14px;
  border: 1.7px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}

.search-glyph::after {
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 1.7px;
  content: "";
  transform: rotate(45deg);
  border-radius: 999px;
  background: var(--muted);
}

.library-create-button {
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  font-size: 0.84rem;
}

.category-filters {
  display: flex;
  gap: 7px;
  min-width: 0;
  overflow-x: auto;
  padding: 8px 18px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.category-filters::-webkit-scrollbar {
  display: none;
}

.category-chip {
  min-height: 34px;
  flex: none;
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}

.category-chip.is-active {
  color: var(--white);
  background: var(--navy-800);
  border-color: var(--navy-800);
}

.category-chip.add-chip {
  color: var(--coral-dark);
  border-style: dashed;
}

.category-chip.manage-chip {
  color: var(--navy-700);
  background: var(--white);
}

.library-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 4px 18px calc(30px + var(--app-safe-bottom));
  scrollbar-gutter: stable;
}

.library-screen.is-selecting .library-scroll {
  padding-bottom: calc(164px + var(--app-safe-bottom));
}

.library-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 1px 12px;
}

.library-summary h2 {
  margin: 0;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 500;
}

.library-summary span {
  color: var(--muted);
  font-size: 0.72rem;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.note-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 7px 22px rgba(23, 35, 59, 0.06);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.note-card.is-holding {
  border-color: #e9a095;
  transform: scale(0.985);
}

.note-card.is-selected {
  border-color: var(--navy-800);
  box-shadow: 0 0 0 2px var(--navy-800), 0 10px 26px rgba(23, 35, 59, 0.16);
}

.note-card-main {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  background: transparent;
  text-align: left;
}

.note-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1.55 / 1;
  overflow: hidden;
  background: #e9e8e3;
  border-bottom: 1px solid var(--line);
}

.note-preview canvas {
  position: absolute;
  top: 9px;
  left: 50%;
  display: block;
  height: calc(100% - 9px);
  width: auto;
  transform: translateX(-50%);
  background: var(--paper);
  box-shadow: 0 5px 13px rgba(23, 35, 59, 0.15);
}

.voice-note-preview {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: 9px;
  background: #e5e7e8;
}

.voice-preview-photo {
  position: absolute;
  top: 10px;
  left: 9px;
  width: 42%;
  height: calc(100% - 18px);
  overflow: hidden;
  background: #e4e5e3;
  border: 3px solid var(--white);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(23, 35, 59, 0.2);
}

.voice-preview-photo-image {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  pointer-events: none;
}

.voice-note-preview:has(.voice-preview-photo) .voice-preview-page {
  width: 66%;
  margin-left: 28%;
}

.voice-preview-page {
  width: 78%;
  height: 100%;
  padding: 10px 11px;
  overflow: hidden;
  color: var(--navy-900);
  background: var(--paper);
  border: 1px solid #deded8;
  border-radius: 4px 4px 0 0;
  box-shadow: 0 5px 13px rgba(23, 35, 59, 0.15);
}

.voice-preview-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 7px;
  color: var(--coral-dark);
  border-bottom: 1px solid var(--line);
  font-size: 0.56rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.voice-preview-label .mic-glyph {
  width: 11px;
  height: 14px;
  transform: scale(0.74);
  transform-origin: left center;
}

.voice-preview-page p {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--navy-700);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.67rem;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.rich-note-preview {
  background: #deded9;
}

.note-preview canvas.rich-preview-canvas {
  border: 1px solid #deded8;
}

.note-card-body {
  padding: 12px 40px 12px 12px;
}

.note-card h3 {
  margin: 0;
  overflow: hidden;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-schedule {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  overflow: hidden;
  color: var(--coral-dark);
  font-size: 0.62rem;
  font-weight: 850;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-schedule::before {
  width: 7px;
  height: 7px;
  flex: none;
  content: "";
  border: 1.5px solid currentColor;
  border-radius: 2px;
  box-shadow: inset 0 2px 0 currentColor;
}

.note-card.is-past-due .note-schedule {
  color: var(--danger);
}

.note-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.2;
}

.note-meta span:first-child {
  max-width: 54%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-meta i {
  width: 3px;
  height: 3px;
  flex: none;
  border-radius: 50%;
  background: #b5bbc4;
}

.note-card-menu {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-radius: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.note-card-menu:hover,
.note-card-menu:active {
  background: #f2f3f5;
}

.note-selection-checkbox {
  position: absolute;
  z-index: 4;
  top: 8px;
  right: 8px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 254, 249, 0.94);
  box-shadow: 0 5px 14px rgba(23, 35, 59, 0.18);
}

.note-selection-checkbox input {
  width: 23px;
  height: 23px;
  margin: 0;
  accent-color: var(--navy-900);
}

.note-selection-order {
  position: absolute;
  top: -5px;
  left: -5px;
  display: grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  color: var(--white);
  background: var(--coral-dark);
  border: 2px solid var(--white);
  border-radius: 10px;
  font-size: 0.58rem;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

.note-selection-bar {
  position: fixed;
  z-index: 20;
  right: 12px;
  bottom: calc(12px + var(--app-safe-bottom));
  left: 12px;
  width: min(calc(100% - 24px), 560px);
  margin: 0 auto;
  padding: 12px;
  color: var(--white);
  background: rgba(23, 33, 55, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 18px 44px rgba(23, 35, 59, 0.3);
  backdrop-filter: blur(14px);
}

.note-selection-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 10px 4px;
}

.note-selection-heading div {
  min-width: 0;
}

.note-selection-heading strong,
.note-selection-heading small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-selection-heading > div > strong {
  font-size: 0.76rem;
}

.note-selection-heading small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.6rem;
}

.note-selection-heading > button {
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  font-size: 1.1rem;
}

.note-selection-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.note-selection-action {
  min-height: 54px;
  padding: 8px 10px;
  color: var(--navy-900);
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  text-align: left;
}

.note-selection-action.is-combine {
  color: var(--white);
  background: var(--coral-dark);
}

.note-selection-action strong,
.note-selection-action small {
  display: block;
}

.note-selection-action strong {
  font-size: 0.7rem;
}

.note-selection-action small {
  margin-top: 2px;
  color: inherit;
  font-size: 0.56rem;
  opacity: 0.72;
}

.note-selection-action:disabled {
  color: #7f8796;
  background: #dfe2e7;
  box-shadow: none;
  opacity: 0.64;
}

.empty-library {
  display: flex;
  min-height: 48vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-library h2 {
  margin: 16px 0 3px;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
}

.empty-library p {
  max-width: 260px;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
}

.empty-page {
  position: relative;
  width: 70px;
  height: 92px;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  box-shadow: var(--shadow-soft);
}

.empty-page::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 16px;
  width: 1px;
  content: "";
  background: rgba(219, 100, 88, 0.35);
}

.empty-page i {
  position: absolute;
  left: 24px;
  width: 34px;
  height: 1px;
  background: #d7e1eb;
}

.empty-page i:nth-child(1) { top: 28px; }
.empty-page i:nth-child(2) { top: 44px; }
.empty-page i:nth-child(3) { top: 60px; }

/* Photo placement mode */

.photo-adjust-mode {
  position: absolute;
  z-index: 20;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 9px;
  padding: calc(9px + var(--app-safe-top)) 9px calc(9px + var(--app-safe-bottom));
  overflow: hidden;
  color: var(--white);
  background: #111827;
}

.photo-adjust-header {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto minmax(72px, 1fr);
  align-items: center;
  gap: 8px;
}

.photo-adjust-header > div {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-direction: column;
  gap: 1px;
  text-align: center;
}

.photo-adjust-header strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.94rem;
}

.photo-adjust-header span {
  max-width: 32vw;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.58rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-adjust-cancel,
.photo-adjust-done {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 850;
}

.photo-adjust-cancel {
  justify-self: start;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.photo-adjust-done {
  justify-self: end;
  color: var(--navy-950);
  background: var(--white);
}

.photo-adjust-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  place-items: center;
  background-color: #252d3c;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
  touch-action: none;
}

#photoAdjustImage {
  position: absolute;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  transform-origin: center;
  pointer-events: none;
  user-select: none;
  will-change: transform;
  -webkit-user-drag: none;
  -webkit-user-select: none;
}

.photo-adjust-toolbar {
  display: grid;
  grid-template-columns: minmax(116px, 0.75fr) minmax(170px, 1.25fr);
  gap: 8px;
}

.photo-adjust-modes,
.photo-adjust-actions {
  display: grid;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

.photo-adjust-modes {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.photo-adjust-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.photo-adjust-modes button,
.photo-adjust-actions button {
  min-width: 0;
  min-height: 43px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  border-radius: 9px;
  font-size: 0.66rem;
  font-weight: 850;
}

.photo-adjust-modes button[aria-pressed="true"] {
  color: var(--navy-950);
  background: var(--white);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.photo-adjust-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
}

.photo-adjust-actions button span {
  font-family: Georgia, serif;
  font-size: 1.08rem;
  line-height: 1;
}

.photo-adjust-actions button small {
  color: inherit;
  font-size: 0.55rem;
}

/* Dialogs and sheets */

dialog {
  color: var(--ink);
}

.sheet-dialog {
  position: fixed;
  inset: var(--visible-viewport-top) 0 auto;
  width: min(100%, 560px);
  height: var(--visible-viewport-height);
  max-width: none;
  max-height: none;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
}

.sheet-dialog[open] {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-dialog::backdrop,
.confirm-dialog::backdrop {
  background: rgba(11, 18, 31, 0.58);
  backdrop-filter: blur(3px);
}

.sheet {
  width: 100%;
  min-height: 0;
  max-height: min(calc(100% - 8px), 760px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scroll-padding-block: 20px calc(24px + var(--app-safe-bottom));
  padding: 10px 18px calc(20px + var(--app-safe-bottom));
  background: var(--cream);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 60px rgba(9, 16, 28, 0.26);
}

/* Android keeps the WebView fixed. Resize only the sheet to the keyboard-safe
   rectangle so focusing a field cannot pan the activity or native title bar. */
.native-android .sheet-dialog {
  inset: var(--visible-viewport-top) 0 auto;
  height: var(--visible-viewport-height);
  overflow: hidden;
}

.native-android .sheet-dialog[open] {
  display: flex;
}

.native-android .sheet-dialog > .sheet {
  max-height: min(calc(var(--visible-viewport-height) - 8px), 760px);
}

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 13px;
  border-radius: 999px;
  background: #c5c9cf;
}

.sheet-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 19px;
}

.sheet-heading h2 {
  margin: 2px 0 0;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 550;
  letter-spacing: -0.02em;
}

.close-button {
  width: 38px;
  height: 38px;
  flex: none;
  padding: 0 0 2px;
  color: var(--muted);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
}

.field-label {
  display: block;
  margin: 0 0 7px;
  color: var(--navy-800);
  font-size: 0.69rem;
  font-weight: 850;
}

.text-input,
.select-input,
.transcript-input {
  width: 100%;
  color: var(--navy-900);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}

.text-input,
.select-input {
  min-height: 48px;
  padding: 0 13px;
}

.text-input:focus,
.select-input:focus,
.transcript-input:focus {
  border-color: var(--coral);
}

.field-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin-top: 15px;
}

.field-grow {
  min-width: 0;
  flex: 1;
}

.inline-button {
  min-height: 48px;
  flex: none;
  padding: 0 12px;
  color: var(--coral-dark);
  background: #fff3ef;
  border: 1px solid #efc5bd;
  border-radius: 12px;
  font-size: 0.71rem;
  font-weight: 800;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}

.compact-dialog .sheet {
  padding-bottom: calc(22px + var(--app-safe-bottom));
}

.category-manager-copy {
  margin: -7px 0 12px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.category-manager-copy strong {
  color: var(--navy-800);
}

.category-manager-list {
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.category-manager-row {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px 9px 13px;
}

.category-drag-handle {
  display: grid;
  width: 40px;
  min-height: 44px;
  flex: none;
  margin-left: -8px;
  place-items: center;
  color: #8d96a3;
  background: transparent;
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.category-drag-handle:active {
  color: var(--navy-700);
  background: #eef0f3;
  cursor: grabbing;
}

.category-drag-handle span {
  display: block;
  width: 18px;
  height: 25px;
  background-image: radial-gradient(circle, currentColor 1.5px, transparent 1.8px);
  background-position: 0 1px;
  background-size: 8px 8px;
}

.category-manager-list.is-reordering {
  user-select: none;
  -webkit-user-select: none;
}

.category-manager-row.is-drag-placeholder {
  background: #edf0f3;
}

.category-manager-row.is-drag-placeholder > * {
  visibility: hidden;
}

.category-drag-ghost {
  position: fixed;
  z-index: 20;
  box-sizing: border-box;
  margin: 0;
  background: var(--white);
  border: 1px solid var(--line-strong) !important;
  border-radius: 13px;
  box-shadow: 0 14px 34px rgba(23, 35, 59, 0.24);
  opacity: 0.98;
  pointer-events: none;
  will-change: top;
}

.category-manager-row + .category-manager-row {
  border-top: 1px solid var(--line);
}

.category-manager-name {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  padding: 7px 8px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

button.category-manager-name {
  cursor: pointer;
}

button.category-manager-name.is-holding {
  color: var(--navy-800);
  background: #eef0f3;
  transform: scale(0.985);
}

.category-manager-name strong {
  overflow: hidden;
  color: var(--navy-900);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-manager-name small {
  color: var(--muted);
  font-size: 0.64rem;
}

.category-delete-button {
  min-height: 38px;
  flex: none;
  padding: 0 12px;
  color: var(--danger);
  background: #fff5f4;
  border: 1px solid #ebcac6;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 800;
}

.category-default-label {
  flex: none;
  padding: 5px 9px;
  color: var(--success);
  background: var(--mint);
  border-radius: 999px;
  font-size: 0.61rem;
  font-weight: 850;
}

.color-choices,
.size-choices {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
}

.color-choice,
.size-choice {
  display: flex;
  min-height: 70px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 13px;
  font-size: 0.62rem;
  font-weight: 750;
}

.color-choice.is-active,
.size-choice.is-active {
  color: var(--navy-900);
  border-color: var(--coral);
  box-shadow: 0 0 0 1px var(--coral);
}

.color-choice i {
  width: 29px;
  height: 29px;
  border: 3px solid var(--white);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(23, 35, 59, 0.22);
}

.color-picker-sheet {
  overflow: hidden;
  transition: max-height 180ms ease;
}

.color-sheet-handle {
  position: relative;
  display: block;
  width: 64px;
  height: 32px;
  margin: -10px auto -5px;
  padding: 0;
  background: transparent;
  touch-action: none;
  cursor: ns-resize;
}

.color-sheet-handle::before {
  position: absolute;
  top: 14px;
  left: 13px;
  width: 38px;
  height: 4px;
  content: "";
  background: #c5c9cf;
  border-radius: 999px;
}

.color-palette-viewport {
  max-height: 70px;
  overflow: hidden;
  overscroll-behavior: contain;
  transition: max-height 180ms ease;
}

#colorDialog.is-expanded .color-picker-sheet {
  max-height: min(calc(var(--visible-viewport-height) - 8px), 760px);
}

#colorDialog.is-expanded .color-palette-viewport {
  max-height: min(56vh, 520px);
  padding-right: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.color-palette-hint {
  display: block;
  width: 100%;
  min-height: 31px;
  margin-top: 7px;
  padding: 2px 6px;
  color: var(--muted);
  background: transparent;
  touch-action: none;
  cursor: ns-resize;
  font-size: 0.64rem;
  font-weight: 800;
  text-align: center;
}

.color-palette-hint span {
  display: inline-block;
  margin-right: 4px;
  color: var(--coral-dark);
  font-size: 0.82rem;
}

.add-color-choice i {
  display: grid;
  place-items: center;
  color: var(--coral-dark);
  background: #fff5f1;
  border: 1px dashed var(--coral);
  font-size: 1.25rem;
  font-style: normal;
  font-weight: 500;
  line-height: 1;
  box-shadow: none;
}

.rgb-color-preview-row {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.rgb-color-preview {
  display: block;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  background: var(--navy-900);
  border: 4px solid var(--white);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(23, 35, 59, 0.24);
}

.rgb-color-preview-row > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.rgb-color-preview-row strong {
  color: var(--navy-900);
  font-size: 0.72rem;
}

.rgb-color-preview-row output {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.77rem;
  font-weight: 750;
}

.rgb-channels {
  display: grid;
  gap: 10px;
}

.rgb-channel {
  display: grid;
  grid-template-columns: minmax(70px, 0.65fr) minmax(170px, 1fr);
  align-items: center;
  gap: 12px;
}

.rgb-channel > label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rgb-channel > label strong {
  color: var(--navy-800);
  font-size: 0.72rem;
}

.rgb-channel > label small {
  color: var(--muted);
  font-size: 0.59rem;
}

.rgb-number-adjuster {
  display: grid;
  grid-template-columns: 44px minmax(60px, 1fr) 44px;
  min-width: 0;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}

.rgb-number-adjuster button,
.rgb-number-adjuster input {
  min-height: 44px;
  border-radius: 0;
}

.rgb-number-adjuster button {
  color: var(--coral-dark);
  background: #fff5f1;
  font-size: 1.08rem;
  font-weight: 850;
}

.rgb-number-adjuster input {
  width: 100%;
  min-width: 0;
  padding: 0 3px;
  color: var(--navy-900);
  background: var(--white);
  border: 0;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: center;
}

.size-choice i {
  display: flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
}

.size-choice i::after {
  display: block;
  width: var(--sample-size, 4px);
  height: var(--sample-size, 4px);
  content: "";
  border-radius: 50%;
  background: var(--navy-900);
}

.rich-text-input {
  min-height: 180px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.rich-shape-choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.rich-shape-choices button {
  display: flex;
  min-width: 0;
  min-height: 82px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 3px;
  color: var(--navy-800);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.59rem;
  font-weight: 800;
}

.rich-shape-choices i {
  display: block;
  width: 34px;
  height: 27px;
  border: 2px solid currentColor;
}

.rich-shape-choices .shape-rounded {
  border-radius: 9px;
}

.rich-shape-choices .shape-ellipse {
  border-radius: 50%;
}

.rich-shape-choices .shape-triangle {
  background: currentColor;
  border: 0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.rich-custom-color {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.rich-custom-color span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rich-custom-color strong {
  color: var(--navy-900);
  font-size: 0.73rem;
}

.rich-custom-color small {
  color: var(--muted);
  font-size: 0.62rem;
}

.rich-custom-color input {
  width: 52px;
  height: 38px;
  flex: none;
  padding: 2px;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

.rich-properties-sheet {
  max-height: min(calc(100% - 8px), 820px);
}

.rich-properties-locked-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -5px 0 12px;
  padding: 11px 12px;
  color: var(--navy-800);
  background: #e9edf4;
  border: 1px solid #ccd4e2;
  border-radius: 12px;
}

.rich-properties-locked-notice span {
  display: grid;
  gap: 3px;
}

.rich-properties-locked-notice strong {
  font-size: 0.7rem;
}

.rich-properties-locked-notice small {
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.3;
}

.rich-properties-locked-notice button {
  min-height: 39px;
  flex: none;
  padding: 0 10px;
  color: var(--white);
  background: var(--navy-800);
  border-radius: 9px;
  font-size: 0.65rem;
  font-weight: 850;
}

.rich-property-section {
  padding: 15px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 15px;
}

.rich-property-section + .rich-property-section {
  margin-top: 12px;
}

.rich-property-section h3 {
  margin: 0 0 13px;
  color: var(--navy-700);
  font-size: 0.69rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.rich-properties-text-input {
  min-height: 104px;
  padding: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.4;
  resize: vertical;
}

.rich-property-range {
  display: grid;
  gap: 10px;
  margin-top: 15px;
}

.rich-property-range > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.rich-property-range strong,
.rich-property-control > .field-label {
  color: var(--navy-800);
  font-size: 0.69rem;
  font-weight: 850;
}

.rich-property-range output {
  color: var(--coral-dark);
  font-size: 0.69rem;
  font-weight: 900;
}

.rich-property-help {
  margin-top: -4px;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.35;
}

.rich-property-range input[type="range"] {
  width: 100%;
  min-height: 30px;
  margin: 0;
  accent-color: var(--navy-800);
}

.rich-property-control {
  margin-top: 16px;
}

.rich-property-toggle-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.rich-property-toggle-row button {
  min-height: 43px;
  padding: 0 7px;
  color: var(--navy-800);
  background: #f4f3ee;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 0.69rem;
  font-weight: 800;
}

.rich-property-toggle-row button.is-active {
  color: var(--white);
  background: var(--navy-900);
  border-color: var(--navy-900);
}

.rich-alignment-control {
  grid-template-columns: repeat(3, 1fr);
}

.rich-property-colors {
  gap: 7px;
}

.rich-properties-opacity-range {
  margin: 0 0 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.rich-property-colors .color-choice {
  min-height: 58px;
  gap: 5px;
  padding: 6px 2px;
}

.rich-property-colors .color-choice i {
  width: 23px;
  height: 23px;
}

.rich-properties-custom-color {
  min-height: 54px;
  margin-top: 9px;
}

.rich-properties-delete-button {
  width: 100%;
  min-height: 45px;
  margin-top: 14px;
  color: var(--danger);
  background: #fff5f4;
  border: 1px solid #ebcac6;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 850;
}

.rich-properties-actions {
  position: sticky;
  z-index: 2;
  bottom: calc(-20px - var(--app-safe-bottom));
  margin: 16px -18px calc(-20px - var(--app-safe-bottom));
  padding: 12px 18px calc(14px + var(--app-safe-bottom));
  background: linear-gradient(to bottom, rgba(244, 242, 235, 0.92), var(--cream) 30%);
  border-top: 1px solid rgba(23, 35, 59, 0.08);
}

.option-section + .option-section {
  margin-top: 21px;
}

.option-section h3 {
  margin: 0 0 8px;
  color: var(--navy-700);
  font-size: 0.69rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.photo-options-summary {
  margin: -3px 0 9px;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.4;
}

.photo-option-list .photo-remove-option strong {
  color: var(--danger);
}

.photo-option-list .photo-remove-option b {
  color: var(--danger);
}

.photo-source-sheet .sheet-heading {
  margin-bottom: 9px;
}

.photo-source-sheet .sheet-copy {
  margin: 0 0 15px;
}

.photo-source-glyph {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  color: var(--coral-dark) !important;
  background: #fff2ee;
  border-radius: 10px;
  font-family: inherit !important;
  font-size: 1rem !important;
  font-weight: 800 !important;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  background: #e7e7e4;
  border-radius: 12px;
}

.segmented-control button {
  min-height: 40px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border-radius: 9px;
  font-size: 0.68rem;
  font-weight: 800;
}

.segmented-control button.is-active {
  color: var(--navy-900);
  background: var(--white);
  box-shadow: 0 2px 8px rgba(23, 35, 59, 0.1);
}

.option-list,
.backup-actions {
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.option-row,
.switch-row {
  display: flex;
  width: 100%;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 10px 13px;
  background: var(--white);
  text-align: left;
}

.option-row + .option-row,
.switch-row + .option-row,
.backup-actions .option-row + .option-row {
  border-top: 1px solid var(--line);
}

.option-row span,
.switch-row span {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.option-row strong,
.switch-row strong {
  color: var(--navy-900);
  font-size: 0.76rem;
}

.option-row small,
.switch-row small {
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.35;
}

.option-row b {
  color: var(--soft);
  font-family: Georgia, serif;
  font-size: 1.35rem;
  font-weight: 400;
}

.switch-row {
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-row i {
  position: relative;
  width: 45px;
  height: 26px;
  flex: none;
  border-radius: 999px;
  background: #c8cdd4;
  transition: background 160ms ease;
}

.switch-row i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  content: "";
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 2px 5px rgba(23, 35, 59, 0.25);
  transition: transform 160ms ease;
}

.switch-row input:checked + i {
  background: var(--success);
}

.switch-row input:checked + i::after {
  transform: translateX(19px);
}

.danger-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.danger-list button {
  min-height: 44px;
  padding: 0 12px;
  color: var(--danger);
  background: #fff5f4;
  border: 1px solid #ebcac6;
  border-radius: 11px;
  font-size: 0.7rem;
  font-weight: 800;
}

.danger-list button:last-child {
  grid-column: 1 / -1;
}

.voice-danger-list {
  grid-template-columns: 1fr;
}

.voice-danger-list button:last-child {
  grid-column: auto;
}

.page-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 1px 12px;
  scrollbar-width: none;
}

.page-list::-webkit-scrollbar {
  display: none;
}

.page-list-button {
  width: 94px;
  flex: none;
  padding: 7px;
  color: var(--muted);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.66rem;
  font-weight: 800;
}

.page-list-button.is-active {
  color: var(--navy-900);
  border-color: var(--coral);
  box-shadow: 0 0 0 1px var(--coral);
}

.page-list-preview {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  margin-bottom: 7px;
  background: var(--paper);
  border: 1px solid #e4e2dc;
}

.wide-button {
  width: 100%;
  margin-top: 6px;
}

.sheet-copy {
  margin: -7px 0 12px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

.add-page-type-choices {
  display: grid;
  gap: 9px;
}

.add-page-type-button {
  display: grid;
  min-height: 68px;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  color: var(--navy-900);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  text-align: left;
}

.add-page-type-button:active {
  border-color: var(--coral);
  background: #fff8f5;
}

.add-page-type-button > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.add-page-type-button strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  font-weight: 650;
}

.add-page-type-button small {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.3;
}

.add-page-type-icon {
  display: flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--coral-dark);
  background: #fff1ed;
  border-radius: 11px;
}

.canvas-page-type-icon::before {
  width: 22px;
  height: 27px;
  content: "";
  background-image: radial-gradient(circle, currentColor 1px, transparent 1.4px);
  background-size: 7px 7px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.schedule-date-time {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.reminder-sheet .sheet-heading > div {
  min-width: 0;
}

#reminderDialogTitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-field {
  min-width: 0;
}

.schedule-field .text-input {
  color-scheme: only light;
}

.reminder-fields {
  display: grid;
  gap: 10px;
  margin: 19px 0 0;
  padding: 0;
  border: 0;
}

.reminder-fields legend {
  width: 100%;
  margin-bottom: 8px;
  color: var(--navy-700);
  font-size: 0.69rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.reminder-fields legend small {
  margin-left: 5px;
  color: var(--muted);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
}

.reminder-fields label {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--navy-800);
  font-size: 0.68rem;
  font-weight: 800;
}

.reminder-fields .select-input {
  min-height: 44px;
}

.reminder-permission-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.reminder-permission-card > span {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.reminder-permission-card strong {
  color: var(--navy-900);
  font-size: 0.74rem;
}

.reminder-permission-card small {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.35;
}

.reminder-permission-card.is-enabled {
  background: var(--mint);
  border-color: #c9ddd2;
}

.reminder-permission-card.is-blocked {
  background: #fff5f4;
  border-color: #ebcac6;
}

.reminder-reliability {
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 0.63rem;
  line-height: 1.45;
}

.reminder-validation {
  min-height: 1.1em;
  margin: 7px 2px 0;
  color: var(--danger);
  font-size: 0.65rem;
  font-weight: 750;
}

.clear-reminder-button {
  min-height: 40px;
  margin-top: 6px;
  padding: 0;
  color: var(--danger);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 800;
}

.transcript-input {
  min-height: 168px;
  padding: 12px 13px;
  resize: vertical;
  line-height: 1.5;
}

.split-actions {
  justify-content: space-between;
}

.menu-actions {
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.menu-actions button {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  color: var(--navy-900);
  background: var(--white);
  font-size: 0.76rem;
  font-weight: 750;
}

.menu-actions button + button {
  border-top: 1px solid var(--line);
}

.menu-actions button span {
  color: var(--soft);
  font-size: 1rem;
}

.menu-actions .danger-action {
  color: var(--danger);
}

.privacy-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  background: var(--mint);
  border: 1px solid #c5ded4;
  border-radius: 14px;
}

.privacy-dot {
  width: 11px;
  height: 11px;
  flex: none;
  margin-top: 4px;
  border: 3px solid #aed5c5;
  border-radius: 50%;
  background: var(--success);
  box-sizing: content-box;
}

.privacy-card strong {
  color: #225641;
  font-size: 0.78rem;
}

.privacy-card p {
  margin: 4px 0 0;
  color: #4c6e60;
  font-size: 0.68rem;
  line-height: 1.45;
}

.backup-actions {
  margin-top: 14px;
}

.app-settings-section,
.backup-settings-section {
  margin-top: 18px;
}

.settings-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.settings-section-heading h3 {
  margin: 2px 0 0;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  font-weight: 550;
}

.backup-status-badge {
  padding: 5px 9px;
  color: var(--muted);
  background: #e5e6e5;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 850;
}

.backup-status-badge.is-active {
  color: #245b46;
  background: #d8ece3;
}

.backup-status-badge.is-saving {
  color: #8a3f34;
  background: #ffe3dd;
}

.backup-location-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  background: var(--navy-900);
  border-radius: 14px;
}

.backup-location-card > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.backup-location-card strong {
  overflow: hidden;
  color: var(--white);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backup-location-card small {
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.63rem;
  line-height: 1.35;
}

.backup-location-glyph {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  font-size: 1.25rem;
}

.backup-location-actions {
  margin-top: 8px;
}

.backup-rotation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.backup-rotation > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
  padding: 10px 11px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.backup-rotation span {
  color: var(--navy-800);
  font-size: 0.65rem;
  font-weight: 850;
}

.backup-rotation time {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.59rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-help {
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 0.63rem;
  line-height: 1.45;
}

.portable-copy-heading {
  margin-top: 20px;
  margin-bottom: -5px;
}

#storageDialog[aria-busy="true"] .close-button,
#downloadBackupButton:disabled {
  opacity: 0.42;
}

#restoreBackupButton[aria-busy="true"] {
  background: #fff5f1;
}

#restoreBackupButton[aria-busy="true"] b {
  color: var(--coral-dark);
}

#downloadBackupButton[aria-busy="true"] {
  background: #fff5f1;
}

.confirm-dialog {
  width: min(calc(100% - 32px), 420px);
  padding: 0;
  background: transparent;
  border: 0;
}

.confirm-card {
  padding: 22px;
  background: var(--cream);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(8, 13, 22, 0.32);
}

.confirm-card h2 {
  margin: 3px 0 7px;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.confirm-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.toast {
  position: fixed;
  z-index: 100;
  bottom: calc(92px + var(--app-safe-bottom));
  left: 50%;
  max-width: calc(100% - 34px);
  padding: 10px 14px;
  transform: translate(-50%, 18px);
  color: var(--white);
  background: rgba(17, 26, 45, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  box-shadow: 0 9px 30px rgba(9, 14, 24, 0.3);
  font-size: 0.72rem;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (min-width: 430px) {
  .save-status {
    display: inline;
  }

  .editor-header {
    padding-right: 14px;
    padding-left: 14px;
  }

  .canvas-tool-dock {
    padding-right: 13px;
    padding-left: 13px;
  }
}

@media (min-width: 680px) {
  .voice-control-bar {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .voice-note-status {
    grid-column: auto;
  }

  .editor-screen {
    max-width: 1180px;
    left: 50%;
    width: 100%;
    transform: translateX(-50%);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
  }

  .editor-header {
    grid-template-columns: 110px minmax(0, 1fr) auto;
  }

  .note-heading {
    align-items: center;
    text-align: center;
  }

  .library-button {
    font-size: 0.82rem;
  }

  .canvas-stage {
    padding: 0;
  }

  .ink-tool-drawer {
    justify-content: center;
    gap: 10px;
  }

  .page-bar {
    grid-template-columns: 52px 100px minmax(90px, 1fr) auto 52px;
    padding-right: max(16px, calc((100% - 560px) / 2));
    padding-left: max(16px, calc((100% - 560px) / 2));
  }

  .library-screen {
    width: min(100%, 1120px);
    margin: 0 auto;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }

  .library-header,
  .library-controls,
  .category-filters,
  .library-scroll {
    padding-right: 30px;
    padding-left: 30px;
  }

  .notes-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .note-preview {
    aspect-ratio: 1.65 / 1;
  }

  .sheet-dialog {
    padding-bottom: 28px;
  }

  .sheet {
    border-radius: 22px;
  }
}

@media (min-width: 980px) {
  .notes-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .canvas-tool-dock {
    padding-right: 4px;
    padding-left: 4px;
  }

  .drawing-tools {
    gap: 1px;
  }

  .tool-button {
    min-width: 44px;
  }

  .compact-tool {
    width: 38px;
  }

  .history-button {
    width: 31px;
  }
}

@media (max-width: 370px) {
  .schedule-date-time {
    grid-template-columns: 1fr;
  }

  .reminder-fields label {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .reminder-permission-card {
    align-items: stretch;
    flex-direction: column;
  }

  .reminder-permission-card .inline-button {
    width: 100%;
  }

  .library-header {
    gap: 9px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .library-header-tools {
    gap: 5px;
  }

  .library-icon-button {
    width: 42px;
    height: 42px;
  }

  .library-create-button {
    padding-right: 10px;
    padding-left: 10px;
    font-size: 0.7rem;
  }

  .rich-layer-tools button {
    width: 38px;
    min-width: 38px;
    font-size: 0.55rem;
  }

  .rich-history-tools button {
    width: 33px;
    min-width: 33px;
  }

  .voice-editor {
    gap: 7px;
    padding: 8px;
  }

  .voice-document {
    padding: 12px 13px 9px;
  }

  .voice-note-status small {
    font-size: 0.58rem;
  }

  .editor-header {
    grid-template-columns: 62px minmax(0, 1fr) auto;
    gap: 2px;
    padding-right: 6px;
    padding-left: 6px;
  }

  .library-button {
    gap: 3px;
    padding: 0 3px;
    font-size: 0.66rem;
  }

  .save-button {
    min-width: 46px;
    padding: 0 7px;
    font-size: 0.7rem;
  }

  .more-button {
    width: 35px;
  }

  .canvas-tool-dock {
    padding-right: 4px;
    padding-left: 4px;
  }

  .page-bar {
    grid-template-columns: 36px 54px minmax(56px, 1fr) auto 36px;
    gap: 2px;
    padding-right: 6px;
    padding-left: 6px;
  }

  .add-page-button {
    padding-right: 7px;
    padding-left: 7px;
  }

  .tool-button {
    min-width: 44px;
  }

  .zoom-controls {
    grid-template-columns: 28px 42px 28px;
  }

  .compact-tool {
    width: 38px;
  }

  .history-button {
    width: 31px;
  }

  .library-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .color-choices,
  .size-choices {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  :root {
    --editor-header-height: 50px;
  }

  .editor-header {
    min-height: calc(var(--editor-header-height) + var(--app-safe-top));
    padding-top: calc(4px + var(--app-safe-top));
    padding-bottom: 4px;
  }

  .page-bar {
    position: absolute;
    z-index: 8;
    right: 8px;
    bottom: calc(61px + var(--app-safe-bottom));
    grid-template-columns: 36px 70px 74px auto 36px;
    width: auto;
    min-height: 40px;
    padding: 2px 4px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
  }

  .page-bar button {
    min-height: 34px;
  }

  .canvas-tool-dock {
    min-height: calc(60px + var(--app-safe-bottom));
  }

  .tool-button,
  .compact-tool,
  .history-button,
  .canvas-mode-button {
    min-height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .voice-note-status.is-listening .voice-status-dot {
    animation: none;
  }

  .page-loop-notice.is-visible {
    transform: translate(-50%, 0);
    opacity: 0.9;
  }
}
