:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --color-bg: #f7f0e6;
  --color-surface: #ffffff;
  --color-surface-soft: #fffaf2;
  --color-text: #2f1d13;
  --color-muted: #6d5a4a;
  --color-border: #e2d3bd;
  --color-border-strong: #cdb58f;
  --color-primary: #8a4f0f;
  --color-primary-hover: #6f3f0a;
  --color-primary-soft: #f7ead1;
  --color-header: #3a2416;
  --color-gold: #b9852b;
  --color-terracotta: #a84624;
  --color-success: #2f6b44;
  --color-danger: #9f2f1c;
  --focus-ring: rgba(185, 133, 43, 0.42);
  background: var(--color-bg);
  color: var(--color-text);
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--color-text);
  font-weight: 800;
}

.brand-lockup.auth {
  margin-bottom: 16px;
}

.brand-logo,
.ap-brand-logo {
  width: 40px;
  height: 40px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.brand-logo.auth-logo {
  width: 44px;
  height: 44px;
}

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

button,
.primary-action {
  border: 0;
  border-radius: 6px;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
  white-space: normal;
  text-align: center;
  max-width: 100%;
}

button.secondary {
  background: var(--color-primary-soft);
  color: var(--color-text);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  min-height: 40px;
  padding: 10px 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 22px clamp(16px, 4vw, 40px);
  background: var(--color-header);
  color: #fff;
}

.topbar h1,
.panel h2 {
  margin: 0;
  line-height: 1.15;
}

.topbar h1 {
  font-size: 28px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
  max-width: 100%;
}

.grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

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

.panel {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(47, 29, 19, 0.05);
}

.status-panel {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #f3d69c;
}

.muted {
  color: var(--color-muted);
  margin: 0;
}

.stack {
  display: grid;
  gap: 10px;
}

.checkline {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--color-text);
}

.checkline span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.checkline input {
  width: auto;
  min-height: 0;
}

.list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.list.compact {
  margin-top: 12px;
}

.item {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px;
  background: var(--color-surface-soft);
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta {
  color: var(--color-muted);
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#toast {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: min(360px, calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  z-index: 50;
  background: var(--color-header);
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

.preview-panel {
  display: grid;
  gap: 12px;
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.preview-image {
  width: 100%;
  max-width: 420px;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  object-fit: contain;
  background: var(--color-bg);
}

.stack.compact label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text);
}

.inline-top {
  margin-top: 12px;
}

.item.selectable {
  display: grid;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  align-items: start;
  justify-content: stretch;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface-soft);
}

.item.selectable.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.swatch {
  display: block;
  width: 100%;
  max-width: 120px;
  height: 28px;
  border-radius: 6px;
}

.warning {
  color: var(--color-terracotta);
  margin: 0;
  font-size: 13px;
}

.error-text {
  color: var(--color-danger);
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta-block p {
  margin: 4px 0;
}

@media (max-width: 760px) {
  .topbar,
  .status-panel,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding-top: calc(22px + env(safe-area-inset-top, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 24px;
    overflow-wrap: anywhere;
  }

  .shell {
    width: min(1180px, calc(100% - 24px));
    margin-left: auto;
    margin-right: auto;
  }

  button,
  .primary-action {
    min-height: 44px;
  }

  .topbar .actions {
    width: 100%;
  }

  .topbar .actions .primary-action {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 0;
  }

  .actions {
    width: 100%;
  }

  .panel .actions .secondary,
  .panel .actions button {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
}

.topbar .actions,
.topbar .primary-action + .primary-action {
  margin-left: 8px;
}

.dropzone {
  display: grid;
  gap: 8px;
  place-items: center;
  text-align: center;
  border: 2px dashed var(--color-border-strong);
  border-radius: 8px;
  background: #fff;
  padding: 28px 16px;
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  padding: 14px;
}

#upload-status.hidden,
.hidden {
  display: none !important;
}
