:root {
  --navy: #0c2340;
  --navy-soft: #173c66;
  --emerald: #0d5c3a;
  --emerald-bright: #13754d;
  --amber: #b45309;
  --cream: #faf5eb;
  --paper: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --border: rgba(12, 35, 64, 0.12);
  --border-strong: rgba(12, 35, 64, 0.24);
  --shadow: 0 22px 60px -32px rgba(12, 35, 64, 0.34);
  --radius-lg: 26px;
  --radius-md: 16px;
  --font-display: "Outfit", sans-serif;
  --font-body: "Inter", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 0;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 15%, rgba(19, 117, 77, 0.11), transparent 23rem),
    radial-gradient(circle at 86% 84%, rgba(180, 83, 9, 0.1), transparent 24rem),
    var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 20;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  transition: top 160ms ease;
}
.skip-link:focus { top: 1rem; }

.background-orb {
  position: fixed;
  z-index: -1;
  width: 22rem;
  height: 22rem;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.22;
  pointer-events: none;
}
.orb-one { top: -11rem; left: -10rem; background: #53af80; }
.orb-two { right: -10rem; bottom: -12rem; background: #e0a35c; }

.app-shell {
  width: min(100% - 2rem, 1160px);
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.app-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 0.7rem;
  color: var(--navy);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--navy), var(--emerald));
  color: #fff;
  box-shadow: 0 8px 18px rgba(12, 35, 64, 0.2);
}
.brand-mark svg { width: 27px; height: 27px; }
.brand strong, .brand small { display: block; }
.brand strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 1.1;
}
.brand small {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.back-link {
  flex: 0 0 auto;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  text-underline-offset: 3px;
}
.back-link:hover { color: var(--navy); }

.picker-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(1.25rem, 4vw, 4rem);
  align-items: center;
  flex: 1;
  padding: clamp(2rem, 6vw, 5.5rem) 0;
}

.result-panel { min-width: 0; }

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--emerald);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

h1, h2 { font-family: var(--font-display); }
h1 {
  max-width: 11ch;
  margin: 0;
  color: var(--navy);
  font-size: clamp(2.45rem, 5vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.98;
}
.intro {
  max-width: 35rem;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 1.03rem;
}

.result-stage {
  min-height: 220px;
  display: grid;
  align-content: center;
  margin-top: 2rem;
  padding: 2rem;
  overflow: hidden;
  border: 1px solid rgba(12, 35, 64, 0.15);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0)),
    linear-gradient(145deg, var(--navy), var(--navy-soft));
  box-shadow: var(--shadow);
}
.stage-label {
  color: #bdd2e9;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.picked-name {
  display: block;
  margin: 0.5rem 0;
  overflow-wrap: anywhere;
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.04;
}
.picked-name.empty { color: #dbe8f4; font-size: clamp(1.45rem, 3vw, 2.1rem); }
.stage-helper { margin: 0; color: #bdd2e9; font-size: 0.88rem; }
.result-stage.picking .picked-name { animation: selection-pulse 90ms linear infinite alternate; }

.pick-button,
.secondary-button {
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}
.pick-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1rem;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, var(--emerald), var(--emerald-bright));
  box-shadow: 0 12px 22px -14px rgba(13, 92, 58, 0.72);
  color: #fff;
  font-size: 1rem;
}
.pick-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 25px -14px rgba(13, 92, 58, 0.78); }
.pick-button:active:not(:disabled), .secondary-button:active:not(:disabled) { transform: translateY(1px); }
.pick-button:disabled, .secondary-button:disabled, .text-button:disabled { cursor: not-allowed; opacity: 0.5; }
.pick-icon { width: 22px; height: 22px; }
.pick-button.is-picking .pick-icon { animation: spinner 650ms linear infinite; }
.picker-status { min-height: 1.5rem; margin: 0.7rem 0 0; color: var(--muted); font-size: 0.86rem; text-align: center; }

.list-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}
.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}
.panel-heading .eyebrow { margin-bottom: 0.35rem; }
h2 { margin: 0; color: var(--navy); font-size: 1.45rem; line-height: 1.1; }
.name-count {
  flex: 0 0 auto;
  border: 1px solid rgba(13, 92, 58, 0.2);
  border-radius: 999px;
  padding: 0.34rem 0.62rem;
  background: rgba(13, 92, 58, 0.08);
  color: var(--emerald);
  font-size: 0.78rem;
  font-weight: 800;
}

.entry-form, .bulk-entry { margin-top: 1.5rem; }
.entry-form label, .bulk-entry label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
}
.entry-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.65rem; }
input, textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
}
input { min-height: 52px; padding: 0.75rem 0.9rem; }
textarea { min-height: 108px; padding: 0.75rem 0.9rem; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: #64748b; }
input:focus, textarea:focus { outline: none; border-color: var(--emerald); box-shadow: 0 0 0 3px rgba(13, 92, 58, 0.14); }
.secondary-button { padding: 0.75rem 1rem; background: var(--navy); color: #fff; white-space: nowrap; }
.secondary-button:hover:not(:disabled) { background: #16375c; }
.form-message { min-height: 1.35rem; margin: 0.45rem 0 0; color: var(--muted); font-size: 0.82rem; }
.form-message.error { color: #a03f12; font-weight: 600; }

.bulk-actions, .list-tools, .list-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.bulk-actions, .list-tools { justify-content: space-between; margin-top: 0.55rem; }
.bulk-actions p, .list-note { margin: 0; color: var(--muted); font-size: 0.8rem; }
.text-button {
  min-height: 44px;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--emerald);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-button:hover:not(:disabled) { background: rgba(13, 92, 58, 0.08); }
.text-button.danger { color: #a03f12; }
.text-button.danger:hover:not(:disabled) { background: rgba(160, 63, 18, 0.08); }
.text-button.undo { color: var(--navy); }
.list-tools { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}
.name-chip {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  border: 1px solid rgba(12, 35, 64, 0.14);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--navy);
}
.chip-name { min-width: 0; padding: 0.48rem 0.3rem 0.48rem 0.78rem; overflow-wrap: anywhere; font-size: 0.9rem; font-weight: 700; }
.remove-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  margin-right: 0.18rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--navy);
  font-size: 1.25rem;
  line-height: 1;
}
.remove-button:hover { background: rgba(12, 35, 64, 0.1); }
.empty-list { display: grid; justify-items: center; padding: 2.25rem 1rem 0.5rem; color: var(--muted); text-align: center; }
.empty-list[hidden] { display: none; }
.empty-list svg { width: 42px; height: 42px; margin-bottom: 0.5rem; color: #94a3b8; }
.empty-list p { margin: 0; font-size: 0.9rem; }

.app-footer {
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.83rem;
  text-align: center;
}
.app-footer p { margin: 0 0 0.35rem; }
.app-footer nav { line-height: 1.9; }
.app-footer a { color: var(--navy); font-weight: 700; text-underline-offset: 2px; }
.app-footer span { margin: 0 0.18rem; color: #94a3b8; }

@keyframes spinner { to { transform: rotate(360deg); } }
@keyframes selection-pulse { to { opacity: 0.65; transform: translateY(1px); } }

@media (max-width: 860px) {
  .picker-layout { grid-template-columns: 1fr; max-width: 640px; width: 100%; margin: 0 auto; }
  h1 { max-width: none; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 1.25rem, 1160px); }
  .app-header { min-height: 74px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand strong { font-size: 0.93rem; }
  .brand small { font-size: 0.62rem; }
  .back-link { font-size: 0.78rem; }
  .picker-layout { padding: 1.5rem 0 2.5rem; }
  .result-stage { min-height: 190px; padding: 1.5rem; }
  .entry-row { grid-template-columns: 1fr; }
  .secondary-button { width: 100%; }
  .bulk-actions, .list-tools { align-items: flex-start; flex-direction: column; }
  .list-actions { width: 100%; justify-content: space-between; }
  .list-panel { padding: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
