:root {
  color-scheme: light;
  --bg: #f7f9ff;
  --panel: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #d9e2f1;
  --accent: #1677ff;
  --accent-dark: #145ff2;
  --danger: #9f2727;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(100%, 520px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 36px rgba(23, 33, 43, 0.08);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.heading {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.upload-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field input {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
}

.field input:focus {
  outline: 3px solid rgba(19, 121, 91, 0.18);
  border-color: var(--accent);
}

.file-picker {
  position: relative;
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 1px dashed #9aa8b5;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  cursor: pointer;
}

.file-picker:focus-within {
  outline: 3px solid rgba(19, 121, 91, 0.18);
  border-color: var(--accent);
}

.file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

#fileName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.link-button {
  min-height: 0;
  padding: 4px 0;
  background: transparent;
  color: var(--accent-dark);
}

.link-button:hover {
  background: transparent;
  color: var(--accent);
}

.status {
  min-height: 24px;
  margin-top: 16px;
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.result-link {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: var(--accent-dark);
  font-weight: 700;
}

.recent-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

h2 {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.3;
}

.recent-empty {
  color: var(--muted);
  font-size: 14px;
}

.recent-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recent-list li {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.recent-list a {
  overflow: hidden;
  color: var(--accent-dark);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-list span {
  color: var(--muted);
  font-size: 13px;
}

.upload-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 12%, rgba(22, 119, 255, 0.1), transparent 26%),
    radial-gradient(circle at 88% 8%, rgba(140, 82, 255, 0.12), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #f6f8ff 44%, #fbfdff 100%);
}

.upload-page svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-header {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid rgba(143, 169, 207, 0.25);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 24px rgba(32, 86, 175, 0.08);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #1269e8;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(65, 112, 255, 0.45);
  border-radius: 8px;
  background: linear-gradient(135deg, #2ca7ff 0%, #8b57ff 100%);
  color: white;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.36), 0 10px 20px rgba(40, 115, 255, 0.2);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.logout-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  background: transparent;
  color: #6655f2;
  font-size: 16px;
  font-weight: 700;
}

.logout-button:hover {
  background: transparent;
  color: #1677ff;
}

.upload-shell {
  width: min(100% - 48px, 1780px);
  margin: 26px auto 56px;
}

.upload-hero {
  position: relative;
  min-height: 316px;
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 34px 32px;
  overflow: hidden;
  border: 1px solid rgba(77, 145, 244, 0.3);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(174, 226, 255, 0.24), transparent 28%, transparent 72%, rgba(191, 164, 255, 0.22)),
    #ffffff;
  box-shadow: 0 18px 42px rgba(43, 85, 143, 0.14);
}

.upload-hero.is-dragging {
  border-color: rgba(22, 119, 255, 0.55);
  background:
    linear-gradient(90deg, rgba(174, 226, 255, 0.34), transparent 28%, transparent 72%, rgba(191, 164, 255, 0.32)),
    #ffffff;
  box-shadow: 0 18px 46px rgba(37, 99, 235, 0.22);
}

.upload-hero::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px dashed rgba(91, 151, 230, 0.35);
  border-radius: 8px;
  pointer-events: none;
}

.upload-hero.is-dragging::before {
  border-color: rgba(22, 119, 255, 0.72);
  background: rgba(22, 119, 255, 0.04);
}

.upload-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 112px;
  background:
    linear-gradient(22deg, rgba(158, 107, 255, 0.1) 0 23%, transparent 23%),
    linear-gradient(158deg, transparent 0 74%, rgba(90, 135, 255, 0.1) 74%);
  pointer-events: none;
}

.hero-mark {
  position: relative;
  z-index: 1;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #188eff 0%, #9251ff 100%);
  color: white;
  box-shadow: 0 18px 36px rgba(67, 91, 238, 0.32);
}

.hero-mark svg {
  width: 54px;
  height: 54px;
  stroke-width: 2.4;
}

.upload-hero h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #101828;
  font-size: 32px;
  font-weight: 800;
}

.upload-hero p {
  position: relative;
  z-index: 1;
  margin: 10px 0 22px;
  color: #667085;
  font-size: 18px;
  font-weight: 600;
}

.upload-hero .drop-hint {
  margin: -10px 0 22px;
  color: #1677ff;
  font-size: 16px;
  font-weight: 700;
}

.upload-page .upload-form {
  position: relative;
  z-index: 1;
  display: block;
}

.upload-button {
  position: relative;
  min-width: 290px;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 28px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, #1197ff 0%, #8b49f6 100%);
  color: white;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 14px 26px rgba(70, 94, 235, 0.26);
  cursor: pointer;
  overflow: hidden;
}

.upload-button.is-uploading {
  opacity: 0.78;
  cursor: progress;
}

.upload-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-button svg {
  width: 24px;
  height: 24px;
}

.hero-status {
  position: relative;
  z-index: 1;
  min-height: 22px;
  margin-top: 12px;
  font-weight: 700;
}

.spark {
  position: absolute;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 18px currentColor, 0 0 42px currentColor;
  pointer-events: none;
  animation: lightBreath 8s ease-in-out infinite;
}

.spark-one {
  top: 58px;
  left: 54%;
  width: 18px;
  height: 18px;
  color: rgba(179, 107, 255, 0.78);
  opacity: 0.75;
  animation-duration: 8.5s;
}

.spark-two {
  top: 88px;
  right: 7%;
  width: 22px;
  height: 22px;
  color: rgba(131, 220, 212, 0.86);
  opacity: 0.7;
  animation-duration: 10s;
  animation-delay: -2s;
}

.spark-three {
  top: 138px;
  left: 22%;
  width: 26px;
  height: 26px;
  color: rgba(127, 238, 225, 0.62);
  opacity: 0.72;
  animation-duration: 11s;
  animation-delay: -4s;
}

.spark-four {
  top: 74px;
  left: 38%;
  width: 12px;
  height: 12px;
  color: rgba(255, 201, 94, 0.78);
  opacity: 0.82;
  animation-duration: 7.5s;
  animation-delay: -1s;
}

.spark-five {
  right: 22%;
  top: 148px;
  width: 18px;
  height: 18px;
  color: rgba(191, 151, 255, 0.66);
  opacity: 0.68;
  animation-duration: 9.5s;
  animation-delay: -5s;
}

.spark-six {
  right: 13%;
  bottom: 78px;
  width: 14px;
  height: 14px;
  color: rgba(93, 171, 255, 0.66);
  opacity: 0.7;
  animation-duration: 12s;
  animation-delay: -3s;
}

.spark-seven {
  left: 13%;
  bottom: 88px;
  width: 10px;
  height: 10px;
  color: rgba(156, 126, 255, 0.66);
  opacity: 0.74;
  animation-duration: 8s;
  animation-delay: -6s;
}

.spark-eight {
  left: 30%;
  top: 88px;
  width: 16px;
  height: 16px;
  color: rgba(113, 230, 204, 0.58);
  opacity: 0.7;
  animation-duration: 10.5s;
  animation-delay: -2.5s;
}

@keyframes lightBreath {
  0%,
  100% {
    opacity: 0.48;
    box-shadow: 0 0 12px currentColor, 0 0 28px currentColor;
    transform: scale(0.92);
  }

  50% {
    opacity: 0.86;
    box-shadow: 0 0 24px currentColor, 0 0 58px currentColor;
    transform: scale(1.12);
  }
}

.paper-plane {
  position: absolute;
  left: 7%;
  top: 34%;
  width: 72px;
  height: 52px;
  background: linear-gradient(135deg, transparent 0 34%, rgba(44, 145, 245, 0.28) 35% 100%);
  clip-path: polygon(0 24%, 100% 0, 68% 100%, 47% 58%);
  transform: rotate(-12deg);
}

.paper-sheet {
  position: absolute;
  right: 6%;
  bottom: 54px;
  width: 94px;
  height: 124px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 0 78%, rgba(115, 105, 239, 0.28) 79% 100%),
    linear-gradient(180deg, #ffffff 0%, #eef4ff 100%);
  box-shadow: -14px 18px 26px rgba(87, 120, 184, 0.14);
  transform: rotate(16deg);
}

.upload-page .recent-section {
  margin-top: 24px;
  padding: 24px 38px 32px;
  border: 1px solid rgba(191, 203, 224, 0.55);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(43, 85, 143, 0.1);
}

.upload-page .recent-section h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  color: #111827;
  font-size: 25px;
  font-weight: 800;
}

.upload-page .recent-section h2 > span[aria-hidden="true"] {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(145, 83, 255, 0.14);
  color: #9857ff;
}

.upload-page .recent-section h2 svg {
  width: 18px;
  height: 18px;
}

.recent-table {
  overflow: hidden;
}

.upload-page .recent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px 180px 120px;
  align-items: center;
  gap: 24px;
  min-height: 39px;
  border-bottom: 1px solid #e5eaf3;
}

.recent-head {
  color: #667085;
  font-size: 16px;
  font-weight: 700;
}

.upload-page .recent-list {
  display: block;
  margin: 0;
  padding: 0;
  list-style: none;
}

.upload-page .recent-list li {
  min-width: 0;
}

.file-cell {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.file-cell svg {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: #1677ff;
}

.file-cell span {
  min-width: 0;
  overflow: hidden;
  color: #101828;
  font-size: 18px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-page .recent-row > span:nth-child(2) {
  color: #101828;
  font-size: 18px;
}

.recent-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: #1677ff;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.recent-link svg {
  width: 18px;
  height: 18px;
}

.upload-page .recent-empty {
  padding: 18px 0;
  border-top: 1px solid #e5eaf3;
  color: #667085;
  font-size: 17px;
}

@media (max-width: 560px) {
  .shell {
    padding: 16px;
  }

  .panel {
    padding: 20px;
  }

  h1 {
    font-size: 24px;
  }
}

/* QR code link in recent uploads list - matches .recent-link style */
button.qr-link,
a.qr-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  color: #1677ff;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  min-height: 0;
  line-height: inherit;
  box-shadow: none;
}

button.qr-link:hover,
a.qr-link:hover {
  background: none;
  color: var(--accent-dark);
}

button.qr-link svg,
a.qr-link svg {
  width: 18px;
  height: 18px;
}

/* QR popup overlay */
.qr-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  animation: qrFadeIn 0.15s ease;
}

@keyframes qrFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.qr-popup-card {
  width: min(90vw, 360px);
  padding: 28px 24px 20px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
  text-align: center;
  animation: qrSlideUp 0.2s ease;
}

@keyframes qrSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.qr-popup-title {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.qr-popup-svg {
  display: inline-block;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-popup-svg svg {
  display: block;
  width: 200px;
  height: 200px;
}

.qr-popup-url {
  margin: 12px 0 16px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
  line-height: 1.5;
}

.qr-popup-close {
  min-height: 36px;
  padding: 0 24px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.qr-popup-close:hover {
  background: var(--accent-dark);
}

@media (max-width: 900px) {
  .app-header {
    height: 48px;
    padding: 0 14px;
  }

  .brand {
    gap: 8px;
    font-size: 18px;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
  }

  .logout-button {
    font-size: 14px;
  }

  .upload-shell {
    width: min(100% - 28px, 1780px);
    margin-top: 18px;
  }

  .upload-hero {
    min-height: 300px;
    padding: 30px 18px;
  }

  .upload-hero h1 {
    font-size: 26px;
  }

  .upload-hero p {
    max-width: 300px;
    font-size: 15px;
    text-align: center;
  }

  .paper-plane,
  .paper-sheet {
    display: none;
  }

  .upload-page .recent-section {
    padding: 20px;
  }

  .upload-page .recent-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: 12px 0;
  }

  .upload-page .recent-head {
    display: none;
  }

  .qr-link {
    justify-self: start;
  }
}
