:root {
  --bg: #f4f5f2;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #61666d;
  --line: #d7dce0;
  --accent: #1b6f5c;
  --accent-ink: #ffffff;
  --brand-gold: #e7b44f;
  --brand-red: #c9584a;
  --brand-blue: #5378b6;
  --warning: #a34718;
  --danger: #b3261e;
  --shadow: rgba(31, 36, 42, 0.12);
  --rail: #e9ede7;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior-y: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

[hidden] {
  display: none !important;
}

.app {
  width: min(1100px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: grid;
  gap: 12px;
  align-content: start;
}

.topbar,
.dialog-head,
.toolbar,
.scan-actions,
.dialog-actions {
  display: flex;
  align-items: center;
}

.topbar,
.dialog-head {
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  min-height: 52px;
}

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

.account-button.is-signed-in {
  border-color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark,
.empty-mark {
  display: block;
  flex: 0 0 auto;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(31, 36, 42, 0.16);
}

.brand-mark {
  width: 42px;
  height: 42px;
}

.empty-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 6px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1;
}

h2 {
  font-size: 1.08rem;
  line-height: 1.2;
}

.scan-panel,
.stats-grid article,
.empty-state,
dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px var(--shadow);
}

.workspace,
.capture-column,
.inventory-column {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.capture-column,
.inventory-column {
  align-content: start;
}

.scan-panel {
  border-top: 4px solid var(--brand-gold);
  padding: 12px;
  display: grid;
  gap: 12px;
}

.scan-panel p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.38;
}

.scan-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.type-picker {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--rail);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.type-picker label {
  min-width: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  cursor: pointer;
}

.type-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.type-picker label:has(input:checked) {
  color: var(--accent-ink);
  background: var(--accent);
}

.photo-button,
.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 760;
}

.photo-button,
.primary-button {
  color: var(--accent-ink);
  background: var(--accent);
}

.photo-button {
  flex: 1;
  min-width: 96px;
  display: grid;
  place-items: center;
  padding: 0 14px;
}

.photo-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  opacity: 0;
}

.photo-button.secondary,
.secondary-button,
.icon-button {
  color: var(--ink);
  background: var(--rail);
  border-color: var(--line);
}

.secondary-button {
  padding: 0 14px;
}

.danger-button {
  color: #fff;
  background: var(--danger);
}

.icon-button {
  width: 44px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}

.icon-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  opacity: 0;
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.quiet {
  background: transparent;
  box-shadow: none;
}

.photo-button:focus-within,
.icon-button:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stats-grid article {
  min-width: 0;
  padding: 10px;
}

.stats-grid article:nth-child(1) {
  border-top: 4px solid var(--accent);
}

.stats-grid article:nth-child(2) {
  border-top: 4px solid var(--brand-blue);
}

.stats-grid article:nth-child(3) {
  border-top: 4px solid var(--brand-red);
}

.stats-grid article:nth-child(4) {
  border-top: 4px solid var(--brand-gold);
}

.stats-grid span,
.item-main span,
.analysis-status,
label {
  color: var(--muted);
}

.stats-grid span {
  display: block;
  min-height: 2.3em;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stats-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.25rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.toolbar {
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select,
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

.toolbar input:focus,
.toolbar select:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(27, 111, 92, 0.14);
}

.toolbar input {
  flex: 1;
  min-width: min(100%, 260px);
}

.toolbar select {
  width: 150px;
}

.inventory {
  min-height: 150px;
}

.empty-state {
  padding: 16px;
  display: grid;
  gap: 4px;
  text-align: center;
}

.empty-state span {
  color: var(--muted);
}

.item-list {
  display: grid;
  gap: 8px;
}

.item-row {
  width: 100%;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto 40px;
  align-items: center;
  gap: 10px;
  text-align: left;
  box-shadow: 0 5px 14px rgba(31, 36, 42, 0.06);
}

.thumb {
  width: 48px;
  height: 58px;
  border-radius: 6px;
  background: #dfe5e8;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.item-main small,
.item-main strong,
.item-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-main small {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.item-main strong {
  font-size: 0.98rem;
}

.item-main span {
  font-size: 0.85rem;
}

.price {
  font-weight: 800;
}

.status {
  max-width: 76px;
  border-radius: 6px;
  padding: 4px 7px;
  color: var(--accent);
  background: rgba(27, 111, 92, 0.1);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.status.for_sale {
  color: #875c00;
  background: rgba(231, 180, 79, 0.2);
}

.status.listed {
  color: #315b99;
  background: rgba(83, 120, 182, 0.14);
}

.status.sold {
  color: var(--warning);
  background: rgba(163, 71, 24, 0.12);
}

dialog {
  width: min(720px, calc(100% - 18px));
  max-height: min(860px, calc(100dvh - 18px));
  padding: 0;
  color: var(--ink);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(18, 22, 26, 0.42);
}

.account-dialog {
  width: min(440px, calc(100% - 18px));
  padding: 14px;
}

.account-body {
  padding-top: 18px;
  display: grid;
  gap: 14px;
}

.account-body > strong {
  font-size: 1.05rem;
}

.account-body p {
  color: var(--muted);
  line-height: 1.45;
}

.provider-actions,
.account-actions {
  display: grid;
  gap: 8px;
}

.provider-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-weight: 780;
}

.provider-button.google {
  border-left: 5px solid var(--brand-gold);
}

.provider-button.facebook {
  border-left: 5px solid var(--brand-blue);
}

.provider-button.x {
  border-left: 5px solid var(--ink);
}

.account-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.account-actions button {
  padding: 0 14px;
}

.legal-links {
  font-size: 0.82rem;
}

.legal-links a {
  color: var(--muted);
}

.legal-page {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(32px, env(safe-area-inset-top)) 0 max(48px, env(safe-area-inset-bottom));
  line-height: 1.65;
}

.legal-page h1,
.legal-page h2 {
  line-height: 1.2;
}

.legal-page h2 {
  margin-top: 2rem;
}

#item-form {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.photo-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.photo-preview figure {
  margin: 0;
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #dfe5e8;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview figcaption {
  position: absolute;
  left: 8px;
  bottom: 8px;
  border-radius: 999px;
  padding: 3px 8px;
  color: #fff;
  background: rgba(0, 0, 0, 0.58);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: capitalize;
}

.remove-photo {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, 0.64);
  cursor: pointer;
  font-weight: 900;
}

.editor-photo-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.photo-edit-button {
  min-width: 0;
  padding: 0 12px;
  display: grid;
  place-items: center;
  text-align: center;
}

.photo-edit-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.analysis-status {
  min-height: 20px;
  font-size: 0.9rem;
}

.clarification-panel {
  border-left: 4px solid var(--brand-blue);
  padding: 12px;
  background: rgba(83, 120, 182, 0.08);
  display: grid;
  gap: 10px;
}

.clarification-panel h3 {
  margin: 0;
  font-size: 0.95rem;
}

#clarification-list {
  display: grid;
  gap: 10px;
}

#clarification-list input,
#clarification-list select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

.clarification-panel .secondary-button {
  justify-self: end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 800;
}

label.wide {
  grid-column: 1 / -1;
}

textarea {
  resize: vertical;
}

.dialog-actions {
  justify-content: end;
  gap: 8px;
  flex-wrap: wrap;
}

.dialog-actions button {
  padding: 0 14px;
}

@media (max-width: 620px) {
  .app {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .topbar {
    gap: 8px;
  }

  .brand-lockup {
    gap: 7px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-lockup .eyebrow {
    display: none;
  }

  h1 {
    font-size: 1.45rem;
  }

  .topbar-actions {
    gap: 4px;
  }

  .topbar-actions .icon-button {
    width: 38px;
    min-height: 38px;
  }

  .stats-grid span {
    min-height: 0;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar select {
    width: 100%;
  }

  .type-picker {
    grid-template-columns: 1fr;
  }

  .item-row {
    grid-template-columns: 50px minmax(0, 1fr) auto;
  }

  .thumb {
    width: 50px;
    height: 62px;
  }

  .status {
    display: none;
  }

  .form-grid,
  .photo-preview,
  .editor-photo-actions {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (min-width: 780px) {
  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .photo-button,
  .primary-button,
  .secondary-button,
  .danger-button,
  .icon-button,
  .provider-button {
    min-height: 40px;
  }

  .icon-button {
    width: 40px;
  }

  .toolbar input,
  .toolbar select,
  .form-grid input,
  .form-grid select,
  .form-grid textarea {
    min-height: 38px;
    padding: 7px 9px;
  }
}

@media (min-width: 920px) {
  .workspace {
    grid-template-columns: minmax(270px, 300px) minmax(0, 1fr);
    align-items: start;
  }

  .capture-column {
    position: sticky;
    top: max(14px, env(safe-area-inset-top));
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
  }

  .stats-grid span {
    min-height: 0;
  }

  .stats-grid strong {
    margin-top: 0;
  }

  .item-row {
    min-height: 72px;
    grid-template-columns: 48px minmax(0, 1fr) 86px 76px;
    grid-template-areas: "thumb main price status";
  }

  .thumb {
    grid-area: thumb;
    width: 46px;
    height: 56px;
  }

  .item-main {
    grid-area: main;
  }

  .price {
    grid-area: price;
    align-self: center;
    text-align: right;
  }

  .status {
    grid-area: status;
    align-self: center;
  }
}

@media (min-width: 1260px) {
  .item-list {
    grid-template-columns: 1fr;
  }
}

@media (horizontal-viewport-segments: 2) {
  .app {
    width: 100%;
  }

  .workspace {
    grid-template-columns: env(viewport-segment-width 0 0) env(viewport-segment-width 1 0);
    column-gap: calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0) + 14px);
  }

  .capture-column {
    padding-left: env(viewport-segment-left 0 0);
  }

  .inventory-column {
    padding-right: calc(100vw - env(viewport-segment-right 1 0));
  }
}
