:root {
  color-scheme: light;
  --background: #f7f8fb;
  --foreground: #18202f;
  --muted: #667085;
  --border: #d9deea;
  --card: #ffffff;
  --card-raised: #ffffff;
  --surface: #f3f6fb;
  --surface-raised: #ffffff;
  --surface-tinted: #eef5ff;
  --section-header: #edf4fc;
  --input-bg: #fbfcff;
  --input-border: #c8d2e2;
  --button-secondary: #eef3f8;
  --button-secondary-hover: #e2eaf4;
  --primary: #1f6feb;
  --primary-foreground: #ffffff;
  --accent: #eaf2ff;
  --accent-strong: #9bc3ff;
  --control: #eef2f7;
  --danger: #dc2626;
  --danger-surface: #fff1f2;
  --success: #047857;
  --success-surface: #e7f8ef;
  --warning: #b45309;
  --hover: #f2f5fa;
  --page-shadow: rgb(16 24 40 / 18%);
  --sidebar: #ffffff;
  --topbar: rgb(255 255 255 / 82%);
  --tooltip: #18202f;
  --tooltip-border: rgb(255 255 255 / 18%);
  --tooltip-foreground: #ffffff;
  --viewer: #dfe4ed;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #12151b;
  --foreground: #edf2f7;
  --muted: #aab4c3;
  --border: #313949;
  --card: #1a202b;
  --card-raised: #232b38;
  --surface: #171d27;
  --surface-raised: #242c3a;
  --surface-tinted: #1c2b3e;
  --section-header: #202a39;
  --input-bg: #111827;
  --input-border: #4b5567;
  --button-secondary: #263140;
  --button-secondary-hover: #303b4d;
  --primary: #77a7ff;
  --primary-foreground: #0d1320;
  --accent: #26364f;
  --accent-strong: #77a7ff;
  --control: #242c3a;
  --danger: #f87171;
  --danger-surface: #3b1f28;
  --success: #34d399;
  --success-surface: #12362d;
  --warning: #fbbf24;
  --hover: #252d3a;
  --page-shadow: rgb(0 0 0 / 34%);
  --sidebar: #171c25;
  --topbar: rgb(18 21 27 / 88%);
  --tooltip: #f8fafc;
  --tooltip-border: rgb(17 24 39 / 18%);
  --tooltip-foreground: #12151b;
  --viewer: #202734;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--background);
  color: var(--foreground);
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button,
.file-button {
  align-items: center;
  background: var(--button-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--foreground);
  cursor: pointer;
  display: inline-flex;
  font-weight: 650;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
}

button:hover,
.file-button:hover {
  background: var(--button-secondary-hover);
}

button:focus-visible,
.file-button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 60%, transparent);
  outline-offset: 2px;
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

button.danger-button {
  background: var(--danger-surface);
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  color: var(--danger);
}

input,
select {
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--foreground);
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;
  background-repeat: no-repeat;
  background-size:
    5px 5px,
    5px 5px;
  padding-right: 34px;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.sidebar-rail {
  border-radius: 0 8px 8px 0;
  box-shadow: 0 12px 30px var(--page-shadow);
  left: 0;
  min-height: 46px;
  position: fixed;
  top: 72px;
  transform-origin: left center;
  writing-mode: vertical-rl;
  z-index: 18;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 100vh;
  overflow: auto;
  padding: 18px;
}

body.sidebar-auto .app-shell {
  grid-template-columns: 1fr;
}

body.sidebar-auto .sidebar {
  box-shadow: 18px 0 40px rgb(16 24 40 / 24%);
  height: 100vh;
  left: 0;
  max-height: 100vh;
  position: fixed;
  top: 0;
  transform: translateX(calc(-100% + 10px));
  transition: transform 180ms ease;
  width: 340px;
  z-index: 17;
}

body.sidebar-auto.sidebar-peek .sidebar,
body.sidebar-auto.sidebar-open .sidebar,
body.sidebar-auto .sidebar:focus-within {
  transform: translateX(0);
}

body.sidebar-auto .sidebar-rail {
  display: inline-flex;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand-copy {
  min-width: 0;
}

.brand-mark {
  background: var(--foreground);
  border-radius: 8px;
  color: var(--background);
  display: grid;
  font-weight: 800;
  height: 42px;
  place-items: center;
  width: 42px;
}

.sidebar-actions {
  display: grid;
  gap: 6px;
  margin-left: auto;
}

.sidebar-actions button {
  min-height: 36px;
  padding-inline: 10px;
  white-space: nowrap;
}

.brand h1,
.brand p,
.panel h2,
.panel h3 {
  margin: 0;
}

.brand p,
.status,
#stageSubtitle,
.empty-state p {
  color: var(--muted);
}

.card,
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-section-title {
  background: var(--section-header);
  border: 1px solid color-mix(in srgb, var(--input-border) 72%, transparent);
  border-radius: 8px;
  justify-content: space-between;
  margin: -4px -4px 0;
  padding: 8px 10px;
}

.sidebar-section-actions {
  margin-left: auto;
}

.sidebar-section-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-section-toggle,
.icon-button {
  flex: 0 0 auto;
  min-width: 38px;
  padding-inline: 10px;
}

.chevron-down,
.chevron-left,
.chevron-right {
  border-color: currentColor;
  border-style: solid;
  border-width: 0 2px 2px 0;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.chevron-down {
  transform: translateY(-2px) rotate(45deg);
}

.chevron-right {
  transform: translateX(-2px) rotate(-45deg);
}

.chevron-left {
  transform: translateX(2px) rotate(135deg);
}

.next-track-icon {
  display: inline-block;
  height: 16px;
  position: relative;
  width: 18px;
}

.next-track-icon::before,
.next-track-icon::after {
  content: "";
  position: absolute;
}

.next-track-icon::before {
  border-block: 7px solid transparent;
  border-left: 10px solid currentColor;
  height: 0;
  left: 2px;
  top: 1px;
  width: 0;
}

.next-track-icon::after {
  background: currentColor;
  border-radius: 1px;
  height: 14px;
  right: 2px;
  top: 1px;
  width: 3px;
}

.sidebar-section-collapsed {
  gap: 0;
}

.panel h2,
.sidebar-section-title h2 {
  font-size: 15px;
}

.panel h3 {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.segmented {
  background: var(--control);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
  padding: 4px;
}

.segmented button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  min-height: 34px;
}

.segmented button.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 1px 4px rgb(16 24 40 / 18%);
  color: var(--primary-foreground);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.audio-controls {
  align-items: stretch;
  flex-wrap: nowrap;
}

.audio-toggle {
  flex: 0 0 136px;
  min-width: 136px;
  white-space: nowrap;
}

.audio-toggle-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
}

#audioRateSelect {
  min-width: 94px;
}

.room-code {
  background: var(--accent);
  border-radius: 8px;
  color: var(--primary);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0;
  padding: 12px;
  text-align: center;
}

.status {
  font-size: 13px;
  margin: 12px 0 0;
}

.cache-picker {
  display: grid;
  gap: 8px;
}

.cache-picker .row button {
  flex: 1 1 0;
}

.presence-list button {
  justify-content: flex-start;
  overflow-wrap: anywhere;
  text-align: left;
}

.share-box {
  display: grid;
  gap: 8px;
}

.share-box img {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 132px;
  padding: 8px;
  width: 132px;
}

.tooltip-anchor {
  position: relative;
}

.tooltip-anchor > button {
  width: 100%;
}

.confirmation-tooltip {
  background: var(--tooltip);
  border: 1px solid var(--tooltip-border);
  border-radius: 8px;
  bottom: calc(100% + 8px);
  box-shadow: 0 12px 26px rgb(16 24 40 / 20%);
  color: var(--tooltip-foreground);
  font-size: 13px;
  font-weight: 700;
  left: 50%;
  padding: 7px 10px;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 6;
}

.confirmation-tooltip::after {
  background: var(--tooltip);
  bottom: -5px;
  content: "";
  height: 10px;
  left: calc(50% - 5px);
  position: absolute;
  transform: rotate(45deg);
  width: 10px;
}

.panel-title {
  justify-content: space-between;
}

.presence-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-summary {
  background: var(--surface-tinted);
  border: 1px solid color-mix(in srgb, var(--input-border) 55%, transparent);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  padding: 8px 10px;
}

.room-safety {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

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

.participant-row.removed {
  opacity: 0.68;
}

.participant {
  align-items: center;
  display: grid;
  gap: 2px;
  grid-template-columns: 1fr auto;
  width: 100%;
}

.participant strong {
  font-size: 14px;
}

.participant span {
  color: var(--muted);
  font-size: 12px;
}

.participant.active {
  background: var(--accent);
  border-color: var(--accent-strong);
}

.participant.offline {
  opacity: 0.55;
}

.participant-remove {
  align-self: stretch;
  color: var(--danger);
  font-size: 12px;
  min-height: 0;
  padding-inline: 8px;
}

.participant-restore {
  align-self: stretch;
  background: var(--success-surface);
  border-color: color-mix(in srgb, var(--success) 48%, var(--border));
  color: var(--success);
  font-size: 12px;
  min-height: 0;
  padding-inline: 8px;
}

.transfer-feedback {
  background: var(--surface-tinted);
  border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--input-border));
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 10%);
  color: var(--foreground);
  display: grid;
  gap: 7px;
  padding: 10px;
}

.transfer-feedback.success {
  background: var(--success-surface);
  border-color: color-mix(in srgb, var(--success) 42%, var(--border));
}

.transfer-feedback.error {
  background: var(--danger-surface);
  border-color: color-mix(in srgb, var(--danger) 50%, var(--border));
}

.transfer-feedback-header {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.transfer-feedback-label {
  font-size: 13px;
  font-weight: 750;
}

.transfer-feedback-percent {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.transfer-feedback-detail {
  color: var(--muted);
  font-size: 12px;
}

.transfer-progress-track {
  background: color-mix(in srgb, var(--input-border) 48%, transparent);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.transfer-progress-bar {
  background: var(--primary);
  border-radius: inherit;
  height: 100%;
  transition: width 120ms ease;
}

.transfer-feedback.success .transfer-progress-bar {
  background: var(--success);
}

.transfer-feedback.error .transfer-progress-bar {
  background: var(--danger);
}

.transfer-feedback.indeterminate .transfer-progress-bar {
  animation: transfer-indeterminate 1100ms ease-in-out infinite;
  width: 42%;
}

@keyframes transfer-indeterminate {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(240%);
  }
}

.follow-status {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.transcript-link {
  color: var(--primary);
  font-weight: 650;
  text-decoration: none;
}

.audio-engine {
  display: none;
}

.file-button input {
  display: none;
}

.stage {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
}

.topbar {
  align-items: center;
  background: var(--topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  min-width: 0;
  padding: 12px 18px;
}

.topbar > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.marker-toolbar {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  flex-direction: row;
  gap: 8px;
}

.marker-colors {
  align-items: center;
  background: var(--control);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 6px;
  min-height: 38px;
  padding: 5px 6px 5px 10px;
}

.marker-colors span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.color-swatch {
  background: var(--swatch-color);
  border-color: rgb(16 24 40 / 22%);
  border-radius: 999px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  width: 28px;
}

.color-swatch:hover {
  background: var(--swatch-color);
}

.color-swatch.active {
  box-shadow:
    0 0 0 2px var(--card),
    0 0 0 4px var(--primary);
}

#pointerColorInput {
  border-radius: 999px;
  height: 30px;
  min-height: 30px;
  padding: 2px;
  width: 34px;
}

.viewer {
  background: var(--viewer);
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.pdf-scroller {
  height: 100%;
  overflow: auto;
  width: 100%;
}

.pdf-pages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.pdf-page {
  background: white;
  box-shadow: 0 12px 30px var(--page-shadow);
  margin: 0 auto;
  position: relative;
}

.pdf-page canvas {
  display: block;
}

.annotation-canvas {
  height: 100%;
  inset: 0;
  position: absolute;
  touch-action: none;
  width: 100%;
}

.page-loading {
  color: var(--muted);
  display: grid;
  min-height: 220px;
  place-items: center;
}

.empty-state {
  display: grid;
  inset: 0;
  padding: 24px;
  place-content: center;
  pointer-events: none;
  position: absolute;
  text-align: center;
  z-index: 3;
}

.tour {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 20;
}

.tour-highlight {
  border: 2px solid var(--primary);
  border-radius: 10px;
  box-shadow:
    0 0 0 9999px rgb(24 32 47 / 18%),
    0 0 0 6px rgb(31 111 235 / 16%);
  position: fixed;
  transition:
    height 120ms ease,
    left 120ms ease,
    top 120ms ease,
    width 120ms ease;
}

.tour-card {
  background: var(--tooltip);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgb(16 24 40 / 26%);
  color: var(--tooltip-foreground);
  max-width: 360px;
  padding: 14px;
  pointer-events: auto;
  position: fixed;
  width: min(360px, calc(100vw - 24px));
}

.tour-card::before {
  background: var(--tooltip);
  content: "";
  height: 14px;
  position: absolute;
  transform: rotate(45deg);
  width: 14px;
}

.tour-card[data-placement="right"]::before {
  left: -7px;
  top: calc(var(--tour-arrow-y, 50%) - 7px);
}

.tour-card[data-placement="left"]::before {
  right: -7px;
  top: calc(var(--tour-arrow-y, 50%) - 7px);
}

.tour-card[data-placement="bottom"]::before {
  left: calc(var(--tour-arrow-x, 50%) - 7px);
  top: -7px;
}

.tour-card[data-placement="top"]::before {
  bottom: -7px;
  left: calc(var(--tour-arrow-x, 50%) - 7px);
}

.tour-card button {
  background: transparent;
  border-color: var(--tooltip-border);
  color: var(--tooltip-foreground);
}

.tour-card button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.tour-step {
  margin: 0 0 12px;
}

.empty-state h2 {
  font-size: 24px;
  margin: 0 0 8px;
}

.hidden {
  display: none;
}

@media (max-width: 840px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  body.sidebar-auto .app-shell {
    grid-template-columns: none;
  }

  .sidebar {
    border-bottom: 1px solid var(--border);
    border-right: 0;
    flex: 0 0 auto;
    gap: 10px;
    max-height: 46dvh;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 12px;
  }

  body.sidebar-auto .sidebar {
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-100%);
    width: min(92vw, 340px);
  }

  body.sidebar-auto.sidebar-open .sidebar,
  body.sidebar-auto .sidebar:focus-within {
    transform: translateX(0);
  }

  body.sidebar-auto.sidebar-peek .sidebar {
    transform: translateX(-100%);
  }

  .sidebar-rail {
    top: 16px;
  }

  .stage {
    flex: 1 1 auto;
    min-height: 0;
  }

  button,
  .file-button,
  input,
  select {
    min-height: 44px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    height: 38px;
    width: 38px;
  }

  .sidebar-actions {
    grid-template-columns: repeat(3, auto);
  }

  .sidebar-actions button {
    min-height: 38px;
  }

  .card,
  .panel {
    padding: 12px;
  }

  .segmented {
    margin-bottom: 10px;
  }

  .room-code {
    font-size: clamp(24px, 8vw, 32px);
    padding: 10px;
  }

  .row {
    flex-wrap: wrap;
  }

  .row > button,
  .row > .file-button,
  .row > select {
    flex: 1 1 auto;
  }

  .audio-controls {
    flex-wrap: nowrap;
  }

  .audio-controls > .audio-toggle {
    flex: 0 0 136px;
  }

  .audio-controls > .icon-button {
    flex: 0 0 44px;
  }

  .audio-controls > select {
    flex: 1 1 82px;
    min-width: 76px;
  }

  .share-box img {
    height: 112px;
    width: 112px;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 0;
    padding: 10px 12px;
  }

  .topbar > div:first-child {
    flex: 1 1 180px;
    min-width: 0;
  }

  .marker-toolbar {
    align-items: stretch;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .marker-colors {
    flex: 0 0 auto;
    min-width: max-content;
  }

  .marker-toolbar > button {
    flex: 0 0 auto;
  }

  .follow-status {
    white-space: normal;
  }

  .pdf-pages {
    gap: 12px;
    padding: 12px;
  }
}

@media (max-width: 520px) {
  .sidebar {
    max-height: 52dvh;
  }

  .brand {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  .sidebar-actions {
    grid-column: 1 / -1;
    margin-left: 0;
  }

  .brand p {
    font-size: 13px;
  }

  .panel-title {
    align-items: flex-start;
  }

  .share-box {
    grid-template-columns: 1fr;
  }

  .marker-toolbar {
    scrollbar-width: thin;
  }
}
