/* ACCESSIBILITY PANEL */

.accessibility-panel {
  margin-bottom: 20px;
  padding: 24px;

  background: var(--color-surface);

  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);

  box-shadow: var(--shadow-sm);
}

.accessibility-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 15px;

  margin-bottom: 24px;
}

.accessibility-panel-header h2 {
  margin: 0 0 6px;

  font-size: 1.1rem;
}

.accessibility-panel-header p {
  margin: 0;

  color: var(--color-text-secondary);

  font-size: var(--font-size-sm);
  line-height: 1.6;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.setting-control {
  min-width: 0;
}

.setting-control label {
  display: flex;
  justify-content: space-between;
  align-items: center;

  gap: 10px;

  margin-bottom: 11px;

  font-size: var(--font-size-sm);
  font-weight: 600;
}

.setting-control output {
  color: var(--color-primary);
  font-size: var(--font-size-xs);
}

.setting-control select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;

  color: var(--color-text);

  background: var(--color-surface);

  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
}

.setting-control input[type="range"] {
  display: block;
  width: 100%;

  accent-color: var(--color-primary);

  cursor: pointer;
}

.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  margin-top: 24px;
  padding-top: 20px;

  border-top: 1px solid var(--color-border);
}

.toggle-setting {
  display: flex;
  align-items: center;
  gap: 15px;

  position: relative;

  cursor: pointer;
}

.toggle-setting > span:first-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toggle-setting strong {
  font-size: var(--font-size-sm);
}

.toggle-setting small {
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

.toggle-setting input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;

  width: 42px;
  height: 24px;

  flex-shrink: 0;

  background: var(--color-border-strong);

  border-radius: 20px;

  transition: background var(--transition-fast);
}

.toggle-track::after {
  content: "";

  position: absolute;
  top: 3px;
  left: 3px;

  width: 18px;
  height: 18px;

  background: white;

  border-radius: 50%;

  transition: transform var(--transition-fast);
}

.toggle-setting input:checked + .toggle-track {
  background: var(--color-primary);
}

.toggle-setting input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.toggle-setting input:focus-visible + .toggle-track {
  outline: 3px solid rgba(98, 87, 217, 0.35);
  outline-offset: 3px;
}

.text-button {
  padding: 8px 0;

  color: var(--color-primary);

  background: none;
  border: 0;

  font-size: var(--font-size-sm);
  font-weight: 600;
}

.text-button:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}


/* SPEECH PLAYER */

.speech-player {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  margin-bottom: 20px;
  padding: 17px 20px;

  background: var(--color-surface);

  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.speech-info {
  display: flex;
  align-items: center;
  gap: 12px;

  min-width: 0;
}

.speech-icon {
  display: grid;
  place-items: center;

  flex-shrink: 0;

  width: 42px;
  height: 42px;

  color: var(--color-primary);

  background: var(--color-primary-soft);

  border-radius: var(--radius-md);
}

.speech-info > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.speech-info strong {
  font-size: var(--font-size-sm);
}

.speech-info span:not(.speech-icon) {
  color: var(--color-text-secondary);

  font-size: var(--font-size-xs);
}

.speech-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.speech-action {
  min-width: 72px;
  min-height: 39px;
  padding: 8px 12px;
}

.speech-action:disabled {
  opacity: 0.45;
}


/* READING THEMES */

.reading-card {
  --reading-background: #ffffff;
  --reading-text: #414458;
  --reading-heading: #202238;

  background: var(--reading-background);
}

.reading-card[data-theme="warm"] {
  --reading-background: #fbf4e8;
  --reading-text: #554b3d;
  --reading-heading: #342c24;
}

.reading-card[data-theme="dark"] {
  --reading-background: #202331;
  --reading-text: #e1e3eb;
  --reading-heading: #ffffff;

  border-color: #35394b;
}

.reading-card .reading-title {
  color: var(--reading-heading);
}

.reading-card .reading-content {
  color: var(--reading-text);
}

.reading-card .reading-divider {
  background: var(--color-border);
}

.reading-card[data-theme="dark"] .reading-divider {
  background: #3c4052;
}

.reading-card[data-theme="dark"] .reading-meta {
  color: #b0b4c6;
}


/* READING RULER */

.reading-ruler {
  position: fixed;
  z-index: 50;

  left: 0;
  top: -100px;

  width: 100%;
  height: 40px;

  background: rgba(98, 87, 217, 0.10);

  border-top: 1px solid rgba(98, 87, 217, 0.32);
  border-bottom: 1px solid rgba(98, 87, 217, 0.32);

  pointer-events: none;

  opacity: 0;

  transition: opacity 120ms ease;
}

.reading-ruler.active {
  opacity: 1;
}


/* FOCUS MODE ADJUSTMENTS */

.focus-mode .speech-player,
.focus-mode .accessibility-panel {
  max-width: 850px;
  margin-right: auto;
  margin-left: auto;
}

.focus-mode .reading-card {
  max-width: 850px;
  margin: 0 auto;
}

.focus-mode .reader-section {
  padding-top: 25px;
}

/* Annotation selection toolbar */

.annotation-toolbar {
  position: absolute;
  z-index: 1000;
  display: none;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px;
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e2e5ec);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13);
  max-width: calc(100vw - 16px);
}

.annotation-toolbar.visible {
  display: flex;
}

.annotation-toolbar button {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.annotation-toolbar button:hover {
  background: #f0f2f7;
}

.annotation-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.annotation-dot.yellow {
  background: #f4d35e;
}

.annotation-dot.green {
  background: #81c995;
}

.annotation-dot.blue {
  background: #80b8ed;
}


/* Saved highlights */

.saved-highlight {
  padding: 1px 2px;
  border-radius: 3px;
}

.saved-highlight.yellow {
  background: #fff0a6;
  color: #302700;
}

.saved-highlight.green {
  background: #c9f0d5;
  color: #173c25;
}

.saved-highlight.blue {
  background: #c9e4ff;
  color: #173858;
}


/* Annotations panel */

.annotations-panel {
  position: fixed;
  z-index: 1100;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100dvh;
  padding: 24px;
  background: var(--color-surface, #ffffff);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
  transform: translateX(105%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.annotations-panel.visible {
  transform: translateX(0);
}

.annotations-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 24px;
}

.annotations-header h2 {
  margin: 0 0 5px;
}

.annotations-header p {
  margin: 0;
  font-size: 13px;
  opacity: 0.7;
}

.annotations-header button {
  border: 0;
  background: transparent;
  font-size: 26px;
  cursor: pointer;
}

.annotation-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border, #e2e5ec);
}

.annotation-item blockquote {
  margin: 10px 0;
  padding-left: 12px;
  border-left: 3px solid #a8b6cf;
  line-height: 1.6;
}

.annotation-note-preview {
  padding: 10px;
  background: #f3f5f9;
  border-radius: 8px;
  font-size: 14px;
}

.annotation-item-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.annotation-item-actions button {
  border: 0;
  background: transparent;
  color: var(--color-primary, #5266bd);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.annotations-empty {
  line-height: 1.7;
  opacity: 0.7;
}


/* Note dialog */

.annotation-note-dialog {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

.annotation-note-dialog.visible {
  display: flex;
}

.annotation-note-dialog form {
  width: min(440px, 100%);
  padding: 24px;
  background: #ffffff;
  border-radius: 16px;
  color: #202532;
}

.annotation-note-dialog h2 {
  margin-top: 0;
}

.note-selected-text {
  padding: 12px;
  background: #f2f4f8;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
}

.annotation-note-dialog label {
  display: block;
  margin: 16px 0 8px;
  font-weight: 600;
}

.annotation-note-dialog textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid #d6dbe5;
  border-radius: 8px;
  resize: vertical;
  font: inherit;
}

.annotation-note-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.annotation-note-actions button {
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.annotation-note-actions button[type="submit"] {
  background: #5266bd;
  color: white;
}

@media (max-width: 480px) {
  .annotation-toolbar {
    gap: 2px;
    padding: 5px;
  }

  .annotation-toolbar button {
    padding: 8px 6px;
    font-size: 11px;
  }

  .annotations-panel {
    padding: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .annotations-panel {
    transition: none;
  }
}

/* Compact read-aloud control */

.speech-player {
  align-items: center;
  flex-direction: row;
  gap: 14px;
}

.speech-controls {
  flex-shrink: 0;
}

.speech-toggle-button {
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  padding: 0;

  display: grid;
  place-items: center;

  border-radius: 50%;
}

.speech-toggle-button svg {
  width: 21px;
  height: 21px;
}

.speech-pause-icon {
  display: none;
}

.speech-toggle-button.is-playing .speech-play-icon {
  display: none;
}

.speech-toggle-button.is-playing .speech-pause-icon {
  display: block;
}

@media (max-width: 600px) {

  .speech-player {
    padding: 12px 14px;
  }

  .speech-info {
    flex: 1;
  }

  .speech-toggle-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

}