.view-editor {
  background: var(--chrome);
  color: #e8efe9;
}

.editor-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  height: calc(var(--header-h) + var(--safe-top));
  padding:
    var(--safe-top)
    calc(var(--safe-right) + 0.35rem)
    0
    calc(var(--safe-left) + 0.35rem);
  background: var(--chrome);
  z-index: 5;
  position: relative;
}

.note-title-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #e8efe9;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 0.4rem 0.25rem;
  outline: none;
}

.note-title-input::placeholder {
  color: var(--ink-faint);
}

.save-indicator {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-soft);
  min-width: 3.2rem;
  text-align: right;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.save-indicator.visible {
  opacity: 1;
  animation: save-pulse 0.6s var(--ease-out);
}

@keyframes save-pulse {
  0% { opacity: 0.3; }
  40% { opacity: 1; }
  100% { opacity: 1; }
}

.export-menu {
  position: absolute;
  top: calc(var(--header-h) + var(--safe-top) - 4px);
  right: calc(var(--safe-right) + 0.5rem);
  z-index: 20;
  background: var(--chrome-raised);
  border-radius: 12px;
  padding: 0.4rem;
  box-shadow: 0 12px 32px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 200px;
  animation: menu-in 0.2s var(--ease-out);
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.export-menu button {
  appearance: none;
  border: none;
  background: transparent;
  color: #e8efe9;
  font: inherit;
  font-weight: 600;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
}

.export-menu button:hover {
  background: color-mix(in srgb, white 8%, transparent);
}

.export-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem 0.7rem;
  font-size: 0.8rem;
  color: var(--ink-faint);
  border-top: 1px solid color-mix(in srgb, white 8%, transparent);
  margin-top: 0.2rem;
}

.page-scroll {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background:
    radial-gradient(ellipse at top, #2a3832 0%, var(--chrome) 55%);
  display: flex;
  justify-content: center;
  padding: 0.75rem calc(var(--safe-right) + 0.75rem) 0.5rem calc(var(--safe-left) + 0.75rem);
  /* Allow vertical scroll of the pad; drawing surface disables touch gestures */
  touch-action: pan-y;
}

.page {
  position: relative;
  width: min(100%, 720px);
  /* Tall writing pad ~3 letter pages */
  height: calc(min(100vw, 720px) * 3.3);
  flex-shrink: 0;
  margin-bottom: 0.5rem;
  border-radius: 2px;
  box-shadow:
    0 1px 0 color-mix(in srgb, white 25%, transparent),
    0 18px 40px rgba(0, 0, 0, 0.35);
  touch-action: none;
  overflow: hidden;
}

#paper-canvas,
#draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#draw-canvas {
  cursor: crosshair;
  z-index: 1;
}

.toolbar {
  flex: 0 0 auto;
  background: var(--chrome);
  padding:
    0.45rem
    calc(var(--safe-right) + 0.55rem)
    calc(var(--safe-bottom) + 0.45rem)
    calc(var(--safe-left) + 0.55rem);
  border-top: 1px solid color-mix(in srgb, white 8%, transparent);
  z-index: 5;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.toolbar-row.tools {
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.toolbar-row.secondary {
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tool-btn {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  border-radius: 10px;
  padding: 0.45rem 0.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s var(--ease-out);
}

.tool-btn span {
  line-height: 1;
}

.tool-btn.active {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: #e8f5f0;
  transform: translateY(-1px);
}

.size-group,
.history-group {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.size-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.size-btn.active {
  background: color-mix(in srgb, white 12%, transparent);
  color: #e8efe9;
}

.color-swatches {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  appearance: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, black 15%, transparent);
  transition: transform 0.15s var(--ease-out), border-color 0.15s ease;
}

.color-swatch.active {
  border-color: #e8efe9;
  transform: scale(1.12);
}

.history-group .btn-icon {
  color: #c5d0ca;
}

@media (min-width: 700px) {
  .toolbar-row.tools {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }

  .toolbar-row.secondary {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
  }
}
