:root {
  --bg: #050608;
  --bg-soft: #0d1015;
  --panel: #10141a;
  --panel-2: #161b22;
  --ink: #f3f5f7;
  --muted: #8a95a3;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --accent: #f3f5f7;
  --accent-soft: rgba(255, 255, 255, 0.1);
  --danger: #ff6f61;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 24%),
    linear-gradient(180deg, #0a0d11, #040507 55%, #020304);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.shell {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  background: rgba(6, 8, 11, 0.96);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.deck-button {
  position: relative;
  width: 60px;
  height: 60px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #0f1318;
  transition: border-color 140ms ease, background 140ms ease;
}

.deck-button:hover {
  border-color: var(--accent);
  background: #151a21;
}

.deck-button canvas,
.deck-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.deck-button__label {
  position: absolute;
  inset: auto 0 0 0;
  padding: 4px 0;
  font-family: "Azeret Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c6ced8;
  background: rgba(0, 0, 0, 0.74);
}

.rail__meta {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 4px 0;
  font-family: "Azeret Mono", monospace;
  font-size: 10px;
  color: var(--muted);
}

.rail__divider {
  width: 14px;
  height: 1px;
  background: var(--line);
}

.page-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 2px 0 6px;
  overflow-y: auto;
  scrollbar-width: none;
}

.page-nav::-webkit-scrollbar {
  display: none;
}

.page-nav__button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #0c1015;
  color: var(--muted);
  font-family: "Azeret Mono", monospace;
  font-size: 12px;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.page-nav__button:focus {
  outline: none;
  box-shadow: none;
}

.page-nav__button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.page-nav__button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.page-nav__button.is-active {
  border-color: var(--accent);
  background: #e9edf2;
  color: #050608;
}

.viewer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 6px;
  gap: 6px;
  overflow: hidden;
}

.viewer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  min-height: 40px;
  background: rgba(12, 15, 20, 0.92);
  border: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 3px;
  font-family: "Azeret Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.viewer__header h1,
.drawer__header h2 {
  margin: 0;
  font-size: clamp(0.95rem, 1.5vw, 1.2rem);
  line-height: 1.1;
}

.viewer__status {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.viewer__tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border: 1px solid var(--line);
  background: #0c1015;
  overflow: hidden;
}

.zoom-controls__button,
.zoom-controls__value {
  height: 100%;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Azeret Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.zoom-controls__button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
}

.zoom-controls__button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

.zoom-controls__button:disabled {
  color: #66707d;
  cursor: default;
}

.zoom-controls__value {
  min-width: 48px;
  padding: 0 8px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.mode-switch {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: center;
  width: 118px;
  height: 24px;
  padding: 2px;
  border: 1px solid var(--line);
  background: #0c1015;
  overflow: hidden;
}

.mode-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(50% - 2px);
  height: calc(100% - 4px);
  background: #eef2f7;
  transition: transform 160ms ease;
}

.mode-switch.is-render::before {
  transform: translateX(100%);
}

.mode-switch__button {
  position: relative;
  z-index: 1;
  min-width: 0;
  height: 100%;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: "Azeret Mono", monospace;
  font-size: 9px;
  font-weight: 700;
}

.mode-switch__button.is-active {
  color: #050608;
}

.mode-switch.is-render .mode-switch__button:not(.is-active),
.mode-switch.is-pdf .mode-switch__button:not(.is-active) {
  color: #a6b1bf;
}

.mode-switch__button:disabled {
  color: #66707d;
  cursor: default;
}

.stage {
  position: relative;
  min-height: 0;
  height: 100%;
  padding: 3px;
  background: #050608;
  border: 1px solid var(--line);
  overflow: hidden;
}

.stage__surface {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 8px;
  overflow: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.stage__surface::-webkit-scrollbar {
  display: none;
}

.stage__surface.is-scrollable {
  overflow-y: auto;
  overflow-x: hidden;
}

.stage__media {
  position: absolute;
  display: grid;
  place-items: center;
}

.stage__surface.is-scrollable .stage__media {
  position: relative;
  margin: 0 auto;
}

.stage__media canvas,
.stage__media img {
  grid-area: 1 / 1;
  display: block;
  background: #050608;
  box-shadow: var(--shadow);
  clip-path: inset(1px);
}

.stage__media img {
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity 180ms ease, filter 220ms ease;
}

.stage__media canvas {
  width: auto;
  height: auto;
  opacity: 0;
  transition: opacity 180ms ease;
}

.stage__media img.is-visible,
.stage__media canvas.is-visible {
  opacity: 1;
}

.stage__media img.is-preview {
  filter: blur(10px) saturate(0.92);
}

.stage__empty {
  position: absolute;
  inset: 3px;
  display: grid;
  justify-items: center;
  align-items: center;
  gap: 12px;
  border: 1px dashed var(--line-strong);
  background: rgba(12, 15, 20, 0.96);
  color: var(--muted);
  text-align: center;
}

.nav-button,
.primary-button,
.secondary-button,
.icon-button,
.deck-item__action {
  border: 1px solid var(--line);
  border-radius: 0;
  transition: border-color 140ms ease, background 140ms ease, opacity 140ms ease;
}

.nav-button {
  position: absolute;
  bottom: 10px;
  z-index: 3;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  background: rgba(8, 10, 13, 0.44);
  backdrop-filter: blur(4px);
}

.nav-button:hover:not(:disabled),
.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.deck-item__action:hover {
  border-color: var(--accent);
}

.nav-button:disabled {
  cursor: default;
  opacity: 0.28;
}

.nav-button--prev {
  left: 8px;
}

.nav-button--next {
  right: 8px;
}

.nav-button__glyph {
  display: block;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}

.nav-button__glyph--left {
  border-right: 15px solid rgba(255, 255, 255, 0.92);
  margin-left: -2px;
}

.nav-button__glyph--right {
  border-left: 15px solid rgba(255, 255, 255, 0.92);
  margin-right: -2px;
}

.primary-button,
.secondary-button {
  padding: 10px 14px;
}

.primary-button {
  color: #050608;
  background: #e9edf2;
}

.secondary-button {
  color: var(--ink);
  background: #161b22;
}

.icon-button {
  width: 34px;
  height: 34px;
  color: var(--ink);
  background: #161b22;
  font-size: 1.4rem;
  line-height: 1;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 10;
}

.drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.56);
}

.drawer__panel {
  position: absolute;
  top: 6px;
  left: 80px;
  width: min(420px, calc(100vw - 92px));
  max-height: calc(100vh - 12px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  background: #0b0e12;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.drawer__header,
.drawer__actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.drawer__actions {
  flex-wrap: wrap;
}

.drawer__upload-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.upload-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.upload-indicator__spinner {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: upload-spin 700ms linear infinite;
}

.upload-indicator__text {
  font-family: "Azeret Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.drawer__hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.drawer__list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
}

.deck-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #10151b;
}

.deck-item.is-active {
  border-color: var(--accent);
  background: #171d24;
}

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

.deck-item__header,
.deck-item__badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deck-item__header {
  justify-content: space-between;
}

.deck-item__title {
  margin: 0 0 6px;
  font-size: 0.96rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.deck-item__badge {
  padding: 4px 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: "Azeret Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.deck-item__badge--ready {
  color: #87d696;
  border-color: rgba(135, 214, 150, 0.35);
}

.deck-item__meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.deck-item__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.deck-item__action {
  display: inline-flex;
  align-items: center;
  padding: 9px 12px;
  background: #0c1015;
  color: var(--ink);
  text-decoration: none;
}

.deck-item__action:disabled {
  color: #6d7682;
  border-color: var(--line);
  background: #13171d;
  cursor: default;
}

.deck-item__action--delete {
  color: var(--danger);
}

@keyframes upload-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .viewer__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .viewer__tools {
    width: 100%;
    justify-content: space-between;
  }

  .viewer__status {
    text-align: left;
    white-space: normal;
  }

  .mode-switch {
    width: 124px;
  }
}

@media (max-width: 720px) {
  .shell {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .rail {
    padding: 6px 4px;
  }

  .deck-button {
    width: 52px;
    height: 52px;
  }

  .page-nav__button {
    width: 34px;
    height: 34px;
    font-size: 11px;
  }

  .viewer {
    padding: 4px;
    gap: 4px;
  }

  .drawer__panel {
    top: 4px;
    left: 68px;
    width: calc(100vw - 72px);
    max-height: calc(100vh - 8px);
    padding: 10px;
  }

  .nav-button {
    width: 46px;
    height: 46px;
    bottom: 8px;
  }

  .nav-button--prev {
    left: 6px;
  }

  .nav-button--next {
    right: 6px;
  }

  .stage__surface,
  .stage__empty {
    padding: 6px;
  }
}
