/* Final button polish: solid colors, no raised motion, theme-aware hover. */
:root {
  --button-hover: color-mix(in srgb, var(--accent) 58%, white 42%);
  --button-secondary-hover: color-mix(in srgb, var(--accent) 16%, white 84%);
  --button-danger-hover: color-mix(in srgb, var(--danger-bg) 72%, #ffffff 28%);
  --button-study-hover: color-mix(in srgb, var(--study-accent) 78%, white 22%);
}

.hard-item-slot.is-import-progress,
.hard-item-slot.is-import-error,
.hard-item-slot.is-import-resume {
  opacity: 1 !important;
  filter: none !important;
  visibility: visible !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hard-item-slot.is-import-complete {
  opacity: 1 !important;
  visibility: visible !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body.phone-library-switching-lock {
  cursor: progress;
}

body.phone-library-switching-lock::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1150;
  pointer-events: none;
  background: color-mix(in srgb, var(--bg) 22%, transparent);
}

body.phone-library-switching-lock .wrap,
body.phone-library-switching-lock .library-selector-shell,
body.phone-library-switching-lock .theme-toggle {
  filter: saturate(.82);
  transition: filter .18s ease;
}

body.phone-library-switching-lock #hardItemSlot,
body.phone-library-switching-lock .focus-badge-history-panel {
  position: relative;
  z-index: 1200;
}

body.phone-library-switching-lock #hardItemSlot {
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 20%, transparent), 0 18px 38px var(--shadow);
}

body.google-signing-out {
  cursor: progress;
}

body.google-signing-out::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1190;
  pointer-events: auto;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 54%, transparent), color-mix(in srgb, var(--bg) 66%, transparent));
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

body.google-signing-out .study-set-modal:not(#appPromptModal),
body.google-signing-out .google-auth-modal,
body.google-signing-out .study-profile-modal,
body.google-signing-out .consent-banner,
body.google-signing-out .drive-import-chooser {
  z-index: 1100 !important;
  pointer-events: none !important;
}

body.google-signing-out #hardItemSlot.is-process-badge-forced,
body.google-signing-out #hardItemSlot.is-import-progress,
body.google-signing-out #hardItemSlot.is-import-complete,
body.google-signing-out #hardItemSlot.is-import-error,
body.google-signing-out #hardItemSlot.is-import-resume,
body.google-signing-out #hardItemSlot.is-focus-notice {
  position: relative;
  z-index: 1210 !important;
  isolation: isolate;
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
}

body.google-signing-out .focus-badge-history-panel {
  z-index: 1210 !important;
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
}

body.google-signing-out #appPromptModal.open {
  z-index: 1500 !important;
  pointer-events: auto !important;
}

body.library-process-lock {
  cursor: wait;
}

body.library-process-lock::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1160;
  pointer-events: auto;
  background: color-mix(in srgb, var(--bg) 32%, transparent);
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

body.google-picker-open.library-process-lock::after {
  pointer-events: none !important;
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

body.google-picker-open.library-process-lock [data-action-progress="true"],
body.google-picker-open.library-process-lock button.action-progress-focus-target.is-action-progress,
body.google-picker-open.library-process-lock .button.action-progress-focus-target.is-action-progress {
  z-index: 1 !important;
  pointer-events: none !important;
}

body.google-picker-open .picker-dialog-bg {
  z-index: 2147483000 !important;
}

body.google-picker-open .picker-dialog {
  z-index: 2147483001 !important;
  opacity: 1 !important;
  filter: none !important;
}

body.library-process-lock .wrap,
body.library-process-lock .library-selector-shell,
body.library-process-lock .theme-toggle {
  filter: none !important;
  transition: filter .18s ease;
}

body.library-process-lock.action-progress-focus-active .wrap,
body.library-process-lock.action-progress-focus-active .library-selector-shell,
body.library-process-lock.action-progress-focus-active .theme-toggle {
  filter: none !important;
}

body.library-process-lock #hardItemSlot,
body.library-process-lock .focus-badge-history-panel,
body.library-process-lock [data-action-progress="true"] {
  position: relative;
  z-index: 1210;
}

body.library-process-lock #hardItemSlot.is-process-badge-forced,
body.library-process-lock #hardItemSlot.is-import-progress,
body.library-process-lock #hardItemSlot.is-import-complete,
body.library-process-lock #hardItemSlot.is-import-error,
body.library-process-lock #hardItemSlot.is-import-resume,
body.library-process-lock #hardItemSlot.is-focus-notice {
  z-index: 1210 !important;
  isolation: isolate;
  opacity: 1 !important;
  filter: none !important;
  transform: none !important;
  box-shadow: none !important;
}

body.library-process-lock [data-action-progress="true"] {
  pointer-events: none !important;
  opacity: 1 !important;
  filter: none !important;
}

body.library-process-lock button.action-progress-focus-target.is-action-progress,
body.library-process-lock .button.action-progress-focus-target.is-action-progress {
  z-index: 1210 !important;
  isolation: isolate;
  opacity: 1 !important;
  filter: none !important;
  min-height: 44px;
  white-space: normal;
  text-align: center;
  line-height: 1.15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: none !important;
}

body.library-process-lock #appPromptModal,
body.library-process-lock .google-auth-modal,
body.library-process-lock .study-profile-modal,
body.library-process-lock .consent-banner,
body.library-process-lock .drive-import-chooser {
  position: fixed;
  z-index: 1300;
}

.hard-item-slot.is-import-complete .focus-import-done {
  color: #ffffff !important;
}

/* Touch and stylus polish for editor/viewer controls. */
.anatomy-image-editor-stage-wrap,
.viewer-stage {
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
}

.anatomy-image-editor-stage,
.anatomy-image-editor-canvas,
.anatomy-image-editor-crop,
.viewer-stage,
#zoomImage,
#sharpCanvas,
.viewer-mask-layer {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

/* Study Tape mask style: raised paper-like cover strips with tap-to-reveal behavior. */
.anatomy-image-editor-color.is-tape-swatch {
  width: 38px;
  border-radius: 6px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 251, 239, 0.62), transparent 64%, rgba(112, 86, 42, 0.10)),
    #eadfbd;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 1px 0 rgba(91, 65, 10, 0.10),
    0 3px 5px rgba(78, 57, 11, 0.10);
}

.anatomy-image-editor-color.is-tape-swatch::before,
.anatomy-image-editor-color.is-tape-swatch::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(105, 75, 18, 0.42) 0 2px,
    transparent 2px 4px
  );
  opacity: 0.64;
}

.anatomy-image-editor-color.is-tape-swatch::before { left: 3px; }
.anatomy-image-editor-color.is-tape-swatch::after { right: 3px; }

.anatomy-mask-group,
.anatomy-quiz-mask-group {
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.anatomy-tape-shadow,
.anatomy-tape-contact,
.anatomy-tape-edge,
.anatomy-tape-main,
.anatomy-tape-hit {
  stroke: none;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.anatomy-tape-highlight,
.anatomy-tape-bottom {
  fill: none;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.anatomy-tape-shadow {
  fill: rgba(44, 34, 9, 0.026);
}

.anatomy-tape-contact {
  fill: rgba(35, 27, 7, 0.034);
}

.anatomy-tape-edge {
  fill: none;
  stroke: rgba(94, 73, 31, 0.055);
  stroke-width: 1;
}

.anatomy-tape-main {
  opacity: 0.99;
}

.anatomy-tape-highlight {
  stroke: rgba(255, 255, 255, 0.20);
  opacity: 0.24;
  pointer-events: none;
}

.anatomy-tape-bottom {
  stroke: rgba(64, 48, 18, 0.075);
  opacity: 0.30;
  pointer-events: none;
}

.anatomy-tape-hit {
  fill: rgba(0, 0, 0, 0);
  pointer-events: all;
}

.anatomy-quiz-mask-target {
  cursor: pointer;
}

.anatomy-quiz-mask-target:hover .anatomy-tape-main,
.anatomy-quiz-mask-target:focus-visible .anatomy-tape-main {
  opacity: 0.97;
}

.anatomy-quiz-mask-target.is-revealed {
  opacity: 0.045;
}

.anatomy-quiz-mask-target.is-revealed.anatomy-tape-mask {
  opacity: 0.035;
}

input[type="range"]:not(#quizDifficultySlider) {
  --range-track-height: 6px;
  --range-thumb-size: 20px;
  --range-progress: 0%;
  --range-track-color: color-mix(in srgb, var(--line, #cbd5e1) 64%, transparent);
  --range-fill-color: var(--accent, #4285f4);
  box-sizing: border-box;
  min-width: 0;
  padding: 0 !important;
  border: 0;
  background: transparent;
  accent-color: var(--accent, #4285f4);
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]:not(#quizDifficultySlider)::-webkit-slider-runnable-track {
  width: 100%;
  height: var(--range-track-height);
  border: 0;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--range-fill-color) 0 var(--range-progress), var(--range-track-color) var(--range-progress) 100%);
  box-shadow: none;
}

input[type="range"]:not(#quizDifficultySlider)::-webkit-slider-thumb {
  width: var(--range-thumb-size);
  height: var(--range-thumb-size);
  margin-top: calc((var(--range-track-height) - var(--range-thumb-size)) / 2);
  border: 2px solid var(--surface, #fff);
  border-radius: 50%;
  background: var(--range-fill-color);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.18);
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]:not(#quizDifficultySlider)::-moz-range-track {
  width: 100%;
  height: var(--range-track-height);
  border: 0;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--range-fill-color) 0 var(--range-progress), var(--range-track-color) var(--range-progress) 100%);
  box-shadow: none;
}

input[type="range"]:not(#quizDifficultySlider)::-moz-range-progress {
  height: var(--range-track-height);
  border-radius: 999px;
  background: var(--range-fill-color);
}

input[type="range"]:not(#quizDifficultySlider)::-moz-range-thumb {
  width: var(--range-thumb-size);
  height: var(--range-thumb-size);
  border: 2px solid var(--surface, #fff);
  border-radius: 50%;
  background: var(--range-fill-color);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.18);
}

input[type="range"]:not(#quizDifficultySlider):focus-visible {
  outline: none;
}

input[type="range"]:not(#quizDifficultySlider):focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, #4285f4) 22%, transparent);
}

input[type="range"]:not(#quizDifficultySlider):focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, #4285f4) 22%, transparent);
}

.anatomy-image-editor-brush input[type="range"] {
  width: min(150px, 38vw);
  height: var(--range-thumb-size);
  flex: 1 1 132px;
}

.microscope-enhance-slider input[type="range"] {
  --range-track-height: 5px;
  --range-thumb-size: 18px;
  --range-fill-color: #4285f4;
  --range-track-color: #dbeafe;
}

.range-value-popover {
  position: fixed;
  z-index: 4200;
  min-width: 34px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--accent, #4285f4) 32%, var(--line, #cbd5e1) 68%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-elevated, #ffffff) 94%, white 6%);
  color: var(--text, #0f172a);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -8px) scale(0.96);
  transition: opacity 120ms ease, transform 120ms ease;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.range-value-popover.is-visible {
  opacity: 1;
  transform: translate(-50%, -12px) scale(1);
}

.anatomy-image-editor-tools button,
.anatomy-image-editor-actions button,
.anatomy-image-editor-text-toolbar button,
.viewer-toolbar button,
#closeModalBtn,
#zoomInBtn,
#zoomOutBtn,
#zoomResetBtn,
.anatomy-quiz-action,
.anatomy-quiz-card,
.library-selector-switch,
.mobile-library-option {
  touch-action: manipulation !important;
}

@media (pointer: coarse), (max-width: 820px) {
  .anatomy-image-editor-card {
    max-height: calc(100dvh - 18px) !important;
  }

  .anatomy-image-editor-body {
    overscroll-behavior: contain !important;
  }

  .anatomy-image-editor-stage-wrap {
    padding: 10px !important;
    max-height: min(58dvh, 620px) !important;
  }

  .anatomy-image-editor-tools {
    align-items: stretch !important;
    gap: 8px !important;
  }

  .anatomy-image-editor-tool-group {
    max-width: 100% !important;
  }

  .anatomy-image-editor-active-tool-group {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: auto minmax(126px, 1fr) !important;
    align-items: center !important;
  }

  .anatomy-image-editor-active-tool-group .anatomy-image-editor-color-row {
    grid-column: 1 / -1;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .anatomy-image-editor-brush {
    min-width: 0;
  }

  .anatomy-image-editor-brush input[type="range"] {
    width: 100% !important;
    min-width: 112px;
  }

  .anatomy-image-editor-tools button,
  .anatomy-image-editor-actions button,
  .anatomy-image-editor-text-toolbar button,
  .viewer-toolbar button,
  #closeModalBtn,
  #zoomInBtn,
  #zoomOutBtn,
  #zoomResetBtn {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
  }

  .anatomy-image-editor-color,
  [data-anatomy-note-color],
  .anatomy-back-color {
    min-width: 34px !important;
    min-height: 34px !important;
  }

  .anatomy-image-editor-brush input[type="range"],
  #contrastSlider,
  #sharpenSlider {
    min-height: 36px !important;
  }

  .anatomy-image-editor-crop span {
    width: 26px !important;
    height: 26px !important;
    margin: 0 !important;
  }

  .anatomy-image-editor-crop [data-handle="nw"] {
    left: -13px !important;
    top: -13px !important;
  }

  .anatomy-image-editor-crop [data-handle="ne"] {
    right: -13px !important;
    top: -13px !important;
  }

  .anatomy-image-editor-crop [data-handle="sw"] {
    left: -13px !important;
    bottom: -13px !important;
  }

  .anatomy-image-editor-crop [data-handle="se"] {
    right: -13px !important;
    bottom: -13px !important;
  }

  .library-selector-switch[data-library-help]:active::after,
  .library-selector-switch[data-library-help]:focus::after,
  .library-selector-switch .library-selector-hover-zone[data-library-help]:active::after,
  .library-selector-switch .library-selector-hover-zone[data-library-help]:focus::after {
    opacity: 1 !important;
    transform: translate(0, -50%) scale(1) !important;
  }
}

@media (max-width: 420px), (max-height: 620px) {
  .anatomy-image-editor-top {
    padding: 14px 14px 10px !important;
  }

  .anatomy-image-editor-body {
    padding: 12px !important;
    gap: 10px !important;
  }

  .anatomy-image-editor-stage-wrap {
    max-height: min(52dvh, 520px) !important;
    border-radius: 18px !important;
  }

  .anatomy-image-editor-actions {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

html[data-theme="dark"] {
  --button-hover: color-mix(in srgb, var(--accent) 64%, white 36%);
  --button-secondary-hover: color-mix(in srgb, var(--accent) 14%, var(--surface-elevated) 86%);
  --button-danger-hover: color-mix(in srgb, var(--danger-bg) 86%, white 14%);
  --button-study-hover: color-mix(in srgb, var(--study-accent) 72%, white 28%);
}

button:not(.hard-item-slot),
.button,
.btn-primary,
.btn-secondary,
.btn-soft,
.btn-study,
.btn-danger,
.tab,
.chrome-action-btn,
.chrome-profile-btn,
.study-timer-preset,
.study-timer-btn,
.shared-pack-author-link,
.shared-pack-thumbs-btn,
.shared-pack-coffee-link,
.profile-avatar-remove,
.anatomy-entry-upload-btn,
.anatomy-back-size-btn,
.study-tool-btn,
.study-swatch,
.study-swatch-clear,
.quiz-saved-group-preview-delete {
  box-shadow: none !important;
  transform: none !important;
  background-image: none !important;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, opacity .16s ease !important;
}

.anatomy-entry-replace-btn,
.anatomy-entry-edit-btn,
.anatomy-entry-add-text-btn {
  box-shadow: none !important;
  background-image: none !important;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, opacity .16s ease !important;
}

.anatomy-entry-replace-btn,
.anatomy-entry-edit-btn,
.anatomy-entry-add-text-btn,
.anatomy-entry-replace-btn:hover,
.anatomy-entry-edit-btn:hover,
.anatomy-entry-add-text-btn:hover,
.anatomy-entry-replace-btn:active,
.anatomy-entry-edit-btn:active,
.anatomy-entry-add-text-btn:active,
.anatomy-entry-replace-btn:focus-visible,
.anatomy-entry-edit-btn:focus-visible,
.anatomy-entry-add-text-btn:focus-visible {
  transform: translate(-50%, -50%) !important;
}

button:not(.hard-item-slot):hover,
button:not(.hard-item-slot):active,
button:not(.hard-item-slot):focus-visible,
.button:hover,
.button:active,
.button:focus-visible {
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary,
.tab.active,
.empty-guide-step button {
  background: var(--accent) !important;
  color: #0f172a !important;
  border-color: var(--accent) !important;
}

.btn-primary:hover,
.tab.active:hover,
.empty-guide-step button:hover {
  background: var(--button-hover) !important;
  border-color: var(--button-hover) !important;
}

.btn-study {
  background: var(--study-accent) !important;
  color: var(--study-text) !important;
  border-color: var(--study-accent) !important;
}

.btn-study:hover {
  background: var(--button-study-hover) !important;
  border-color: var(--button-study-hover) !important;
}

.btn-secondary,
.btn-soft,
.tab,
.chrome-action-btn,
.chrome-profile-btn,
.shared-pack-author-link,
.shared-pack-thumbs-btn,
.shared-pack-coffee-link,
.study-timer-preset,
.study-timer-btn,
.anatomy-back-size-btn {
  background: var(--secondary-bg) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

.btn-secondary:hover,
.btn-soft:hover,
.tab:hover,
.chrome-action-btn:hover,
.chrome-profile-btn:hover,
.shared-pack-author-link:hover,
.shared-pack-thumbs-btn:hover,
.shared-pack-coffee-link:hover,
.study-timer-preset:hover,
.study-timer-btn:hover,
.anatomy-back-size-btn:hover {
  background: var(--button-secondary-hover) !important;
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line) 58%) !important;
}

.chrome-action-icon {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  width: 16px !important;
  height: 16px !important;
  font-size: 15px !important;
}

.shared-pack-thumbs-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  min-width: 54px !important;
  padding-inline: 10px !important;
}

.shared-pack-thumbs-btn.is-active {
  background: rgba(22,163,74,0.14) !important;
  border-color: rgba(22,163,74,0.28) !important;
  color: #166534 !important;
}

.shared-pack-thumbs-btn.is-active:hover {
  background: rgba(22,163,74,0.2) !important;
  border-color: rgba(22,163,74,0.34) !important;
  color: #14532d !important;
}

html[data-theme="dark"] .shared-pack-thumbs-btn.is-active {
  background: rgba(34,197,94,0.2) !important;
  border-color: rgba(34,197,94,0.32) !important;
  color: #86efac !important;
}

.shared-pack-heart-btn.is-active {
  background: rgba(244,63,94,0.14) !important;
  border-color: rgba(244,63,94,0.28) !important;
  color: #be123c !important;
}

.shared-pack-heart-btn.is-active:hover {
  background: rgba(244,63,94,0.2) !important;
  border-color: rgba(244,63,94,0.34) !important;
  color: #9f1239 !important;
}

html[data-theme="dark"] .shared-pack-heart-btn.is-active {
  background: rgba(251,113,133,0.2) !important;
  border-color: rgba(251,113,133,0.34) !important;
  color: #fda4af !important;
}

.btn-danger {
  background: var(--danger-bg) !important;
  color: var(--danger-text) !important;
  border-color: var(--danger-border) !important;
}

.btn-danger:hover {
  background: var(--button-danger-hover) !important;
  border-color: var(--danger-border) !important;
}

#exitQuizBtn {
  color: var(--danger-text) !important;
  border-color: color-mix(in srgb, var(--danger-border) 72%, var(--line) 28%) !important;
  background: color-mix(in srgb, var(--danger-bg) 58%, var(--surface-raised) 42%) !important;
}

#exitQuizBtn:hover,
#exitQuizBtn:focus-visible {
  background: color-mix(in srgb, var(--danger-bg) 76%, var(--surface-raised) 24%) !important;
  border-color: var(--danger-border) !important;
}

#exitQuizBtn.is-confirming-exit {
  color: #ffffff !important;
  background: color-mix(in srgb, var(--danger-text) 78%, var(--danger-bg) 22%) !important;
  border-color: color-mix(in srgb, var(--danger-text) 70%, var(--danger-border) 30%) !important;
}

button.is-inline-confirming,
.btn-primary.is-inline-confirming,
.btn-secondary.is-inline-confirming {
  min-width: var(--inline-confirm-min-width, max-content) !important;
  max-width: none !important;
  white-space: nowrap !important;
  font-weight: 500 !important;
  color: #ffffff !important;
  background: color-mix(in srgb, var(--accent) 84%, #111827 16%) !important;
  border-color: color-mix(in srgb, var(--accent) 72%, #111827 28%) !important;
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent),
    0 10px 22px color-mix(in srgb, var(--accent) 18%, transparent) !important;
}

button.is-inline-confirming:hover,
button.is-inline-confirming:focus-visible,
.btn-primary.is-inline-confirming:hover,
.btn-primary.is-inline-confirming:focus-visible,
.btn-secondary.is-inline-confirming:hover,
.btn-secondary.is-inline-confirming:focus-visible {
  background: color-mix(in srgb, var(--accent) 90%, #111827 10%) !important;
  border-color: color-mix(in srgb, var(--accent) 82%, #111827 18%) !important;
}

button:disabled,
.button.disabled,
.btn-primary.disabled,
.btn-secondary.disabled,
.btn-study.disabled {
  transform: none !important;
  box-shadow: none !important;
  opacity: .52 !important;
  cursor: not-allowed !important;
  filter: saturate(.65) brightness(.94) !important;
}

.btn-primary:disabled,
.btn-primary.disabled {
  background: color-mix(in srgb, var(--surface-muted) 74%, #475569 26%) !important;
  border-color: color-mix(in srgb, var(--line) 72%, #475569 28%) !important;
  color: var(--muted) !important;
}

.btn-secondary:disabled,
.btn-secondary.disabled,
.btn-soft:disabled,
.btn-soft.disabled {
  background: var(--surface-muted) !important;
  border-color: var(--line) !important;
  color: var(--muted) !important;
}

.theme-toggle,
.theme-toggle:hover,
.system-toggle,
.system-toggle:hover {
  background: var(--theme-toggle-bg) !important;
  border-color: var(--theme-toggle-border) !important;
}

.theme-toggle-thumb,
.system-toggle .theme-toggle-thumb {
  background: var(--accent) !important;
  box-shadow: none !important;
}

.library-selector-shell .system-toggle,
.library-selector-shell .system-toggle:hover {
  background: transparent !important;
  border-color: transparent !important;
}

.anatomy-entry-back-top-flip-zone,
.anatomy-entry-back-top-flip-zone:hover,
.anatomy-entry-back-top-flip-zone:focus-visible {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
}

/* Final visual guard: solid colors across the app, with the themed header preserved. */
:root {
  --app-bg: var(--system-ambient-bg, #f8fbff) !important;
  --theme-toggle-thumb: var(--accent) !important;
}

html[data-theme="dark"] {
  --app-bg: var(--system-ambient-bg, #0a1426) !important;
  --theme-toggle-thumb: var(--accent) !important;
}

/* Process badge owns the focus slot temporarily; keep its active visuals out of the global button reset. */
.hard-item-slot.is-import-progress:not(.is-import-complete):not(.is-import-error),
.hard-item-slot.is-import-resume {
  opacity: 1 !important;
  filter: none !important;
  visibility: visible !important;
  transform: none !important;
  background: var(--surface-elevated) !important;
  background-color: var(--surface-elevated) !important;
  background-image: none !important;
  border-color: var(--line) !important;
  box-shadow: none !important;
  animation: none !important;
}

.hard-item-slot.is-import-progress:not(.is-import-complete):not(.is-import-error)::before {
  content: none !important;
  background: none !important;
  background-image: none !important;
}

.hard-item-slot.is-import-progress:not(.is-import-complete):not(.is-import-error)::after {
  content: none !important;
  background: none !important;
  background-image: none !important;
}

.hard-item-slot.is-import-progress:not(.is-import-complete):not(.is-import-error) .focus-import-track {
  background: color-mix(in srgb, #dbeafe 78%, var(--surface-elevated) 22%) !important;
  background-image: none !important;
  box-shadow: none !important;
}

.hard-item-slot.is-import-progress:not(.is-import-complete):not(.is-import-error) .focus-import-track::after {
  content: none !important;
  animation: none !important;
  background: none !important;
  background-image: none !important;
}

.hard-item-slot.is-import-progress:not(.is-import-complete):not(.is-import-error) .focus-import-track span {
  background: var(--accent) !important;
  background-image: none !important;
  animation: none !important;
}

.hard-item-slot.is-import-complete {
  opacity: 1 !important;
  visibility: visible !important;
  display: grid !important;
  place-items: center !important;
  text-align: center !important;
  box-sizing: border-box !important;
  padding: 7px 10px !important;
  overflow: hidden !important;
  background: linear-gradient(145deg, #34a853, var(--success-text, #17803a)) !important;
  background-color: #22a34a !important;
  border-color: color-mix(in srgb, var(--success-text, #17803a) 74%, #ffffff 26%) !important;
}

.hard-item-slot.is-import-complete .focus-import-done {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 100% !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #ffffff !important;
  font-size: clamp(24px, 3.4vw, 32px) !important;
  font-weight: 950 !important;
  line-height: 1 !important;
  letter-spacing: 0 !important;
  text-align: center !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: clip !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

.hard-item-slot.is-import-progress:not(.is-import-complete),
.hard-item-slot.is-focus-notice {
  display: grid !important;
  align-content: center !important;
  justify-content: stretch !important;
  justify-items: stretch !important;
  gap: 0 !important;
  padding: 10px 12px !important;
  overflow: hidden !important;
  text-align: left !important;
}

.focus-process-card,
.focus-process-stack {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  overflow: hidden;
}

.focus-process-card {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  gap: 4px;
}

.focus-process-notice-card {
  grid-template-rows: auto auto auto;
  gap: 4px;
}

.focus-process-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.focus-process-head-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.focus-process-status-icon {
  display: inline-grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line) 74%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-elevated) 90%);
  color: var(--accent-strong);
  line-height: 1;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #ffffff 54%, transparent);
}

.focus-process-status-icon svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.focus-process-status-icon[data-status-state="good"] {
  border-color: color-mix(in srgb, var(--success-text, #17803a) 26%, var(--line) 74%);
  background: color-mix(in srgb, var(--success-text, #17803a) 12%, var(--surface-elevated) 88%);
  color: var(--success-text, #17803a);
}

.focus-process-status-icon[data-status-state="attention"],
.focus-process-status-icon[data-status-state="notice"] {
  border-color: color-mix(in srgb, #d97706 28%, var(--line) 72%);
  background: color-mix(in srgb, #fbbf24 14%, var(--surface-elevated) 86%);
  color: #9a6700;
}

.focus-process-status-icon[data-status-state="mismatch"] {
  border-color: color-mix(in srgb, var(--danger-text) 34%, var(--line) 66%);
  background: color-mix(in srgb, var(--danger-text) 10%, var(--surface-elevated) 90%);
  color: var(--danger-text);
}

.focus-process-status-icon[data-status-state="linked"] {
  border-color: color-mix(in srgb, #2563eb 30%, var(--line) 70%);
  background: color-mix(in srgb, #dbeafe 64%, var(--surface-elevated) 36%);
  color: #1d4ed8;
}

.focus-process-kicker {
  min-width: 0;
  color: color-mix(in srgb, #4285f4 84%, var(--text) 16%);
  font-size: 9.5px;
  font-weight: 950;
  letter-spacing: .02em;
  line-height: 1;
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-process-card[data-tone="good"] .focus-process-kicker,
.focus-process-row.is-good .focus-process-row-label {
  color: var(--success-text, #17803a);
}

.focus-process-card[data-tone="warn"] .focus-process-kicker,
.focus-process-row.is-warn .focus-process-row-label {
  color: #9a6700;
}

.focus-process-card[data-tone="bad"] .focus-process-kicker,
.focus-process-row.is-bad .focus-process-row-label {
  color: var(--danger-text);
}

.focus-process-card[data-tone="quiz-cold"] .focus-process-kicker,
.focus-process-row.is-quiz-cold .focus-process-row-label {
  color: #dc2626;
}

.focus-process-card[data-tone="quiz-warmer"] .focus-process-kicker,
.focus-process-row.is-quiz-warmer .focus-process-row-label {
  color: #f97316;
}

.focus-process-card[data-tone="quiz-hot"] .focus-process-kicker,
.focus-process-row.is-quiz-hot .focus-process-row-label {
  color: #a16207;
}

.focus-process-card[data-tone="quiz-very-hot"] .focus-process-kicker,
.focus-process-row.is-quiz-very-hot .focus-process-row-label {
  color: #65a30d;
}

.focus-process-card[data-tone="resume"] .focus-process-kicker {
  color: var(--accent-strong);
}

.focus-process-percent,
.focus-process-title {
  min-width: 0;
  color: var(--text);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-process-percent {
  font-size: 22px;
  text-align: right;
}

.focus-process-title {
  font-size: 15px;
  text-align: right;
}

.focus-process-head-copy .focus-process-title {
  font-size: 14px;
  text-align: left;
}

.focus-process-subline {
  min-width: 0;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-process-track {
  position: relative;
  display: block;
  height: 9px;
  min-height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, #dbeafe 76%, var(--surface-elevated) 24%) !important;
  box-shadow:
    inset 0 0 0 1px rgba(66, 133, 244, .18),
    inset 0 1px 2px rgba(15, 23, 42, .08);
}

.focus-process-track::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(90deg, transparent 0%, rgba(59, 130, 246, .2) 20%, rgba(255,255,255,.95) 48%, rgba(96, 165, 250, .26) 72%, transparent 100%);
  transform: translateX(-110%);
  animation: focusProcessTrackFlow .78s ease-in-out infinite;
  pointer-events: none;
}

.focus-process-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(105deg, transparent 0 30%, rgba(255,255,255,.9) 44%, transparent 58%),
    repeating-linear-gradient(115deg, rgba(255,255,255,.38) 0 7px, rgba(255,255,255,0) 7px 15px),
    linear-gradient(90deg, #1d4ed8, #3b82f6 50%, #8ec5ff) !important;
  background-size: 42px 100%, 24px 100%, 100% 100%;
  animation: focusProcessFillFlow .48s linear infinite;
  transition: width .24s ease;
}

.focus-process-card[data-tone="bad"] .focus-process-track > span {
  background:
    linear-gradient(105deg, transparent 0 30%, rgba(255,255,255,.55) 44%, transparent 58%),
    linear-gradient(90deg, var(--danger-text), color-mix(in srgb, var(--danger-text) 55%, #ffffff 45%)) !important;
}

.focus-process-card[data-tone="resume"] .focus-process-track > span {
  background:
    linear-gradient(105deg, transparent 0 30%, rgba(255,255,255,.82) 44%, transparent 58%),
    linear-gradient(90deg, var(--accent-strong), color-mix(in srgb, var(--accent) 52%, #ffffff 48%)) !important;
}

.focus-process-detail {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-process-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.focus-process-detail-text {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-process-trust-chip {
  display: inline-grid;
  place-items: center;
  min-height: 16px;
  max-width: 82px;
  padding: 3px 5px;
  border: 1px solid color-mix(in srgb, #2563eb 22%, var(--line) 78%);
  border-radius: 7px;
  background: color-mix(in srgb, #dbeafe 58%, var(--surface-elevated) 42%);
  color: #1d4ed8;
  font-size: 7px;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-process-trust-chip.is-mismatch {
  border-color: color-mix(in srgb, var(--danger-text) 30%, var(--line) 70%);
  background: color-mix(in srgb, var(--danger-text) 10%, var(--surface-elevated) 90%);
  color: var(--danger-text);
}

.focus-process-stack {
  display: grid;
  grid-auto-rows: minmax(0, 1fr);
  align-content: stretch;
  gap: 4px;
}

.focus-process-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 0;
  padding: 4px 6px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-elevated) 80%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 72%, transparent);
  overflow: hidden;
}

.focus-process-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.focus-process-row.is-good .focus-process-dot {
  background: var(--success-text, #17803a);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success-text, #17803a) 16%, transparent);
}

.focus-process-row.is-warn .focus-process-dot {
  background: #d97706;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, .14);
}

.focus-process-row.is-bad .focus-process-dot {
  background: var(--danger-text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger-text) 15%, transparent);
}

.focus-process-row.is-quiz-cold .focus-process-dot {
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .14);
}

.focus-process-row.is-quiz-warmer .focus-process-dot {
  background: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .14);
}

.focus-process-row.is-quiz-hot .focus-process-dot {
  background: #eab308;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, .16);
}

.focus-process-row.is-quiz-very-hot .focus-process-dot {
  background: #84cc16;
  box-shadow: 0 0 0 3px rgba(132, 204, 22, .16);
}

.focus-process-row-main {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.focus-process-row-title,
.focus-process-row-detail,
.focus-process-row-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-process-row-title {
  color: var(--text);
  font-size: 11px;
  font-weight: 920;
  line-height: 1.05;
}

.focus-process-row-detail {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 760;
  line-height: 1.05;
}

.focus-process-row-label {
  color: var(--accent-strong);
  font-size: 8.5px;
  font-weight: 950;
  letter-spacing: .12em;
  line-height: 1;
  text-transform: uppercase;
}

.focus-badge-history-panel {
  --process-panel-ink: #0f172a;
  --process-panel-muted: #64748b;
  --process-panel-soft: #eef6ff;
  --process-panel-edge: #dbe7f3;
  --process-panel-line: #dbe7f3;
  --process-panel-cyan: #2563eb;
  --process-panel-cyan-strong: #1d4ed8;
  --process-panel-green: #16a34a;
  --process-panel-amber: #d97706;
  --process-panel-red: #dc2626;
  position: fixed;
  z-index: 22000;
  width: min(430px, calc(100vw - 22px));
  max-height: min(500px, calc(100vh - 22px));
  display: grid;
  grid-template-rows: auto minmax(124px, auto) minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--process-panel-edge);
  border-radius: 15px;
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow:
    0 24px 58px rgba(15,23,42,.22),
    0 8px 20px rgba(15,23,42,.12),
    inset 0 1px 0 rgba(255,255,255,.9);
  color: var(--process-panel-ink);
  isolation: isolate;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px) scale(.985);
  transform-origin: top left;
  transition:
    opacity .16s ease,
    transform .16s ease;
  overflow: hidden;
}

.focus-badge-history-panel::before,
.focus-badge-history-panel::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.focus-badge-history-panel::before {
  left: 14px;
  right: 14px;
  top: 0;
  z-index: 0;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, transparent, #60a5fa 18%, #2563eb 50%, #16a34a 82%, transparent);
  opacity: .9;
}

.focus-badge-history-panel::after {
  content: none;
}

.focus-badge-history-panel > * {
  position: relative;
  z-index: 1;
}

.focus-badge-history-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  animation: none;
}

.focus-badge-history-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  padding: 9px 10px;
  border: 1px solid var(--process-panel-line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15,23,42,.05);
}

.focus-badge-history-head::before {
  content: none;
}

.focus-badge-history-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.focus-badge-history-panel.is-dragging .focus-badge-history-head {
  cursor: grabbing;
}

.focus-badge-history-title strong {
  min-width: 0;
  color: var(--process-panel-ink);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0;
  text-shadow: none;
}

.focus-badge-history-title span {
  color: var(--process-panel-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
}

.focus-badge-history-clear {
  appearance: none;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--process-panel-line);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--process-panel-muted);
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
}

.focus-badge-history-clear:hover,
.focus-badge-history-clear:focus-visible {
  border-color: rgba(37,99,235,.42);
  background: #eff6ff;
  color: var(--process-panel-cyan-strong);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}

.focus-badge-history-preview {
  --text: #0f172a;
  --muted: #64748b;
  --surface: #ffffff;
  --surface-elevated: #f8fbff;
  --line: #dbe7f3;
  --accent: var(--process-panel-cyan);
  --accent-strong: var(--process-panel-cyan-strong);
  --success-text: var(--process-panel-green);
  --danger-text: var(--process-panel-red);
  position: relative;
  height: 160px;
  min-height: 124px;
  max-height: 160px;
  display: grid;
  align-items: stretch;
  padding: 8px;
  border: 1px solid var(--process-panel-line);
  border-radius: 12px;
  background: var(--process-panel-soft);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.focus-badge-history-preview::after {
  content: none;
}

.focus-badge-history-preview > * {
  position: relative;
  z-index: 1;
}

.focus-badge-history-preview .focus-process-card,
.focus-badge-history-preview .focus-process-stack {
  height: 100%;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.focus-badge-history-preview .focus-process-stack {
  gap: 5px;
}

.focus-badge-history-preview .focus-process-card {
  box-sizing: border-box;
  padding: 9px;
  border: 1px solid var(--process-panel-line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

.focus-badge-history-done-replay {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  min-height: 74px;
  border: 1px solid rgba(22,163,74,.22);
  border-radius: 12px;
  color: #14532d;
  background: #f0fdf4;
  box-shadow: none;
  overflow: hidden;
}

.focus-badge-history-done-replay strong {
  font-size: 30px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
}

.focus-badge-history-done-replay span {
  max-width: 90%;
  color: #166534;
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-badge-history-list {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(37,99,235,.35) rgba(226,232,240,.72);
}

.focus-badge-history-item {
  appearance: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--process-panel-line);
  border-radius: 11px;
  color: var(--process-panel-ink);
  background: #ffffff;
  text-align: left;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  cursor: pointer;
  transition:
    background .16s ease,
    border-color .16s ease,
    box-shadow .16s ease;
}

.focus-badge-history-item:hover,
.focus-badge-history-item:focus-visible,
.focus-badge-history-item.is-active,
.focus-badge-history-item.is-selected {
  border-color: rgba(37,99,235,.38);
  background: #eff6ff;
  box-shadow:
    0 0 0 3px rgba(37,99,235,.1),
    0 5px 12px rgba(15,23,42,.08);
  outline: none;
}

.focus-badge-history-item.is-selected {
  border-left-color: var(--process-panel-cyan-strong);
  border-left-width: 3px;
}

.focus-badge-history-item-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.focus-badge-history-item-label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--process-panel-ink);
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-badge-history-item-label .focus-process-status-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-color: rgba(37,99,235,.3);
  border-radius: 6px;
  background: #eff6ff;
  color: var(--process-panel-cyan-strong);
  font-size: 6.5px;
  box-shadow: none;
}

.focus-badge-history-item-label > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-badge-history-item-text {
  min-width: 0;
  color: var(--process-panel-muted);
  font-size: 10px;
  font-weight: 760;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
}

.focus-badge-history-item-text span,
.focus-badge-history-marquee span {
  display: inline-block;
  min-width: 100%;
  padding-right: 24px;
  transform: translateX(0);
}

.focus-badge-history-item:hover .focus-badge-history-item-text span,
.focus-badge-history-item:focus-visible .focus-badge-history-item-text span,
.focus-badge-history-preview:hover .focus-badge-history-marquee span {
  animation: focusBadgeHistoryMarquee 5.8s linear infinite;
}

.focus-badge-history-item-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 15px;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid rgba(37,99,235,.14);
  background: #eef6ff;
  color: var(--process-panel-cyan-strong);
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

.focus-badge-history-repeat {
  color: var(--process-panel-cyan-strong);
  font-size: 8px;
  font-weight: 950;
}

.focus-badge-history-item-time {
  color: var(--process-panel-muted);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
}

.focus-badge-history-item-side {
  display: grid;
  justify-items: end;
  gap: 3px;
  min-width: max-content;
}

.focus-badge-history-item-copy {
  max-width: 76px;
  color: var(--process-panel-cyan-strong);
  font-size: 7.5px;
  font-weight: 900;
  letter-spacing: .02em;
  line-height: 1;
  text-align: right;
  text-transform: none;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: copy;
  transition: opacity .14s ease;
}

.focus-badge-history-item:hover .focus-badge-history-item-copy,
.focus-badge-history-item:focus-visible .focus-badge-history-item-copy,
.focus-badge-history-item.is-active .focus-badge-history-item-copy,
.focus-badge-history-item.is-selected .focus-badge-history-item-copy {
  color: var(--process-panel-cyan-strong);
  opacity: 1;
  visibility: visible;
}

.focus-badge-history-empty,
.focus-badge-history-empty-row {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 66px;
  color: var(--process-panel-muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.focus-badge-history-empty strong {
  color: var(--process-panel-ink);
  font-size: 13px;
  font-weight: 950;
}

.focus-badge-history-empty-row {
  min-height: 48px;
  border: 1px dashed rgba(37,99,235,.24);
  border-radius: 12px;
  background: #f8fbff;
}

@media (max-width: 560px) {
  .hard-item-slot.is-import-progress:not(.is-import-complete),
  .hard-item-slot.is-focus-notice {
    padding: 9px 11px !important;
  }

  .focus-process-percent {
    font-size: 20px;
  }

  .focus-process-title {
    font-size: 14px;
  }

  .focus-process-row {
    gap: 6px;
    padding: 4px 5px;
  }

  .focus-badge-history-panel {
    grid-template-rows: auto minmax(99px, auto) minmax(0, 1fr);
    max-height: min(390px, calc(100vh - 22px));
    border-radius: 14px;
    padding: 8px;
  }

  .focus-badge-history-preview {
    height: 113px;
    min-height: 99px;
    max-height: 113px;
  }
}

@keyframes focusBadgeHistoryMarquee {
  0%,
  18% {
    transform: translateX(0);
  }

  82%,
  100% {
    transform: translateX(calc(-100% + 140px));
  }
}

@keyframes focusBadgeHistoryScanner {
  0%,
  100% {
    opacity: .32;
    transform: translateX(-18%);
  }
  48%,
  56% {
    opacity: .88;
    transform: translateX(18%);
  }
}

@keyframes focusBadgeHistoryPanelPulse {
  0%,
  100% {
    box-shadow:
      0 18px 42px var(--shadow),
      0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent),
      0 0 0 4px color-mix(in srgb, var(--accent) 9%, var(--surface) 91%) inset;
  }
  50% {
    box-shadow:
      0 20px 46px var(--shadow),
      0 0 0 7px color-mix(in srgb, var(--accent) 13%, transparent),
      0 0 0 4px color-mix(in srgb, var(--accent) 12%, var(--surface) 88%) inset;
  }
}

@media (prefers-reduced-motion: reduce) {
  .focus-badge-history-panel::after,
  .focus-badge-history-item:hover .focus-badge-history-item-text span,
  .focus-badge-history-item:focus-visible .focus-badge-history-item-text span,
  .focus-badge-history-preview:hover .focus-badge-history-marquee span {
    animation: none !important;
  }
}

@keyframes focusImportDoneGlow {
  0%,
  100% {
    transform: translateY(0) scale(1);
    filter: brightness(1) saturate(1.04);
    box-shadow:
      0 0 0 4px color-mix(in srgb, #22a34a 30%, transparent),
      0 0 24px color-mix(in srgb, #22a34a 38%, transparent),
      0 16px 34px color-mix(in srgb, #22a34a 34%, var(--shadow));
  }

  50% {
    transform: translateY(-1px) scale(1.035);
    filter: brightness(1.14) saturate(1.2);
    box-shadow:
      0 0 0 14px color-mix(in srgb, #22a34a 24%, transparent),
      0 0 44px color-mix(in srgb, #22a34a 58%, transparent),
      0 24px 56px color-mix(in srgb, #22a34a 48%, var(--shadow));
  }
}

:root {
  --modal-solid-bg: color-mix(in srgb, var(--accent) 5%, #ffffff 95%);
  --modal-solid-panel: color-mix(in srgb, var(--accent) 8%, #ffffff 92%);
  --modal-solid-soft: color-mix(in srgb, var(--accent) 4%, #f8fbff 96%);
  --modal-solid-strong: #ffffff;
}

html[data-theme="dark"] {
  --modal-solid-bg: color-mix(in srgb, var(--accent) 8%, #0f172a 92%);
  --modal-solid-panel: color-mix(in srgb, var(--accent) 10%, #111827 90%);
  --modal-solid-soft: color-mix(in srgb, var(--accent) 6%, #0b1220 94%);
  --modal-solid-strong: #111827;
}

.study-set-card,
.author-profile-card,
.current-user-profile-card,
.app-prompt-card,
.drive-import-chooser-card,
.google-auth-modal,
.study-profile-modal,
.consent-banner {
  background: var(--modal-solid-bg) !important;
  border-color: color-mix(in srgb, var(--accent) 18%, var(--line) 82%) !important;
}

.study-set-top,
.drive-import-chooser-card .study-set-top,
.consent-banner-top,
.google-auth-top,
.study-profile-top {
  background: var(--modal-solid-panel) !important;
}

.drive-import-chooser-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.drive-list-search-bar {
  display: flex;
  align-items: end;
  gap: 10px;
  min-width: 0;
  padding: 14px 14px 0;
  background: var(--modal-solid-bg);
}

.drive-list-search {
  display: grid;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
}

.drive-list-search-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.drive-list-search-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line) 80%);
  border-radius: 8px;
  outline: none;
  background: var(--modal-solid-strong);
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
}

.drive-list-search-input::placeholder {
  color: var(--muted);
  opacity: .86;
}

.drive-list-search-input:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line) 30%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.drive-list-search-count {
  display: inline-grid;
  flex: 0 0 auto;
  min-width: 28px;
  min-height: 28px;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--modal-solid-panel) 88%);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.current-user-pack-search-bar {
  padding: 0 0 12px;
  background: transparent;
}

.drive-import-file[hidden],
.current-user-shared-card[hidden],
.drive-import-empty[hidden],
.current-user-shared-empty[hidden] {
  display: none !important;
}

.study-set-body,
.study-set-detail,
.current-user-profile-grid,
.app-prompt-body,
.consent-banner-body {
  background: var(--modal-solid-bg) !important;
}

.study-set-list,
.study-profile-card,
.current-user-profile-panel,
.current-user-profile-stat,
.profile-avatar-options,
.profile-avatar-upload,
.profile-avatar-upload-body,
.drive-import-file,
.drive-import-empty,
.consent-banner-details,
.consent-banner-points li,
.author-profile-pack-item,
.shared-pack-author-preview,
.drive-publish-link {
  background: var(--modal-solid-panel) !important;
}

.current-user-shared-card {
  background: color-mix(in srgb, #ffffff 94%, var(--surface-raised) 6%) !important;
}

.study-set-list-item,
.drive-import-file:hover,
.drive-import-file:focus-visible {
  background: var(--modal-solid-strong) !important;
}

.study-set-list-item.active,
.study-set-list-item[aria-current="true"] {
  background: color-mix(in srgb, var(--accent-soft) 62%, var(--modal-solid-strong) 38%) !important;
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line) 46%) !important;
  border-left-width: 4px !important;
  outline: 2px solid color-mix(in srgb, var(--accent) 18%, transparent) !important;
  outline-offset: -2px !important;
}

.study-set-list-item.active .study-set-list-code,
.study-set-list-item[aria-current="true"] .study-set-list-code {
  color: color-mix(in srgb, var(--accent-strong) 78%, var(--text) 22%) !important;
}

.study-set-list-item.active .study-set-list-name,
.study-set-list-item[aria-current="true"] .study-set-list-name {
  color: var(--text) !important;
  font-weight: 800 !important;
}

.study-set-list-item.active .study-set-list-meta,
.study-set-list-item[aria-current="true"] .study-set-list-meta {
  color: color-mix(in srgb, var(--accent-strong) 48%, var(--muted) 52%) !important;
}

.current-user-shared-card.is-current {
  position: relative;
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line) 46%) !important;
  background: color-mix(in srgb, #ffffff 94%, var(--surface-raised) 6%) !important;
}

.current-user-shared-card.is-current::before {
  content: "";
  position: absolute;
  inset: 12px auto 12px 0;
  width: 4px;
  border-radius: 0 999px 999px 0;
  background: var(--accent);
}

.current-user-shared-card.is-current .current-user-shared-title {
  color: color-mix(in srgb, var(--accent-strong) 72%, var(--text) 28%);
}

.hero h1 {
  max-width: 100%;
  font-size: 38px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

html[data-theme="dark"] .study-set-list-item,
html[data-theme="dark"] .drive-import-file:hover,
html[data-theme="dark"] .drive-import-file:focus-visible {
  background: var(--modal-solid-soft) !important;
}

html[data-theme="dark"] .study-set-list-item.active,
html[data-theme="dark"] .study-set-list-item[aria-current="true"] {
  background: color-mix(in srgb, var(--accent-soft) 72%, var(--modal-solid-soft) 28%) !important;
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line) 38%) !important;
  outline-color: color-mix(in srgb, var(--accent) 26%, transparent) !important;
}

/* Responsive modal guard: keep profile/settings/import windows inside the viewport at any zoom. */
.study-set-card,
.author-profile-card,
.current-user-profile-card,
.app-prompt-card,
.drive-import-chooser-card,
.google-auth-modal,
.study-profile-modal {
  box-sizing: border-box !important;
  max-width: calc(100vw - 24px) !important;
  max-height: calc(100dvh - 24px) !important;
  min-height: 0 !important;
  overscroll-behavior: contain !important;
}

.study-set-modal.open {
  overflow: hidden !important;
  z-index: 1300 !important;
}

#appPromptModal.open {
  z-index: 1500 !important;
}

@supports not (height: 100dvh) {
  .study-set-card,
  .author-profile-card,
  .current-user-profile-card,
  .app-prompt-card,
  .drive-import-chooser-card,
  .google-auth-modal,
  .study-profile-modal {
    max-height: calc(100vh - 24px) !important;
  }
}

.study-set-card,
.author-profile-card,
.current-user-profile-card,
.drive-import-chooser-card {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  overflow: hidden !important;
}

.current-user-profile-card {
  width: min(1100px, calc(100vw - 24px)) !important;
  height: calc(100dvh - 24px) !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
}

.current-user-profile-card:not(.drive-libraries-card) {
  width: min(820px, calc(100vw - 24px)) !important;
}

.current-user-profile-grid.is-single-panel {
  grid-template-columns: minmax(0, 1fr) !important;
}

.current-user-drive-grid .current-user-shared-list {
  max-height: none !important;
  overflow: visible !important;
}

.current-user-profile-content,
.current-user-drive-grid {
  display: block !important;
}

.current-user-drive-toolbar-row {
  justify-content: flex-end !important;
  margin-bottom: 14px;
}

.current-user-drive-toolbar-row .current-user-pack-toolbar {
  width: 100%;
  flex-wrap: nowrap;
}

.current-user-drive-toolbar-search {
  flex: 1 1 auto;
  min-width: 180px;
  max-width: none;
}

.current-user-drive-toolbar-search .drive-list-search-input {
  min-height: 38px;
}

.current-user-drive-toolbar-row .drive-list-search-count {
  min-height: 34px;
}

@media (max-width: 720px) {
  .current-user-drive-toolbar-row .current-user-pack-toolbar {
    flex-wrap: wrap;
  }

  .current-user-drive-toolbar-search {
    flex-basis: 100%;
    max-width: none;
  }
}

.author-profile-card {
  width: min(920px, calc(100vw - 24px)) !important;
  height: min(760px, calc(100dvh - 24px)) !important;
  grid-template-rows: auto auto auto minmax(0, 1fr) !important;
}

.study-set-top,
.author-profile-top {
  min-width: 0 !important;
  flex-wrap: wrap !important;
}

.study-set-body,
.study-set-detail,
.study-set-list,
.current-user-profile-grid,
.current-user-profile-panel,
.current-user-shared-list,
.author-profile-pack-list,
.app-prompt-body,
.drive-import-chooser-list,
.google-auth-body,
.study-profile-body {
  min-width: 0 !important;
  min-height: 0 !important;
}

.current-user-profile-grid {
  align-content: start !important;
  grid-auto-rows: max-content !important;
  overflow: auto !important;
  padding: 16px !important;
  scrollbar-gutter: stable both-edges;
}

.current-user-profile-panel {
  overflow: hidden !important;
}

.current-user-profile-panel:first-child {
  overflow: visible !important;
}

.current-user-profile-panel:nth-child(2) {
  display: block !important;
  height: auto !important;
}

.current-user-profile-form,
.profile-avatar-upload,
.profile-avatar-upload-body,
.profile-avatar-options {
  max-width: 100% !important;
  min-width: 0 !important;
}

.profile-avatar-options {
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)) !important;
  justify-content: stretch !important;
  align-items: stretch !important;
  overflow: visible !important;
}

.profile-avatar-option {
  min-width: 0 !important;
  max-width: 100% !important;
}

.profile-avatar-option-meta {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow-wrap: anywhere !important;
}

.profile-avatar-option-meta span {
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.author-profile-pack-list,
.drive-import-chooser-list {
  max-height: none !important;
}

.current-user-profile-panel .current-user-shared-list {
  max-height: min(560px, calc(100dvh - 290px)) !important;
  overflow: auto !important;
  overscroll-behavior: contain !important;
}

.current-user-profile-panel:nth-child(2) .current-user-shared-list {
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow: visible !important;
}

.current-user-pack-section-fixed {
  display: block !important;
  height: auto !important;
  min-height: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  overflow: visible !important;
}

.current-user-pack-section-fixed .current-user-pack-section-body {
  height: auto !important;
  max-height: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
  overscroll-behavior: auto !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
}

.current-user-profile-grid,
.current-user-shared-list,
.current-user-pack-section-body,
.author-profile-pack-list,
.author-profile-stats,
.study-set-body,
.study-set-detail,
.study-set-list,
.drive-import-chooser-list,
.app-prompt-body,
.google-auth-body,
.study-profile-body {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 58%, var(--line) 42%) rgba(148,163,184,0.10);
}

.current-user-profile-grid::-webkit-scrollbar,
.current-user-shared-list::-webkit-scrollbar,
.current-user-pack-section-body::-webkit-scrollbar,
.author-profile-pack-list::-webkit-scrollbar,
.author-profile-stats::-webkit-scrollbar,
.study-set-body::-webkit-scrollbar,
.study-set-detail::-webkit-scrollbar,
.study-set-list::-webkit-scrollbar,
.drive-import-chooser-list::-webkit-scrollbar,
.app-prompt-body::-webkit-scrollbar,
.google-auth-body::-webkit-scrollbar,
.study-profile-body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.current-user-profile-grid::-webkit-scrollbar-track,
.current-user-shared-list::-webkit-scrollbar-track,
.current-user-pack-section-body::-webkit-scrollbar-track,
.author-profile-pack-list::-webkit-scrollbar-track,
.author-profile-stats::-webkit-scrollbar-track,
.study-set-body::-webkit-scrollbar-track,
.study-set-detail::-webkit-scrollbar-track,
.study-set-list::-webkit-scrollbar-track,
.drive-import-chooser-list::-webkit-scrollbar-track,
.app-prompt-body::-webkit-scrollbar-track,
.google-auth-body::-webkit-scrollbar-track,
.study-profile-body::-webkit-scrollbar-track {
  background: rgba(148,163,184,0.10);
  border-radius: 999px;
  margin: 10px 0;
}

.current-user-profile-grid::-webkit-scrollbar-thumb,
.current-user-shared-list::-webkit-scrollbar-thumb,
.current-user-pack-section-body::-webkit-scrollbar-thumb,
.author-profile-pack-list::-webkit-scrollbar-thumb,
.author-profile-stats::-webkit-scrollbar-thumb,
.study-set-body::-webkit-scrollbar-thumb,
.study-set-detail::-webkit-scrollbar-thumb,
.study-set-list::-webkit-scrollbar-thumb,
.drive-import-chooser-list::-webkit-scrollbar-thumb,
.app-prompt-body::-webkit-scrollbar-thumb,
.google-auth-body::-webkit-scrollbar-thumb,
.study-profile-body::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  background: color-mix(in srgb, var(--accent) 66%, var(--line) 34%);
  background-clip: padding-box;
  border-radius: 999px;
}

@media (max-width: 920px), (max-height: 720px) {
  .current-user-profile-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  .current-user-profile-card,
  .author-profile-card,
  .study-set-card,
  .drive-import-chooser-card {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
  }

  .current-user-profile-card {
    height: calc(100dvh - 16px) !important;
  }

  .author-profile-card {
    height: min(720px, calc(100dvh - 16px)) !important;
  }

}

@media (max-width: 560px) {
  .drive-list-search-bar {
    align-items: stretch;
    padding: 12px 12px 0;
  }

  .current-user-pack-search-bar {
    padding: 0 0 10px;
  }

  .drive-list-search-input {
    min-height: 46px;
    font-size: 16px;
  }

  .drive-list-search-count {
    align-self: end;
    min-height: 46px;
  }

  .current-user-profile-grid,
  .study-set-body,
  .drive-import-chooser-list {
    padding: 12px !important;
  }

  .author-profile-top,
  .current-user-profile-card .author-profile-top {
    align-items: flex-start !important;
  }

  .author-profile-hero,
  .current-user-profile-header-actions {
    width: 100% !important;
    min-width: 0 !important;
  }

  .current-user-profile-header-actions {
    justify-content: flex-start !important;
  }

  .profile-avatar-choice {
    width: 58px !important;
    height: 58px !important;
  }
}

/* Shared dropdown/select system. Keep native behavior, but make every select match the app. */
:root {
  --select-bg: var(--input-bg-strong);
  --select-bg-hover: color-mix(in srgb, var(--accent) 7%, var(--input-bg-strong) 93%);
  --select-border: color-mix(in srgb, var(--accent) 16%, var(--line) 84%);
  --select-border-hover: color-mix(in srgb, var(--accent) 36%, var(--line) 64%);
  --select-focus-ring: color-mix(in srgb, var(--accent) 20%, transparent);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10' viewBox='0 0 14 10'%3E%3Cpath d='M2 2.4 7 7.4l5-5' fill='none' stroke='%2364758b' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

html[data-theme="dark"] {
  --select-bg: var(--input-bg-strong);
  --select-bg-hover: color-mix(in srgb, var(--accent) 12%, var(--input-bg-strong) 88%);
  --select-border: color-mix(in srgb, var(--accent) 18%, var(--line) 82%);
  --select-border-hover: color-mix(in srgb, var(--accent) 42%, var(--line) 58%);
  --select-focus-ring: color-mix(in srgb, var(--accent) 24%, transparent);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10' viewBox='0 0 14 10'%3E%3Cpath d='M2 2.4 7 7.4l5-5' fill='none' stroke='%23b4c2d8' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

select {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  border: 1px solid var(--select-border) !important;
  border-radius: 14px !important;
  background-color: var(--select-bg) !important;
  color: var(--text) !important;
  font: inherit;
  font-size: 14px;
  line-height: 1.25;
  box-shadow: none !important;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}

html body select:not([multiple]):not(.native-select) {
  appearance: none !important;
  -webkit-appearance: none !important;
  padding: 12px 42px 12px 14px !important;
  background-image: var(--select-arrow) !important;
  background-position: calc(100% - 15px) 50% !important;
  background-repeat: no-repeat !important;
  background-size: 14px 10px !important;
  cursor: pointer;
}

select[multiple] {
  min-height: 132px;
  padding: 10px !important;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 58%, var(--line) 42%) rgba(148,163,184,0.10);
}

select:hover:not(:disabled),
select:focus-visible {
  background-color: var(--select-bg-hover) !important;
  border-color: var(--select-border-hover) !important;
}

select:focus,
select:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 3px var(--select-focus-ring) !important;
}

select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

select option {
  background: var(--modal-solid-strong);
  color: var(--text);
}

html[data-theme="dark"] select option {
  background: var(--modal-solid-soft);
  color: var(--text);
}

select[multiple] option {
  border-radius: 10px;
  padding: 8px 10px;
}

select[multiple] option:checked {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

select[multiple]::-webkit-scrollbar {
  width: 10px;
}

select[multiple]::-webkit-scrollbar-track {
  background: rgba(148,163,184,0.10);
  border-radius: 999px;
}

select[multiple]::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  background: color-mix(in srgb, var(--accent) 66%, var(--line) 34%);
  background-clip: padding-box;
  border-radius: 999px;
}

.study-tool-select {
  min-height: 34px !important;
  height: 34px !important;
  border-radius: 10px !important;
  font-size: 13px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

button.is-action-progress,
.button.is-action-progress {
  cursor: wait !important;
  opacity: 1 !important;
  position: relative;
  box-shadow: none !important;
  outline: none !important;
}

button.is-action-progress-busy::before,
.button.is-action-progress-busy::before {
  content: "";
  width: 0.78em;
  height: 0.78em;
  margin-right: 7px;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  display: inline-block;
  vertical-align: -0.1em;
  animation: actionProgressSpin 0.82s linear infinite;
}

button.is-action-progress-good,
.button.is-action-progress-good {
  box-shadow: none !important;
}

button.is-action-progress-bad,
.button.is-action-progress-bad {
  box-shadow: none !important;
}

body.action-progress-focus-active .guided-input-target,
body.action-progress-focus-active .guided-action-target {
  animation: none !important;
  outline: none !important;
}

body.action-progress-focus-active .guided-input-target::before,
body.action-progress-focus-active .guided-input-target::after,
body.action-progress-focus-active .guided-action-target::before,
body.action-progress-focus-active .guided-action-target::after {
  display: none !important;
}

body.action-progress-focus-active .import-ready-pulse {
  animation: none !important;
  box-shadow: none !important;
}

body.action-progress-focus-active .guide-target-active:not(.action-progress-focus-container) {
  outline: none !important;
  box-shadow: none !important;
}

body.action-progress-focus-active .action-progress-focus-container {
  box-shadow: none !important;
}

button.action-progress-focus-target.is-action-progress,
.button.action-progress-focus-target.is-action-progress {
  opacity: 1 !important;
  filter: none !important;
  box-shadow: none !important;
  outline: none !important;
}

@media (max-width: 600px) {
  body.library-process-lock button.action-progress-focus-target.is-action-progress,
  body.library-process-lock .button.action-progress-focus-target.is-action-progress {
    width: 100% !important;
    max-width: calc(100vw - 28px) !important;
    min-height: 48px;
    padding-inline: 14px !important;
    font-size: 14px !important;
  }

  body.library-process-lock #hardItemSlot.is-process-badge-forced,
  body.library-process-lock #hardItemSlot.is-import-progress,
  body.library-process-lock #hardItemSlot.is-import-complete,
  body.library-process-lock #hardItemSlot.is-import-error,
  body.library-process-lock #hardItemSlot.is-import-resume,
  body.library-process-lock #hardItemSlot.is-focus-notice {
    width: 100% !important;
    max-width: calc(100vw - 28px) !important;
  }
}

/* Processing states should inform quietly, without glowing or floating above modal windows. */
body.library-process-lock .study-set-modal.open,
body.library-process-lock .anatomy-image-editor-modal:not([hidden]),
body.library-process-lock .drive-import-chooser.open,
body.library-process-lock .drive-import-chooser {
  z-index: 1300 !important;
  pointer-events: auto !important;
}

body.library-process-lock .anatomy-image-editor-modal:not([hidden]),
body.library-process-lock .anatomy-image-editor-modal:not([hidden]) .anatomy-image-editor-card,
body.library-process-lock .anatomy-image-editor-modal:not([hidden]) .anatomy-image-editor-stage-wrap,
body.library-process-lock .anatomy-image-editor-modal:not([hidden]) .anatomy-image-editor-tools,
body.library-process-lock .anatomy-image-editor-modal:not([hidden]) .anatomy-image-editor-actions {
  cursor: auto !important;
}

body.library-process-lock .anatomy-image-editor-modal:not([hidden]) button:not(:disabled),
body.library-process-lock .anatomy-image-editor-modal:not([hidden]) input:not(:disabled),
body.library-process-lock .anatomy-image-editor-modal:not([hidden]) [contenteditable="true"] {
  pointer-events: auto !important;
}

body.library-process-lock #appPromptModal.open,
body.app-prompt-open #appPromptModal.open {
  z-index: 1500 !important;
  pointer-events: auto !important;
}

button.is-action-progress,
.button.is-action-progress,
button.action-progress-focus-target.is-action-progress,
.button.action-progress-focus-target.is-action-progress,
body.library-process-lock button.action-progress-focus-target.is-action-progress,
body.library-process-lock .button.action-progress-focus-target.is-action-progress {
  box-shadow: none !important;
  outline: none !important;
  transform: none !important;
  filter: none !important;
}

body.action-progress-focus-active .action-progress-focus-container,
body.action-progress-focus-active .guide-target-active,
body.action-progress-focus-active .import-ready-pulse {
  box-shadow: none !important;
  outline: none !important;
  animation: none !important;
}

.hard-item-slot.is-import-progress,
.hard-item-slot.is-import-resume,
.hard-item-slot.is-focus-notice,
body.library-process-lock #hardItemSlot.is-process-badge-forced,
body.library-process-lock #hardItemSlot.is-import-progress,
body.library-process-lock #hardItemSlot.is-import-complete,
body.library-process-lock #hardItemSlot.is-import-error,
body.library-process-lock #hardItemSlot.is-import-resume,
body.library-process-lock #hardItemSlot.is-focus-notice {
  box-shadow: none !important;
  outline: none !important;
  animation: none !important;
}

body.library-process-lock:has(.drive-import-chooser.open):not(.app-prompt-open) #hardItemSlot:not(.is-import-error) {
  z-index: 1 !important;
}

body.library-process-lock #hardItemSlot.is-import-error,
body.library-process-lock #hardItemSlot.is-import-resume,
body.library-process-lock .focus-badge-history-panel {
  pointer-events: auto !important;
}

body.library-process-lock:not(.app-prompt-open) #hardItemSlot.is-import-error,
body.library-process-lock:not(.app-prompt-open) #hardItemSlot.is-import-resume {
  z-index: 1210 !important;
  cursor: pointer;
}

.focus-import-track,
.hard-item-slot .focus-process-track {
  box-shadow: none !important;
}

.focus-import-track::after,
.hard-item-slot .focus-process-track::after {
  content: none !important;
  animation: none !important;
  background: none !important;
}

.focus-import-track span,
.hard-item-slot .focus-process-track > span,
.hard-item-slot .focus-process-card[data-tone="bad"] .focus-process-track > span,
.hard-item-slot .focus-process-card[data-tone="resume"] .focus-process-track > span {
  background: var(--accent) !important;
  background-image: none !important;
  animation: none !important;
}

@media (max-width: 820px) {
  body.library-process-lock.mobile-process-badge-spotlight::after {
    background: rgba(15, 23, 42, .38) !important;
    -webkit-backdrop-filter: blur(3px) saturate(.92) !important;
    backdrop-filter: blur(3px) saturate(.92) !important;
  }

  html[data-theme="dark"] body.library-process-lock.mobile-process-badge-spotlight::after {
    background: rgba(2, 6, 23, .52) !important;
  }

  body.library-process-lock.mobile-process-badge-spotlight.sidebar-open:not(.quiz-mode) .sidebar {
    z-index: 1205 !important;
    pointer-events: auto !important;
    box-shadow: 18px 0 44px rgba(15, 23, 42, .22) !important;
  }

  body.library-process-lock.mobile-process-badge-spotlight.sidebar-open:not(.quiz-mode) .app-sidebar-scrim {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  body.library-process-lock.mobile-process-badge-spotlight #hardItemSlot.is-process-badge-forced,
  body.library-process-lock.mobile-process-badge-spotlight #hardItemSlot.is-import-progress,
  body.library-process-lock.mobile-process-badge-spotlight #hardItemSlot.is-import-complete,
  body.library-process-lock.mobile-process-badge-spotlight #hardItemSlot.is-import-error,
  body.library-process-lock.mobile-process-badge-spotlight #hardItemSlot.is-import-resume,
  body.library-process-lock.mobile-process-badge-spotlight #hardItemSlot.is-focus-notice {
    position: relative !important;
    z-index: 1220 !important;
    border-color: rgba(37, 99, 235, .58) !important;
    border-color: color-mix(in srgb, var(--accent) 58%, #ffffff 42%) !important;
    outline: 2px solid rgba(37, 99, 235, .34) !important;
    outline: 2px solid color-mix(in srgb, var(--accent) 34%, transparent) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, .18),
      0 18px 34px rgba(15, 23, 42, .26) !important;
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent),
      0 18px 34px rgba(15, 23, 42, .26) !important;
    filter: none !important;
    opacity: 1 !important;
    transform: translateZ(0) !important;
  }
}

.hard-item-slot .focus-process-row,
.hard-item-slot .focus-process-dot,
.hard-item-slot .focus-process-row.is-good .focus-process-dot,
.hard-item-slot .focus-process-row.is-warn .focus-process-dot,
.hard-item-slot .focus-process-row.is-bad .focus-process-dot,
.hard-item-slot .focus-process-row.is-quiz-cold .focus-process-dot,
.hard-item-slot .focus-process-row.is-quiz-warmer .focus-process-dot,
.hard-item-slot .focus-process-row.is-quiz-hot .focus-process-dot,
.hard-item-slot .focus-process-row.is-quiz-very-hot .focus-process-dot {
  box-shadow: none !important;
}

@keyframes actionProgressSpin {
  to { transform: rotate(360deg); }
}

/* Mobile/tablet polish pass for dense study panels. */
@media (max-width: 820px), (pointer: coarse) and (max-width: 1024px) {
  .wrap {
    width: min(100%, calc(100vw - 12px)) !important;
  }

  .layout,
  .library-study-grid,
  .backup-grid,
  .study-profile-grid,
  .shared-pack-form-grid,
  .shared-pack-filter-grid,
  .current-user-shared-edit-form,
  .current-user-profile-form {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .hero,
  .card,
  .hero-card,
  .upload-box,
  .study-panel,
  .shared-pack-result,
  .author-profile-pack-item,
  .current-user-shared-card {
    border-radius: 16px !important;
  }

  .tabs,
  .tab-row-primary,
  .app-chrome-actions,
  .shared-pack-result-top,
  .current-user-shared-top,
  .author-profile-pack-head,
  .shared-pack-actions,
  .author-profile-pack-actions,
  .current-user-shared-actions,
  .study-profile-actions,
  .study-profile-actions-right,
  .study-set-top {
    gap: 8px !important;
  }

  .shared-pack-corner-actions {
    position: static !important;
    justify-content: flex-start !important;
    margin-bottom: 10px !important;
  }

  .shared-pack-result,
  .author-profile-pack-item,
  .current-user-shared-card {
    padding: 12px !important;
  }

  .shared-pack-actions .btn-primary,
  .shared-pack-actions .btn-secondary,
  .author-profile-pack-actions .btn-primary,
  .author-profile-pack-actions .btn-secondary,
  .current-user-shared-actions .btn-primary,
  .current-user-shared-actions .btn-secondary,
  .current-user-shared-actions .btn-study,
  .drive-link-row button {
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  .drive-link-row input,
  .search input,
  .field input,
  .field select,
  .field textarea {
    min-width: 0 !important;
  }

  .shared-pack-results {
    max-height: min(62dvh, 520px) !important;
    overscroll-behavior: contain !important;
    gap: 14px !important;
    padding: 2px 4px 8px 2px !important;
  }
}

@media (max-width: 520px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    overflow-x: hidden !important;
  }

  .wrap {
    width: min(100%, calc(100vw - 8px)) !important;
    padding: 4px !important;
  }

  .hero {
    padding: 16px !important;
    margin-bottom: 10px !important;
  }

  .hero h1 {
    font-size: 26px !important;
    line-height: 1.15 !important;
    letter-spacing: 0 !important;
  }

  .hero p {
    font-size: 14px !important;
    line-height: 1.45 !important;
  }

  .pill-row {
    gap: 7px !important;
    margin-top: 12px !important;
  }

  .pill {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  .card,
  .sidebar,
  .main {
    padding: 12px !important;
  }

  .layout {
    gap: 10px !important;
  }

  .section {
    margin-bottom: 14px !important;
    padding-bottom: 14px !important;
  }

  .tabs {
    align-items: stretch !important;
    flex-direction: column !important;
  }

  .tab-row-primary {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  .tab-row-primary .tab {
    width: auto !important;
    min-height: 42px !important;
    padding: 9px 6px !important;
    font-size: 13px !important;
  }

  .app-chrome-actions {
    min-width: 0 !important;
    width: 100% !important;
    justify-content: flex-end !important;
  }

  .chrome-action-btn {
    min-height: 42px !important;
    flex: 1 1 auto !important;
    justify-content: center !important;
  }

  .chrome-profile-btn {
    width: 44px !important;
    height: 44px !important;
    flex: 0 0 44px !important;
  }

  .current-user-profile-card,
  .author-profile-card,
  .study-set-card {
    width: min(100vw - 14px, 760px) !important;
    max-height: calc(100dvh - 14px) !important;
    border-radius: 22px !important;
  }

  .current-user-profile-grid,
  .author-profile-body {
    max-height: calc(100dvh - 150px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .study-set-top,
  .author-profile-top {
    padding: 12px !important;
  }

  .author-profile-avatar {
    width: 58px !important;
    height: 58px !important;
    flex-basis: 58px !important;
  }

  .author-profile-stats {
    padding-inline: 12px !important;
  }

  .author-profile-stat-pill,
  .shared-pack-autosave {
    width: 100% !important;
    justify-content: center !important;
  }
}

.google-open-pack-restore-modal {
  z-index: 1180;
}

.google-open-pack-restore-card {
  width: min(548px, calc(100vw - 34px));
  display: block !important;
  grid-template-rows: none !important;
  overflow: visible !important;
  padding: 28px 30px !important;
  border-radius: 26px !important;
  background: var(--modal-solid-bg) !important;
}

.google-open-pack-restore-card .study-set-top {
  display: block !important;
  padding: 0 !important;
  border-bottom: 0 !important;
  background: transparent !important;
}

.google-open-pack-restore-card .study-set-kicker {
  margin-bottom: 10px !important;
}

.google-open-pack-restore-card .study-set-top h3 {
  margin: 0 !important;
  font-size: clamp(26px, 3vw, 36px) !important;
  line-height: 1.06 !important;
}

.google-open-pack-restore-sub {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.48;
  font-size: 15px;
}

.google-open-pack-restore-progress {
  height: 8px;
  margin: 22px 0 12px !important;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--line));
  background: color-mix(in srgb, var(--surface-elevated) 82%, var(--accent) 3%);
}

.google-open-pack-restore-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.22s ease;
}

.google-open-pack-restore-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  padding: 0 !important;
}

.google-open-pack-restore-meta strong {
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.google-open-pack-restore-list {
  display: grid;
  gap: 7px;
  margin-top: 16px !important;
}

.google-open-pack-restore-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 10%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, #fff 72%, var(--surface-elevated) 28%);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.google-open-pack-restore-row span {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  text-align: right;
}

.google-open-pack-restore-row span i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 38%, transparent);
  flex: 0 0 auto;
}

.google-open-pack-restore-row strong {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  min-width: 92px;
}

.google-open-pack-restore-row[data-state="working"] {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  background: color-mix(in srgb, #fff 68%, var(--accent) 6%);
}

.google-open-pack-restore-row[data-state="working"] span i {
  background: var(--accent);
  animation: googleRestorePulse 1.1s ease-in-out infinite;
}

.google-open-pack-restore-row[data-state="working"] strong,
.google-open-pack-restore-row[data-state="done"] strong {
  color: var(--accent-strong);
}

.google-open-pack-restore-row[data-state="done"] {
  border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
}

.google-open-pack-restore-row[data-state="done"] span i {
  background: color-mix(in srgb, var(--accent) 82%, #34a853 18%);
}

.google-open-pack-restore-row[data-state="skipped"] {
  opacity: 0.72;
}

.google-open-pack-restore-row[data-state="skipped"] span i {
  background: color-mix(in srgb, var(--muted) 52%, transparent);
}

@keyframes googleRestorePulse {
  0%, 100% { transform: scale(0.82); opacity: 0.55; }
  50% { transform: scale(1.18); opacity: 1; }
}

.google-open-pack-restore-actions {
  justify-content: flex-start;
  margin-top: 18px;
  padding: 0 !important;
  border-top: 0 !important;
}

.google-open-pack-restore-actions .btn-secondary {
  width: auto !important;
}

.google-signin-local-conflict-modal.open,
body.library-process-lock .google-signin-local-conflict-modal.open {
  z-index: 1500 !important;
  pointer-events: auto !important;
}

.google-signin-local-conflict-card {
  width: min(620px, calc(100vw - 32px)) !important;
  display: block !important;
  grid-template-rows: none !important;
  overflow: visible !important;
}

.google-signin-local-conflict-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.google-signin-local-conflict-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.google-signin-local-conflict-summary > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 14%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-elevated) 86%, var(--accent) 4%);
}

.google-signin-local-conflict-summary span,
.google-signin-local-conflict-summary small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.google-signin-local-conflict-summary strong {
  display: block;
  min-width: 0;
  margin: 4px 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.google-signin-local-conflict-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.google-signin-local-conflict-actions .btn-primary,
.google-signin-local-conflict-actions .btn-secondary {
  width: auto !important;
  min-width: 144px;
  max-width: 100%;
  white-space: normal;
  text-align: center;
}

@media (max-width: 640px) {
  .google-signin-local-conflict-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .google-signin-local-conflict-actions .btn-primary,
  .google-signin-local-conflict-actions .btn-secondary {
    flex: 1 1 100%;
    min-width: 0;
  }
}

/* Anatomy quiz-card surface polish */
.anatomy-entry-card,
.anatomy-quiz-card {
  --anatomy-card-front-a: #ffe868;
  --anatomy-card-front-b: #ffd21f;
  --anatomy-card-front-c: #f5b400;
  --anatomy-card-back-a: #efad00;
  --anatomy-card-back-b: #c77f00;
  --anatomy-card-ink: #563700;
  --anatomy-card-muted-ink: rgba(86, 55, 0, 0.68);
  --anatomy-card-border: rgba(207, 139, 0, 0.38);
}

.anatomy-entry-card[data-card-tone="pink"],
.anatomy-quiz-card[data-card-tone="pink"] {
  --anatomy-card-front-a: #f2a8cf;
  --anatomy-card-front-b: #e67fb5;
  --anatomy-card-front-c: #d95b9f;
  --anatomy-card-back-a: #cb4d93;
  --anatomy-card-back-b: #a73579;
  --anatomy-card-ink: #551236;
  --anatomy-card-muted-ink: rgba(85, 18, 54, 0.7);
  --anatomy-card-border: rgba(190, 55, 130, 0.34);
}

.anatomy-entry-card[data-card-tone="orange"],
.anatomy-quiz-card[data-card-tone="orange"] {
  --anatomy-card-front-a: #ffc45d;
  --anatomy-card-front-b: #f7a72b;
  --anatomy-card-front-c: #ef8f00;
  --anatomy-card-back-a: #df8300;
  --anatomy-card-back-b: #b85f00;
  --anatomy-card-ink: #572b00;
  --anatomy-card-muted-ink: rgba(87, 43, 0, 0.7);
  --anatomy-card-border: rgba(216, 116, 0, 0.36);
}

.anatomy-entry-card[data-card-tone="yellow"],
.anatomy-quiz-card[data-card-tone="yellow"] {
  --anatomy-card-front-a: #ffef79;
  --anatomy-card-front-b: #ffd82e;
  --anatomy-card-front-c: #f0b90b;
  --anatomy-card-back-a: #dfa600;
  --anatomy-card-back-b: #b97600;
  --anatomy-card-ink: #513700;
  --anatomy-card-muted-ink: rgba(81, 55, 0, 0.7);
  --anatomy-card-border: rgba(205, 142, 0, 0.36);
}

.anatomy-entry-card .anatomy-entry-face,
.anatomy-quiz-card .anatomy-quiz-card-face {
  border-color: var(--anatomy-card-border) !important;
  isolation: isolate;
}

.anatomy-entry-card .anatomy-entry-face-front,
.anatomy-quiz-card .anatomy-quiz-card-front {
  background:
    radial-gradient(circle at 22% 16%, rgba(255, 255, 255, 0.5), transparent 18%),
    repeating-conic-gradient(
      from -8deg at 50% 52%,
      color-mix(in srgb, var(--anatomy-card-front-a) 88%, #fff 12%) 0deg 7deg,
      color-mix(in srgb, var(--anatomy-card-front-b) 90%, #fff 10%) 7deg 14deg
    ),
    linear-gradient(145deg, var(--anatomy-card-front-a), var(--anatomy-card-front-c)) !important;
}

.anatomy-entry-card .anatomy-entry-face-back,
.anatomy-quiz-card .anatomy-quiz-card-back {
  background:
    linear-gradient(
      160deg,
      color-mix(in srgb, var(--anatomy-card-back-a) 90%, #fff 10%),
      var(--anatomy-card-back-b)
    ) !important;
}

.anatomy-entry-card .anatomy-entry-kicker,
.anatomy-entry-card .anatomy-entry-back-editor,
.anatomy-entry-card .anatomy-entry-back-editor:empty::before,
.anatomy-quiz-card .anatomy-quiz-card-answer {
  color: var(--anatomy-card-ink) !important;
}

.anatomy-entry-card .anatomy-entry-kicker,
.anatomy-entry-card .anatomy-entry-back-editor:empty::before {
  color: var(--anatomy-card-muted-ink) !important;
}

.anatomy-entry-card .anatomy-entry-back-tools,
.anatomy-entry-card .anatomy-entry-back-flip-pill {
  color: var(--anatomy-card-ink) !important;
  border-color: color-mix(in srgb, var(--anatomy-card-ink) 16%, transparent) !important;
  background: color-mix(in srgb, #fff 26%, transparent) !important;
}

.anatomy-entry-card .anatomy-entry-face-back::before,
.anatomy-quiz-card .anatomy-quiz-card-back::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(62%, 360px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
  background-color: color-mix(in srgb, var(--anatomy-card-ink) 68%, #fff 32%) !important;
  background-image: none !important;
  -webkit-mask-image: url("../icons/card-back-gqb-watermark.png");
  mask-image: url("../icons/card-back-gqb-watermark.png");
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
  opacity: 0.18;
  mix-blend-mode: multiply;
  filter: none;
}

.anatomy-entry-card .anatomy-entry-face-back::after,
.anatomy-quiz-card .anatomy-quiz-card-back::after {
  content: none;
  display: none;
}

.anatomy-entry-card .anatomy-entry-face-inner,
.anatomy-quiz-card .anatomy-quiz-card-answer {
  position: relative;
  z-index: 1;
}

.anatomy-entry-card .anatomy-entry-replace-btn,
.anatomy-entry-card .anatomy-entry-edit-btn,
.anatomy-entry-card .anatomy-entry-add-text-btn,
.anatomy-quiz-card .anatomy-quiz-mask-layer {
  z-index: 6;
}

.anatomy-quiz-card .anatomy-quiz-card-answer {
  position: relative;
  z-index: 1;
}

.anatomy-quiz-card .anatomy-quiz-card-answer.anatomy-quiz-card-answer-canvas {
  padding: 0 !important;
  overflow: hidden !important;
}

.anatomy-quiz-card .anatomy-quiz-card-answer.anatomy-quiz-card-answer-canvas .anatomy-quiz-canvas-image {
  width: 100%;
  height: 100%;
  min-height: 100%;
  border-radius: inherit;
}

.anatomy-quiz-card .anatomy-quiz-card-answer.anatomy-quiz-card-answer-canvas .anatomy-quiz-canvas-image img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

html[data-theme="dark"] .anatomy-entry-card,
html[data-theme="dark"] .anatomy-quiz-card {
  --anatomy-card-ink: #fff7ed;
  --anatomy-card-muted-ink: rgba(255, 247, 237, 0.72);
}

html[data-theme="dark"] .anatomy-entry-card .anatomy-entry-face-back::before,
html[data-theme="dark"] .anatomy-quiz-card .anatomy-quiz-card-back::before {
  background-color: color-mix(in srgb, var(--anatomy-card-ink) 86%, #fbbf24 14%) !important;
  opacity: 0.15;
  mix-blend-mode: screen;
}

html[data-theme="dark"] .anatomy-entry-card .anatomy-entry-face-back::after,
html[data-theme="dark"] .anatomy-quiz-card .anatomy-quiz-card-back::after {
  content: none;
  display: none;
}

/* Phone-only fit and quiz usability. Keep tablet/desktop layouts untouched. */
@media (max-width: 600px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  *,
  *::before,
  *::after {
    max-width: 100%;
  }

  .wrap,
  .layout,
  .main,
  .sidebar,
  .card,
  .tab-panel,
  details,
  .shared-pack-card,
  .shared-pack-results,
  .shared-pack-result,
  .quiz-shell,
  .quiz-focus,
  .anatomy-quiz-shell,
  .anatomy-quiz-card-stage {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: clip !important;
  }

  .shared-pack-results {
    max-height: none !important;
    overflow: visible !important;
    gap: 12px !important;
    padding: 0 !important;
    margin-top: 14px !important;
  }

  .shared-pack-result {
    width: 100% !important;
    padding: 13px !important;
    border-radius: 8px !important;
  }

  .shared-pack-result.is-current::before {
    inset: 10px auto 10px 0 !important;
    width: 3px !important;
  }

  .shared-pack-result-top {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    padding-right: 0 !important;
  }

  .shared-pack-corner-actions {
    position: static !important;
    order: -1;
    justify-content: flex-start !important;
    margin: 0 !important;
  }

  .shared-pack-author-row {
    min-width: 0 !important;
    align-items: flex-start !important;
  }

  .shared-pack-result-title,
  .shared-pack-result-sub,
  .shared-pack-description,
  .shared-pack-meta,
  .shared-pack-preview-line {
    overflow-wrap: anywhere !important;
    word-break: normal !important;
  }

  .shared-pack-result-title {
    font-size: 16px !important;
    line-height: 1.18 !important;
  }

  .shared-pack-badges,
  .shared-pack-tags,
  .shared-pack-social-row {
    gap: 6px !important;
  }

  .shared-pack-badge,
  .shared-pack-tag {
    padding: 5px 8px !important;
    font-size: 11px !important;
  }

  .shared-pack-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  .shared-pack-actions .btn-primary,
  .shared-pack-actions .btn-secondary {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  body.quiz-mode .hero {
    display: none !important;
  }

  body.quiz-mode .wrap {
    width: 100vw !important;
    max-width: 100vw !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.quiz-mode .layout {
    gap: 8px !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
  }

  body.quiz-mode .sidebar {
    display: none !important;
  }

  body.quiz-mode .main {
    min-height: 100vh !important;
    min-height: 100dvh !important;
    padding: 0 !important;
  }

  body.quiz-mode #tab-quiz {
    width: 100vw !important;
    max-width: 100vw !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    padding-top: 0 !important;
  }

  body.quiz-mode .tabs {
    margin-bottom: 8px !important;
  }

  body.quiz-mode #tab-quiz .quiz-shell {
    min-height: 100vh !important;
    min-height: 100dvh !important;
    gap: 0 !important;
    padding: 0 !important;
    background: var(--bg) !important;
  }

  body.quiz-mode #tab-quiz .quiz-options {
    margin: 0 !important;
    border-radius: 0 0 14px 14px !important;
    box-shadow: none !important;
  }

  body.quiz-mode #tab-quiz .quiz-topbar {
    position: static !important;
    padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left)) !important;
    border-radius: 0 !important;
    gap: 8px !important;
    border-inline: 0 !important;
    border-bottom: 1px solid var(--line) !important;
    box-shadow: none !important;
    filter: none !important;
  }

  body.quiz-mode #tab-quiz .quiz-mode-badges {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
  }

  body.quiz-mode #tab-quiz .quiz-mode-badges .badge {
    margin: 0 !important;
    justify-content: center !important;
    padding: 6px 7px !important;
    font-size: 11px !important;
    min-width: 0 !important;
    box-shadow: none !important;
  }

  body.quiz-mode #tab-quiz .quiz-toolbar-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
  }

  body.quiz-mode #tab-quiz .quiz-toolbar-actions > * {
    width: 100% !important;
    min-width: 0 !important;
    padding-inline: 7px !important;
    font-size: 11px !important;
    box-shadow: none !important;
  }

  body.quiz-mode #tab-quiz .quiz-focus {
    flex: 1 1 auto !important;
    display: grid !important;
    align-content: start !important;
    min-height: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)) !important;
    border-inline: 0 !important;
    border-top: 0 !important;
    border-bottom: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    filter: none !important;
  }

  body.quiz-mode #tab-quiz .quiz-only-input {
    margin-bottom: 6px !important;
    box-shadow: none !important;
  }

  body.quiz-mode #tab-quiz .quiz-only-input .row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 7px !important;
  }

  body.quiz-mode #tab-quiz .quiz-only-input input {
    min-width: 0 !important;
    padding: 12px !important;
    font-size: 16px !important;
    box-shadow: none !important;
  }

  body.quiz-mode #tab-quiz .quiz-study-grid,
  body.quiz-mode #tab-quiz #quizImages {
    width: 100% !important;
    max-width: 100% !important;
    gap: 8px !important;
    margin: 0 !important;
    justify-content: center !important;
    justify-items: center !important;
  }

  body.quiz-mode #tab-quiz #quizImages {
    grid-template-columns: repeat(auto-fit, minmax(148px, 156px)) !important;
    align-content: start !important;
  }

  body.quiz-mode #tab-quiz #quizImages .img-card,
  body.quiz-mode #tab-quiz .notice,
  body.quiz-mode #tab-quiz .quiz-answer-guide,
  body.quiz-mode #tab-quiz .quiz-answer-hint {
    box-shadow: none !important;
    filter: none !important;
  }

  body.quiz-mode #tab-quiz .anatomy-quiz-shell {
    align-content: stretch !important;
    gap: 8px !important;
    min-height: 0 !important;
    width: 100% !important;
  }

  body.quiz-mode #tab-quiz .anatomy-quiz-card-stage {
    align-content: stretch !important;
    min-height: 0 !important;
    width: 100% !important;
  }

  body.quiz-mode #tab-quiz .anatomy-quiz-card {
    width: 100% !important;
    max-height: min(var(--anatomy-quiz-fit-height, 62dvh), 62dvh) !important;
    border-radius: 18px !important;
    box-shadow: none !important;
    filter: none !important;
  }

  body.quiz-mode #tab-quiz .anatomy-quiz-card-face {
    border-radius: 18px !important;
    box-shadow: none !important;
    outline: 0 !important;
    filter: none !important;
  }

  body.quiz-mode #tab-quiz .anatomy-quiz-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 0 !important;
  }

  body.quiz-mode #tab-quiz .anatomy-quiz-action {
    min-width: 0 !important;
    min-height: 50px !important;
    padding-inline: 8px !important;
    font-size: 13px !important;
    border-radius: 15px !important;
    box-shadow: none !important;
    filter: none !important;
  }
}
