:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #171714;
  background: #f2f1ec;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  background: #f2f1ec;
}

button,
.button {
  font: inherit;
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(23, 23, 20, 0.13);
  background: rgba(242, 241, 236, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 6px;
  background: #171714;
  color: #f7f6f2;
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 400;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.privacy {
  color: #77766f;
  font-size: 12px;
}

.button {
  display: inline-flex;
  min-height: 35px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid #171714;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}

.button.primary {
  background: #171714;
  color: white;
}

.button.primary:hover {
  background: #30302b;
}

.viewer {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.viewer.is-dragging::after {
  position: absolute;
  z-index: 8;
  inset: 14px;
  border: 1px dashed #171714;
  border-radius: 12px;
  background: rgba(242, 241, 236, 0.5);
  content: "";
  pointer-events: none;
}

.canvas-host,
.canvas-host canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.canvas-host canvas {
  outline: none;
}

.drop-prompt {
  position: absolute;
  z-index: 3;
  top: 28px;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 3px;
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
  transition: opacity 160ms ease;
}

.drop-prompt[hidden] {
  opacity: 0;
}

.drop-prompt p,
.drop-prompt span,
.file-meta p {
  margin: 0;
}

.drop-prompt p {
  font-size: 14px;
  font-weight: 600;
}

.drop-prompt span {
  color: #77766f;
  font-size: 12px;
}

.viewer-actions {
  position: absolute;
  z-index: 5;
  top: 18px;
  right: 18px;
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(23, 23, 20, 0.15);
  border-radius: 9px;
  background: rgba(248, 247, 243, 0.9);
  box-shadow: 0 5px 22px rgba(25, 24, 19, 0.06);
  backdrop-filter: blur(10px);
}

.icon-button {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 0;
  border-right: 1px solid rgba(23, 23, 20, 0.13);
  background: transparent;
  color: #5c5b55;
  cursor: pointer;
}

.icon-button:last-child {
  border-right: 0;
}

.icon-button:hover,
.icon-button[aria-pressed="true"] {
  background: #171714;
  color: white;
}

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

.file-meta {
  position: absolute;
  z-index: 4;
  bottom: 18px;
  left: 18px;
  min-width: 180px;
  padding: 11px 13px;
  border: 1px solid rgba(23, 23, 20, 0.13);
  border-radius: 9px;
  background: rgba(248, 247, 243, 0.88);
  box-shadow: 0 5px 22px rgba(25, 24, 19, 0.05);
  backdrop-filter: blur(10px);
}

#file-name {
  overflow: hidden;
  max-width: min(360px, calc(100vw - 72px));
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#file-details {
  margin-top: 3px;
  color: #77766f;
  font-size: 11px;
}

.loading {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(242, 241, 236, 0.78);
  color: #3d3d38;
  font-size: 13px;
  backdrop-filter: blur(3px);
}

.loading[hidden],
.error[hidden] {
  display: none;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 1.5px solid #b5b4ad;
  border-top-color: #171714;
  border-radius: 50%;
  animation: spin 750ms linear infinite;
}

.error {
  position: absolute;
  z-index: 12;
  bottom: 18px;
  left: 50%;
  max-width: calc(100% - 36px);
  padding: 10px 13px;
  transform: translateX(-50%);
  border: 1px solid rgba(135, 45, 30, 0.25);
  border-radius: 8px;
  background: #f7e9e4;
  color: #792b1d;
  font-size: 12px;
  box-shadow: 0 6px 20px rgba(65, 24, 17, 0.08);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 600px) {
  body {
    grid-template-rows: 58px minmax(0, 1fr);
  }

  .topbar {
    padding: 0 14px;
  }

  .privacy {
    display: none;
  }

  .drop-prompt {
    top: 78px;
  }

  .viewer-actions {
    top: 12px;
    right: 12px;
  }

  .file-meta {
    bottom: 12px;
    left: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1500ms;
  }
}
