@font-face {
  font-family: "Faire Octave";
  src: url("/assets/fonts/faire-octave.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

:root {
  color-scheme: dark;
  --bg: #080807;
  --panel: #11110f;
  --text: #f3f1eb;
  --muted: #9d9b94;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #b8cf80;
  --accent-strong: #d7e9a7;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body,
button {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  color: var(--text);
  font-size: 16px;
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.paper-site-back {
  left: 20px !important;
  bottom: 20px !important;
  width: 42px !important;
  height: 42px !important;
  border: 1px solid rgba(184, 207, 128, 0.42) !important;
  background: rgba(8, 8, 7, 0.76) !important;
  color: var(--accent-strong) !important;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28) !important;
  backdrop-filter: blur(10px);
}

.paper-site-back:hover {
  background: rgba(184, 207, 128, 0.13) !important;
}

.site-shell {
  width: min(100%, 1920px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 22px 40px 20px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 30px;
  overflow: hidden;
}

.paper-header {
  width: min(100%, 1480px);
  margin: 0 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 34px;
}

.paper-heading {
  min-width: 0;
}

.dialog-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.paper-heading h1 {
  max-width: 880px;
  margin: 0;
  font-family: "Faire Octave", Georgia, "Times New Roman", serif;
  font-size: 36px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0;
}

.paper-heading h1 span {
  color: var(--accent-strong);
}

.paper-actions {
  position: relative;
  top: -8px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.action-link {
  min-width: 0;
  height: 42px;
  padding: 0 11px 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.018));
  color: #dedcd5;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.action-link:hover,
.action-link:focus-visible {
  border-color: rgba(184, 207, 128, 0.65);
  background: rgba(184, 207, 128, 0.1);
  color: var(--accent-strong);
  transform: translateY(-2px);
  outline: none;
}

.action-link.is-disabled {
  color: #6e6d68;
  cursor: default;
}

.action-button {
  font: inherit;
  cursor: pointer;
}

.action-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.09);
}

.action-icon img {
  width: 17px;
  height: 17px;
  object-fit: contain;
}

.action-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-icon-paper {
  color: #9b9a94;
}

.action-icon-cite {
  color: var(--accent-strong);
  background: rgba(184, 207, 128, 0.13);
}

.action-copy {
  display: grid;
  gap: 1px;
  text-align: left;
}

.action-copy strong {
  font-size: 11px;
  line-height: 1.15;
}

.action-copy small {
  display: none;
}

.gallery {
  width: min(100%, 1040px);
  margin: 0 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 12px;
}

.prompt-row {
  min-width: 0;
  display: block;
}

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

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

.prompt-label {
  display: block;
  color: #77766f;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.prompt-text {
  min-height: 47px;
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  color: #aaa9a3;
  font-size: 12px;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.prompt-copy-button {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  color: #85847e;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.prompt-copy-button:hover,
.prompt-copy-button:focus-visible {
  border-color: rgba(184, 207, 128, 0.52);
  background: rgba(184, 207, 128, 0.09);
  color: var(--accent-strong);
  outline: none;
}

.prompt-copy-button svg {
  width: 15px;
  height: 15px;
  grid-area: 1 / 1;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.prompt-check-icon {
  opacity: 0;
}

.prompt-copy-button.is-copied {
  border-color: rgba(184, 207, 128, 0.5);
  color: var(--accent-strong);
}

.prompt-copy-button.is-copied .prompt-copy-icon {
  opacity: 0;
}

.prompt-copy-button.is-copied .prompt-check-icon {
  opacity: 1;
}

.viewer {
  position: relative;
  width: min(100%, 768px);
  height: min(54vh, 576px);
  justify-self: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 7px;
  background: transparent;
  isolation: isolate;
  transition: width 220ms ease, height 220ms ease;
}

.image-stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.main-image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain !important;
  user-select: none;
  transition: opacity 150ms ease, transform 240ms ease;
}

.main-image.is-loading {
  opacity: 0.3;
  transform: scale(0.995);
}

.icon-button svg,
.copy-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.thumbnail-viewport {
  position: relative;
  z-index: 4;
  width: min(88%, 980px);
  height: 112px;
  margin: 8px auto 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 8px;
  scrollbar-width: none;
  cursor: grab;
  overscroll-behavior-inline: contain;
  touch-action: pan-x;
}

.thumbnail-viewport::-webkit-scrollbar {
  display: none;
}

.thumbnail-viewport.is-dragging {
  cursor: grabbing;
}

.thumbnail-track {
  min-height: 108px;
  width: max-content;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  padding: 8px 2px 10px;
}

.thumbnail {
  position: relative;
  width: 62px;
  height: 58px;
  flex: 0 0 62px;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  background: #151512;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  opacity: 0.58;
  transition: opacity 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.thumbnail img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.thumbnail:hover,
.thumbnail:focus-visible {
  opacity: 0.92;
  transform: translateY(-5px);
  outline: none;
}

.thumbnail.is-active {
  border-color: var(--accent-strong);
  opacity: 1;
  transform: translateY(-8px);
}

.thumbnail:nth-child(4n + 1) {
  width: 48px;
  height: 46px;
  flex-basis: 48px;
}

.thumbnail:nth-child(4n + 2) {
  width: 58px;
  height: 62px;
  flex-basis: 58px;
}

.thumbnail:nth-child(4n + 3) {
  width: 68px;
  height: 76px;
  flex-basis: 68px;
}

.thumbnail:nth-child(4n) {
  width: 76px;
  height: 88px;
  flex-basis: 76px;
}

.thumbnail.is-active {
  width: 88px;
  height: 98px;
  flex-basis: 88px;
}

.cite-dialog {
  width: min(620px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 8px;
  background: #10100e;
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.cite-dialog::backdrop {
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(5px);
}

.cite-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.cite-dialog h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 500;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: #bbb9b2;
  cursor: pointer;
}

.cite-dialog pre {
  margin: 20px 0 14px;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: #060605;
  color: #dcdbd4;
  font: 12px/1.6 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.copy-button {
  height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(184, 207, 128, 0.44);
  border-radius: 6px;
  background: rgba(184, 207, 128, 0.12);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 1120px) {
  .site-shell {
    padding-right: 22px;
    padding-left: 22px;
  }

  .paper-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .paper-actions {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .paper-actions::-webkit-scrollbar {
    display: none;
  }

  .paper-heading h1 {
    font-size: 29px;
  }

  .gallery {
    width: min(100%, 880px);
  }
}

@media (max-width: 680px) {
  .site-shell {
    padding: 12px 12px 14px;
    gap: 18px;
  }

  .paper-heading h1 {
    font-size: 25px;
    line-height: 1.12;
  }

  .action-link {
    height: 40px;
    padding-right: 10px;
  }

  .action-icon {
    width: 25px;
    height: 25px;
    flex-basis: 25px;
  }

  .action-copy strong {
    font-size: 10px;
  }

  .prompt-text {
    min-height: 43px;
    font-size: 11px;
  }

  .thumbnail-viewport {
    width: calc(100% - 44px);
    height: 94px;
    margin-top: 6px;
    padding: 0 4px;
  }

  .thumbnail {
    transform: scale(0.86);
    transform-origin: bottom center;
    margin: 0 -4px;
  }

  .thumbnail.is-active {
    transform: translateY(-5px) scale(0.86);
  }
}

@media (max-height: 720px) {
  .site-shell {
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 15px;
  }

  .paper-heading h1 {
    font-size: 21px;
  }

  .action-link {
    height: 40px;
  }

  .prompt-text {
    min-height: 17px;
    -webkit-line-clamp: 1;
  }

  .thumbnail {
    height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
