:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #16324f;
  background: #f4f7fa;
}

body {
  margin: 0;
}

main {
  width: min(100% - 2rem, 54rem);
  box-sizing: border-box;
  margin: 0 auto;
  padding: 2rem 0;
}

h1 {
  margin-top: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h2 {
  margin: 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.page-header p {
  margin-bottom: 0;
}

.install-prompt {
  max-width: 20rem;
  text-align: right;
}

.install-prompt p {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

button {
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 0.5rem;
  color: #fff;
  background: #16324f;
  font: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid #8a4b08;
  outline-offset: 3px;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-container {
  display: grid;
  width: min(100%, 32rem);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.search-container label {
  font-weight: 600;
}

.search-container input[type="search"] {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #8295a8;
  border-radius: 0.5rem;
  color: inherit;
  background: #fff;
  font: inherit;
}

.search-container input[type="search"]:focus-visible {
  outline: 3px solid #8a4b08;
  outline-offset: 2px;
}

.number-visibility-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.number-visibility-option input {
  width: auto;
  min-height: auto;
  margin: 0;
  accent-color: #16324f;
}

.card-form-section {
  max-width: 34rem;
  margin-bottom: 2rem;
  padding: 1.25rem;
  border: 1px solid #d5dee7;
  border-radius: 0.75rem;
  background: #fff;
}

#delete-section {
  max-width: 34rem;
  margin-bottom: 2rem;
  padding: 1.25rem;
  border: 1px solid #e6baba;
  border-radius: 0.75rem;
  background: #fff;
}

.backup-section {
  max-width: 40rem;
  margin: 2rem 0;
  padding: 1.25rem;
  border: 1px solid #d5dee7;
  border-radius: 0.75rem;
  background: #fff;
}

.backup-section h2 {
  margin-top: 0;
}

.backup-section h3 {
  margin: 1rem 0 0;
}

.backup-form {
  display: grid;
  gap: 1rem;
}

.backup-password-fields {
  display: grid;
  gap: 1rem;
}

.backup-checkbox,
.backup-radio {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 400;
}

.backup-checkbox {
  cursor: pointer;
}

.backup-checkbox input,
.backup-radio input {
  width: 1.125rem;
  height: 1.125rem;
  flex: 0 0 1.125rem;
  margin: 0.2rem 0 0;
}

.import-mode {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.import-mode legend {
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.replace-confirmation {
  padding: 0.75rem;
  border-left: 4px solid #a32121;
  background: #fff4f4;
}

.security-warning {
  margin: 0 0 1rem;
  padding: 0.75rem;
  border-left: 4px solid #8a4b08;
  color: #4d300d;
  background: #fff7e8;
}

.backup-form > p {
  margin: 0;
}

.backup-section hr {
  width: 100%;
  margin: 1.5rem 0;
  border: 0;
  border-top: 1px solid #d5dee7;
}

.import-details {
  max-height: 12rem;
  overflow: auto;
  margin: 0;
  padding-left: 1.5rem;
  color: #a32121;
}

#delete-heading {
  margin-top: 0;
}

.card-form-section h2 {
  margin-top: 0;
}

.card-form {
  display: grid;
  gap: 1rem;
}

.scanner-actions {
  display: grid;
  justify-items: start;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.scanner-actions p {
  margin: 0;
}

#scanner-section {
  display: grid;
  justify-items: start;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

#scanner-section p {
  margin: 0;
}

#scanner-video {
  width: min(100%, 32rem);
  max-height: 60vh;
  aspect-ratio: 4 / 3;
  border-radius: 0.75rem;
  background: #102338;
  object-fit: cover;
}

.form-field {
  display: grid;
  gap: 0.4rem;
}

.form-field label {
  font-weight: 600;
}

.form-field input:not([type="radio"]):not([type="checkbox"]),
.form-field select {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #8295a8;
  border-radius: 0.5rem;
  color: inherit;
  background: #fff;
  font: inherit;
}

.form-field input:not([type="radio"]):not([type="checkbox"]):focus-visible,
.form-field select:focus-visible {
  outline: 3px solid #e99026;
  outline-offset: 2px;
}

.color-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.color-field legend {
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.color-option {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400 !important;
  cursor: pointer;
}

.color-option input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.color-swatch {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  flex: 0 0 1.75rem;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #8295a8;
}

.color-swatch::after {
  color: #fff;
  content: "";
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1;
}

.color-option input[type="radio"]:checked + .color-swatch::after {
  content: "✓";
}

.color-option input[type="radio"]:focus-visible + .color-swatch {
  outline: 3px solid #8a4b08;
  outline-offset: 3px;
}

.color-swatch-navy {
  background: #16324f;
}

.color-swatch-green {
  background: #1d5e43;
}

.color-swatch-amber {
  background: #8a4b08;
}

.color-swatch-red {
  background: #922b21;
}

.color-swatch-purple {
  background: #5b3b8c;
}

.color-swatch-teal {
  background: #075e75;
}

.field-help {
  margin: 0;
  color: #435b70;
  font-size: 0.875rem;
}

#create-logo-status,
#edit-logo-status {
  margin: 0;
}

.logo-removal-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400 !important;
}

.form-field input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  min-height: 0;
  margin: 0;
}

.field-error,
.error-message {
  margin: 0;
  color: #a32121;
}

.duplicate-warning {
  margin: 0;
  color: #724500;
}

.form-actions,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.secondary-button {
  color: #16324f;
  background: #e7edf3;
}

.danger-button {
  background: #a32121;
}

.loyalty-card {
  display: flex;
  min-height: 7rem;
  align-items: center;
  gap: 1rem;
  box-sizing: border-box;
  padding: 1rem;
  border: 1px solid #d5dee7;
  border-radius: 0.75rem;
  color: #fff;
  background: #16324f;
}

.loyalty-card[data-color="green"] {
  background: #1d5e43;
}

.loyalty-card[data-color="amber"] {
  background: #8a4b08;
}

.loyalty-card[data-color="red"] {
  background: #922b21;
}

.loyalty-card[data-color="purple"] {
  background: #5b3b8c;
}

.loyalty-card[data-color="teal"] {
  background: #075e75;
}

.loyalty-card .card-actions button:not(.danger-button) {
  color: #16324f;
  background: #fff;
}

.presentation-screen {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  border: 0;
  color: #16324f;
  background: #fff;
}

.presentation-screen::backdrop {
  background: #fff;
}

.presentation-header {
  display: flex;
  width: min(100%, 56rem);
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0 auto;
}

.presentation-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.presentation-header h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.presentation-code {
  display: grid;
  min-height: 45vh;
  place-items: center;
  margin: 1rem auto;
}

.presentation-code svg {
  display: block;
  max-width: min(100%, 56rem);
  max-height: 52vh;
  height: auto;
}

.presentation-code .qr-code-svg {
  width: min(82vw, 52vh, 32rem);
  max-height: none;
}

.presentation-code .barcode-svg {
  width: min(100%, 56rem);
}

.presentation-number-label,
.presentation-number,
.presentation-wake-status,
.presentation-brightness-status {
  margin: 0.5rem auto;
  text-align: center;
}

.presentation-number {
  max-width: min(100%, 56rem);
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-variant-numeric: tabular-nums;
}

.presentation-wake-status {
  min-height: 1.5em;
}

.presentation-brightness-status {
  max-width: min(100%, 40rem);
}

@media (max-width: 40rem) {
  .presentation-header {
    align-items: flex-start;
  }

  .presentation-header h2 {
    font-size: 1.25rem;
  }

  .presentation-code {
    min-height: 38vh;
  }
}

.loyalty-card h3 {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 1.125rem;
}

.card-details {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.card-number {
  margin: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.card-actions {
  margin-top: 0.25rem;
}

.card-logo {
  width: 4rem;
  height: 4rem;
  flex: 0 0 4rem;
  object-fit: contain;
}

.card-color {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 1.5rem;
}

.card-color rect {
  stroke: #fff;
  stroke-width: 2;
}

.empty-state {
  padding: 1.25rem;
  border: 1px dashed #8295a8;
  border-radius: 0.75rem;
  background: #fff;
}

.error-message {
  color: #a32121;
}

[hidden] {
  display: none;
}

@media (max-width: 38rem) {
  .page-header {
    flex-direction: column;
  }

  .install-prompt {
    text-align: left;
  }
}
