@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

:root {
  color-scheme: light;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --bg: #eef2f7;
  --panel: #ffffff;
  --border: #d6dbe6;
  --text: #0f172a;
  --muted: #4b5563;
  --sidebar-width: 320px;
  --chat-width: 360px;
  --chat-flyout-width: var(--chat-width);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

body.premium-page {
  overflow: auto;
}

body.sidebar-open {
  overflow: hidden;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--chat-width);
  min-height: 100vh;
  height: 100vh;
  background: #ffffff;
  position: relative;
}

.no-select {
  user-select: none;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #f8fafc;
  padding: 10px 10px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100vh;
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease;
  grid-column: 1;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 2;
  padding-bottom: 4px;
}

.nav-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.premium-panel {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.premium-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: none;
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 13px;
  color: #0f172a;
  cursor: pointer;
}

.premium-toggle:hover,
.premium-toggle:focus-visible {
  background: #eef2ff;
  outline: none;
}

.premium-toggle-indicator {
  transform: rotate(90deg);
  transition: transform 0.2s ease;
  color: var(--muted);
}

.premium-panel[data-state='collapsed'] .premium-toggle-indicator {
  transform: rotate(0deg);
}

.premium-panel[data-state='collapsed'] .premium-toggle {
  background: #ffffff;
  border: 1px dashed #d9e0ea;
}

.premium-panel[data-state='collapsed'] .premium-collapsible {
  display: none;
}

.premium-toggle.has-premium {
  background: linear-gradient(135deg, #fef3c7, #fffbeb);
  border: 1px solid #fbbf24;
  color: #92400e;
}

.premium-collapsible {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.premium-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.premium-banner {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #0f172a;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #fbbf24;
}

.premium-status-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.premium-status-form.is-loading {
  opacity: 0.75;
  pointer-events: none;
}

.premium-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.premium-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.premium-input-row input {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid #d9e0ea;
  font-size: 13px;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.2);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-strong);
  outline: none;
}

.premium-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.premium-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.premium-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.premium-actions .primary-button {
  width: 100%;
}

.premium-link:hover,
.premium-link:focus-visible {
  text-decoration: underline;
}

.button-icon {
  font-size: 14px;
  line-height: 1;
}

.premium-status-message {
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}

.premium-status-message[data-variant='error'] {
  color: #dc2626;
}

.premium-status-message[data-variant='success'] {
  color: #16a34a;
}

.auth-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  background: #f8fafc;
}

.auth-user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.auth-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-email {
  font-weight: 700;
  color: #0f172a;
  word-break: break-all;
  font-size: 12px;
}

.secondary-button {
  background: #eef2ff;
  color: #312e81;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: #e0e7ff;
  outline: none;
}

.logout-button {
  padding: 8px 10px;
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #312e81;
}

.logout-button:hover,
.logout-button:focus-visible {
  background: #e0e7ff;
}

.helper-text {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.debug-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #d9e0ea;
  background: #f8fafc;
  font-size: 11px;
  color: #0f172a;
  max-height: 120px;
  overflow-y: auto;
}

.debug-log-entry {
  word-break: break-word;
}

.search-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #ffffff;
  border: 1px solid #d9e0ea;
  border-radius: 6px;
}

.icon-button {
  border: 1px solid #d9e0ea;
  background: #ffffff;
  border-radius: 6px;
  padding: 7px 9px;
  cursor: pointer;
  color: #111827;
  font-weight: 700;
  line-height: 1;
  min-width: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: #b9c4d6;
  background: #f7f9fc;
  outline: none;
}

.sidebar-toggle-floating {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  z-index: 14;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
  display: none;
  padding: 14px 6px;
  min-width: unset;
  width: 28px;
  border-radius: 0 10px 10px 0;
}

.sidebar-toggle-floating.visible {
  display: inline-flex;
}

.search-box svg {
  width: 18px;
  height: 18px;
  color: #6b7280;
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  width: 100%;
  color: var(--text);
}

.nav-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.nav-scroll {
  overflow: auto;
  padding-right: 0;
  flex: 1;
  min-height: 0;
}

.nav-list {
  list-style: none;
  padding: 0 2px 10px 2px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-section {
  --section-color: var(--accent);
}

.nav-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 12px;
  font-weight: 700;
  color: var(--section-color);
  padding: 7px 10px 6px 8px;
  text-transform: none;
  letter-spacing: 0.01em;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--section-color) 12%, #f8fafc);
  z-index: 1;
  border: none;
  cursor: pointer;
  text-align: left;
  border-left: 3px solid var(--section-color);
}

.nav-section-heading:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--section-color) 40%, #000000);
  outline-offset: 2px;
}

.nav-section-heading .nav-section-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  color: currentColor;
  transition: transform 0.15s ease;
  transform: rotate(90deg);
}

.nav-section.is-collapsed .nav-section-arrow {
  transform: rotate(0deg);
}

.nav-section-heading::first-letter {
  font-weight: 800;
}

.nav-section-list,
.nav-sublist {
  list-style: none;
  margin: 0;
  padding: 2px 0 4px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section.is-collapsed .nav-section-list {
  display: none;
}

.nav-item {
  display: flex;
  flex-direction: column;
}

.nav-link {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  padding: 5px 10px 5px 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: background 0.12s ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: rgba(37, 99, 235, 0.08);
  outline: none;
}

.nav-label {
  min-width: 28px;
  height: 22px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--section-color) 30%, #ffffff);
  color: var(--section-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  padding: 0 6px;
}

.nav-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-title {
  font-weight: 600;
  color: #0f172a;
  font-size: 13px;
}

.nav-sublist {
  padding-left: 14px;
  padding-right: 6px;
}

.nav-link.is-subtable .nav-label {
  font-weight: 700;
  font-style: normal;
}

.nav-link.is-subtable .nav-title {
  font-style: italic;
  font-weight: 500;
}

.nav-link.is-subtable {
  padding-left: 10px;
}

.nav-section[data-theme='algemeen'] {
  --section-color: #c94195;
}

.nav-section[data-theme='natuurkunde'] {
  --section-color: #0163ac;
}

.nav-section[data-theme='wiskunde'] {
  --section-color: #a0341a;
}

.nav-section[data-theme='scheikunde'] {
  --section-color: #ff3b2d;
}

.nav-section[data-theme='biologie'] {
  --section-color: #2c9a44;
}

.nav-section[data-theme='register'] {
  --section-color: #aa9b88;
}

.layout.sidebar-collapsed {
  grid-template-columns: 0px 1fr var(--chat-width);
}

.layout.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.layout.chat-collapsed {
  grid-template-columns: var(--sidebar-width) 1fr 0px;
}

.layout.sidebar-collapsed.chat-collapsed {
  grid-template-columns: 0px 1fr 0px;
}

.layout.chat-collapsed .chat-sidebar {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 11;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.nav-dialog {
  position: fixed;
  inset: 0;
  background: rgba(12, 20, 38, 0.45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 15;
}

.upgrade-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 16;
}

.upgrade-modal.visible {
  display: flex;
}

.upgrade-modal-content {
  width: min(760px, 92vw);
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 90vh;
  overflow: auto;
}

.upgrade-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.upgrade-modal-title {
  font-size: 16px;
  font-weight: 700;
}

.upgrade-modal-text {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.plus-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.plus-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
}

.plus-card.plus {
  background: #fefce8;
  border-color: #facc15;
}

.plus-card-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.plus-card ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text);
}

.plus-details {
  display: grid;
  gap: 10px;
}

.plus-detail {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  background: #ffffff;
}

.plus-detail-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}

.plus-detail ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted);
}

.upgrade-checkout {
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
  display: grid;
  gap: 8px;
}

.plus-account-panel {
  border-top: 1px dashed #d1d5db;
  padding-top: 12px;
  display: grid;
  gap: 8px;
}

.plus-account-title {
  font-weight: 700;
  font-size: 14px;
}

.plus-provider-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.upgrade-email-input {
  padding: 9px 10px;
  border: 1px solid #d9e0ea;
  font-size: 13px;
}

.upgrade-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.upgrade-actions .primary-button,
.upgrade-actions .secondary-button {
  width: 100%;
}

.upgrade-modal .premium-status-message {
  min-height: unset;
}

.sidebar .search-box,
.sidebar .icon-button,
.sidebar .premium-panel,
.sidebar .premium-toggle,
.sidebar .premium-banner,
.sidebar .premium-input-row input,
.sidebar .primary-button,
.sidebar .secondary-button,
.sidebar .auth-user-row,
.sidebar .nav-section-heading {
  border-radius: 0;
}

.sidebar-toggle-floating {
  border-radius: 0 10px 10px 0;
}

.upgrade-email-input {
  border-radius: 0;
}

.upgrade-modal-content {
  border-radius: 10px;
}

.upgrade-modal .icon-button,
.upgrade-modal .primary-button,
.upgrade-modal .secondary-button {
  border-radius: 8px;
}
.nav-dialog.visible {
  display: flex;
}

body.nav-dialog-open .chat-toggle-floating {
  display: none;
}

.nav-dialog-content {
  width: min(1100px, 92vw);
  height: min(86vh, 900px);
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nav-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px 16px;
  border-bottom: 1px solid #e3e8f2;
}

.nav-dialog-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-dialog-title {
  font-weight: 700;
  font-size: 16px;
}

.nav-dialog-toggle {
  border: 1px solid #d9e0ea;
  background: #f8fafc;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #0f172a;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-dialog-toggle:hover,
.nav-dialog-toggle:focus-visible {
  background: #eef2ff;
  border-color: #c4cff1;
  outline: none;
}

.premium-panel.is-hidden {
  display: none;
}

.nav-dialog-search {
  border-radius: 0;
  border: none;
  border-bottom: 1px solid #e3e8f2;
}

.nav-dialog-list-wrapper {
  flex: 1;
  overflow: auto;
  padding: 8px 10px 12px 10px;
}

.viewer {
  display: flex;
  flex-direction: column;
  grid-column: 2;
  min-height: 100vh;
  background: #ffffff;
}

.viewer-area {
  flex: 1;
  background: #111827;
  display: flex;
  position: relative;
}

.viewer-frame-wrapper {
  flex: 1;
  position: relative;
  background: #1f2937;
}

.viewer-frame-wrapper iframe {
  border: none;
  width: 100%;
  height: 100%;
  background: #111827;
}

.footer-note {
  position: fixed;
  bottom: 12px;
  right: 14px;
  background: rgba(17, 24, 39, 0.8);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: default;
}

.layout:not(.chat-collapsed) ~ .footer-note {
  right: 50%;
  transform: translateX(50%);
}

.chat-sidebar {
  border-left: 1px solid var(--border);
  background: #f8fafc;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease;
  grid-column: 3;
}

.chat-embed {
  width: 100%;
  height: 100%;
  flex: 1;
}

.chat-embed iframe,
.chat-embed > div {
  width: 100%;
  height: 100%;
}

.chat-toggle-floating {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 20;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border: none;
  border-radius: 10px 0 0 10px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.35);
}

.chat-toggle-floating.is-open {
  right: var(--chat-flyout-width);
}

.chat-toggle-floating:hover,
.chat-toggle-floating:focus-visible {
  background: var(--accent-strong);
  outline: none;
}

.chat-toggle-floating svg {
  width: 22px;
  height: 22px;
}

.chat-toggle-icon {
  display: inline-flex;
}

.chat-toggle-icon-close,
.chat-toggle-label-close {
  display: none;
}

.chat-toggle-floating.is-open .chat-toggle-icon-open,
.chat-toggle-floating.is-open .chat-toggle-label-open {
  display: none;
}

.chat-toggle-floating.is-open .chat-toggle-icon-close,
.chat-toggle-floating.is-open .chat-toggle-label-close {
  display: inline-flex;
}

.chat-toggle-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.premium-page {
  background-color: #f8fafc;
  background-image: radial-gradient(circle at 10% 20%, rgba(79, 70, 229, 0.08), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(249, 115, 22, 0.08), transparent 25%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 55%, #eef2ff 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
  .premium-page {
    background-attachment: scroll;
  }
}

.premium-header {
  display: block;
}

.premium-brand {
  letter-spacing: -0.01em;
}

.premium-logo {
  text-decoration: none;
}

.premium-tag {
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.premium-nav-link {
  text-decoration: none;
}

.premium-nav-link:hover,
.premium-nav-link:focus-visible {
  text-decoration: underline;
}

.premium-main {
  width: 100%;
}

.premium-hero-text h1 {
  margin: 0;
}

.premium-hero-text .lead {
  margin: 0;
}

.eyebrow {
  margin: 0;
}

.premium-card {
  backdrop-filter: blur(6px);
}

.premium-card-header {
  margin-bottom: 0;
}

.premium-form {
  width: 100%;
}

.premium-input {
  background: #f8fafc;
}

.small-print {
  margin: 0;
}

.form-message {
  color: var(--muted);
}

.form-message[data-variant='error'] {
  color: #dc2626;
}

.form-message[data-variant='success'] {
  color: #16a34a;
}

.benefit-icon {
  font-size: 20px;
}

.premium-footer {
  font-size: 13px;
}

.premium-form.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  :root {
    --chat-flyout-width: min(var(--chat-width), 90vw);
  }

  .layout:not(.chat-collapsed) {
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  .chat-sidebar {
    position: fixed;
    z-index: 12;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(var(--chat-width), 90vw);
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.15);
  }

  .layout.chat-collapsed .chat-sidebar {
    transform: translateX(105%);
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 300px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .layout.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .layout.chat-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 12;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.15);
  }

  .viewer {
    grid-column: 1;
  }

  .layout.sidebar-collapsed .sidebar {
    transform: translateX(-105%);
    opacity: 0;
  }

  .sidebar-overlay.visible {
    backdrop-filter: blur(2px);
  }

  .nav-dialog-content {
    width: 95vw;
    height: 85vh;
  }

  .chat-sidebar {
    width: min(var(--chat-width), 92vw);
  }
}
