/* Dream visualization — glassmorphism aligned with .panel / .controls */

#dream-details {
  margin-top: 4px;
}

.dream-visualize-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-visualize {
  width: 100%;
  margin-top: 4px;
  border: 1px solid rgba(130, 190, 255, 0.35);
  background: rgba(22, 30, 48, 0.65);
  color: #e8f4ff;
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  font-size: 13px;
  font-family: Arial, sans-serif;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-visualize:hover {
  background: rgba(34, 48, 73, 0.85);
  border-color: rgba(120, 205, 255, 0.55);
  box-shadow: 0 6px 22px rgba(0, 40, 80, 0.2);
}

.btn-visualize:disabled {
  opacity: 0.65;
  cursor: wait;
}

#dream-visualize-input,
#loc-visualize-input,
#ea-visualize-input {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(180, 220, 255, 0.16);
  background: rgba(10, 16, 28, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#dream-visualize-input label,
#loc-visualize-input label,
#ea-visualize-input label {
  display: block;
  font-size: 12px;
  color: #9db4c9;
  margin-bottom: 8px;
}

#dream-visualize-input textarea,
#loc-visualize-input textarea,
#ea-visualize-input textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(180, 220, 255, 0.18);
  background: rgba(10, 16, 28, 0.52);
  color: #eff7ff;
  padding: 10px;
  font-size: 13px;
  font-family: Arial, sans-serif;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#dream-visualize-input textarea::placeholder,
#loc-visualize-input textarea::placeholder,
#ea-visualize-input textarea::placeholder {
  color: rgba(220, 234, 248, 0.55);
}

#dream-visualize-input textarea:focus,
#loc-visualize-input textarea:focus,
#ea-visualize-input textarea:focus {
  border-color: rgba(100, 200, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(100, 200, 255, 0.15);
}

#dream-visualize-generate-btn,
#loc-visualize-generate-btn,
#ea-visualize-generate-btn {
  width: 100%;
  margin-top: 10px;
  border: 1px solid rgba(130, 190, 255, 0.3);
  background: rgba(22, 30, 48, 0.75);
  color: #ebf4ff;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-family: Arial, sans-serif;
  transition: background 0.2s ease, border-color 0.2s ease;
}

#dream-visualize-generate-btn:hover:not(:disabled),
#loc-visualize-generate-btn:hover:not(:disabled),
#ea-visualize-generate-btn:hover:not(:disabled) {
  background: rgba(34, 48, 73, 0.9);
  border-color: rgba(120, 205, 255, 0.65);
}

#dream-visualize-generate-btn:disabled,
#loc-visualize-generate-btn:disabled,
#ea-visualize-generate-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

#dream-visualize-container,
#loc-visualize-container,
#ea-visualize-container {
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(20, 20, 30, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

#dream-visualize-container img,
#loc-visualize-container img,
#ea-visualize-container img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ──────────────────────────────────────────────────────────────
   Dream Diary modal — visuals only; sizing/positioning is shared
   with #profile-modal/#lavka-modal in index.html.
   ────────────────────────────────────────────────────────────── */
#dream-diary-modal {
  color: #eaf5ff;
  font-family: Arial, sans-serif;
}
#dream-diary-modal.modal-show {
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
#dream-diary-modal #diary-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.dream-diary-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
}
.dream-diary-header h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: 0.02em; }
.diary-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.diary-tab {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(130, 190, 255, 0.18);
  background: rgba(10,16,28,0.52);
  color: #9db4c9;
  font-size: 13px; cursor: pointer;
  transition: all 0.2s ease;
  font-family: Arial, sans-serif;
}
.diary-tab:hover { color: #eaf5ff; border-color: rgba(110,195,255,0.45); background: rgba(30,38,58,0.7); }
.diary-tab.active {
  border-color: rgba(155, 89, 182, 0.7);
  background: rgba(155, 89, 182, 0.22);
  color: #f5ebff;
  box-shadow: 0 0 16px rgba(155,89,182,0.28);
}
.diary-pane { display: none; }
.diary-pane.active { display: block; }

.diary-card {
  display: flex; gap: 14px; padding: 14px 16px;
  border-radius: 12px; border: 1px solid rgba(180,220,255,0.1);
  background: rgba(12,16,28,0.5); margin-bottom: 10px;
  cursor: pointer; transition: all 0.2s ease;
  align-items: stretch;
}
.diary-card:hover {
  border-color: rgba(130,190,255,0.3); background: rgba(18,24,40,0.65);
  box-shadow: 0 6px 22px rgba(0,0,0,0.28); transform: translateY(-1px);
}
.diary-card.selected { border-color: rgba(155,89,182,0.55); background: rgba(40,20,60,0.5); }
.diary-mood-stripe {
  width: 6px; border-radius: 6px; flex-shrink: 0;
  align-self: stretch; min-height: 100%;
}
.diary-check-wrap {
  display: flex; align-items: center; flex-shrink: 0;
}
.diary-card-body { flex: 1; min-width: 0; }
.diary-card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 5px; }
.diary-card-date { font-size: 11px; color: rgba(220,234,248,0.65); }
.diary-card-title { font-size: 14px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diary-card-text-shell {
  margin-bottom: 8px;
}
.diary-card-excerpt-wrap {
  overflow: hidden;
  max-height: 5.6em;
  /* Переключение контента превью ↔ полный текст — без анимации max-height (избегаем рывков). */
  transition: none;
}
.diary-card--excerpt-open .diary-card-excerpt-wrap {
  max-height: none;
  overflow: visible;
}
.diary-card-excerpt {
  font-size: 12px;
  color: #9db4c9;
  line-height: 1.4;
  margin-bottom: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.diary-excerpt-toggle {
  margin-top: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(110, 195, 255, 0.38);
  background: rgba(70, 140, 220, 0.12);
  color: #c8dff5;
  font-family: Arial, sans-serif;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.diary-excerpt-toggle:hover {
  background: rgba(70, 140, 220, 0.22);
  border-color: rgba(110, 195, 255, 0.55);
  color: #eaf5ff;
}
.diary-mood-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 600;
  border: 1px solid rgba(180,180,200,0.15); color: #aabac9; background: rgba(180,180,200,0.1);
}
.diary-mood-badge[data-mood="anxiety"] { color: #ff8fab; border-color: rgba(255,77,109,0.25); background: rgba(255,77,109,0.18); }
.diary-mood-badge[data-mood="joy"]     { color: #8dffbc; border-color: rgba(141,255,188,0.22); background: rgba(141,255,188,0.12); }
.diary-mood-badge[data-mood="sadness"] { color: #9dd8ff; border-color: rgba(110,195,255,0.22); background: rgba(110,195,255,0.12); }
.diary-mood-badge[data-mood="lucid"]   { color: #e0aaff; border-color: rgba(224,170,255,0.25); background: rgba(224,170,255,0.14); }
.diary-mood-badge[data-mood="awe"]     { color: #ffd166; border-color: rgba(255,209,102,0.25); background: rgba(255,209,102,0.14); }
.diary-mood-badge[data-mood="unknown"] {
  color: #9ca3af;
  border-color: rgba(156,163,175,0.35);
  background: rgba(107,114,142,0.22);
}
.diary-mood-unclassified {
  display: inline-block;
  margin-right: 3px;
  color: #9ca3af;
  font-size: 11px;
  line-height: 1;
  vertical-align: -0.05em;
}
.diary-mood-badge.diary-mood-badge--editable {
  cursor: pointer;
  text-decoration: underline dotted rgba(156,163,175,0.45);
  text-underline-offset: 2px;
}
.diary-mood-badge.diary-mood-badge--editable:hover {
  filter: brightness(1.08);
}

/* Ручное настроение сна (поверх дневника) */
#mood-edit-modal {
  display: none;
  position: fixed;
  z-index: 2500;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  box-sizing: border-box;
  padding:
    calc(16px + env(safe-area-inset-top, 0px))
    calc(14px + env(safe-area-inset-right, 0px))
    calc(16px + env(safe-area-inset-bottom, 0px))
    calc(14px + env(safe-area-inset-left, 0px));
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  transform: none;
  background: rgba(16, 14, 28, 0.95);
  border: none;
  box-shadow: none;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 0;
  color: #eaf5ff;
  font-family: Arial, sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.34s ease, transform 0.34s ease;
}
#mood-edit-modal.modal-show {
  display: flex;
}
#mood-edit-modal.modal-show.modal-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
@media (min-width: 769px) {
  #mood-edit-modal {
    inset: auto;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: min(440px, 94vw);
    max-height: min(420px, 90vh);
    padding: 22px;
    transform: translate(-50%, calc(-50% + 14px)) scale(0.985);
    border: 1px solid rgba(155, 89, 182, 0.38);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(140, 220, 255, 0.1) inset;
    border-radius: 16px;
  }
  #mood-edit-modal.modal-show.modal-visible {
    transform: translate(-50%, -50%) scale(1);
  }
}
@media (max-width: 768px) {
  #mood-edit-modal.modal-show.modal-visible,
  #mood-edit-modal.modal-stack-top {
    background: rgb(16, 14, 28) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}
.mood-edit-modal__inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.mood-edit-modal__title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.mood-edit-modal__hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: rgba(200, 220, 248, 0.72);
  line-height: 1.45;
}
.mood-edit-modal__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(180, 200, 230, 0.75);
  margin-top: 4px;
}
.mood-edit-modal__select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(130, 190, 255, 0.28);
  background: rgba(10, 16, 28, 0.72);
  color: #eaf5ff;
  font-size: 14px;
  font-family: Arial, sans-serif;
}
.mood-edit-modal__range-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}
#mood-intensity {
  flex: 1;
  accent-color: #b39ddb;
}
.mood-edit-modal__range-value {
  min-width: 2.2em;
  text-align: right;
  font-weight: 700;
  font-size: 14px;
  color: #e0aaff;
}
.mood-edit-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  justify-content: flex-end;
}
.mood-edit-modal__btn {
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(180, 200, 230, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: #eaf5ff;
  font-size: 13px;
  font-family: Arial, sans-serif;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.mood-edit-modal__btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.mood-edit-modal__btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.mood-edit-modal__btn--primary {
  border-color: rgba(155, 89, 182, 0.65);
  background: rgba(120, 60, 160, 0.45);
}
.mood-edit-modal__btn--primary:hover:not(:disabled) {
  background: rgba(140, 80, 180, 0.55);
}

.diary-check {
  width: 18px; height: 18px; appearance: none;
  border: 1.5px solid rgba(155,89,182,0.45);
  border-radius: 5px; background: rgba(10,8,20,0.6);
  cursor: pointer; position: relative; flex-shrink: 0;
}
.diary-check:checked {
  background: rgba(155,89,182,0.55); border-color: #e0aaff;
  box-shadow: 0 0 8px rgba(155,89,182,0.6);
}
.diary-check:checked::after {
  content: '✓'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%); color: #fff; font-size: 11px; line-height: 1;
}

.diary-entity-card {
  padding: 14px 14px 12px;
  border-radius: 12px;
  border: 1px solid rgba(180,220,255,0.1);
  background: rgba(12,16,28,0.5);
  cursor: default;
  transition: all 0.2s;
  /* Normalised layout: head, bars (auto), meta (1fr — flex grow), insight (auto), button (auto). */
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 10px;
}
.diary-entity-card:hover { border-color: rgba(130,190,255,0.28); background: rgba(18,24,40,0.65); transform: translateY(-2px); }
.diary-entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  align-items: stretch;
}
.diary-entity-bars { display: flex; flex-direction: column; gap: 6px; }
.diary-entity-bar {
  display: grid; grid-template-columns: 80px 1fr auto;
  gap: 8px; align-items: center;
  font-size: 11px; color: rgba(220, 234, 248, 0.65);
}
.diary-entity-bar b { color: #eaf5ff; }
.diary-entity-meta {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: rgba(220, 234, 248, 0.7);
  min-height: 0;
}
.diary-entity-mood-row { display: flex; align-items: baseline; gap: 6px; }
.diary-entity-mood-row b { color: #eaf5ff; }
.diary-entity-corr-row {
  display: flex; flex-direction: column; gap: 4px;
}
.diary-entity-corr-row > span:first-child { color: rgba(220, 234, 248, 0.65); }
.diary-entity-actions {
  margin-top: 4px;
  display: flex;
  justify-content: center;
}
.diary-entity-actions .diary-show-graph-btn {
  width: 100%;
  text-align: center;
  padding: 7px 12px;
}

.diary-prism-wrap {
  margin: 16px 0; padding: 16px; border-radius: 12px;
  background: rgba(10,8,20,0.6); border: 1px solid rgba(155,89,182,0.3);
}
.diary-prism-slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 4px; outline: none;
  background: linear-gradient(90deg, #6ec3ff 0%, #9b59b6 50%, #ff6db6 100%);
}
.diary-prism-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid #9b59b6;
  cursor: pointer; box-shadow: 0 0 12px rgba(155,89,182,0.6);
}
.diary-prism-labels { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; color: rgba(220,234,248,0.65); }
.diary-prism-current { text-align: center; margin-top: 6px; font-size: 12px; color: #e0aaff; font-weight: 600; }

.diary-oracle-output {
  margin-top: 16px; padding: 16px; border-radius: 12px;
  border: 1px solid rgba(155,89,182,0.3); background: rgba(8,6,18,0.7);
}
.diary-oracle-highlight {
  margin: 12px 0; padding: 10px 14px; border-radius: 8px;
  border-left: 3px solid #e0aaff; background: rgba(155,89,182,0.12);
  font-size: 12px; color: #e0d0f8; line-height: 1.5;
}
.diary-oracle-tag {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  border: 1px solid rgba(155,89,182,0.4); background: rgba(155,89,182,0.12);
  font-size: 11px; color: #d0b8f0; margin: 0 4px 4px 0;
}

.diary-top-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: 8px; background: rgba(10,14,24,0.5);
  border: 1px solid rgba(255,255,255,0.07); cursor: pointer;
  transition: all 0.18s; margin-bottom: 8px;
}
.diary-top-link:hover { background: rgba(18,24,40,0.65); border-color: rgba(130,190,255,0.22); }
.diary-show-graph-btn {
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid rgba(110,195,255,0.45);
  background: rgba(70,140,220,0.12); color: #d0efff;
  font-size: 11px; cursor: pointer; transition: all 0.18s; white-space: nowrap;
  font-family: Arial, sans-serif;
}
.diary-show-graph-btn:hover { background: rgba(70,140,220,0.22); box-shadow: 0 0 10px rgba(110,195,255,0.2); }

body.onboarding-active.onboarding-diary-hints-front #onboarding-root.is-active { z-index: 2010; }
.diary-tab.onboarding-diary-tab-pulse {
  animation: onboardingTabPulse 1.1s ease-in-out infinite;
  border-color: rgba(155,89,182,0.7) !important;
}

/* Chronograph toolbar + chips + metrics */
.diary-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.diary-toolbar input[type="text"] {
  flex: 1; min-width: 180px; padding: 8px 12px; border-radius: 12px;
  border: 1px solid rgba(180,220,255,0.18); background: rgba(10,16,28,0.52);
  color: #eaf5ff; font-size: 13px; font-family: Arial, sans-serif; outline: none;
}
.diary-btn-secondary, .diary-btn-accent {
  padding: 8px 14px; border-radius: 8px; font-size: 12px; cursor: pointer;
  font-family: Arial, sans-serif; transition: all 0.2s ease;
}
.diary-btn-secondary {
  border: 1px solid rgba(255,95,95,0.6); background: rgba(140,26,26,0.7);
  color: #ffe7e7;
}
.diary-btn-secondary:hover { background: rgba(176,35,35,0.85); }
.diary-btn-accent {
  border: 1px solid rgba(155,89,182,0.55); background: rgba(155,89,182,0.22);
  color: #f5ebff; font-weight: 700;
}
.diary-btn-accent:hover { background: rgba(155,89,182,0.38); box-shadow: 0 0 16px rgba(155,89,182,0.4); }
.diary-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid rgba(231, 76, 60, 0.65);
  background: rgba(192, 57, 43, 0.42);
  color: #ffecec;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}
.diary-btn-danger:hover:not(:disabled) {
  background: rgba(231, 76, 60, 0.55);
  border-color: rgba(255, 120, 100, 0.85);
}
.diary-btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.diary-entity-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid rgba(185,215,255,0.18); background: rgba(10,16,30,0.42);
  font-size: 11px; color: #9db4c9; margin-right: 4px;
}
.diary-card-metrics {
  display: flex; gap: 14px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 11px; color: rgba(220,234,248,0.65);
}
.diary-card-metrics b { color: #eaf5ff; }

/* Registry sub-tabs and entity card details */
.diary-subtabs { display: flex; gap: 6px; margin-bottom: 14px; }
.diary-subtab {
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid rgba(180,220,255,0.18); background: rgba(10,16,28,0.52);
  color: #9db4c9; font-size: 12px; cursor: pointer;
  transition: all 0.2s; font-family: Arial, sans-serif;
}
.diary-subtab:hover { color: #eaf5ff; }
.diary-subtab.active {
  border-color: rgba(255,179,110,0.55); background: rgba(255,120,40,0.12); color: #ffe6c9;
}
.diary-entity-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-weight: 700;
}
.diary-entity-card-icon { font-size: 16px; margin-right: 6px; }
.diary-entity-card-name { flex: 1; }
.diary-entity-card-count {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.08); color: #9db4c9;
}
.diary-entity-card-bar {
  display: grid; grid-template-columns: 80px 1fr auto;
  gap: 8px; align-items: center; font-size: 11px;
  color: rgba(220,234,248,0.65); margin-bottom: 6px;
}
.diary-bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.07); overflow: hidden; }
.diary-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }
.diary-entity-card-bar b { color: #eaf5ff; }
.diary-entity-card-meta { font-size: 11px; color: rgba(220,234,248,0.65); margin-top: 6px; line-height: 1.4; }
.diary-insight-slot { margin-top: 8px; }
/* Глобальный кулдаун AI — все кнопки AI-функций (карта, дневник, реестр) */
.dr-ai-cooldown-btn {
  position: relative;
  overflow: hidden;
}
.dr-ai-cooldown-fill,
.diary-insight-lazy-cd-fill {
  position: absolute;
  inset: 0;
  transform-origin: right center;
  background: linear-gradient(115deg, rgba(6, 10, 20, 0.78), rgba(20, 32, 52, 0.62));
  pointer-events: none;
  border-radius: inherit;
  z-index: 0;
  transition: transform 0.2s linear;
}
.dr-ai-cooldown-label,
.diary-insight-lazy-btn .diary-insight-lazy-label {
  position: relative;
  z-index: 1;
}
.dr-ai-cooldown-label--timer,
.diary-insight-lazy-label--cd {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.dr-ai-cooldown-btn--active:disabled,
.diary-insight-lazy-btn--cooldown:disabled {
  opacity: 1;
  cursor: not-allowed;
}
.btn-visualize.dr-ai-cooldown-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-delete-btn.dr-ai-cooldown-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 7rem;
}
.diary-btn-accent.dr-ai-cooldown-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

.diary-insight-lazy-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #eaf6ff;
  border: 1px solid rgba(160, 220, 255, 0.38);
  background: linear-gradient(145deg, rgba(36, 58, 102, 0.5), rgba(14, 22, 38, 0.82));
  box-shadow: 0 0 22px rgba(100, 190, 255, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(12px);
  transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.diary-insight-lazy-cd-fill {
  position: absolute;
  inset: 0;
  transform-origin: right center;
  background: linear-gradient(115deg, rgba(6, 10, 20, 0.78), rgba(20, 32, 52, 0.62));
  pointer-events: none;
  border-radius: inherit;
  z-index: 0;
  transition: transform 0.2s linear;
}
.diary-insight-lazy-btn .diary-insight-lazy-label,
.diary-insight-lazy-btn .diary-insight-lazy-spinner {
  position: relative;
  z-index: 1;
}
.diary-insight-lazy-label--cd {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.diary-insight-lazy-btn--cooldown:disabled {
  opacity: 1;
  cursor: not-allowed;
}
.diary-insight-lazy-btn:hover:not(:disabled) {
  border-color: rgba(200, 245, 255, 0.55);
  transform: translateY(-1px);
}
.diary-insight-lazy-btn:disabled {
  cursor: wait;
  opacity: 0.88;
}
.diary-insight-lazy-spinner {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: rgba(170, 230, 255, 0.95);
  border-radius: 50%;
  animation: diary-insight-spin 0.65s linear infinite;
}
@keyframes diary-insight-spin {
  to { transform: rotate(360deg); }
}

/* Oracle scope + history */
.diary-oracle-scope { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; align-items: center; }
.diary-scope-chip {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid rgba(180,220,255,0.18); background: rgba(10,16,28,0.52);
  color: #9db4c9; font-size: 12px; cursor: pointer;
  transition: all 0.2s; font-family: Arial, sans-serif;
}
.diary-scope-chip:hover { color: #eaf5ff; }
.diary-scope-chip.active { border-color: rgba(155,89,182,0.6); background: rgba(155,89,182,0.22); color: #f5ebff; }
.diary-oracle-history-row {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 6px; cursor: pointer;
  border-radius: 8px; border: 1px solid rgba(255,255,255,0.06); background: rgba(10,14,24,0.4);
  transition: all 0.2s;
}
.diary-oracle-history-row:hover { background: rgba(18,24,40,0.65); border-color: rgba(130,190,255,0.22); }

/* ─── How-to-read collapsible block (custom for smooth animation) ─── */
.diary-howto {
  margin: 0 0 14px;
  border-radius: 12px;
  background: rgba(155, 89, 182, 0.08);
  border: 1px solid rgba(155, 89, 182, 0.25);
  color: #d3c5e8;
  overflow: hidden;
}
.diary-howto-toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: #f5ebff;
  font-family: Arial, sans-serif;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  text-align: left;
  user-select: none;
}
.diary-howto-icon { color: #e0aaff; font-size: 14px; flex-shrink: 0; }
.diary-howto-toggle > span:nth-child(2) { flex: 1; }
.diary-howto-chevron {
  font-size: 12px; color: #e0aaff; flex-shrink: 0;
  transition: transform 0.32s ease;
  transform: rotate(-90deg);
}
.diary-howto.open .diary-howto-chevron { transform: rotate(0deg); }
.diary-howto-body {
  padding: 0 14px;
}
.diary-howto.open .diary-howto-body {
  padding: 0 14px 12px;
}
.diary-howto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 14px;
  font-size: 12px;
  line-height: 1.45;
}
.diary-howto-row {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 8px; border-radius: 8px; background: rgba(10, 8, 20, 0.35);
  cursor: help;
  transition: background 0.15s;
}
.diary-howto-row:hover { background: rgba(155, 89, 182, 0.18); }
.diary-howto-row b { color: #f5ebff; font-size: 11.5px; }
.diary-howto-row span { color: rgba(220, 234, 248, 0.7); font-size: 11.5px; }

/* ─── Atmosphere badge ─── */
.diary-atmo-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 600;
  border: 1px solid rgba(255,255,255,0.14);
}

/* ─── Two timestamps row in chrono card ─── */
.diary-card-dates {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 11px; color: rgba(220, 234, 248, 0.6); margin-bottom: 6px;
}
.diary-card-dates b { color: #eaf5ff; font-weight: 600; }

/* ─── Inline metric expand inside chrono card (click-to-toggle, single-open) ─── */
.diary-card-details {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(10, 8, 20, 0.5);
  border: 1px solid transparent;
  transition: max-height 0.32s ease, opacity 0.22s ease, margin-top 0.32s ease, padding 0.22s ease, border-color 0.22s ease;
}
.diary-card.expanded .diary-card-details {
  max-height: 280px;
  opacity: 1;
  margin-top: 10px;
  padding: 10px 12px;
  border-color: rgba(155, 89, 182, 0.32);
}

/* Expand toggle button — sits at the right end of the metrics row. */
.diary-card-expand-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(155, 89, 182, 0.42);
  background: rgba(155, 89, 182, 0.12);
  color: #e0d0f8;
  font-family: Arial, sans-serif;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.diary-card-expand-btn:hover {
  background: rgba(155, 89, 182, 0.26);
  border-color: rgba(155, 89, 182, 0.7);
  color: #f5ebff;
}
.diary-card-expand-chevron {
  font-size: 10px;
  transition: transform 0.28s ease;
  display: inline-block;
  line-height: 1;
}
.diary-card.expanded .diary-card-expand-chevron { transform: rotate(180deg); }
.tooltip-title {
  font-size: 11px; font-weight: 700; color: #e0aaff;
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px;
}
.tooltip-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px; font-size: 12px;
}
.tooltip-row .tkey { color: rgba(220, 234, 248, 0.72); }
.tooltip-row .tval { color: #eaf5ff; font-weight: 600; }
.tooltip-bar-wrap {
  height: 4px; background: rgba(255, 255, 255, 0.08);
  border-radius: 2px; margin: 2px 0 8px; overflow: hidden;
}
.tooltip-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

/* ─── Metric mini blocks (consistent dot+label+value) ─── */
.metric-mini {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: rgba(220, 234, 248, 0.65);
}
.metric-mini b { color: #eaf5ff; }
.metric-mini .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
}

/* ─── Pagination ─── */
.diary-pagination {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 16px; padding: 10px 14px;
  border-radius: 10px; background: rgba(10, 16, 28, 0.45);
  border: 1px solid rgba(180, 220, 255, 0.12);
}
.diary-page-btn {
  padding: 6px 14px; border-radius: 8px;
  border: 1px solid rgba(155, 89, 182, 0.4);
  background: rgba(155, 89, 182, 0.14);
  color: #f5ebff; font-size: 12px; cursor: pointer;
  font-family: Arial, sans-serif; transition: all 0.18s;
}
.diary-page-btn:hover:not(:disabled) {
  background: rgba(155, 89, 182, 0.3);
  box-shadow: 0 0 12px rgba(155, 89, 182, 0.35);
}
.diary-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.diary-page-info { font-size: 12px; color: rgba(220, 234, 248, 0.72); }
.diary-page-info b { color: #eaf5ff; }

/* ─── Empty / error state ─── */
.diary-empty {
  padding: 18px; text-align: center;
  color: rgba(220, 234, 248, 0.6); font-size: 13px;
}

/* ─── Top-link row text + degree + button ─── */
.diary-top-link-text {
  flex: 1;            /* takes the rest of the row so degree+button stick to the right */
  min-width: 0;       /* allow ellipsis instead of pushing siblings out */
  overflow: hidden;
}
.diary-top-link-name {
  font-size: 13px; font-weight: 600; color: #eaf5ff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.diary-top-link-sub  { font-size: 11px; color: rgba(220, 234, 248, 0.65); }
.diary-top-link-degree {
  font-size: 16px; font-weight: 700; color: #6ec3ff;
  min-width: 28px; text-align: right;
  flex-shrink: 0;
}
.diary-top-link-marker {
  width: 4px; height: 28px; border-radius: 2px;
  flex-shrink: 0;
}
.diary-top-link.diary-chip-loc  .diary-top-link-marker { background: #ffb36e; box-shadow: 0 0 6px rgba(255, 179, 110, 0.55); }
.diary-top-link.diary-chip-char .diary-top-link-marker { background: #6ec3ff; box-shadow: 0 0 6px rgba(110, 195, 255, 0.55); }
.diary-top-link.diary-chip-art  .diary-top-link-marker { background: #e0aaff; box-shadow: 0 0 6px rgba(224, 170, 255, 0.55); }
.diary-top-link .diary-show-graph-btn { flex-shrink: 0; }

/* Dream-to-dream semantic links (diary tab «Связи снов») */
.diary-dream-link-card {
  padding: 14px 16px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: rgba(10, 14, 24, 0.55);
  border: 1px solid rgba(155, 89, 182, 0.22);
  box-shadow: 0 0 0 1px rgba(110, 195, 255, 0.04) inset;
}
.diary-dream-link-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.diary-dream-link-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #f5ebff;
  border: 1px solid rgba(155, 89, 182, 0.55);
  background: linear-gradient(
    135deg,
    rgba(155, 89, 182, calc(0.12 + var(--link-score, 50) * 0.004)),
    rgba(70, 140, 220, calc(0.08 + var(--link-score, 50) * 0.003))
  );
  box-shadow: 0 0 12px rgba(155, 89, 182, 0.18);
}
.diary-dream-link-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(141, 255, 188, 0.45);
  background: rgba(76, 175, 80, 0.14);
  color: #bff5c8;
  white-space: nowrap;
}
.diary-dream-link-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-bottom: 10px;
}
.diary-dream-link-dream-title {
  font-size: 14px;
  font-weight: 700;
  color: #eaf5ff;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.diary-dream-link-dream-date {
  font-size: 11px;
  color: rgba(220, 234, 248, 0.62);
  margin-top: 3px;
}
.diary-dream-link-bridge {
  align-self: center;
  font-size: 18px;
  color: rgba(224, 170, 255, 0.85);
  text-shadow: 0 0 10px rgba(155, 89, 182, 0.45);
}
.diary-dream-link-preview {
  font-size: 12px;
  line-height: 1.45;
  margin: 0 0 10px;
}
.diary-dream-link-analysis {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(40, 18, 60, 0.45);
  border: 1px solid rgba(155, 89, 182, 0.28);
}
.diary-dream-link-analysis-meta {
  font-size: 11px;
  color: rgba(200, 220, 248, 0.65);
  margin-bottom: 8px;
}
.diary-dream-link-analysis-body {
  font-size: 13px;
  line-height: 1.55;
  color: #eaf5ff;
}
.diary-dream-link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.diary-dream-link-actions .diary-btn-secondary,
.diary-dream-link-actions .diary-btn-accent {
  margin: 0;
}
.diary-dream-links-toolbar {
  align-items: center;
  margin-bottom: 12px;
}
.diary-dream-links-sort-label {
  font-size: 12px;
  color: rgba(220, 234, 248, 0.72);
  white-space: nowrap;
}
.diary-dream-links-sort {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(155, 89, 182, 0.35);
  background: rgba(10, 16, 28, 0.62);
  color: #eaf5ff;
  font-size: 13px;
  font-family: Arial, sans-serif;
  outline: none;
  cursor: pointer;
}
.diary-dream-links-sort:focus {
  border-color: rgba(155, 89, 182, 0.7);
  box-shadow: 0 0 0 2px rgba(155, 89, 182, 0.2);
}

/* ─── Oracle scope inline list ─── */
.diary-scope-list {
  margin: 6px 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(155, 89, 182, 0.3);
  background: rgba(10, 8, 20, 0.55);
  padding: 10px 14px;
}
.diary-scope-list-head {
  font-size: 11px; color: rgba(220, 234, 248, 0.65);
  margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.diary-scope-warn { color: #ff8fab; font-weight: 600; }
.diary-scope-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.diary-scope-row:last-child { border-bottom: none; }
.diary-scope-row-title {
  font-size: 12px; color: #eaf5ff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.diary-scope-row-date { font-size: 11px; color: rgba(220, 234, 248, 0.6); }
.diary-scope-remove {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 95, 95, 0.5);
  background: rgba(140, 26, 26, 0.45);
  color: #ffe7e7; font-size: 14px; line-height: 1;
  cursor: pointer; transition: all 0.18s;
}
.diary-scope-remove:hover { background: rgba(176, 35, 35, 0.7); }

.diary-btn-accent:disabled {
  opacity: 0.55; cursor: not-allowed; box-shadow: none; background: rgba(60, 40, 80, 0.35);
}

/* ─── How-to-read row hover → glow on the matching element ─── */
.diary-howto-row { cursor: help; transition: background 0.15s; border-radius: 8px; }
.diary-howto-row:hover { background: rgba(155, 89, 182, 0.15); }

@keyframes howtoGlowPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.55), 0 0 14px rgba(255, 209, 102, 0.35); }
  50%      { box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.95), 0 0 22px rgba(255, 209, 102, 0.6); }
}
.howto-glow {
  animation: howtoGlowPulse 1.1s ease-in-out infinite;
  border-radius: 8px;
  position: relative;
  z-index: 1;
}

/* ─── Registry sub-tabs: ico + label + count, all baseline-aligned ─── */
.diary-subtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.diary-subtab-ico { font-size: 14px; line-height: 1; }
.diary-subtab-label { line-height: 1; }
.diary-subtab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(220, 234, 248, 0.85);
  line-height: 1;
}
.diary-subtab.active .diary-subtab-count {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* ─── Registry: typed accents ─── */
.diary-entity-card-loc  { border-top: 2px solid rgba(255, 179, 110, 0.55); }
.diary-entity-card-char { border-top: 2px solid rgba(110, 195, 255, 0.55); }
.diary-entity-card-art  { border-top: 2px solid rgba(224, 170, 255, 0.55); }
.diary-entity-card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 16px; margin-right: 8px;
}
.diary-entity-card-loc .diary-entity-card-icon  { background: rgba(255, 179, 110, 0.18); }
.diary-entity-card-char .diary-entity-card-icon { background: rgba(110, 195, 255, 0.18); }
.diary-entity-card-art .diary-entity-card-icon  { background: rgba(224, 170, 255, 0.18); }

/* ─── Entity chip colour by type (chrono card) ─── */
.diary-entity-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; margin-right: 4px;
  border: 1px solid rgba(185, 215, 255, 0.18);
  background: rgba(10, 16, 30, 0.42);
  color: #9db4c9;
}
.diary-entity-chip.diary-chip-loc  { color: #ffd0a8; border-color: rgba(255, 179, 110, 0.28); background: rgba(255, 179, 110, 0.08); }
.diary-entity-chip.diary-chip-char { color: #d0efff; border-color: rgba(110, 195, 255, 0.28); background: rgba(110, 195, 255, 0.08); }
.diary-entity-chip.diary-chip-art  { color: #f0e0ff; border-color: rgba(224, 170, 255, 0.28); background: rgba(224, 170, 255, 0.10); }
/* Контейнер чипов под текстом сна в Хронографе: ровные отступы по обеим осям, чтобы не было «впритык». */
.diary-entities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 6px;
  margin-top: 2px;
  margin-bottom: 2px;
}
.diary-entities .diary-entity-chip { margin: 0; }
/* coloured stripe is rendered by .diary-top-link-marker; row keeps its full border */
.diary-top-link-icon {
  font-size: 17px; width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(255, 255, 255, 0.05);
}

/* ─── Registry: correlation chips ─── */
.diary-corr-row { display: flex; flex-wrap: wrap; gap: 4px; }
.diary-corr-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px;
  background: rgba(155, 89, 182, 0.12);
  border: 1px solid rgba(155, 89, 182, 0.32);
  color: #e0d0f8;
  white-space: nowrap;
}
.diary-corr-chip b { color: #ffd166; font-weight: 700; }
.diary-corr-empty { color: rgba(220, 234, 248, 0.4); }

/* ─── Registry: insight block (fixed height, internal scroll if long) ─── */
.diary-insight {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 209, 102, 0.3);
  background: rgba(255, 209, 102, 0.06);
  font-size: 12px;
  color: rgba(220, 234, 248, 0.85);
  line-height: 1.45;
  min-height: 0;
  /* Cap height ≈ 5 lines; scroll inside (critical on touch / nested modal scroll). */
  max-height: min(7.5em, 28vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 209, 102, 0.45) transparent;
}
.diary-entity-card > .diary-insight,
.diary-entity-card > .diary-insight-slot {
  min-height: 0;
}
.diary-insight::-webkit-scrollbar { width: 5px; }
.diary-insight::-webkit-scrollbar-thumb {
  background: rgba(255, 209, 102, 0.4);
  border-radius: 3px;
}
.diary-insight::-webkit-scrollbar-thumb:hover { background: rgba(255, 209, 102, 0.65); }
.diary-insight::-webkit-scrollbar-track { background: transparent; }
.diary-insight b { color: #ffd166; }
.diary-insight-empty {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
  color: rgba(220, 234, 248, 0.5);
}

/* ─── Oracle: scope-empty CTA + cached tag ─── */
.diary-scope-empty {
  padding: 14px;
  border-radius: 10px;
  background: rgba(10, 8, 20, 0.45);
  border: 1px dashed rgba(155, 89, 182, 0.35);
  color: rgba(220, 234, 248, 0.78);
  font-size: 13px;
  line-height: 1.5;
}
.diary-scope-empty b { color: #f5ebff; }
.diary-link-tab {
  color: #e0aaff;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.diary-link-tab:hover { color: #fff; }
.diary-oracle-cached-tag {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(141, 255, 188, 0.14);
  border: 1px solid rgba(141, 255, 188, 0.35);
  color: #8dffbc;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.diary-oracle-scope-head {
  font-size: 11px;
  color: rgba(220, 234, 248, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 14px 0 6px;
}

/* ──────────────────────────────────────────────────────────────
   Diary — Touch & Mobile polish
   - (hover: none): kill the lift/shadow that "sticks" on tap
   - (max-width: 768px): tablet/phone layout pass
   - (max-width: 520px): tightened phone-only layout
   ────────────────────────────────────────────────────────────── */

/* No-hover devices: drop transforms/shadows/colour shifts that get pinned
   on tap and look like "stuck pressed" until next tap. */
@media (hover: none) {
  .diary-card:hover,
  .diary-entity-card:hover,
  .diary-top-link:hover,
  .diary-dream-link-card:hover,
  .diary-tab:hover,
  .diary-subtab:hover,
  .diary-howto-row:hover,
  .diary-card-expand-btn:hover,
  .diary-show-graph-btn:hover,
  .diary-page-btn:hover,
  .diary-btn-secondary:hover,
  .diary-btn-accent:hover,
  .diary-scope-chip:hover,
  .diary-oracle-history-row:hover {
    transform: none !important;
    box-shadow: none !important;
  }
  .diary-card:hover            { background: rgba(12, 16, 28, 0.5); border-color: rgba(180, 220, 255, 0.1); }
  .diary-entity-card:hover     { background: rgba(12, 16, 28, 0.5); border-color: rgba(180, 220, 255, 0.1); }
  .diary-top-link:hover        { background: rgba(10, 14, 24, 0.5); border-color: rgba(255, 255, 255, 0.07); }
  .diary-dream-link-card:hover { background: rgba(10, 14, 24, 0.5); border-color: rgba(155, 89, 182, 0.22); }
}

/* Tablet & phone */
@media (max-width: 768px) {
  /* Modal — trim header so we don't waste vertical space on small screens. */
  .dream-diary-header {
    padding-bottom: 10px;
    margin-bottom: 12px;
  }
  .dream-diary-header h2 { font-size: 17px; }

  /* Tabs: horizontal scroll instead of wrapping to 2 rows. */
  .diary-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 12px;
    padding-bottom: 4px;
  }
  .diary-tabs::-webkit-scrollbar { display: none; }
  .diary-tab {
    flex-shrink: 0;
    padding: 10px 16px;
    font-size: 13px;
    min-height: 40px;
  }

  /* Search input — 16px prevents iOS Safari zoom-on-focus. */
  .diary-toolbar input[type="text"] {
    font-size: 16px;
    padding: 10px 14px;
    min-height: 44px;
  }
  /* Hint text only: smaller so the long Chronograph placeholder fits narrow widths;
     typed text stays 16px above — no extra zoom on focus. */
  .diary-toolbar input[type="text"]::placeholder {
    font-size: 11.5px;
    line-height: 1.35;
    opacity: 0.88;
  }
  .diary-toolbar input[type="text"]::-webkit-input-placeholder {
    font-size: 11.5px;
    line-height: 1.35;
    opacity: 0.88;
  }
  .diary-toolbar input[type="text"]::-moz-placeholder {
    font-size: 11.5px;
    line-height: 1.35;
    opacity: 0.88;
  }

  /* Toolbar: stack vertically; buttons span full width. */
  .diary-toolbar {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    /* Sticky to top of scroll area so action buttons stay reachable */
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(16, 14, 28, 0.92);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 10px 0;
  }
  .diary-btn-secondary,
  .diary-btn-accent,
  .diary-btn-danger {
    width: 100%;
    min-height: 44px;
    font-size: 13px;
  }

  /* Card touch targets: bigger checkbox, looser spacing. */
  .diary-card {
    padding: 12px 12px;
    gap: 10px;
  }
  .diary-mood-stripe {
    width: 8px;
    border-radius: 8px;
  }
  .diary-check {
    width: 24px; height: 24px;
    border-radius: 6px;
  }
  .diary-check:checked::after { font-size: 14px; }
  /* Title takes the full first row so it can wrap to ≤2 lines instead of
     getting cut to ellipsis. Badges drop to row 2 via flex-wrap on parent. */
  .diary-card-meta { align-items: flex-start; }
  .diary-card-title {
    flex: 1 1 100%;
    font-size: 14px;
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .diary-card-excerpt { font-size: 12.5px; }
  .diary-excerpt-toggle {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 12px;
  }
  .diary-card-dates { font-size: 12px; gap: 10px; }
  .diary-card-metrics {
    flex-wrap: wrap;
    gap: 10px;
  }
  .metric-mini { font-size: 12px; }
  .diary-card-expand-btn {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Registry sub-tabs — horizontal scroll if locale ever expands. */
  .diary-subtabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .diary-subtabs::-webkit-scrollbar { display: none; }
  .diary-subtab {
    flex-shrink: 0;
    min-height: 38px;
    padding: 8px 14px;
  }

  /* Registry cards: tighter padding + narrower bar label. */
  .diary-entity-card { padding: 12px 12px 10px; gap: 8px; }
  .diary-insight {
    max-height: min(9.5em, 34vh);
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }
  .diary-entity-bar { grid-template-columns: 64px 1fr auto; font-size: 11.5px; }
  .diary-entity-actions .diary-show-graph-btn {
    min-height: 40px;
    font-size: 12.5px;
  }
  .diary-show-graph-btn {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 12px;
  }

  /* Top-link rows: 2-line compact layout — 1st row [marker icon name degree],
     2nd row [sub  ✦button right-aligned]. */
  .diary-top-link {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 4px;
    padding: 10px 12px;
  }
  .diary-top-link-marker { grid-row: 1 / span 2; align-self: center; height: 36px; }
  .diary-top-link-icon   { grid-row: 1 / span 2; align-self: center; }
  .diary-top-link-text {
    grid-column: 3;
    grid-row: 1;
    overflow: hidden;
  }
  .diary-top-link-degree {
    grid-column: 4;
    grid-row: 1;
    align-self: center;
    font-size: 17px;
  }
  .diary-top-link .diary-show-graph-btn {
    grid-column: 3 / span 2;
    grid-row: 2;
    justify-self: stretch;
    min-height: 38px;
  }

  .diary-dream-link-pair {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .diary-dream-link-bridge {
    justify-self: center;
    transform: rotate(90deg);
  }
  .diary-dream-link-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .diary-dream-link-actions .diary-btn-secondary,
  .diary-dream-link-actions .diary-btn-accent {
    width: 100%;
    min-height: 44px;
  }
  .diary-dream-links-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .diary-dream-links-sort {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  /* Pagination — compact form on phones: "← 2 / 5 →". */
  .diary-pagination { padding: 8px 10px; gap: 8px; }
  .diary-page-btn   { min-height: 38px; padding: 8px 12px; font-size: 12px; }
  .diary-page-info  { font-size: 12px; }

  /* How-to-read body: 1 column on phones for legibility. */
  .diary-howto-grid { grid-template-columns: 1fr; gap: 6px; }
  .diary-howto-toggle { min-height: 44px; }

  /* Oracle prism labels — show only the two extremes; centre label hidden. */
  .diary-prism-labels span:nth-child(2) { display: none; }
  .diary-prism-labels { font-size: 12px; }
  .diary-prism-current { font-size: 13px; }

  /* Oracle scope row: still readable on narrow widths. */
  .diary-scope-row {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    row-gap: 2px;
    padding: 8px 0;
  }
  .diary-scope-row .diary-mood-badge { grid-column: 1; grid-row: 1; }
  .diary-scope-row-title             { grid-column: 2; grid-row: 1; }
  .diary-scope-row-date              { grid-column: 2; grid-row: 2; font-size: 11.5px; }
  .diary-scope-remove                { grid-column: 3; grid-row: 1 / span 2; min-width: 32px; min-height: 32px; }

  /* Mood/atmo badges — slightly larger for readability. */
  .diary-mood-badge,
  .diary-atmo-badge { font-size: 11px; padding: 3px 9px; }

  /* Touch-friendly chrono mini-button at end of metrics row. */
  .diary-card-expand-btn { margin-left: auto; }
}

@media (max-width: 520px) {
  /* Phone-only further tightening. */
  .diary-toolbar input[type="text"] {
    padding-left: 10px;
    padding-right: 10px;
  }
  .diary-toolbar input[type="text"]::placeholder {
    font-size: 10.5px;
    letter-spacing: -0.015em;
  }
  .diary-toolbar input[type="text"]::-webkit-input-placeholder {
    font-size: 10.5px;
    letter-spacing: -0.015em;
  }
  .diary-toolbar input[type="text"]::-moz-placeholder {
    font-size: 10.5px;
    letter-spacing: -0.015em;
  }
  .diary-tab { padding: 9px 14px; font-size: 12.5px; }
  .diary-card { padding: 10px 10px; gap: 8px; }
  .diary-card-meta { gap: 6px; }
  .diary-entity-card-name { font-size: 13.5px; }
  .diary-entity-grid { gap: 10px; }
  .diary-howto-toggle { font-size: 12.5px; padding: 10px 12px; }
  .diary-howto-body, .diary-howto.open .diary-howto-body { padding-left: 10px; padding-right: 10px; }
  .diary-prism-wrap { padding: 12px; }
  .diary-oracle-output { padding: 12px; }
}

/* Глобальный тост «оракул трудится» (index.html + дневник) */
.dr-ai-wait-toast {
  position: fixed;
  z-index: 12150;
  max-width: min(360px, 92vw);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.35;
  color: #f0f4ff;
  background: rgba(18, 22, 38, 0.92);
  border: 1px solid rgba(120, 160, 255, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.dr-ai-wait-toast--visible {
  opacity: 1;
  transform: translateY(0);
}
.dr-ai-wait-toast:not(.dr-ai-wait-toast--mobile) {
  top: max(16px, env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
}
.dr-ai-wait-toast--mobile {
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  width: auto;
  max-width: none;
  box-sizing: border-box;
  transform: translateY(8px);
}
.dr-ai-wait-toast--mobile.dr-ai-wait-toast--visible {
  transform: translateY(0);
}
@media (max-width: 768px) {
  .dr-ai-wait-toast {
    background: rgb(18, 22, 38) !important;
    background-image: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}
.perf-lite .dr-ai-wait-toast,
.android-lite .dr-ai-wait-toast {
  background: rgb(18, 22, 38) !important;
  background-image: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Панель сна (граф): превью текста + «Показать всё»; в открытом виде без внутреннего скролла — крутится вся панель/модалка */
.dream-panel-text-shell {
  margin-bottom: 16px;
}
.dream-panel-text-wrap {
  overflow: hidden;
}
.dream-panel-text-shell:not(.dream-panel-text-shell--open) .dream-panel-text-wrap {
  max-height: 12em;
}
.dream-panel-text-shell--open .dream-panel-text-wrap {
  max-height: none;
  overflow: visible;
}
.dream-panel-text-toggle {
  margin-top: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(110, 195, 255, 0.38);
  background: rgba(70, 140, 220, 0.12);
  color: #c8dff5;
  font-family: Arial, sans-serif;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.dream-panel-text-toggle:hover {
  background: rgba(70, 140, 220, 0.22);
  border-color: rgba(110, 195, 255, 0.55);
  color: #eaf5ff;
}

/* ─── Дневник: вкладка «Визуализации» (альбом AI-картинок) ─── */
.diary-viz-retention-warning {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 196, 86, 0.55);
  background: linear-gradient(
    135deg,
    rgba(255, 196, 86, 0.14),
    rgba(230, 126, 80, 0.12)
  );
  box-shadow: 0 0 18px rgba(255, 196, 86, 0.12);
}
.diary-viz-retention-warning__title {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffd86b;
}
.diary-viz-retention-warning__text {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(248, 250, 255, 0.92);
}
.diary-viz-retention-warning__pass {
  color: #ffe9b3;
  font-weight: 700;
}
.diary-viz-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.diary-viz-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.diary-viz-pick {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  border-radius: 8px;
  background: rgba(8, 10, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.diary-viz-pick:hover {
  border-color: rgba(110, 195, 255, 0.45);
}
.diary-viz-cb {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: #9b59b6;
}
.diary-viz-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.diary-viz-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(120, 160, 255, 0.28);
  background: rgba(22, 28, 48, 0.65);
  color: #c8dff5;
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}
.diary-viz-filter:hover {
  border-color: rgba(155, 89, 182, 0.45);
  color: #eaf5ff;
}
.diary-viz-filter.is-active {
  border-color: rgba(155, 89, 182, 0.65);
  background: rgba(155, 89, 182, 0.22);
  color: #f6ecff;
  box-shadow: 0 0 14px rgba(155, 89, 182, 0.2);
}
.diary-viz-filter-n {
  font-weight: 700;
  font-size: 11px;
  opacity: 0.88;
  color: rgba(200, 223, 245, 0.75);
}
.diary-viz-filter.is-active .diary-viz-filter-n {
  color: rgba(246, 236, 255, 0.95);
}
.diary-viz-loading {
  padding: 20px 0;
}
.diary-viz-empty {
  margin-top: 8px;
}
.diary-viz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
  padding-bottom: 8px;
}
.diary-viz-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid rgba(130, 160, 255, 0.22);
  background: linear-gradient(165deg, rgba(20, 26, 44, 0.92), rgba(14, 18, 32, 0.88));
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  min-width: 0;
}
.diary-viz-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: rgba(8, 10, 20, 0.85);
  cursor: zoom-in;
}
.diary-viz-thumb:focus-visible {
  outline: 2px solid rgba(110, 195, 255, 0.65);
  outline-offset: 2px;
}
.diary-viz-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.diary-viz-thumb-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  color: rgba(157, 180, 201, 0.65);
}
.diary-viz-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
}
.diary-viz-badge--dream {
  color: #e0c3ff;
  background: rgba(88, 28, 135, 0.55);
  border-color: rgba(200, 170, 255, 0.35);
}
.diary-viz-badge--loc {
  color: #9be7ff;
  background: rgba(12, 74, 110, 0.55);
  border-color: rgba(120, 200, 255, 0.35);
}
.diary-viz-badge--char {
  color: #b8f5c8;
  background: rgba(18, 90, 50, 0.55);
  border-color: rgba(120, 255, 180, 0.28);
}
.diary-viz-badge--art {
  color: #ffe6a7;
  background: rgba(110, 70, 20, 0.55);
  border-color: rgba(255, 200, 120, 0.35);
}
.diary-viz-badge--misc {
  color: #dce4f0;
  background: rgba(60, 70, 90, 0.55);
}
.diary-viz-card-body {
  padding: 10px 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
}
.diary-viz-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #f0f4ff;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}
.diary-viz-card-date {
  font-size: 11px;
  color: rgba(157, 180, 201, 0.78);
}
.diary-viz-card-actions {
  margin-top: auto;
  padding-top: 4px;
}
.diary-viz-card-actions .diary-btn-secondary {
  width: 100%;
  text-align: center;
  font-size: 11px;
  padding: 7px 8px;
}
.diary-viz-lightbox {
  border: none;
  padding: 0;
  max-width: calc(100vw - 16px);
  background: transparent;
}
.diary-viz-lightbox::backdrop {
  background: rgba(4, 6, 14, 0.78);
  backdrop-filter: blur(4px);
}
.diary-viz-lightbox-inner {
  position: relative;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(130, 160, 255, 0.35);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  background: rgba(12, 14, 24, 0.92);
}
.diary-viz-lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 12, 22, 0.75);
  color: #eaf5ff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.diary-viz-lightbox-close:hover {
  background: rgba(40, 44, 62, 0.9);
}
.diary-viz-lightbox-img {
  display: block;
  max-width: min(92vw, 920px);
  max-height: min(82vh, 920px);
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  background: #05060c;
}
.diary-viz-lightbox-caption {
  margin: 0;
  padding: 10px 14px 14px;
  font-size: 13px;
  line-height: 1.4;
  color: #dce8f8;
  text-align: center;
}
@media (max-width: 768px) {
  .diary-viz-grid {
    grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
    gap: 10px;
  }
  .diary-viz-filter {
    font-size: 11.5px;
    padding: 8px 11px;
  }
}
