:root {
  color-scheme: light;
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-muted: #f6f8fb;
  --ink: #101318;
  --muted: #66717f;
  --line: #d9e0e8;
  --line-strong: #c1cbd6;
  --green: #108567;
  --green-soft: #e6f6f1;
  --blue: #315fd5;
  --red: #c73c34;
  --shadow: 0 14px 34px rgba(20, 28, 38, 0.10);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(49, 95, 213, 0.11), transparent 30rem),
    linear-gradient(180deg, #fafbfc, var(--bg));
  color: var(--ink);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

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

svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  width: min(1240px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 0 24px;
}

.topbar {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(16, 19, 24, 0.12);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.05;
}

.brand strong {
  font-size: 0.95rem;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
}

.topbar-meta {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.84rem;
  backdrop-filter: blur(12px);
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
}

.settings-button {
  box-shadow: 0 8px 20px rgba(16, 19, 24, 0.08);
}

.settings-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: min(340px, calc(100vw - 20px));
  max-height: calc(100vh - 58px);
  overflow: hidden;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(20, 28, 38, 0.16);
  backdrop-filter: blur(14px);
}

.settings-menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.workspace {
  padding-top: 12px;
}

.desk-layout {
  display: grid;
  grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.action-stack {
  display: grid;
  gap: 12px;
  align-content: start;
}

.side-stack {
  display: grid;
  gap: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 10px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-heading.compact {
  margin-bottom: 7px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: 1.28rem;
}

h2 {
  font-size: 1.08rem;
}

label > span,
legend {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 760;
}

input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  padding: 0 11px;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(49, 95, 213, 0.12);
}

.secret-row.is-hidden,
[hidden] {
  display: none !important;
}

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

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.option-row {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 8px;
}

.segmented {
  display: grid;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #edf2f6;
}

.mode-options {
  grid-template-columns: 1fr 1fr;
}

.count-options {
  grid-template-columns: repeat(4, 1fr);
}

.segmented label {
  position: relative;
  min-width: 0;
}

.segmented input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 28px;
  padding: 0 7px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
  cursor: pointer;
}

.segmented input:checked + span {
  background: #101318;
  color: #ffffff;
  box-shadow: 0 7px 14px rgba(16, 19, 24, 0.17);
}

.drop-zone {
  position: relative;
  min-height: 76px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(16, 133, 103, 0.10), rgba(49, 95, 213, 0.08)),
    var(--surface-muted);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.drop-zone.is-dragging {
  transform: translateY(-2px);
  border-color: var(--green);
  background:
    linear-gradient(135deg, rgba(16, 133, 103, 0.18), rgba(49, 95, 213, 0.12)),
    var(--surface-muted);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-art {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #101318;
  color: #86e8cc;
}

.drop-zone strong,
.drop-zone span {
  display: block;
}

.drop-zone strong {
  font-size: 0.92rem;
}

.drop-zone span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.selected-strip {
  display: grid;
  gap: 7px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.selected-strip.is-empty {
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  align-content: center;
  color: var(--muted);
}

.selected-strip > strong {
  font-size: 0.84rem;
}

.thumb-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
  max-height: 72px;
  overflow: auto;
}

.thumb-strip img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.thumb-file {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101318;
  color: #9fe8d4;
  font-size: 0.68rem;
  font-weight: 900;
}

.progress-wrap {
  display: none;
  align-items: center;
  gap: 10px;
}

.progress-wrap.is-active {
  display: flex;
}

.progress-line {
  flex: 1;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe6ed;
}

.progress-line span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 140ms ease;
}

#progressText {
  width: 42px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: right;
}

.primary-button,
.secondary-button,
.icon-button {
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}

.primary-button,
.secondary-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  font-weight: 850;
}

.primary-button {
  border: 0;
  background: #101318;
  color: #ffffff;
  box-shadow: 0 12px 22px rgba(16, 19, 24, 0.17);
}

.primary-button:hover {
  background: #252a30;
}

.primary-button:disabled {
  cursor: not-allowed;
  background: #9aa3ad;
  box-shadow: none;
}

.secondary-button {
  position: relative;
  z-index: 1;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--blue);
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-button:hover {
  border-color: var(--blue);
}

.code-ticket {
  display: grid;
  gap: 7px;
  margin-top: 8px;
  padding: 9px;
  border-radius: var(--radius);
  background: #101318;
  color: #ffffff;
}

.code-ticket > span {
  color: #9fe8d4;
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

#codeList {
  display: grid;
  gap: 7px;
}

.code-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 6px;
  cursor: pointer;
  text-align: left;
}

.code-chip strong {
  letter-spacing: 0.08em;
  font-size: 1rem;
}

.code-chip span {
  overflow: hidden;
  color: #dce8ea;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.public-panel {
  min-height: calc(100vh - 82px);
}

.public-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
  max-height: calc(100vh - 154px);
  min-height: calc(100vh - 154px);
  align-content: start;
  overflow: auto;
  padding-right: 2px;
}

.public-grid > .empty-state {
  grid-column: 1 / -1;
  min-height: calc(100vh - 166px);
}

.public-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.file-button {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: #e7edf4;
  color: var(--ink);
  cursor: pointer;
}

.file-button:hover {
  background: #dfe7ef;
}

.file-fallback {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 7px;
  background: #101318;
  color: #9fe8d4;
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0;
}

.image-button {
  position: relative;
  overflow: hidden;
  display: block;
  background:
    linear-gradient(45deg, #edf2f6 25%, transparent 25%),
    linear-gradient(-45deg, #edf2f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf2f6 75%),
    linear-gradient(-45deg, transparent 75%, #edf2f6 75%),
    #ffffff;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.image-button .file-fallback {
  display: none;
}

.image-button img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
}

.image-button.is-preview-broken {
  display: grid;
  place-items: center;
}

.image-button.is-preview-broken img {
  display: none;
}

.image-button.is-preview-broken .file-fallback {
  display: grid;
}

.public-card > div {
  padding: 6px;
}

.public-card strong,
.public-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-card strong {
  font-size: 0.84rem;
}

.public-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.pickup-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: end;
}

#codeInput {
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.mini-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 850;
}

.pickup-card {
  display: grid;
  gap: 5px;
  margin-top: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.pickup-card strong,
.pickup-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pickup-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 2px 0 0;
}

.stat-grid div {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.stat-grid dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.stat-grid dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 6px;
  max-height: min(240px, calc(100vh - 136px));
  overflow: auto;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.history-item strong,
.history-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item strong {
  font-size: 0.84rem;
}

.history-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.history-item em {
  min-width: 42px;
  min-height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e8eef4;
  color: var(--ink);
  font-style: normal;
  font-weight: 900;
  font-size: 0.8rem;
}

.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.compact-empty {
  min-height: 54px;
}

.empty-state.is-error {
  color: var(--red);
}

.toast {
  min-height: 20px;
  margin-top: 5px;
  color: var(--green);
  font-size: 0.84rem;
  font-weight: 780;
}

.toast.is-error {
  color: var(--red);
}

@media (max-width: 1040px) {
  .app-shell {
    width: min(100% - 28px, 1240px);
  }

  .desk-layout {
    grid-template-columns: minmax(310px, 340px) minmax(0, 1fr);
  }

  .public-grid {
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 1240px);
    padding-top: 8px;
  }

  .topbar-meta {
    display: none;
  }

  .desk-layout,
  .side-stack {
    grid-template-columns: 1fr;
  }

  .desk-layout {
    gap: 10px;
  }

  .action-stack {
    display: contents;
  }

  .upload-panel {
    order: 1;
  }

  .public-panel {
    order: 2;
  }

  .side-stack {
    order: 3;
  }

  .panel {
    padding: 10px;
  }

  .public-panel {
    min-height: 0;
  }

  .drop-zone {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

  #pickButton,
  #uploadButton,
  #claimButton {
    padding: 0 10px;
  }

  #pickButton span {
    display: none;
  }

  .drop-zone .secondary-button {
    grid-column: auto;
  }

  .count-options {
    grid-template-columns: repeat(4, 1fr);
  }

  .option-row {
    grid-template-columns: 1fr 1fr;
  }

  .public-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    min-height: 190px;
    max-height: none;
  }

  .public-grid > .empty-state {
    min-height: 190px;
  }

  .pickup-form {
    grid-template-columns: 1fr;
  }
}
