:root {
  --gradient: linear-gradient(135deg, #5bc0f8 10%, #4285f4 50%, #3659d4 100%);
  --bg: #0d1b3d;
  --panel: #ffffff;
  --panel-soft: #ffffff;
  --text: #000000;
  --muted: #9ba4b5;
  --accent: #5bc0f8;
  --accent-strong: #4285f4;
  --border: #4f7de3;
  --shadow: 0 25px 70px -25px rgba(0, 0, 0, 0.5);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  line-height: 1.25em;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
  background: linear-gradient(135deg, #0b1f3f, #103f77, #0d6bbf, #103f77, #0b1f3f);
  background-size: 400% 400%;
  animation: gradient 15s ease infinite;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 18px 42px;
  gap: 16px;
  overflow-x: hidden;
}

@keyframes gradient {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.app-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: calc(100% + 60px);
  margin-left: -18px;
  padding: 16px 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transform: translateY(-24px);
  border: none;
}

.header-top {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  width: min(1100px, 100%);
  margin: 0 auto;
}

.logo {
  width: 64px;
  height: 64px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}

.titles {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 1;
  gap: 16px;
}

.eyebrow {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.control-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  margin-left: auto;
  padding: 6px 8px;
}

.app-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(1100px, 100%);
  gap: 16px;
}

.upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  width: min(600px, 100%);
  text-align: center;
}

.upload-instructions {
  margin: 0;
  font-weight: 600;
  color: #1f2937;
}

.reset-row {
  display: none;
  width: min(1100px, 100%);
  justify-content: center;
  margin: 4px auto 0;
}

.reset-row.visible {
  display: flex;
}

.hidden {
  display: none !important;
}

.upload-button,
button:not(.delete-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 22px;
  background-image: var(--gradient);
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: none;
  box-shadow: 0 18px 32px -20px rgba(66, 133, 244, 0.85);
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.upload-button:hover,
button:not(.delete-btn):not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 38px -18px rgba(66, 133, 244, 0.95);
}

.upload-button:active,
button:not(.delete-btn):not(:disabled):active {
  transform: translateY(0);
}

button:not(.delete-btn):disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

#file {
  display: none;
}

.control-bar label {
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
}

.control-bar input[type="text"],
.control-bar input[type="number"],
.control-bar select {
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  min-width: 180px;
  outline: none;
}

.control-bar input[type="number"] {
  width: 80px;
}

.control-bar select {
  width: 140px;
  appearance: none;
}

.control-bar button {
  font-size: 15px;
}

.control-bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.control-bar button:not(:disabled):hover {
  transform: translateY(-1px);
}

#pages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  width: 100%;
}

.page {
  position: relative;
  display: inline-block;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 25px 55px -25px rgba(0, 0, 0, 0.65);
  border: 1px solid var(--border);
}

.overlay {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.mark {
  position: absolute;
  color: #000000;
  font-size: 14px;
  font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
  padding: 2px 4px;
  white-space: pre;
  cursor: move;
  user-select: none;
  pointer-events: auto;
  border-radius: 8px;
  backdrop-filter: blur(2px);
}

.mark .mark-text {
  pointer-events: none;
  display: inline-block;
  padding: 2px;
}

.mark.selected {
  border-color: #f45b69;
  box-shadow: 0 0 0 1px #f45b69, 0 12px 30px -22px rgba(244, 91, 105, 0.9);
}

.mark .delete-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: #f45b69;
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  cursor: pointer;
  display: none;
  padding: 0;
  box-shadow: 0 8px 18px -12px rgba(0, 0, 0, 0.55);
}

.mark.selected .delete-btn {
  display: block;
}

.mark.editing {
  cursor: text;
  background: rgba(114, 237, 242, 0.28);
}

.mark.editing .mark-text {
  pointer-events: auto;
}