:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #18211a;
  --muted: #66705f;
  --line: #dfe5da;
  --panel: #ffffff;
  --green: #1f7a4d;
  --green-dark: #145837;
  --gold: #d8ad44;
  --danger: #b73535;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(216, 173, 68, 0.18), transparent 32rem),
    linear-gradient(180deg, #fbfcf8 0%, var(--bg) 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 2px 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: 0;
}

.printer-mark {
  position: relative;
  flex: 0 0 74px;
  height: 74px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff 0 9px, transparent 10px),
    repeating-radial-gradient(circle at center, #ffffff 0 2px, #edf1e8 2px 6px);
  border: 1px solid var(--line);
  box-shadow: 0 14px 36px rgba(28, 60, 32, 0.16);
}

.printer-mark span {
  position: absolute;
  right: -2px;
  bottom: 8px;
  width: 26px;
  height: 8px;
  border-radius: 999px;
  background: var(--gold);
  transform: rotate(-22deg);
}

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

.account-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.user-summary,
.auth-form {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 24px rgba(23, 37, 25, 0.06);
}

.user-summary {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 10px;
}

.user-summary span,
#authHint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.user-summary strong {
  display: block;
  margin-top: 3px;
  font-size: 17px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-actions button,
.ghost-btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}

.auth-actions button:first-child {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.ghost-btn {
  padding: 0 12px;
  color: var(--muted);
}

#authHint {
  margin: 0;
  line-height: 1.45;
}

.upload-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  border: 1.5px dashed #bcc9b8;
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(31, 122, 77, 0.05) 25%, transparent 25% 75%, rgba(31, 122, 77, 0.05) 75%),
    linear-gradient(45deg, rgba(31, 122, 77, 0.05) 25%, transparent 25% 75%, rgba(31, 122, 77, 0.05) 75%);
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
}

.upload-panel > input[type="file"],
.upload-panel > input[type="hidden"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.circle-editor {
  display: grid;
  place-items: center;
  width: min(72vw, 236px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--green);
  border-radius: 50%;
  background:
    linear-gradient(45deg, rgba(31, 122, 77, 0.05) 25%, transparent 25% 75%, rgba(31, 122, 77, 0.05) 75%),
    linear-gradient(45deg, rgba(31, 122, 77, 0.05) 25%, transparent 25% 75%, rgba(31, 122, 77, 0.05) 75%);
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
  box-shadow: 0 12px 32px rgba(23, 37, 25, 0.14);
  touch-action: none;
}

.circle-editor canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.upload-panel.has-image .upload-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  align-items: flex-end;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 28px rgba(23, 37, 25, 0.12);
}

.upload-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

.upload-hint strong {
  color: var(--ink);
  font-size: 18px;
}

.upload-hint span {
  font-size: 13px;
  line-height: 1.45;
}

.zoom-control {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.zoom-control span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.zoom-control input {
  min-height: 28px;
  padding: 0;
  accent-color: var(--green);
}

.gallery-section {
  display: grid;
  gap: 10px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.gallery-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.gallery-tab {
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.gallery-tab.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.gallery-grid {
  display: flex;
  gap: 9px;
  margin: 0 -18px;
  padding: 0 18px 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.gallery-grid::-webkit-scrollbar {
  height: 6px;
}

.gallery-grid::-webkit-scrollbar-track {
  background: transparent;
}

.gallery-grid::-webkit-scrollbar-thumb {
  background: #cbd8c8;
  border-radius: 999px;
}

.artwork-card {
  flex: 0 0 112px;
  display: grid;
  gap: 7px;
  align-content: start;
  min-width: 0;
  padding: 8px 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  scroll-snap-align: start;
}

.artwork-card.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.12);
}

.artwork-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  padding: 6px;
  border-radius: 6px;
  background:
    linear-gradient(45deg, rgba(31, 122, 77, 0.05) 25%, transparent 25% 75%, rgba(31, 122, 77, 0.05) 75%),
    linear-gradient(45deg, rgba(31, 122, 77, 0.05) 25%, transparent 25% 75%, rgba(31, 122, 77, 0.05) 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
}

.artwork-card span {
  min-height: 18px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.field-group {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
}

label span,
summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--panel);
  color: var(--ink);
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.12);
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

details {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

summary {
  cursor: pointer;
}

details label {
  margin-top: 12px;
}

.submit-btn {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(31, 122, 77, 0.26);
}

.submit-btn:active {
  background: var(--green-dark);
  transform: translateY(1px);
}

.submit-btn[disabled] {
  opacity: 0.68;
}

.result {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(23, 37, 25, 0.08);
}

.result h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.result p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.result.success h2 {
  color: var(--green);
}

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

@media (max-width: 360px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  h1 {
    font-size: 26px;
  }

  .printer-mark {
    flex-basis: 62px;
    height: 62px;
  }

  .auth-fields,
  .user-summary {
    grid-template-columns: 1fr;
  }

  .gallery-tabs {
    gap: 6px;
  }

  .gallery-tab {
    font-size: 13px;
  }

  .gallery-grid {
    gap: 7px;
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .artwork-card {
    flex-basis: 104px;
  }
}
