/* ==============================================================
   Study Hub — AI Notes Engine
   --------------------------------------------------------------
   Styles for the notes generator inside #notes-generator on
   index.html. Self-contained: it only relies on the page's dark
   palette and the Plus Jakarta Sans font already loaded there.
   ============================================================== */

.ain-shell {
  --ain-line: rgba(148, 163, 184, 0.16);
  --ain-line-strong: rgba(148, 163, 184, 0.3);
  --ain-ink: #e6edf7;
  --ain-dim: #93a4bd;
  --ain-blue: #3b82f6;
  --ain-cyan: #22d3ee;
  --ain-violet: #8b5cf6;
  --ain-green: #34d399;
  --ain-amber: #fbbf24;
  position: relative;
  border-radius: 28px;
  border: 1px solid var(--ain-line);
  background:
    radial-gradient(900px 420px at 12% -12%, rgba(59, 130, 246, 0.16), transparent 62%),
    radial-gradient(700px 380px at 92% 6%, rgba(139, 92, 246, 0.14), transparent 60%),
    linear-gradient(180deg, rgba(9, 13, 24, 0.94), rgba(5, 7, 13, 0.96));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  color: var(--ain-ink);
}

.ain-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(620px 300px at 50% -4%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(620px 300px at 50% -4%, #000 20%, transparent 78%);
  pointer-events: none;
}

.ain-inner {
  position: relative;
  z-index: 1;
  padding: clamp(22px, 4vw, 44px);
}

/* ---------------- header ---------------- */

.ain-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.7px;
  text-transform: uppercase;
  color: var(--ain-cyan);
  background: rgba(34, 211, 238, 0.09);
  border: 1px solid rgba(34, 211, 238, 0.24);
  padding: 6px 13px;
  border-radius: 9999px;
}

.ain-eyebrow i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ain-green);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
}

.ain-title {
  margin: 16px 0 10px;
  font-size: clamp(1.7rem, 4.4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.12;
}

.ain-title em {
  font-style: normal;
  background: linear-gradient(100deg, #7dd3fc, #a78bfa 55%, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ain-lede {
  margin: 0;
  max-width: 620px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ain-dim);
}

/* ---------------- search row ---------------- */

.ain-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  margin-top: 28px;
}

.ain-field {
  position: relative;
  min-width: 0;
}

.ain-field svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #64748b;
  pointer-events: none;
}

.ain-input,
.ain-select {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ain-ink);
  background: rgba(2, 6, 16, 0.72);
  border: 1px solid var(--ain-line);
  border-radius: 16px;
  padding: 17px 18px 17px 46px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.ain-input::placeholder { color: #5c6b83; }

.ain-input:focus,
.ain-select:focus {
  border-color: rgba(59, 130, 246, 0.65);
  background: rgba(2, 6, 16, 0.9);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
}

.ain-select {
  padding: 17px 42px 17px 16px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.ain-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--ain-blue), var(--ain-violet));
  border: 0;
  border-radius: 16px;
  padding: 17px 28px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 12px 32px rgba(59, 130, 246, 0.34);
  transition: transform 0.2s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.2s, filter 0.2s;
}

.ain-go:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 18px 42px rgba(59, 130, 246, 0.46);
}

.ain-go:disabled { opacity: 0.6; cursor: progress; }

.ain-go .ain-spin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: ainSpin 0.7s linear infinite;
}

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

.ain-hint {
  margin: 10px 2px 0;
  font-size: 12.5px;
  color: #64748b;
}

.ain-hint kbd {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.13);
  border: 1px solid var(--ain-line);
  border-radius: 6px;
  padding: 1px 6px;
}

/* ---------------- suggestion chips ---------------- */

.ain-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.ain-chip {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: #b6c4d8;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--ain-line);
  border-radius: 9999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s, transform 0.18s;
}

.ain-chip:hover {
  color: #eaf2ff;
  border-color: rgba(96, 165, 250, 0.5);
  background: rgba(59, 130, 246, 0.14);
  transform: translateY(-1px);
}

/* ---------------- progress ---------------- */

.ain-progress {
  margin-top: 26px;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid var(--ain-line);
  background: rgba(2, 6, 16, 0.55);
}

.ain-progress-bar {
  height: 5px;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.15);
  overflow: hidden;
}

.ain-progress-fill {
  height: 100%;
  width: 8%;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--ain-blue), var(--ain-cyan));
  transition: width 0.5s ease;
}

.ain-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 14px;
  font-size: 12.5px;
  color: #64748b;
}

.ain-step { display: inline-flex; align-items: center; gap: 7px; }
.ain-step b { font-weight: 600; }

.ain-step span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.3);
  flex: 0 0 auto;
}

.ain-step.is-running { color: #bae6fd; }
.ain-step.is-running span { background: var(--ain-cyan); animation: ainPulse 1s ease-in-out infinite; }
.ain-step.is-done { color: var(--ain-green); }
.ain-step.is-done span { background: var(--ain-green); }

@keyframes ainPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(34, 211, 238, 0); }
}

/* ---------------- errors / empty ---------------- */

.ain-note {
  margin-top: 24px;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid var(--ain-line);
  background: rgba(2, 6, 16, 0.5);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ain-dim);
}

.ain-note.is-error {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
  color: #fecaca;
}

.ain-note strong { color: #fff; }

/* ---------------- result ---------------- */

.ain-result { margin-top: 28px; }

.ain-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ain-line);
}

.ain-result-title {
  margin: 0;
  font-size: clamp(1.25rem, 2.6vw, 1.6rem);
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.25;
}

.ain-result-desc {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--ain-dim);
}

.ain-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ain-act {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.09);
  border: 1px solid var(--ain-line);
  border-radius: 11px;
  padding: 9px 14px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.ain-act:hover { color: #fff; border-color: var(--ain-line-strong); background: rgba(148, 163, 184, 0.16); }
.ain-act.is-done { color: var(--ain-green); border-color: rgba(52, 211, 153, 0.45); }

.ain-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.ain-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-size: 12px;
  color: var(--ain-dim);
  background: rgba(148, 163, 184, 0.07);
  border: 1px solid var(--ain-line);
  border-radius: 10px;
  padding: 7px 12px;
}

.ain-stat b { font-size: 13.5px; font-weight: 800; color: #eaf2ff; }

/* ---------------- tabs ---------------- */

.ain-tabs {
  display: flex;
  gap: 4px;
  margin: 22px 0 4px;
  padding: 4px;
  border-radius: 13px;
  border: 1px solid var(--ain-line);
  background: rgba(2, 6, 16, 0.5);
  overflow-x: auto;
  scrollbar-width: none;
}

.ain-tabs::-webkit-scrollbar { display: none; }

.ain-tab {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ain-dim);
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.18s, background 0.18s;
}

.ain-tab:hover { color: #e2e8f0; }
.ain-tab.is-active { color: #fff; background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(139, 92, 246, 0.85)); }

.ain-panel { padding-top: 20px; }
.ain-panel[hidden] { display: none; }

/* ---------------- notes blocks ---------------- */

.ain-block + .ain-block { margin-top: 26px; }

.ain-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.ain-block-head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #dbe6f6;
}

.ain-block-head em {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: #7c8ba4;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 9999px;
  padding: 3px 9px;
}

.ain-rule { flex: 1; height: 1px; background: var(--ain-line); }

.ain-lead {
  font-size: 15.5px;
  line-height: 1.8;
  color: #d7e2f1;
}

.ain-list { display: grid; gap: 11px; }

.ain-point {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  font-size: 14.5px;
  line-height: 1.75;
  color: #cbd9ea;
  background: rgba(148, 163, 184, 0.05);
  border: 1px solid var(--ain-line);
  border-left: 3px solid rgba(59, 130, 246, 0.7);
  border-radius: 12px;
  padding: 13px 16px;
}

.ain-point b {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--ain-blue), var(--ain-violet));
}

.ain-point.is-fact { border-left-color: rgba(52, 211, 153, 0.75); }
.ain-point.is-fact b { background: linear-gradient(135deg, #10b981, #22d3ee); }

/* timeline */

.ain-timeline {
  position: relative;
  display: grid;
  gap: 14px;
  padding-left: 26px;
}

.ain-timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, var(--ain-cyan), var(--ain-violet));
  opacity: 0.5;
}

.ain-era {
  position: relative;
  font-size: 14px;
  line-height: 1.7;
  color: #cbd9ea;
}

.ain-era::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #0b1120;
  border: 2px solid var(--ain-cyan);
}

.ain-era b { color: #7dd3fc; font-weight: 800; margin-right: 6px; }

/* glossary */

.ain-glossary { display: grid; gap: 10px; }

.ain-term {
  border: 1px solid var(--ain-line);
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.05);
  padding: 13px 16px;
}

.ain-term dt {
  font-size: 14px;
  font-weight: 800;
  color: #a5b4fc;
  margin-bottom: 5px;
}

.ain-term dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: #c6d4e6;
}

/* flashcards */

.ain-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 12px;
}

.ain-card {
  position: relative;
  min-height: 148px;
  border-radius: 16px;
  border: 1px solid var(--ain-line);
  background: linear-gradient(160deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.9));
  padding: 18px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.2s, transform 0.2s;
}

.ain-card:hover { border-color: rgba(139, 92, 246, 0.55); transform: translateY(-2px); }

.ain-card-front {
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.4;
  color: #e8eeF9;
}

.ain-card-back {
  margin-top: 12px;
  font-size: 13.5px;
  line-height: 1.7;
  color: #a9bacf;
}

.ain-card-tap {
  position: absolute;
  right: 14px;
  bottom: 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #64748b;
}

.ain-card.is-open .ain-card-back { color: #cbd9ea; }
.ain-card.is-open .ain-card-tap { color: var(--ain-violet); }
.ain-card:not(.is-open) .ain-card-back { filter: blur(5px); user-select: none; opacity: 0.55; }

/* quiz */

.ain-quiz { display: grid; gap: 14px; }

.ain-q {
  border: 1px solid var(--ain-line);
  border-radius: 16px;
  background: rgba(148, 163, 184, 0.05);
  padding: 16px 18px;
}

.ain-q-text { font-size: 14.5px; font-weight: 700; line-height: 1.7; color: #e2ebf8; }
.ain-q-text u { text-decoration: none; color: var(--ain-cyan); border-bottom: 2px dashed rgba(34, 211, 238, 0.6); }

.ain-opts { display: grid; gap: 8px; margin-top: 12px; }

.ain-opt {
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: #c5d3e6;
  background: rgba(2, 6, 16, 0.5);
  border: 1px solid var(--ain-line);
  border-radius: 11px;
  padding: 11px 14px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.ain-opt:hover:not(:disabled) { border-color: var(--ain-line-strong); color: #fff; }
.ain-opt:disabled { cursor: default; }
.ain-opt.is-right { color: #bbf7d0; border-color: rgba(52, 211, 153, 0.65); background: rgba(52, 211, 153, 0.13); }
.ain-opt.is-wrong { color: #fecaca; border-color: rgba(248, 113, 113, 0.6); background: rgba(248, 113, 113, 0.11); }

.ain-quiz-score {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ain-amber);
  margin-top: 4px;
}

/* sources */

.ain-sources { display: grid; gap: 10px; }

.ain-source {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--ain-line);
  border-radius: 14px;
  padding: 13px 15px;
  background: rgba(148, 163, 184, 0.05);
  text-decoration: none;
  transition: border-color 0.18s, background 0.18s;
}

.ain-source:hover { border-color: rgba(59, 130, 246, 0.5); background: rgba(59, 130, 246, 0.1); }

.ain-source-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #334155, #1e293b);
}

.ain-source b { display: block; font-size: 13.5px; font-weight: 700; color: #dbe6f6; }
.ain-source span { display: block; margin-top: 3px; font-size: 12.5px; color: var(--ain-dim); line-height: 1.55; }

/* ---------------- recent ---------------- */

.ain-recent { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--ain-line); }

.ain-recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ain-recent-head h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #7c8ba4;
}

.ain-clear {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 2px 4px;
}

.ain-clear:hover { color: #fca5a5; }

/* ---------------- responsive ---------------- */

@media (max-width: 860px) {
  .ain-search { grid-template-columns: minmax(0, 1fr) auto; }
  .ain-field { grid-column: 1 / -1; }
  .ain-go { width: 100%; }
}

@media (max-width: 520px) {
  .ain-inner { padding: 20px 16px; }
  .ain-shell { border-radius: 20px; }
  .ain-point { padding: 12px 13px; font-size: 14px; }
  .ain-tab { padding: 9px 12px; font-size: 12.5px; }
  .ain-cards { grid-template-columns: 1fr; }
  .ain-actions { width: 100%; }
  .ain-act { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .ain-go, .ain-chip, .ain-card, .ain-act { transition: none; }
  .ain-go .ain-spin, .ain-step.is-running span { animation-duration: 1.6s; }
}
