:root {
  --ink: #273446;
  --ink-soft: #68727a;
  --paper: #ebe6da;
  --surface: #fffdf5;
  --surface-raised: #fffdf7;
  --line: #d2d2c6;
  --line-strong: #aeb8ae;
  --accent: #c8664c;
  --accent-soft: #f7e3d8;
  --teal: #54796f;
  --teal-soft: #e0ebe5;
  --mustard: #d8a744;
  --mustard-soft: #f6ebc9;
  --margin-red: #d6907e;
  --danger: #ae493b;
  --selection: #82949c;
  --selection-soft: rgba(130, 148, 156, 0.14);
  --header-size: 38px;
  --row-header-size: 56px;
  --radius: 10px;
  --font-ui: "Avenir Next", Avenir, ui-rounded, "Trebuchet MS", sans-serif;
  --font-hand: Noteworthy, "Bradley Hand", "Segoe Print", cursive;
  --font-code: "SFMono-Regular", Menlo, Consolas, monospace;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 820px;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgba(64, 78, 72, 0.12) 1px, transparent 1.15px) 0 0 / 20px 20px,
    linear-gradient(112deg, rgba(255, 255, 255, 0.64), transparent 38%),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="color"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.grid-viewport:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.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 {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  z-index: 30;
  height: 66px;
  flex: 0 0 66px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(220px, 2fr) minmax(260px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 253, 245, 0.94), rgba(255, 253, 245, 0.94)),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(84, 121, 111, 0.09) 31px 32px);
  border-bottom: 1px dashed #b9b9ad;
  box-shadow: 0 3px 0 rgba(120, 109, 86, 0.07);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  width: 20px;
  height: 20px;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  transform: rotate(-4deg);
  filter: drop-shadow(1px 2px 0 rgba(39, 52, 70, 0.14));
}

.brand-mark span {
  border-radius: 1px 4px 2px 3px;
  background: var(--accent);
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(3) {
  background: var(--mustard);
  opacity: 0.82;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-copy strong {
  font-family: var(--font-hand);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-copy small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.breadcrumb {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-soft);
  overflow: hidden;
}

.breadcrumb button {
  max-width: 170px;
  padding: 5px 10px 4px;
  overflow: hidden;
  color: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.52);
  border: 0;
  border-radius: 3px 8px 4px 7px;
  font-family: var(--font-hand);
  font-size: 13px;
  transform: rotate(-0.5deg);
}

.breadcrumb button:hover {
  color: var(--ink);
  background: var(--mustard-soft);
}

.breadcrumb button[aria-current="page"] {
  color: var(--ink);
  background: linear-gradient(176deg, transparent 55%, rgba(216, 167, 68, 0.35) 56%);
  font-weight: 700;
}

.breadcrumb-separator {
  color: #9aa299;
  font-family: var(--font-hand);
}

.topbar-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 7px;
}

.save-status {
  margin-right: 5px;
  font-size: 11px;
  color: #7d897f;
  font-family: var(--font-hand);
  transition: color 160ms ease;
}

.save-status.is-saving {
  color: var(--accent);
}

.button,
.icon-button,
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
}

.button {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 5px 9px 6px 8px;
  font-size: 12px;
  font-weight: 650;
}

.button-quiet {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.45);
  border: 1px dashed #c4c4b8;
}

.button-quiet:hover {
  color: var(--ink);
  background: var(--mustard-soft);
}

.button-primary {
  color: white;
  background: var(--teal);
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  font-weight: 800;
  letter-spacing: 1px;
}

.icon-button:hover,
.icon-button[aria-expanded="true"] {
  background: var(--accent-soft);
}

.popover-menu {
  position: absolute;
  top: 42px;
  right: 0;
  width: 210px;
  padding: 6px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #c9c5b7;
  border-radius: 4px 10px 5px 9px;
  box-shadow: 4px 8px 0 rgba(77, 69, 54, 0.12), 0 20px 50px rgba(39, 52, 70, 0.12);
  transform: rotate(0.4deg);
}

.popover-menu button {
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 6px;
  font-size: 12px;
}

.popover-menu button:hover {
  background: var(--mustard-soft);
}

.popover-menu .danger-action {
  color: var(--danger);
}

.workspace {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 19px 28px 24px;
}

.document-heading {
  position: relative;
  z-index: 40;
  min-height: 54px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 5px;
}

.document-heading h1 {
  position: relative;
  display: inline-block;
  margin: 0;
  font-family: var(--font-hand);
  font-size: 35px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.005em;
  transform: rotate(-0.8deg);
}

.document-heading h1::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: -5px;
  left: -3px;
  height: 7px;
  z-index: -1;
  background: rgba(216, 167, 68, 0.34);
  border-radius: 50% 8% 45% 12%;
  transform: rotate(-1deg);
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sheet-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 5px;
  color: var(--ink-soft);
  background: rgba(255, 253, 245, 0.64);
  border: 1px dashed #bdbdaf;
  border-radius: 3px 8px 4px 7px;
  font-family: var(--font-hand);
  font-size: 11px;
  transform: rotate(0.6deg);
}

.readonly-badge {
  padding: 4px 7px;
  color: #3e655b;
  background: var(--teal-soft);
  border-radius: 999px;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.toolbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  padding: 6px 9px;
  background: rgba(255, 253, 245, 0.93);
  border: 1px solid #c8c6b8;
  border-radius: 5px 12px 6px 10px;
  box-shadow: 2px 3px 0 rgba(69, 76, 67, 0.09);
  transform: rotate(-0.08deg);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  margin: 0 3px;
  background: repeating-linear-gradient(to bottom, #bfc0b5 0 2px, transparent 2px 5px);
}

.toolbar-spacer {
  flex: 1;
}

.tool-button {
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  color: var(--ink-soft);
  background: transparent;
  border-radius: 4px 8px 5px 7px;
}

.tool-button:hover,
.tool-button.is-active,
.tool-button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--mustard-soft);
}

.tool-button:disabled {
  cursor: default;
  opacity: 0.28;
}

.text-tool {
  font-family: var(--font-hand);
  font-size: 15px;
}

.select-tool select {
  height: 32px;
  max-width: 128px;
  padding: 0 28px 0 9px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 4px 8px 5px 7px;
  font-size: 11px;
}

.select-tool select:hover {
  color: var(--ink);
  background-color: var(--mustard-soft);
}

.format-tool select {
  width: 98px;
}

.border-tool select {
  width: 100px;
}

.color-tool {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 7px;
  color: var(--ink-soft);
  border-radius: 4px 8px 5px 7px;
  font-size: 11px;
}

.color-tool:hover {
  background: var(--mustard-soft);
}

.color-tool input {
  width: 19px;
  height: 19px;
  padding: 0;
  overflow: hidden;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.color-tool input::-webkit-color-swatch-wrapper {
  padding: 1px;
}

.color-tool input::-webkit-color-swatch {
  border: 0;
  border-radius: 3px;
}

.clear-color {
  min-width: 23px;
  width: 23px;
  padding: 0;
  font-size: 16px;
}

.child-sheet-button {
  color: #405f57;
  background: linear-gradient(176deg, #e8f0ea, #dbe8e1);
  border: 1px dashed #a8bdb3;
  white-space: nowrap;
  transform: rotate(0.4deg);
}

.child-sheet-button:hover {
  background: #cfe0d7;
}

.child-icon {
  margin-right: 6px;
  font-size: 15px;
}

.formula-bar {
  height: 43px;
  flex: 0 0 43px;
  display: grid;
  grid-template-columns: 74px 38px minmax(180px, 1fr) auto;
  align-items: center;
  background:
    linear-gradient(rgba(255, 249, 225, 0.92), rgba(255, 249, 225, 0.92)),
    repeating-linear-gradient(0deg, transparent 0 20px, rgba(84, 121, 111, 0.14) 20px 21px);
  border: 1px solid #d4c9a8;
  border-bottom: 0;
  border-radius: 5px 10px 0 0;
  box-shadow: 2px 2px 0 rgba(95, 83, 53, 0.07);
}

.cell-reference {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  border-right: 1px dashed #c7b98d;
  font-family: var(--font-hand);
  font-size: 12px;
  font-weight: 700;
}

.formula-symbol {
  text-align: center;
  color: var(--accent);
  font-family: var(--font-hand);
  font-size: 17px;
  font-style: normal;
  transform: rotate(-6deg);
}

.formula-bar input {
  min-width: 0;
  height: 100%;
  padding: 0 9px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-left: 1px dashed #c7b98d;
  outline: 0;
  font-family: var(--font-code);
  font-size: 12px;
}

.formula-bar input:focus {
  background: rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 -2px var(--accent);
}

.formula-result {
  max-width: 260px;
  padding: 0 12px;
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.formula-result.is-error {
  color: var(--danger);
  font-weight: 700;
}

.grid-card {
  position: relative;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border: 1px solid #c9c5b5;
  border-radius: 5px 12px 5px 11px;
  box-shadow: 5px 8px 0 rgba(80, 71, 53, 0.1), 0 18px 38px rgba(39, 52, 70, 0.08);
  overflow: hidden;
}

.grid-card::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: -5px;
  width: 74px;
  height: 16px;
  z-index: 15;
  pointer-events: none;
  background: rgba(216, 167, 68, 0.27);
  border-right: 1px solid rgba(132, 102, 41, 0.12);
  border-left: 1px solid rgba(132, 102, 41, 0.12);
  transform: rotate(-2deg);
}

.keyboard-hint {
  flex: 0 0 auto;
  margin-right: 96px;
}

.grid-viewport {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: auto;
  outline: 0;
  background: var(--surface-raised);
}

.grid {
  position: relative;
  display: grid;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  align-content: start;
  background-color: var(--surface-raised);
  background-image: radial-gradient(circle, rgba(95, 112, 107, 0.28) 0 0.8px, transparent 1px);
  background-position: 8px 8px;
  background-size: 18px 18px;
  user-select: none;
}

.grid-corner,
.column-header,
.row-header {
  position: sticky;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7a8179;
  background: rgba(246, 243, 232, 0.94);
  font-family: var(--font-hand);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.025em;
}

.grid-corner {
  top: 0;
  left: 0;
  z-index: 12;
  border-right: 2px solid rgba(214, 144, 126, 0.7);
  border-bottom: 1px dashed #bbbeb5;
}

.grid-corner::after {
  content: "✦";
  color: var(--mustard);
  font-size: 12px;
  transform: rotate(12deg);
}

.column-header {
  top: 0;
  border-right: 1px dotted rgba(139, 150, 143, 0.48);
  border-bottom: 1px dashed #bbbeb5;
}

.row-header {
  left: 0;
  padding-left: 13px;
  border-right: 2px solid rgba(214, 144, 126, 0.7);
  border-bottom: 1px dotted rgba(139, 150, 143, 0.48);
}

.row-header::before {
  content: "";
  position: absolute;
  left: 8px;
  width: 5px;
  height: 5px;
  background: #e3dfd3;
  border: 1px solid #bcb9ae;
  border-radius: 50%;
  box-shadow: inset 1px 1px 1px rgba(68, 64, 53, 0.14);
}

.column-header.is-selected,
.row-header.is-selected {
  color: #3f665c;
  background: rgba(224, 235, 229, 0.95);
}

.resize-handle {
  position: absolute;
  z-index: 4;
}

.column-header .resize-handle {
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
}

.row-header .resize-handle {
  right: 0;
  bottom: -3px;
  width: 100%;
  height: 7px;
  cursor: row-resize;
}

.resize-handle:hover,
body.is-resizing .resize-handle {
  background: rgba(200, 102, 76, 0.42);
}

.cell {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 6px 9px;
  overflow: hidden;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.7);
  border-right: 1px dotted rgba(148, 156, 149, 0.5);
  border-bottom: 1px dotted rgba(148, 156, 149, 0.5);
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.005em;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.cell.is-selected-range::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: var(--selection-soft);
}

.grid-viewport:not(.is-readonly) .cell.is-selected-range {
  cursor: grab;
}

body.is-moving-cells,
body.is-moving-cells * {
  cursor: grabbing !important;
}

.cell.is-dragging-source .cell-content,
.cell.is-dragging-source .child-indicator {
  opacity: 0.32;
}

.cell.is-drop-target {
  --drop-top: transparent;
  --drop-right: transparent;
  --drop-bottom: transparent;
  --drop-left: transparent;
  z-index: 4;
  background: rgba(211, 224, 219, 0.72);
  box-shadow:
    inset 0 2px var(--drop-top),
    inset -2px 0 var(--drop-right),
    inset 0 -2px var(--drop-bottom),
    inset 2px 0 var(--drop-left);
}

.cell.is-drop-target.is-dragging-source .cell-content,
.cell.is-drop-target.is-dragging-source .child-indicator {
  opacity: 0.72;
}

.cell.is-drop-top { --drop-top: var(--selection); }
.cell.is-drop-right { --drop-right: var(--selection); }
.cell.is-drop-bottom { --drop-bottom: var(--selection); }
.cell.is-drop-left { --drop-left: var(--selection); }

.cell.is-drop-invalid {
  z-index: 5;
  outline: 2px dashed var(--danger);
  outline-offset: -4px;
  background: rgba(181, 78, 64, 0.08);
}

.cell.is-active {
  z-index: 3;
  overflow: visible;
}

.cell.is-active::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: 5;
  pointer-events: none;
  border: 2px solid var(--selection);
  border-radius: 2px 6px 3px 5px;
  box-shadow: 0 0 0 2px rgba(255, 253, 247, 0.8);
  transform: rotate(-0.15deg);
}

.cell-content {
  position: relative;
  z-index: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-text {
  position: relative;
  z-index: 1;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.cell-text.marker-highlight {
  margin: 0 -0.34em;
  padding: 0.07em 0.38em 0.13em;
  background: linear-gradient(
    177deg,
    transparent 0 8%,
    var(--marker-color) 10% 88%,
    transparent 91% 100%
  );
  border-radius: 43% 8% 34% 12%;
  box-shadow: 0.14em 0 0 var(--marker-color), -0.14em 0 0 var(--marker-color);
}

.cell-ink-line {
  position: absolute;
  z-index: 2;
  display: block;
  pointer-events: none;
  overflow: visible;
  filter: saturate(0.88);
}

.cell-ink-line path {
  fill: none;
  stroke: var(--ink-line-color);
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.cell-ink-line.ink-top,
.cell-ink-line.ink-bottom {
  right: 0;
  left: 0;
  width: 100%;
  height: 8px;
}

.cell-ink-line.ink-top { top: -4px; }
.cell-ink-line.ink-bottom { bottom: -4px; }

.cell-ink-line.ink-left,
.cell-ink-line.ink-right {
  top: 0;
  bottom: 0;
  width: 8px;
  height: 100%;
}

.cell-ink-line.ink-left { left: -4px; }
.cell-ink-line.ink-right { right: -4px; }

.cell-ink-path {
  stroke-width: 1.85;
  opacity: 0.9;
}

.cell-ink-echo {
  stroke-width: 0.8;
  opacity: 0.32;
}

.cell-content {
  z-index: 3;
}

.cell.has-child .cell-content {
  padding-right: 25px;
}

.child-indicator {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #71858e;
  background: rgba(224, 231, 232, 0.54);
  padding: 0;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 1px dashed rgba(125, 143, 149, 0.58);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease;
}

.child-indicator:hover {
  color: #40535b;
  background: rgba(196, 209, 212, 0.82);
}

.cell-editor {
  position: absolute;
  inset: -1px;
  z-index: 20;
  min-width: calc(100% + 2px);
  min-height: calc(100% + 2px);
  padding: 6px 9px;
  resize: none;
  color: var(--ink);
  background: #fffdf5;
  border: 2px solid var(--selection);
  border-radius: 2px 6px 3px 5px;
  outline: 0;
  box-shadow: 0 7px 22px rgba(23, 32, 29, 0.16);
  font: inherit;
  line-height: 1.35;
}

.grid-footer {
  height: 30px;
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 11px;
  color: #747c74;
  background:
    linear-gradient(rgba(246, 243, 232, 0.95), rgba(246, 243, 232, 0.95)),
    radial-gradient(circle, rgba(95, 112, 107, 0.25) 0 0.8px, transparent 1px) 0 0 / 18px 18px;
  border-top: 1px dashed #bfc1b8;
  font-family: var(--font-hand);
  font-size: 10px;
}

kbd {
  padding: 1px 4px;
  color: #5a6560;
  background: #fffdf5;
  border: 1px solid #cbc7b9;
  border-bottom-width: 1px;
  border-radius: 3px 5px 3px 4px;
  font-family: inherit;
  font-size: 9px;
}

.dialog {
  width: min(420px, calc(100vw - 40px));
  padding: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 253, 245, 0.94), rgba(255, 253, 245, 0.94)),
    radial-gradient(circle, rgba(95, 112, 107, 0.24) 0 0.8px, transparent 1px) 0 0 / 18px 18px;
  border: 1px solid #c8c3b4;
  border-radius: 5px 13px 6px 11px;
  box-shadow: 7px 10px 0 rgba(73, 67, 53, 0.15), 0 28px 80px rgba(39, 52, 70, 0.2);
  transform: rotate(-0.35deg);
}

.dialog::backdrop {
  background: rgba(16, 24, 21, 0.5);
  backdrop-filter: blur(3px);
}

.dialog form {
  padding: 24px;
}

.dialog-heading {
  margin-bottom: 22px;
}

.dialog h2 {
  margin: 5px 0 0;
  font-family: var(--font-hand);
  font-size: 27px;
  font-weight: 600;
}

.dialog label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
}

.dialog input {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  border: 1px dashed var(--line-strong);
  border-radius: 4px 8px 5px 7px;
  outline: 0;
}

.dialog input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.dialog .button-quiet {
  color: var(--ink-soft);
  border-color: var(--line);
}

.confirm-dialog {
  width: min(390px, calc(100vw - 40px));
}

.confirm-copy {
  margin: -5px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.button-danger {
  color: white;
  background: var(--danger);
}

.button-danger:hover {
  background: #963d33;
}

/* Page-only interface: the notebook is the entire frame. */

[hidden] {
  display: none !important;
}

.document-title-block {
  min-width: 0;
}

.document-actions {
  position: relative;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 9px;
}

.document-actions .save-status {
  margin-right: 2px;
  color: #8b9089;
}

.document-actions .icon-button {
  width: auto;
  min-width: 28px;
  flex: 0 0 auto;
  padding: 0 4px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 3px;
}

.document-actions .icon-button:hover,
.document-actions .icon-button[aria-expanded="true"] {
  background: var(--mustard-soft);
}

.document-actions .popover-menu {
  z-index: 60;
  top: 42px;
  right: 0;
}

.menu-separator {
  display: block;
  height: 1px;
  margin: 5px 7px;
  background: repeating-linear-gradient(90deg, #c8c5b8 0 3px, transparent 3px 7px);
}

.document-title-block .breadcrumb {
  justify-content: flex-start;
  width: fit-content;
  margin-top: 8px;
  overflow: visible;
}

.document-title-block .breadcrumb button {
  padding: 2px 6px;
  background: rgba(255, 253, 245, 0.54);
  font-size: 11px;
}

.document-title-block .breadcrumb button[aria-current="page"] {
  background: none;
}

.toolbar {
  min-height: 44px;
}

.grid-corner,
.column-header,
.row-header {
  background: rgba(255, 253, 247, 0.91);
}

.grid-corner {
  border-right: 2px solid rgba(214, 144, 126, 0.55);
  border-bottom: 0;
}

.grid-corner::after {
  content: "";
}

.column-header {
  color: #7f847d;
  border-right: 0;
  border-bottom: 1px dashed rgba(155, 161, 153, 0.5);
  font-size: 10px;
  font-weight: 550;
}

.row-header {
  padding-left: 0;
  color: #8c9089;
  border-right: 2px solid rgba(214, 144, 126, 0.55);
  border-bottom: 0;
  font-size: 9px;
  font-weight: 550;
}

.row-header::before {
  display: none;
}

.column-header.is-selected,
.row-header.is-selected {
  color: var(--selection);
  background: rgba(255, 253, 247, 0.94);
  font-weight: 750;
}

.cell-context-menu {
  position: fixed;
  z-index: 120;
  width: 264px;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  padding: 10px;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 253, 245, 0.96), rgba(255, 253, 245, 0.96)),
    radial-gradient(circle, rgba(95, 112, 107, 0.22) 0 0.8px, transparent 1px) 0 0 / 18px 18px;
  border: 1px solid #c6c1b2;
  border-radius: 4px 12px 5px 10px;
  box-shadow: 6px 8px 0 rgba(74, 68, 53, 0.13), 0 20px 48px rgba(39, 52, 70, 0.14);
  transform: rotate(-0.25deg);
}

.context-section {
  padding: 6px 5px;
}

.context-section + .context-section {
  border-top: 1px dashed #c8c5b8;
}

.context-section p {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-family: var(--font-hand);
  font-size: 11px;
}

.context-quick-actions {
  display: flex;
  gap: 5px;
}

.context-history-actions {
  justify-content: flex-end;
  padding-top: 8px;
  padding-bottom: 2px;
}

.context-quick-actions button,
.context-tool-row button,
.context-format-grid button {
  min-height: 29px;
  padding: 4px 7px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 3px 7px 4px 6px;
  font-size: 11px;
}

.context-quick-actions button {
  width: 33px;
  font-family: var(--font-hand);
  font-size: 17px;
}

.context-quick-actions button:hover,
.context-tool-row button:hover,
.context-format-grid button:hover,
.context-tool-row button.is-active,
.context-format-grid button.is-active,
.context-tool-row button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--mustard-soft);
}

.context-quick-actions button:disabled {
  color: #b3b5ae;
  cursor: default;
  background: transparent;
}

.context-tool-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.context-format-grid {
  display: grid;
  grid-template-columns: 1.45fr repeat(3, 1fr);
  gap: 4px;
  margin-top: 4px;
}

.context-format-grid button {
  padding-right: 4px;
  padding-left: 4px;
}

.header-context-menu {
  width: 210px;
  padding: 8px;
}

.header-insert-actions {
  display: grid;
  gap: 3px;
}

.header-insert-actions button {
  min-height: 29px;
  padding: 6px 8px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 3px 7px 4px 6px;
  font-size: 11px;
}

.header-insert-actions button:hover {
  background: var(--mustard-soft);
}

.align-glyph {
  display: block;
  width: 20px;
  margin: auto;
  font-family: Arial, sans-serif;
  font-size: 17px;
  line-height: 1;
  letter-spacing: -1px;
}

.align-left { text-align: left; }
.align-center { text-align: center; }
.align-right { text-align: right; }

.marker-palette {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.marker-swatch,
.marker-eraser {
  position: relative;
  width: 25px;
  height: 25px;
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 50%;
}

.marker-swatch::before {
  content: "";
  position: absolute;
  inset: 7px 2px 5px;
  background: var(--swatch);
  border-radius: 45% 8% 38% 12%;
  transform: rotate(-4deg);
  box-shadow: 1px 0 0 var(--swatch), -1px 0 0 var(--swatch);
}

.marker-swatch:hover,
.marker-swatch:focus-visible,
.marker-eraser:hover {
  background: rgba(216, 167, 68, 0.15);
  transform: scale(1.08);
}

.marker-lemon { --swatch: #f4d35e; }
.marker-coral { --swatch: #ef8f7a; }
.marker-mint { --swatch: #8fc7a7; }
.marker-blue { --swatch: #8fb9d9; }
.marker-lilac { --swatch: #c9a7d8; }
.marker-ink { --swatch: #34495e; }

.marker-eraser {
  font-family: var(--font-hand);
  font-size: 18px;
}

.context-lines {
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 3px 6px;
  align-items: center;
}

.context-lines p {
  grid-column: 1 / -1;
}

.context-lines button,
.context-sheet-action button {
  min-height: 29px;
  padding: 5px 7px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 3px 7px 4px 6px;
  font-size: 11px;
}

.context-lines button:hover,
.context-sheet-action button:hover {
  background: var(--mustard-soft);
}

.context-ink {
  grid-row: 2 / span 3;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-soft);
  border-right: 1px dashed #cecbbe;
  font-size: 9px;
}

.context-ink input {
  width: 24px;
  height: 24px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-radius: 50%;
}

.context-ink input::-webkit-color-swatch-wrapper {
  padding: 1px;
}

.context-ink input::-webkit-color-swatch {
  border: 1px solid #aaa99e;
  border-radius: 50%;
}

.context-sheet-action button {
  width: 100%;
  color: var(--teal);
  font-weight: 700;
}

.context-sheet-action .danger-action {
  margin-top: 2px;
  padding-top: 7px;
  color: var(--danger);
  border-top: 1px dashed #d7c5bf;
  font-weight: 600;
}

@media (max-width: 1050px) {
  .color-tool > span,
  .keyboard-hint,
  .save-status {
    display: none;
  }

  .topbar {
    grid-template-columns: 180px 1fr 250px;
  }
}
