:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --ink: #18201d;
  --muted: #66736d;
  --line: #d9ddd4;
  --panel: #ffffff;
  --tile: #f0d782;
  --tile-ink: #241d0c;
  --green: #19745f;
  --blue: #285f9f;
  --red: #b44a48;
  --shadow: 0 18px 45px rgba(28, 34, 30, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.search-panel,
.results-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.search-panel {
  border-radius: 8px 8px 0 0;
  padding: clamp(24px, 5vw, 52px);
}

.results-panel {
  min-height: 360px;
  border-top: 0;
  border-radius: 0 0 8px 8px;
  padding: clamp(20px, 4vw, 36px);
}

.brand-row,
.result-toolbar,
.group-heading,
.rack-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: 4.8rem;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1rem;
}

.source-pill,
.result-stats,
#letter-count {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.source-pill {
  align-self: flex-start;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfbf8;
}

.search-form {
  margin-top: 34px;
}

.search-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.input-row input {
  width: 100%;
  min-width: 0;
  padding: 18px 20px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fbfbf8;
  color: var(--ink);
  font-size: 2.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.input-row input:focus {
  outline: 3px solid rgba(25, 116, 95, 0.22);
}

.input-row button,
.examples button,
.length-filter button {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.examples button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.input-row button {
  min-width: 110px;
  padding: 0 24px;
  background: var(--green);
  color: #fff;
}

.rack-row {
  min-height: 48px;
  margin-top: 14px;
}

.rack {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 40px;
}

.tile {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(36, 29, 12, 0.22);
  border-radius: 6px;
  background: var(--tile);
  color: var(--tile-ink);
  font-weight: 900;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.examples button,
.length-filter button {
  min-height: 36px;
  padding: 0 13px;
  background: #edf3f0;
  color: var(--green);
}

.examples button:hover,
.length-filter button:hover {
  background: #dfeae5;
}

.length-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 22px;
}

.length-filter button.is-active {
  background: var(--ink);
  color: #fff;
}

.message {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}

.groups {
  display: grid;
  gap: 24px;
}

.word-group {
  display: grid;
  gap: 12px;
}

.group-heading {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.group-heading span {
  color: var(--muted);
  font-size: 0.92rem;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.word-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 44px;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
  color: var(--ink);
  text-align: left;
}

.word-card:hover {
  border-color: rgba(40, 95, 159, 0.48);
  box-shadow: 0 8px 20px rgba(40, 95, 159, 0.12);
}

.word-card.copied {
  border-color: var(--green);
  background: #eef7f3;
}

.word {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.score {
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e7edf5;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

@media (max-width: 700px) {
  .shell {
    width: min(100% - 18px, 1120px);
    padding-top: 9px;
  }

  .brand-row,
  .result-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-pill,
  .result-stats {
    white-space: normal;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.65rem;
  }

  h2 {
    font-size: 1.55rem;
  }

  .input-row input {
    font-size: 2rem;
  }

  .input-row button {
    min-height: 48px;
  }

  .word-grid {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 2rem;
  }

  .input-row input {
    font-size: 1.75rem;
  }
}

@media (max-width: 340px) {
  h1 {
    font-size: 1.82rem;
  }
}
