:root {
  --viewer-border: #dee2e6;
  --viewer-bg: #f8f9fa;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: #fff;
  overscroll-behavior: none;
}

/* Ensure scrolling works in fullscreen mode */
html:fullscreen,
html:-webkit-full-screen,
html:-moz-full-screen,
html:-ms-fullscreen {
  overflow: auto;
  height: 100%;
}

html:fullscreen body,
html:-webkit-full-screen body,
html:-moz-full-screen body,
html:-ms-fullscreen body {
  overflow: auto;
  height: 100%;
}

.landing {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  background: radial-gradient(circle at 10% 20%, #f1f3f5, #fff 25%),
    radial-gradient(circle at 90% 20%, #f8f0fc, #fff 30%);
  position: relative;
}

.landing-menu-container {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

.landing-menu-container .icon-btn {
  padding: 0.5rem;
}

.landing-menu-container [data-tooltip] {
  position: relative;
}

.landing-menu-container [data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translate(-50%, -4px);
  padding: 0.25rem 0.5rem;
  border-radius: 0.35rem;
  background: #212529;
  color: #fff;
  font-size: 0.875rem;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease-in-out, transform 0.12s ease-in-out;
  transition-delay: 0s;
  z-index: 15;
}

.landing-menu-container [data-tooltip]:hover::after,
.landing-menu-container [data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
  transition-delay: 0.5s;
}

.landing-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: #fff;
  border: 1px solid var(--viewer-border);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.12);
  border-radius: 0.75rem;
  padding: 0.25rem;
  min-width: 200px;
  z-index: 12;
}

.landing-menu.hidden {
  display: none;
}

.landing-menu-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: none;
  background: transparent;
  color: #495057;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.1s ease, color 0.1s ease;
  text-align: left;
  text-decoration: none;
}

@media (hover: hover) {
  .landing-menu-option:hover {
    background: #f8f9fa;
    color: #212529;
  }
}

.landing-menu-option:active {
  background: #e9ecef;
}

.landing-menu-option:focus-visible {
  outline: 2px solid #0b7285;
  outline-offset: 2px;
}

.landing-menu-option .material-icons-outlined {
  font-size: 1.5rem;
  line-height: 1;
}

.landing-menu-text {
  font-size: 0.875rem;
  font-weight: 500;
}

.landing-shell {
  width: min(640px, 100%);
  margin: 0 auto;
}

.landing-card {
  border-radius: 1rem;
  width: 100%;
}

.viewer-main {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 0;
}

/* In fullscreen, allow the viewer to expand beyond viewport */
html:fullscreen .viewer-main,
html:-webkit-full-screen .viewer-main,
html:-moz-full-screen .viewer-main,
html:-ms-fullscreen .viewer-main {
  height: auto;
  min-height: 100vh;
}

.viewer-toolbar {
  background-color: var(--viewer-bg);
  border-radius: 0;
  padding: 0.75rem 1rem;
  box-shadow: none;
  border-bottom: 1px solid var(--viewer-border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.icon-btn {
  border: none;
  background-color: transparent;
  color: #495057;
  padding: 0  ;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-toolbar .icon-btn {
  padding-left: 1rem;
}

#gridViewBtn {
  padding-left: 0;
  padding-right: 0;
}

.zoom-menu .icon-btn {
  padding-left: 0;
  padding-right: 0;
}

#zoomMenuBtn {
  padding-left: 0;
  padding-right: 0.5rem;
}

#zoomMenuBtn .material-icons-outlined {
  font-size: 1.7rem;
}

.page-control .icon-btn {
  padding: 0;
}

.viewer-toolbar .gap-2 {
  gap: 0.25rem;
}

.viewer-toolbar [data-tooltip] {
  position: relative;
}

.viewer-toolbar [data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translate(-50%, -4px);
  padding: 0.25rem 0.5rem;
  border-radius: 0.35rem;
  background: #212529;
  color: #fff;
  font-size: 0.975rem;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease-in-out, transform 0.12s ease-in-out;
  transition-delay: 0s;
  z-index: 15;
}

.viewer-toolbar [data-tooltip]:hover::after,
.viewer-toolbar [data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
  transition-delay: 2s;
}

.icon-btn .material-icons-outlined,
.icon-btn .material-symbols-outlined {
  font-size: 2rem;
  line-height: 1;
}

.icon-btn:focus-visible {
  background-color: transparent;
  color: #212529;
}

/* Hover only on devices that support it (not iOS touch) */
@media (hover: hover) {
  .icon-btn:hover {
    background-color: transparent;
    color: #212529;
  }
}

/* Touch feedback for iOS and all devices */
.icon-btn:active {
  opacity: 0.7;
  transform: scale(0.95);
}

.icon-btn.active {
  color: #0b7285;
}

.viewer-canvas-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  /* Prevent text selection, context menu, and tap highlight on iOS */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.viewer-canvas-wrapper canvas {
  display: block;
  height: auto;
  background-color: #fff;
  margin: auto;
  /* Prevent tap highlight on iOS */
  -webkit-tap-highlight-color: transparent;
}

.drawing-layer {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
  pointer-events: none;
  z-index: 2;
  /* Prevent text selection, context menu, and tap highlight on iOS */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.viewer-canvas-wrapper canvas.drawing-layer {
  background-color: transparent;
}

.overlay-layer {
  z-index: 3;
  background: 
    linear-gradient(to bottom, rgba(200, 200, 200, 1) 1px, transparent 1px),
    linear-gradient(to right, rgba(200, 200, 200, 1) 1px, white 1px);
  background-size: 40pt 40pt, 40pt 40pt, auto;
  
}

.overlay-layer.hidden {
  display: none !important;
}

.viewer-overlay {
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / 0.85);
  z-index: 5;
  text-align: center;
}

.viewer-overlay.hidden {
  display: none !important;
}

.page-indicator input[type="number"]::-webkit-outer-spin-button,
.page-indicator input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
}

.page-indicator input[type="number"] {
  appearance: textfield;
  width: 40px;
  text-align: right;
}

.draw-color-picker {
  position: relative;
  padding-left: 1rem;
}

.zoom-menu-container {
  position: relative;
}

.draw-color-toggle {
  cursor: pointer;
  border-radius: 999px;
  padding: 0.25rem;
}

.draw-color-toggle:focus-visible {
  outline: 2px solid #0b7285;
  outline-offset: 2px;
}

.draw-color-picker .draw-color-input {
  appearance: none;
  border: none;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  pointer-events: none;
}

.draw-color-picker .draw-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 50%;
}

.draw-color-picker .draw-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.draw-color-picker .draw-color-input::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.draw-color-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  background: #fff;
  border: 1px solid var(--viewer-border);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.12);
  border-radius: 0.75rem;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 12;
}

.draw-color-menu.hidden {
  display: none;
}

.zoom-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  transform: none;
  background: #fff;
  border: 1px solid var(--viewer-border);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.12);
  border-radius: 0.75rem;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 12;
}

.zoom-menu.hidden {
  display: none;
}

.draw-color-option {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #adb5bd;
  background: var(--swatch-color, #000);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

@media (hover: hover) {
  .draw-color-option:hover {
    transform: translateY(-1px);
  }
}

.draw-color-option:active {
  transform: scale(0.9);
}

.draw-color-option:focus-visible,
.draw-color-palette-btn:focus-visible {
  outline: 2px solid #0b7285;
  outline-offset: 2px;
}

.draw-color-option.active {
  box-shadow: 0 0 0 2px #0b7285;
  transform: scale(1.05);
}

.draw-color-palette-btn {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.65rem;
  border: 1px solid #ced4da;
  background: #f8f9fa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #212529;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

@media (hover: hover) {
  .draw-color-palette-btn:hover {
    background: #e9ecef;
    transform: translateY(-1px);
  }
}

.draw-color-palette-btn:active {
  transform: scale(0.9);
  background: #dee2e6;
}

/* Add Page Picker */
.add-page-picker {
  position: relative;
  padding-left: 0.25rem;
}

.add-page-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  background: #fff;
  border: 1px solid var(--viewer-border);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.12);
  border-radius: 0.75rem;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 12;
}

.add-page-menu.hidden {
  display: none;
}

.add-page-option {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.65rem;
  border: 1px solid #ced4da;
  background: #f8f9fa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #212529;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

@media (hover: hover) {
  .add-page-option:hover {
    background: #e9ecef;
    transform: translateY(-1px);
  }
}

.add-page-option:active {
  transform: scale(0.9);
  background: #dee2e6;
}

.add-page-option:focus-visible {
  outline: 2px solid #0b7285;
  outline-offset: 2px;
}

.viewer-modal {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 1rem;
}

.viewer-modal.hidden {
  display: none !important;
}

.viewer-modal__dialog {
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.15);
  max-width: 360px;
  width: 100%;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.viewer-modal__body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.viewer-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.viewer-code-block {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 0.75rem;
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
}

.viewer-code-block.hidden {
  display: none;
}

/* Grid View */
.grid-view-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--viewer-bg);
  overflow: auto;
  z-index: 9;
}

.grid-view-container.hidden {
  display: none;
}

.grid-view-scroller {
  width: 100%;
  min-height: 100%;
  padding-top: 60px; /* Account for toolbar */
  box-sizing: border-box;
}

.grid-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  justify-content: flex-start;
  align-items: flex-start;
}

.grid-thumbnail {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

@media (hover: hover) {
  .grid-thumbnail:hover {
    transform: scale(1.05);
  }
}

.grid-thumbnail:active {
  transform: scale(0.98);
}

.grid-thumbnail-canvas-container {
  position: relative;
  border: 3px solid transparent;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  background-color: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

@media (hover: hover) {
  .grid-thumbnail:hover .grid-thumbnail-canvas-container {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
}

.grid-thumbnail.current .grid-thumbnail-canvas-container {
  border-color: #0d6efd;
  box-shadow: 0 4px 16px rgba(13, 110, 253, 0.3);
}

.grid-thumbnail-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.grid-thumbnail-page-number {
  margin-top: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6c757d;
  text-align: center;
}

.grid-thumbnail.current .grid-thumbnail-page-number {
  color: #0d6efd;
  font-weight: 600;
}

/* Login form disabled state during config loading */
#userIdInput:disabled,
#landingSubmitBtn:disabled {
  background-color: #e9ecef;
  border-color: #dee2e6;
  color: #6c757d;
  cursor: not-allowed;
  opacity: 0.65;
}

#userIdInput:disabled::placeholder {
  color: #adb5bd;
  opacity: 1;
}

/* Login description text - preserve line breaks from config */
#loginDescription {
  white-space: pre-line;
}

/* Local logout modal - vertical buttons */
.local-logout-actions {
  flex-direction: column;
  gap: 0.5rem;
}

.local-logout-actions .btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Local PDF drop area */
.local-pdf-drop-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  border: 2px dashed #dee2e6;
  border-radius: 0.5rem;
  background-color: #f8f9fa;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

@media (hover: hover) {
  .local-pdf-drop-area:hover {
    border-color: #adb5bd;
    background-color: #e9ecef;
  }
}

.local-pdf-drop-area:active {
  background-color: #dee2e6;
}

.local-pdf-drop-area:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

.local-pdf-drop-area.drag-over {
  border-color: #0d6efd;
  background-color: #e7f1ff;
  border-style: solid;
}

.local-pdf-drop-area .drop-area-icon {
  font-size: 2.5rem;
  color: #6c757d;
}

.local-pdf-drop-area.drag-over .drop-area-icon {
  color: #0d6efd;
}

.local-pdf-drop-area .drop-area-text {
  font-size: 0.875rem;
  color: #6c757d;
  text-align: center;
}

/* SSE Alert Container */
.alert-container {
  position: sticky;
  top: 56px; /* Below toolbar */
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: transparent;
  pointer-events: none;
}

.alert-container > * {
  pointer-events: auto;
}

.alert-container .alert {
  margin-bottom: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: alertSlideIn 0.3s ease-out;
}

.alert-container .alert .alert-message {
  word-break: break-word;
}

@keyframes alertSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-container .alert.fade:not(.show) {
  animation: alertSlideOut 0.15s ease-in forwards;
}

@keyframes alertSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Add to Home Screen Modal */
.add-to-home-dialog {
  max-width: 320px;
}

.add-to-home-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.add-to-home-icon .material-icons-outlined {
  font-size: 3rem;
  color: #0d6efd;
}

.add-to-home-steps {
  padding-left: 1.25rem;
  margin-bottom: 0;
  color: #495057;
}

.add-to-home-steps li {
  margin-bottom: 0.5rem;
}

.add-to-home-steps li:last-child {
  margin-bottom: 0;
}

/* iOS Share icon inline */
.ios-share-icon {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  vertical-align: middle;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230d6efd'%3E%3Cpath d='M16 5l-1.42 1.42-1.59-1.59V16h-2V4.83L9.41 6.41 8 5l4-4 4 4zm4 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h3v2H6v11h12V10h-3V8h3a2 2 0 0 1 2 2z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* Standalone mode indicator */
.standalone-indicator {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  background: #6c757d;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 0.35rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.standalone-indicator .material-icons-outlined {
  font-size: 0.95rem;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 10% 20%, #f1f3f5, #fff 25%),
    radial-gradient(circle at 90% 20%, #f8f0fc, #fff 30%);
}

.loading-screen.hidden {
  display: none;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.loading-icon {
  position: relative;
  width: 240px;
  height: 240px;
}

.loading-cow {
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.loading-cow .cheek-left,
.loading-cow .cheek-right {
  animation: chew 0.65s ease-in-out infinite;
}

.loading-cow .cheek-left {
  transform-origin: 172.4px 249.8px;
}

.loading-cow .cheek-right {
  transform-origin: 265.4px 249.8px;
}

.loading-cow .page-bottom {
  animation: pageMove 0.65s ease-in-out infinite;
  transform-origin: 218.9px 212px;
}

.loading-cow .cow-body {
  animation: bodyBulge 0.65s ease-in-out infinite;
  transform-origin: 218.9px 296px;
}

/* Green particles flying out from mouth */
.loading-cow .particle {
  opacity: 0;
}

/* Left side particles - spray left-down then fall */
.loading-cow .pl1 { animation: particleL1 1.2s linear infinite; }
.loading-cow .pl2 { animation: particleL2 1.2s linear 0.12s infinite; }
.loading-cow .pl3 { animation: particleL3 1.2s linear 0.24s infinite; }
.loading-cow .pl4 { animation: particleL1 1.2s linear 0.36s infinite; }
.loading-cow .pl5 { animation: particleL2 1.2s linear 0.48s infinite; }
.loading-cow .pl6 { animation: particleL3 1.2s linear 0.6s infinite; }
.loading-cow .pl7 { animation: particleL1 1.2s linear 0.72s infinite; }
.loading-cow .pl8 { animation: particleL2 1.2s linear 0.84s infinite; }

/* Right side particles - spray right-down then fall */
.loading-cow .pr1 { animation: particleR1 1.2s linear infinite; }
.loading-cow .pr2 { animation: particleR2 1.2s linear 0.12s infinite; }
.loading-cow .pr3 { animation: particleR3 1.2s linear 0.24s infinite; }
.loading-cow .pr4 { animation: particleR1 1.2s linear 0.36s infinite; }
.loading-cow .pr5 { animation: particleR2 1.2s linear 0.48s infinite; }
.loading-cow .pr6 { animation: particleR3 1.2s linear 0.6s infinite; }
.loading-cow .pr7 { animation: particleR1 1.2s linear 0.72s infinite; }
.loading-cow .pr8 { animation: particleR2 1.2s linear 0.84s infinite; }

@keyframes chew {
  0%, 100% {
    transform: scale(1, 1);
  }
  50% {
    transform: scale(1.1, 0.9);
  }
}

@keyframes pageMove {
  0%, 100% {
    transform: translateY(0) scaleY(1);
  }
  50% {
    transform: translateY(-3px) scaleY(0.97);
  }
}

@keyframes bodyBulge {
  0%, 100% {
    transform: scaleX(1);
  }
  50% {
    transform: scaleX(1.02);
  }
}

/* Left particles - spray diagonal left-down, curve down */
@keyframes particleL1 {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { transform: translate(-20px, 15px); opacity: 1; }
  30% { transform: translate(-45px, 35px); opacity: 1; }
  60% { transform: translate(-55px, 70px); opacity: 0.7; }
  100% { transform: translate(-50px, 120px); opacity: 0; }
}

@keyframes particleL2 {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { transform: translate(-25px, 10px); opacity: 1; }
  30% { transform: translate(-55px, 30px); opacity: 1; }
  60% { transform: translate(-65px, 65px); opacity: 0.7; }
  100% { transform: translate(-60px, 115px); opacity: 0; }
}

@keyframes particleL3 {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { transform: translate(-15px, 18px); opacity: 1; }
  30% { transform: translate(-35px, 40px); opacity: 1; }
  60% { transform: translate(-42px, 75px); opacity: 0.7; }
  100% { transform: translate(-38px, 125px); opacity: 0; }
}

/* Right particles - spray diagonal right-down, curve down */
@keyframes particleR1 {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { transform: translate(20px, 15px); opacity: 1; }
  30% { transform: translate(45px, 35px); opacity: 1; }
  60% { transform: translate(55px, 70px); opacity: 0.7; }
  100% { transform: translate(50px, 120px); opacity: 0; }
}

@keyframes particleR2 {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { transform: translate(25px, 10px); opacity: 1; }
  30% { transform: translate(55px, 30px); opacity: 1; }
  60% { transform: translate(65px, 65px); opacity: 0.7; }
  100% { transform: translate(60px, 115px); opacity: 0; }
}

@keyframes particleR3 {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { transform: translate(15px, 18px); opacity: 1; }
  30% { transform: translate(35px, 40px); opacity: 1; }
  60% { transform: translate(42px, 75px); opacity: 0.7; }
  100% { transform: translate(38px, 125px); opacity: 0; }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .loading-cow .cheek-left,
  .loading-cow .cheek-right,
  .loading-cow .page-bottom,
  .loading-cow .cow-body,
  .loading-cow .particle {
    animation: none;
  }
}

.loading-text {
  font-size: 1rem;
  font-weight: 500;
  color: #6c757d;
}

/* Pen Debug Panel */
.pen-debug-panel {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: rgba(33, 37, 41, 0.95);
  color: #fff;
  border-radius: 0.75rem;
  padding: 0.75rem;
  min-width: 200px;
  max-width: 300px;
  z-index: 10000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.875rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pen-debug-panel.hidden {
  display: none;
}

.pen-debug-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.pen-debug-header .material-icons-outlined {
  font-size: 1.25rem;
  color: #ffc107;
}

.pen-debug-title {
  font-weight: 600;
  flex: 1;
}

.pen-debug-count {
  background: #dc3545;
  color: #fff;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 2rem;
  text-align: center;
}

.pen-debug-actions {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 0.5rem;
}

.pen-debug-actions .btn {
  flex: 1;
  padding: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pen-debug-actions .btn .material-icons-outlined {
  font-size: 1rem;
}

.pen-debug-info {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.4;
  max-height: 150px;
  overflow-y: auto;
}

.pen-debug-info:empty {
  display: none;
}

.pen-debug-info .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pen-debug-info .stat-row:last-child {
  border-bottom: none;
}

.pen-debug-info .stat-label {
  color: rgba(255, 255, 255, 0.6);
}

.pen-debug-info .stat-value {
  font-weight: 600;
  color: #fff;
}

.pen-debug-info .stat-value.warning {
  color: #ffc107;
}

.pen-debug-info .stat-value.error {
  color: #dc3545;
}

.pen-debug-info .stat-value.success {
  color: #28a745;
}

/* Pen debug panel button active state in landing menu */
.landing-menu-option.pen-debug-active {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.landing-menu-option.pen-debug-active .material-icons-outlined {
  color: #ffc107;
}

/* Clearance Lock Overlay */
.clearance-lock-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.clearance-lock-content {
  text-align: center;
  color: #fff;
  padding: 2rem;
}

.clearance-lock-icon {
  font-size: 4rem;
  color: #6c757d;
  margin-bottom: 0.5rem;
}

.clearance-lock-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0.5rem 0;
}

.clearance-lock-message {
  color: #adb5bd;
  max-width: 300px;
  margin: 0 auto;
}

/* Clearance Toast (temporary notification) */
.clearance-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #198754;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10001;
}

.clearance-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.clearance-toast .material-icons-outlined {
  font-size: 1.25rem;
}
