:root {
  --ink: #171815;
  --paper: #f3f0e8;
  --surface: #fffdf7;
  --muted: #706f68;
  --line: #d9d4c8;
  --accent: #c8ff3d;
  --accent-ink: #171815;
  --danger: #a33a2c;
  --shadow: 0 24px 70px rgba(23, 24, 21, 0.12);
  --radius: 22px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, label[for], .photo-field { -webkit-tap-highlight-color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; }
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 24px; padding: 18px clamp(18px, 4vw, 60px);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  border-bottom: 1px solid rgba(23,24,21,.1);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; border: 0; background: none; padding: 0; cursor: pointer; justify-self: start; text-align: left; }
.brand-mark { display: grid; place-items: center; width: 42px; aspect-ratio: 1; border: 1px solid var(--ink); border-radius: 50%; font-family: Georgia, serif; font-size: 13px; letter-spacing: .08em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .05em; text-transform: uppercase; }
.brand small { color: var(--muted); font-size: 11px; }
.main-nav { display: inline-flex; gap: 4px; padding: 4px; background: rgba(23,24,21,.06); border-radius: 999px; }
.nav-button { border: 0; background: transparent; padding: 8px 15px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.nav-button.is-active { background: var(--ink); color: white; }
.site-header > .button { justify-self: end; }

main { width: min(1500px, 100%); margin: 0 auto; padding: clamp(26px, 5vw, 72px) clamp(18px, 4vw, 60px) 80px; }
.view { display: none; }
.view.is-active { display: block; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 40px; margin-bottom: 32px; }
.eyebrow { margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-weight: 750; font-size: 11px; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 880px; margin-bottom: 14px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; line-height: .98; letter-spacing: -.045em; font-size: clamp(48px, 7vw, 102px); }
.hero-copy, .page-heading > p:last-child { max-width: 690px; color: var(--muted); font-size: clamp(16px, 2vw, 20px); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: end; padding-bottom: 8px; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 10px 16px; border: 1px solid var(--ink); border-radius: 999px; cursor: pointer; text-decoration: none; font-weight: 700; font-size: 13px; transition: transform .18s ease, background .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--ink); color: white; }
.button-primary:hover { background: #30312d; }
.button-secondary { background: transparent; }
.button-secondary:hover { background: var(--surface); }
.button-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: transparent; }
.file-label { user-select: none; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--ink); color: white; border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; }
.stats article { min-height: 125px; padding: 24px; border-right: 1px solid rgba(255,255,255,.16); }
.stats article:last-child { border-right: 0; }
.stats span, .stats small { display: block; }
.stats span { font: 500 clamp(35px, 5vw, 60px)/1 Georgia, serif; }
.stats small { margin-top: 10px; color: rgba(255,255,255,.62); text-transform: uppercase; letter-spacing: .12em; font-size: 10px; }

.toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) repeat(3, auto); gap: 10px; margin: 0 0 10px; }
.search-field { position: relative; }
.search-field svg { position: absolute; left: 16px; top: 50%; width: 18px; transform: translateY(-50%); fill: none; stroke: currentColor; stroke-width: 1.7; }
.search-field input, .toolbar select { width: 100%; min-height: 48px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; color: var(--ink); }
.search-field input { padding: 0 16px 0 46px; }
.toolbar select { padding: 0 34px 0 14px; }
.search-field input:focus, select:focus, input:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 2px; }
.results-meta { min-height: 30px; padding: 7px 3px; color: var(--muted); font-size: 12px; }

.shirt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(14px, 2vw, 28px); }
.shirt-card { overflow: hidden; border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 0 rgba(23,24,21,.1); cursor: pointer; text-align: left; padding: 0; transition: transform .25s ease, box-shadow .25s ease; }
.shirt-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card-image { position: relative; aspect-ratio: 4/5; overflow: hidden; background: #ded9ce; }
.card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-placeholder { width: 100%; height: 100%; display: grid; place-items: center; background: linear-gradient(145deg,#d8d1c2,#efebe1); }
.card-placeholder span { display: grid; place-items: center; width: 36%; aspect-ratio: 1; border-radius: 50%; border: 1px solid rgba(23,24,21,.45); font: 500 clamp(34px, 6vw, 64px)/1 Georgia, serif; }
.status-chip { position: absolute; top: 14px; left: 14px; padding: 6px 9px; border-radius: 999px; background: rgba(255,253,247,.9); backdrop-filter: blur(10px); text-transform: uppercase; letter-spacing: .1em; font-size: 9px; font-weight: 800; }
.card-body { padding: 18px; }
.card-kicker { margin: 0 0 5px; color: var(--muted); text-transform: uppercase; letter-spacing: .11em; font-size: 10px; }
.card-title { margin: 0 0 12px; font: 500 25px/1.08 Georgia, serif; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.card-meta span:last-child { text-align: right; }

.empty-state { padding: 80px 20px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }
.empty-illustration { display: grid; place-items: center; width: 90px; aspect-ratio: 1; margin: 0 auto 22px; border: 1px solid var(--ink); border-radius: 50%; font: 500 44px/1 Georgia, serif; }
.empty-state h2 { font: 500 34px/1.1 Georgia, serif; margin-bottom: 9px; }
.empty-state p { color: var(--muted); }

.page-heading { margin-bottom: 34px; }
.page-heading h1 { font-size: clamp(58px, 8vw, 110px); margin-bottom: 10px; }
.places-summary { display: grid; gap: 12px; }
.place-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; padding: 20px 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.place-row h2 { margin: 0 0 4px; font: 500 27px/1.1 Georgia, serif; }
.place-row p { margin: 0; color: var(--muted); font-size: 13px; }
.place-row aside { display: flex; align-items: center; gap: 16px; }
.place-count { display: grid; place-items: center; min-width: 48px; height: 48px; padding: 0 12px; border-radius: 999px; background: var(--accent); font-weight: 800; }
.text-link { color: var(--ink); text-underline-offset: 3px; font-size: 12px; }

::backdrop { background: rgba(23,24,21,.62); backdrop-filter: blur(7px); }
dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.shirt-dialog { width: min(980px, calc(100vw - 24px)); max-height: calc(100vh - 24px); border-radius: 28px; }
.shirt-dialog form { min-height: 100%; }
.dialog-header, .dialog-footer { position: sticky; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 26px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(16px); }
.dialog-header { top: 0; border-bottom: 1px solid var(--line); }
.dialog-footer { bottom: 0; border-top: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font: 500 37px/1 Georgia, serif; }
.icon-button { width: 44px; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; font-size: 25px; line-height: 1; }
.form-body { padding: 8px 26px 36px; }
.form-section { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 28px; padding: 28px 0; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.section-heading { display: flex; gap: 12px; align-items: flex-start; }
.section-heading > span { display: grid; place-items: center; flex: 0 0 34px; width: 34px; aspect-ratio: 1; border-radius: 50%; background: var(--ink); color: white; font-size: 10px; }
.section-heading h3 { margin: 2px 0 4px; font-size: 14px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.photo-fields { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.photo-field { position: relative; display: grid; place-items: center; aspect-ratio: 4/5; overflow: hidden; border: 1px dashed #aaa394; border-radius: 16px; background: #ece8df; cursor: pointer; }
.photo-field:hover { border-color: var(--ink); }
.photo-field img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder { display: grid; gap: 3px; text-align: center; }
.photo-placeholder b { font: 500 20px/1 Georgia, serif; }
.photo-placeholder small { color: var(--muted); font-size: 10px; }
.photo-field.has-image::after { content: "Change"; position: absolute; right: 8px; bottom: 8px; padding: 5px 8px; border-radius: 999px; background: rgba(255,253,247,.9); font-size: 9px; font-weight: 800; }
.form-grid { display: grid; gap: 14px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; align-content: start; }
.field-wide { grid-column: 1 / -1; }
.field > span { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: white; color: var(--ink); }
.field textarea { resize: vertical; min-height: 90px; }
.field small { color: var(--muted); font-size: 10px; }
.footer-actions { display: flex; gap: 10px; }

.detail-dialog { width: min(1120px, calc(100vw - 24px)); max-height: calc(100vh - 24px); border-radius: 28px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(340px, .95fr); min-height: 640px; }
.detail-media { min-height: 600px; background: #ded9ce; }
.detail-media img { display: block; width: 100%; height: 100%; max-height: calc(100vh - 24px); object-fit: cover; }
.detail-placeholder { height: 100%; min-height: 640px; display: grid; place-items: center; background: linear-gradient(145deg,#d8d1c2,#efebe1); font: 500 90px/1 Georgia, serif; }
.detail-body { position: relative; padding: clamp(28px, 5vw, 58px); overflow-y: auto; }
.detail-close { position: absolute; top: 18px; right: 18px; }
.detail-body h2 { margin: 4px 45px 10px 0; font: 500 clamp(42px, 5vw, 70px)/.98 Georgia, serif; letter-spacing: -.035em; }
.detail-location { color: var(--muted); font-size: 14px; }
.detail-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 30px 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.detail-facts div { min-height: 85px; padding: 15px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-facts dt { color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-size: 9px; }
.detail-facts dd { margin: 5px 0 0; font-size: 13px; }
.detail-story { margin: 24px 0; }
.detail-story h3 { margin-bottom: 7px; text-transform: uppercase; letter-spacing: .1em; font-size: 10px; }
.detail-story p { color: #3c3d38; white-space: pre-wrap; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 20px 0; }
.tag { padding: 6px 10px; border-radius: 999px; background: rgba(23,24,21,.07); font-size: 11px; }
.detail-actions { display: flex; gap: 10px; margin-top: 30px; }
.thumb-strip { display: flex; gap: 8px; margin-top: 18px; }
.thumb-strip button { width: 68px; aspect-ratio: 1; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 10px; background: #ddd; cursor: pointer; }
.thumb-strip button.is-active { border-color: var(--ink); }
.thumb-strip img { width: 100%; height: 100%; object-fit: cover; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 999px; background: var(--ink); color: white; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: 12px; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .shirt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .toolbar select:last-child { grid-column: span 2; }
  .form-section { grid-template-columns: 1fr; }
  .section-heading { max-width: 430px; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-media { min-height: 50vh; max-height: 65vh; }
  .detail-media img { max-height: 65vh; }
}
@media (max-width: 720px) {
  .site-header { grid-template-columns: 1fr auto; gap: 14px; padding: 14px 16px; }
  .main-nav { grid-row: 2; grid-column: 1 / -1; justify-self: stretch; }
  .nav-button { flex: 1; }
  .site-header > .button { padding-inline: 13px; }
  main { padding-top: 34px; }
  .hero { align-items: flex-start; flex-direction: column; gap: 18px; }
  .hero-actions { justify-content: flex-start; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats article:nth-child(2) { border-right: 0; }
  .stats article:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.16); }
  .shirt-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  .search-field, .toolbar select:last-child { grid-column: auto; }
  .shirt-dialog, .detail-dialog { width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .dialog-header, .dialog-footer { padding: 16px; }
  .form-body { padding-inline: 16px; }
  .photo-fields { grid-template-columns: 1fr 1fr; }
  .photo-fields .photo-field:first-child { grid-column: 1 / -1; }
  .two-columns { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .detail-media { min-height: 48vh; }
  .detail-placeholder { min-height: 48vh; }
  .detail-body { padding: 28px 20px 42px; }
  .place-row { grid-template-columns: 1fr; }
  .place-row aside { justify-content: space-between; }
}


/* Phone-first PWA additions */
.install-card {
  position: fixed; z-index: 32; top: calc(74px + env(safe-area-inset-top)); left: 50%;
  width: min(520px, calc(100vw - 24px)); transform: translateX(-50%);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 14px 13px 16px; border: 1px solid rgba(23,24,21,.12);
  border-radius: 18px; background: rgba(255,253,247,.96); box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.install-card[hidden] { display: none; }
.install-card strong, .install-card span { display: block; }
.install-card strong { font-size: 13px; }
.install-card span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.install-dismiss { flex: 0 0 auto; width: 36px; }
.mobile-tabbar { display: none; }

@media (max-width: 720px) {
  html, body { overscroll-behavior-y: none; }
  body { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
  .site-header {
    grid-template-columns: 1fr auto; grid-template-rows: auto;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  }
  .brand small, .main-nav, .site-header > .button { display: none; }
  .brand-mark { width: 38px; }
  .brand strong { font-size: 13px; }
  main { padding: 24px 14px 36px; }
  .hero { margin-bottom: 20px; }
  .hero h1 { font-size: clamp(44px, 14vw, 64px); }
  .hero-copy { font-size: 15px; }
  .hero-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; padding-bottom: 0; }
  .hero-actions .button { min-height: 48px; }
  .stats { border-radius: 18px; margin-bottom: 18px; }
  .stats article { min-height: 88px; padding: 16px; }
  .stats span { font-size: 34px; }
  .toolbar { position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 12; margin: 0 -14px 10px; padding: 8px 14px 10px; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(14px); }
  .toolbar select { display: none; }
  .search-field input { min-height: 46px; background: rgba(255,253,247,.96); }
  .shirt-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .shirt-card { border-radius: 16px; }
  .card-body { padding: 12px; }
  .card-title { font-size: 19px; margin-bottom: 8px; }
  .card-meta { align-items: flex-start; flex-direction: column; gap: 2px; font-size: 10px; }
  .card-meta span:last-child { text-align: left; }
  .status-chip { top: 8px; left: 8px; padding: 5px 7px; font-size: 7px; }
  .mobile-tabbar {
    position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(8px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: 1fr 70px 1fr; align-items: end;
    min-height: 66px; padding: 7px 16px 7px; border: 1px solid rgba(23,24,21,.12); border-radius: 24px;
    background: rgba(255,253,247,.93); box-shadow: 0 18px 50px rgba(23,24,21,.2); backdrop-filter: blur(20px);
  }
  .mobile-tab { min-height: 50px; border: 0; background: none; display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); }
  .mobile-tab span { font-size: 21px; line-height: 1; }
  .mobile-tab small { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
  .mobile-tab.is-active { color: var(--ink); }
  .mobile-add {
    width: 62px; height: 62px; margin: -22px auto 0; border: 0; border-radius: 50%;
    background: var(--accent); color: var(--ink); box-shadow: 0 8px 22px rgba(23,24,21,.18);
    font-size: 36px; line-height: 1;
  }
  .shirt-dialog, .detail-dialog {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0;
  }
  .dialog-header { padding: calc(12px + env(safe-area-inset-top)) 14px 12px; }
  .dialog-header h2 { font-size: 30px; }
  .dialog-footer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .dialog-footer > div:first-child { display: none; }
  .footer-actions { width: 100%; }
  .footer-actions .button { min-height: 48px; flex: 1; }
  .form-body { padding: 0 14px 28px; }
  .form-section { padding: 20px 0; gap: 14px; }
  .section-heading > span { width: 30px; flex-basis: 30px; }
  .photo-fields { grid-template-columns: 1fr 1fr; gap: 8px; }
  .photo-fields .photo-field:first-child { grid-column: 1 / -1; aspect-ratio: 4/3; }
  .photo-field { min-height: 150px; border-radius: 16px; }
  .photo-placeholder b { font-size: 22px; }
  .field input, .field select, .field textarea { min-height: 48px; font-size: 16px; }
  .field textarea { min-height: 110px; }
  .detail-layout { min-height: 100%; }
  .detail-media { min-height: 42dvh; max-height: 48dvh; }
  .detail-media img { max-height: 48dvh; }
  .detail-body { padding: 24px 18px calc(40px + env(safe-area-inset-bottom)); }
  .detail-body h2 { font-size: 44px; }
  .install-card { top: calc(58px + env(safe-area-inset-top)); }
}

@media (max-width: 390px) {
  .shirt-grid { grid-template-columns: 1fr; }
}
