:root {
  color: #111827;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #1e3a8a;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.page-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1rem 4rem;
}

.brand-logo { display: block; object-fit: contain; }

.generator-card {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(430px, 2fr);
  width: min(100%, 1050px);
  margin-top: 4rem;
  padding: 2rem;
  overflow: visible;
  border-radius: .5rem;
  background: white;
  box-shadow: 0 10px 25px rgb(15 23 42 / 20%);
}

.preview-column {
  align-self: center;
  margin-right: 1rem;
  text-align: center;
}

.sticker-preview { width: 100%; min-height: 300px; }
.sticker-preview svg { display: block; width: 100%; height: auto; }
.preview-label { margin: .25rem 0 0; font-size: .875rem; }

.controls-column { min-width: 0; margin-left: 1rem; }
h1 { margin: 0 0 2rem; font-size: 1.875rem; line-height: 1.2; }

.color-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.field { display: block; min-width: 0; color: #374151; font-size: .875rem; font-weight: 500; }
.field > span:first-child { display: block; margin-bottom: .25rem; }

.color-input {
  display: flex;
  height: 38px;
  overflow: hidden;
  border: 1px solid #d1d5db;
  border-radius: .375rem;
  box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
}

.color-input:focus-within { border-color: #93c5fd; box-shadow: 0 0 0 1px #93c5fd; }
.color-prefix { display: grid; place-items: center; padding: 0 .65rem; color: #6b7280; background: #f9fafb; }
.color-input input { min-width: 0; flex: 1; border: 0; outline: 0; padding: .45rem 0; color: #111827; }
.color-swatch { width: 1.25rem; height: 1.25rem; align-self: center; margin: 0 .75rem; border: 1px solid #d1d5db; }

.file-field input {
  display: block;
  width: 100%;
  color: #6b7280;
  font-size: .875rem;
}

.file-field input::file-selector-button {
  margin-right: 1rem;
  padding: .5rem 1rem;
  border: 0;
  border-radius: .375rem;
  color: #1d4ed8;
  background: #eff6ff;
  font-weight: 500;
}

.event-controls { display: grid; gap: 1rem; margin-top: 1.5rem; }
.search-select { position: relative; }
.search-select > label { display: block; margin-bottom: .25rem; color: #374151; font-size: .875rem; font-weight: 500; }
.search-select.disabled { opacity: .55; }
.search-select.loading { opacity: .72; }

.select-button {
  position: relative;
  width: 100%;
  padding: .55rem 2.5rem .55rem .75rem;
  border: 1px solid #d1d5db;
  border-radius: .375rem;
  color: #111827;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
  text-align: left;
}
.select-button:hover:not(:disabled) { border-color: #9ca3af; background: #f9fafb; }
.select-button:focus-visible, .select-search:focus-visible { border-color: #2563eb; outline: 2px solid #bfdbfe; outline-offset: 1px; }

.select-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-label.placeholder { color: #9ca3af; }
.chevrons { position: absolute; top: 50%; right: .75rem; color: #9ca3af; transform: translateY(-50%); }

.select-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + .25rem);
  width: 100%;
  overflow: hidden;
  border-radius: .375rem;
  background: white;
  box-shadow: 0 10px 25px rgb(0 0 0 / 18%);
}

.select-search { width: calc(100% - 1rem); margin: .5rem; padding: .4rem .65rem; border: 1px solid #d1d5db; border-radius: .375rem; }
.select-options { max-height: 12rem; margin: 0; padding: .25rem 0; overflow-y: auto; border-top: 1px solid #e5e7eb; }
.select-option { position: relative; display: block; width: 100%; padding: .5rem 2.25rem .5rem .75rem; border: 0; color: #111827; background: transparent; font-size: .875rem; text-align: left; cursor: pointer; user-select: none; transition: background-color 120ms ease, color 120ms ease; }
.select-option:hover, .select-option.pointer-highlighted {
  color: #1e3a8a;
  background: #dbeafe;
  box-shadow: inset 3px 0 #2563eb;
}
.select-option.highlighted { color: white; background: #2563eb; }
.select-option.selected::after { content: "✓"; position: absolute; top: .55rem; right: .8rem; color: #2563eb; font-weight: 700; }
.select-option.selected.highlighted::after { color: white; }
.select-option strong, .select-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-option small { margin-top: .1rem; color: #6b7280; }
.select-option.highlighted small { color: #bfdbfe; }
.select-empty { padding: .6rem .75rem; color: #6b7280; font-size: .875rem; }
.select-status { margin-top: .4rem; color: #6b7280; font-size: .75rem; }
.select-status.error { color: #b91c1c; }
.select-retry { margin-left: .35rem; padding: 0; border: 0; color: inherit; background: transparent; font-weight: 600; text-decoration: underline; }

.secondary-button { justify-self: start; padding: .5rem .75rem; border: 1px solid #d1d5db; border-radius: .375rem; color: #374151; background: white; box-shadow: 0 1px 2px rgb(0 0 0 / 5%); font-size: .875rem; font-weight: 500; }
.secondary-button:hover:not(:disabled) { background: #f9fafb; }
.copy-control { display: flex; align-items: center; gap: .65rem; }
.copy-status { margin: 0; color: #166534; font-size: .8rem; }
.copy-status.error { color: #b91c1c; }

.fixed-event { margin-top: 1.5rem; padding: 1rem; border: 1px solid #bfdbfe; border-radius: .375rem; background: #eff6ff; }
.fixed-event p { margin: 0; }
.fixed-event .eyebrow { color: #1d4ed8; font-size: .75rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.fixed-event .event-name { margin-top: .25rem; font-weight: 600; }
.fixed-event .application-name { margin-top: .25rem; color: #4b5563; font-size: .75rem; }

.palette-picker { margin-top: 1.5rem; }
.palette-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.palette-heading h2 { margin: 0; color: #374151; font-size: .875rem; font-weight: 500; }
.text-button { padding: .25rem .75rem; border: 0; border-radius: .25rem; color: #2563eb; background: transparent; font-size: .875rem; font-weight: 500; }
.text-button:hover { background: #eff6ff; }
.palette-list { display: grid; gap: .75rem; }
.palette { display: flex; align-items: center; gap: .75rem; padding: .5rem; border: 1px solid #e5e7eb; border-radius: .375rem; }
.palette:hover { background: #f9fafb; }
.palette-colors { display: flex; gap: .25rem; }
.palette-color { width: 2rem; height: 2rem; border: 1px solid #e5e7eb; border-radius: .25rem; }
.palette-name { min-width: 0; flex: 1; color: #4b5563; font-size: .875rem; }
.apply-palette { padding: .25rem .75rem; border: 0; border-radius: .25rem; color: #2563eb; background: transparent; font-size: .875rem; font-weight: 500; }
.apply-palette:hover { background: #eff6ff; }

.divider { margin-top: 1rem; border-top: 1px solid #d1d5db; }
.action-buttons { display: flex; align-items: stretch; gap: 1.25rem; margin-top: 1rem; }
.action-button { flex: 1; display: grid; place-items: center; padding: .55rem 1rem; border: 0; border-radius: .375rem; color: white; box-shadow: 0 1px 2px rgb(0 0 0 / 8%); font-size: .875rem; font-weight: 500; }
.download-button { background: #2563eb; }
.download-button:hover { background: #1d4ed8; }
.save-button { background: #16a34a; }
.save-button:hover { background: #15803d; }

[hidden] { display: none !important; }

@media (max-width: 800px) {
  .generator-card { grid-template-columns: 1fr; max-width: 600px; margin-top: 2rem; }
  .preview-column { width: min(100%, 330px); margin: 0 auto 2rem; }
  .controls-column { margin-left: 0; }
}

@media (max-width: 520px) {
  .page-shell { padding-inline: .75rem; }
  .generator-card { padding: 1.25rem; }
  .color-form { grid-template-columns: 1fr; gap: 1rem; }
  .action-buttons { flex-direction: column; gap: .75rem; }
  h1 { font-size: 1.5rem; }
}
