/* AI Study panel: follows the theme variables copied onto body by cloud-sync.js */

.selection-toolbar .ai-study-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto !important;
  width: auto !important;
  padding: 0 10px !important;
  color: var(--accent, #7c5cff);
}

.selection-toolbar .ai-study-tool .lw-ai-tool-label {
  font-size: 12px;
  font-weight: 650;
}

.lw-ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 100030;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 16px;
  background: rgba(8, 12, 20, 0.45);
}

.lw-ai-overlay[hidden] {
  display: none !important;
}

.lw-ai-card {
  display: flex;
  flex-direction: column;
  width: min(480px, 100%);
  max-height: calc(100vh - 32px);
  color: var(--text, #e8edf8);
  background: var(--surface-raised, #172033);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.lw-ai-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
}

.lw-ai-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent, #7c5cff);
}

.lw-ai-header h2 {
  margin: 2px 0 0;
  font-size: 20px;
}

.lw-ai-quote {
  margin: 4px 0 0;
  font-size: 14px;
  font-style: italic;
  color: var(--text-muted, #94a3b8);
}

.lw-ai-close,
.lw-ai-copy,
.lw-ai-ref {
  color: var(--text, #e8edf8);
  background: var(--surface-hover, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  border-radius: 8px;
  font-weight: 650;
  cursor: pointer;
}

.lw-ai-close,
.lw-ai-copy {
  min-height: 36px;
  padding: 0 12px;
}

.lw-ai-body {
  flex: 1;
  overflow: auto;
  padding: 6px 16px 14px;
  font-size: 15px;
  line-height: 1.55;
}

.lw-ai-summary {
  margin: 10px 0 4px;
  font-size: 16px;
  font-weight: 550;
}

.lw-ai-section h3 {
  margin: 16px 0 6px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #94a3b8);
}

.lw-ai-section p {
  margin: 0 0 8px;
}

.lw-ai-section ul {
  margin: 0;
  padding-left: 18px;
}

.lw-ai-section li {
  margin-bottom: 6px;
}

.lw-ai-words,
.lw-ai-refs {
  list-style: none;
  padding: 0 !important;
}

.lw-ai-words li {
  padding: 8px 10px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: 10px;
  background: var(--surface, rgba(255, 255, 255, 0.03));
}

.lw-ai-words p {
  margin: 4px 0 0;
}

.lw-ai-word {
  font-size: 20px;
  font-weight: 600;
  margin-right: 8px;
}

.lw-ai-translit {
  font-style: italic;
  margin-right: 8px;
}

.lw-ai-strongs {
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 6px;
  color: var(--text-muted, #94a3b8);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
}

.lw-ai-refs li {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
}

.lw-ai-ref {
  justify-self: start;
  min-height: 30px;
  padding: 0 10px;
  color: var(--accent, #7c5cff);
}

.lw-ai-webster {
  max-height: 14em;
  overflow: auto;
  padding: 8px 10px;
  font-size: 14px;
  border-left: 3px solid var(--accent, #7c5cff);
  background: var(--surface, rgba(255, 255, 255, 0.03));
  border-radius: 0 8px 8px 0;
}

.lw-ai-webster p {
  margin: 0 0 6px;
}

.lw-ai-caveat,
.lw-ai-meta {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-muted, #94a3b8);
}

.lw-ai-error {
  margin: 14px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, #e11d48 50%, transparent);
  background: color-mix(in srgb, #e11d48 12%, transparent);
}

.lw-ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--text-muted, #94a3b8);
}

.lw-ai-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: lw-ai-spin 0.8s linear infinite;
}

@keyframes lw-ai-spin {
  to { transform: rotate(360deg); }
}

.lw-ai-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.1));
}

.lw-feature-row.is-locked {
  opacity: 0.6;
}

@media (max-width: 820px) {
  .lw-ai-overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .lw-ai-card {
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
  }

  .selection-toolbar .ai-study-tool .lw-ai-tool-label {
    display: none;
  }
}

.app-shell.presentation-mode ~ .lw-ai-overlay,
html[data-tools-off~="aiStudy"] .lw-ai-overlay {
  display: none !important;
}
