:root {
  --ink: #14201c;
  --paper: #f3efe6;
  --paper-deep: #e7e0d2;
  --accent: #0f6a5f;
  --line: rgba(20, 32, 28, 0.12);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 12% 10%, rgba(15, 106, 95, 0.14), transparent 36%),
    radial-gradient(circle at 88% 0%, rgba(196, 112, 48, 0.12), transparent 30%),
    linear-gradient(160deg, #f7f3ea 0%, #ebe4d6 55%, #e2dccf 100%);
}

.brand,
.brand-link,
.brand-logo {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.brand-logo {
  display: inline-block;
  line-height: 0;
}

.brand-logo img {
  display: block;
  width: auto;
  height: 2.5rem;
}

.brand-logo-sm img {
  height: 2rem;
}

.brand-logo-md img {
  height: 2.5rem;
}

.brand-logo-lg img {
  height: 3.25rem;
}

.brand-logo-hero {
  display: block;
  margin: 0 0 0.85rem;
}

.brand-logo-hero img {
  height: clamp(4rem, 10vw, 6.5rem);
}

.brand-logo-link {
  text-decoration: none;
}

.brand-logo-link:hover {
  opacity: 0.92;
}

.home-top {
  padding: 0.35rem 0;
}

.home-top-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 2.25rem;
}

.user-nav {
  display: flex;
  align-items: center;
}

.user-nav-toggle {
  --bs-btn-padding-y: 0.15rem;
  --bs-btn-padding-x: 0.5rem;
  --bs-btn-font-size: 0.75rem;
  --bs-btn-border-radius: 0.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1.2;
}

.user-nav-name {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.9;
}

.user-nav .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.user-nav .dropdown-item i {
  width: 1rem;
  text-align: center;
  opacity: 0.75;
}

.user-nav form {
  margin: 0;
}

/* Light surfaces (home, admin, account, handout) */
.home .user-nav-toggle,
.admin-page .user-nav-toggle,
.auth-page .user-nav-toggle,
.handout .user-nav-toggle {
  --bs-btn-color: var(--ink);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: rgba(20, 32, 28, 0.35);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--ink);
  --bs-btn-hover-border-color: var(--ink);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--ink);
  --bs-btn-active-border-color: var(--ink);
}

/* Dark editor bar */
.editor-shell .user-nav-toggle {
  --bs-btn-color: #f2eee6;
  --bs-btn-bg: transparent;
  --bs-btn-border-color: rgba(255, 255, 255, 0.35);
  --bs-btn-hover-color: #0d100e;
  --bs-btn-hover-bg: #f2eee6;
  --bs-btn-hover-border-color: #f2eee6;
  --bs-btn-active-color: #0d100e;
  --bs-btn-active-bg: #f2eee6;
  --bs-btn-active-border-color: #f2eee6;
}

.app-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 2.25rem;
  margin-bottom: 1rem;
}

.app-top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.85rem;
  padding-left: 0.4rem !important;
  padding-right: 0.4rem !important;
}

.btn i + span,
.btn span + i {
  margin-inline-start: 0.35rem;
}

.auth-page,
.admin-page {
  min-height: 100vh;
}

.auth-card {
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.55);
  border-top: 1px solid var(--line);
}

.auth-card .brand-logo {
  display: block;
  margin: 0 0 1rem;
}

.auth-card .brand-logo img {
  height: 4.5rem;
}

.auth-card h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
}

.admin-page .brand-logo {
  margin: 0;
}

.home-hero {
  padding: 4.5rem 0 3.5rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(120deg, rgba(15, 106, 95, 0.18), transparent 50%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent);
}

.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  margin: 0 0 0.75rem;
  font-weight: 500;
}

.home-hero .lede {
  max-width: 36rem;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

.deck-list {
  display: grid;
  gap: 0.75rem;
}

.deck-row {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid transparent;
  background: rgba(255, 255, 255, 0.35);
}

.deck-thumb {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #0b0d0c;
  padding: 0.35rem;
  border: 1px solid rgba(20, 32, 28, 0.08);
}

.deck-thumb:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.deck-thumb-slide.slide.mini {
  width: 100%;
  aspect-ratio: 16 / 9;
  pointer-events: none;
}

.deck-thumb-slide.slide.mini .slide-inner {
  padding: 0.45rem 0.55rem;
  gap: 0.15rem;
}

.deck-thumb-slide.slide.mini h1 {
  font-size: 0.72rem;
}

.deck-thumb-slide.slide.mini h2 {
  font-size: 0.64rem;
}

.deck-thumb-slide.slide.mini p,
.deck-thumb-slide.slide.mini li {
  font-size: 0.5rem;
}

.deck-thumb-empty {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  color: rgba(247, 242, 232, 0.55);
  font-size: 0.7rem;
  background: #1a1f1c;
}

.deck-meta {
  min-width: 0;
}

.deck-title {
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.deck-title:hover {
  color: var(--accent);
}

.deck-sub {
  margin: 0.2rem 0 0;
  color: rgba(20, 32, 28, 0.65);
  font-size: 0.9rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.deck-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.editor-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #121614;
  color: #f2eee6;
}

.editor-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.28rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #0d100e;
}

.editor-bar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.brand-link {
  color: #f2eee6;
  text-decoration: none;
}

.brand-link:hover {
  color: #fff;
}

.editor-bar-left .brand-logo {
  flex-shrink: 0;
}

.sep {
  opacity: 0.35;
}

.bar-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

.save-status {
  flex-shrink: 0;
  margin-left: 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.55;
}

.save-status[data-state='dirty'] {
  opacity: 0.8;
  color: #f0c674;
}

.save-status[data-state='saving'] {
  opacity: 0.75;
}

.save-status[data-state='error'] {
  opacity: 1;
  color: #ff8a80;
}

.save-status[data-state='saved'] {
  opacity: 0.45;
}

.editor-bar-actions {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  align-items: center;
}

.editor-bar-actions .btn {
  --bs-btn-padding-y: 0.15rem;
  --bs-btn-padding-x: 0.45rem;
  --bs-btn-font-size: 0.75rem;
  --bs-btn-border-radius: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.editor-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) minmax(280px, 0.95fr);
  min-height: 0;
}

.editor-sidebar,
.editor-pane,
.preview-pane {
  min-height: 0;
  padding: 1rem;
}

.editor-sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  background: #151a17;
}

.editor-sidebar .form-label {
  color: rgba(242, 238, 230, 0.75);
  font-size: 0.8rem;
}

.editor-sidebar .form-control,
.editor-sidebar .form-select {
  background: #0f1311;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f2eee6;
}

.theme-meta {
  margin: -0.35rem 0 1rem;
  padding: 0.65rem 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid rgba(215, 195, 154, 0.65);
}

.theme-meta .theme-desc {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: rgba(242, 238, 230, 0.72);
}

.theme-meta .theme-fonts {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(215, 195, 154, 0.95);
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.sidebar-hint {
  font-size: 0.82rem;
  line-height: 1.45;
  color: rgba(242, 238, 230, 0.62);
  margin-bottom: 1rem;
}

.sidebar-hint code {
  color: #d7c39a;
}

.slide-index {
  display: grid;
  gap: 0.35rem;
  overflow: auto;
  flex: 1;
  margin-bottom: 1rem;
}

.slide-index-item {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-left: 3px solid hsl(var(--accent-hue), 55%, 48%);
  color: rgba(242, 238, 230, 0.8);
  text-align: left;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.02);
  font: inherit;
  cursor: pointer;
}

.slide-index-item:hover,
.slide-index-item.is-active {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.slide-index-item .num {
  font-size: 0.75rem;
  opacity: 0.7;
}

.slide-index-item .label {
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-pane {
  padding: 0;
}

.editor-textarea {
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: 0;
  resize: none;
  padding: 1.25rem 1.4rem;
  background: #101412;
  color: #f4f0e7;
  font-family: "Source Sans 3", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  line-height: 1.55;
}

.editor-textarea:focus {
  outline: none;
}

.preview-pane {
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background: #1a201c;
  overflow: auto;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  color: rgba(242, 238, 230, 0.65);
  font-size: 0.85rem;
}

.preview-notes {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-notes h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.5rem;
  opacity: 0.65;
}

.preview-notes.is-empty {
  opacity: 0.55;
}

.preview-empty {
  color: rgba(242, 238, 230, 0.55);
  padding: 2rem 0;
}

.handout {
  background: #f7f3ea;
  min-height: 100vh;
}

.handout-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.handout-header h1 {
  font-family: var(--font-display);
  margin: 0 0 0.5rem;
}

.handout-theme {
  margin: 0.35rem 0 0;
  color: rgba(20, 32, 28, 0.7);
  font-size: 0.95rem;
}

.handout-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.handout-slide {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.handout-slide-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--accent-hue), 45%, 35%);
  margin-bottom: 0.5rem;
}

.handout-notes {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(20, 32, 28, 0.04);
}

.handout-notes h3 {
  font-size: 0.85rem;
  margin: 0 0 0.4rem;
}

.error-page {
  min-height: 100vh;
}

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

  .editor-sidebar,
  .preview-pane {
    border: 0;
  }

  .editor-textarea {
    min-height: 50vh;
  }
}

@media (max-width: 720px) {
  .deck-row {
    grid-template-columns: 7.5rem minmax(0, 1fr);
  }

  .deck-actions {
    grid-column: 1 / -1;
  }

  .home-hero {
    padding: 3rem 0 2.5rem;
  }
}

@media print {
  .handout-actions {
    display: none;
  }
}
