:root {
  --bg: #f4f2ee;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-border: rgba(45, 37, 29, 0.08);
  --ink: #2d251d;
  --muted: #6f655c;
  --accent: #2f7d5f;
  --accent-2: #d9a93b;
  --shadow: 0 18px 60px rgba(33, 24, 16, 0.08);
  --radius: 18px;
  --cell-gap: 1px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(217, 169, 59, 0.16), transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(47, 125, 95, 0.14), transparent 46%),
    linear-gradient(180deg, #f7f5f2 0%, #f0ede7 100%);
  padding: 1.25rem;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.33;
  background-image:
    linear-gradient(rgba(45, 37, 29, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 37, 29, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}

.app-shell {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  padding: 1.2rem;
}

.panel + .panel {
  margin-top: 1rem;
}

.hidden {
  display: none;
}

.panel-header h1,
.panel-header h2 {
  margin: 0.1rem 0 0.4rem;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.02em;
}

.panel-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
}

.panel-header h2 {
  font-size: clamp(1.3rem, 3.4vw, 2rem);
}

.panel-header.tight {
  margin-bottom: 0.9rem;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  text-transform: uppercase;
}

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

.muted.small {
  font-size: 0.92rem;
}

.group-rows {
  display: grid;
  gap: 0.75rem;
  margin: 1.1rem 0 0.9rem;
}

.group-row {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
  padding: 0.8rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(45, 37, 29, 0.06);
}

.group-row label {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.group-row span {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.02em;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  border: 1px solid rgba(45, 37, 29, 0.15);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 0.66rem 0.8rem;
  font-size: 0.98rem;
}

input:focus {
  outline: 2px solid rgba(47, 125, 95, 0.35);
  border-color: rgba(47, 125, 95, 0.55);
}

.btn,
.icon-btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0.7rem 0.95rem;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.btn:active,
.icon-btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(180deg, #2f8f6b, #246d52);
  color: #fff;
  box-shadow: 0 8px 22px rgba(36, 109, 82, 0.18);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(45, 37, 29, 0.12);
  color: var(--ink);
}

.icon-btn {
  align-self: stretch;
  background: rgba(217, 75, 75, 0.08);
  border-color: rgba(217, 75, 75, 0.18);
  color: #b23f3f;
  padding-inline: 0.8rem;
}

.form-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}

.top-gap {
  margin-top: 0.95rem;
}

.error {
  margin-top: 0.8rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(217, 75, 75, 0.08);
  border: 1px solid rgba(217, 75, 75, 0.15);
  color: #a73e3e;
}

.grid-wrap {
  margin-top: 0.8rem;
  padding: 0.65rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(45, 37, 29, 0.06);
  overflow-x: auto;
}

.dot-grid {
  display: grid;
  grid-template-columns: repeat(100, minmax(0, 1fr));
  gap: var(--cell-gap);
  width: min(100%, 980px);
  min-width: 520px;
  margin: 0 auto;
  background: rgba(45, 37, 29, 0.05);
  padding: var(--cell-gap);
  border-radius: 6px;
}

.cell {
  aspect-ratio: 1 / 1;
  border-radius: 1px;
  background: #d4cec7;
}

.legend-panel {
  margin-top: 1rem;
  padding: 0.9rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(45, 37, 29, 0.06);
}

.legend-panel h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.legend {
  display: grid;
  gap: 0.55rem;
}

.legend-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(45, 37, 29, 0.1);
}

.legend-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 760px) {
  body {
    padding: 0.8rem;
  }

  .panel {
    padding: 0.95rem;
    border-radius: 14px;
  }

  .group-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .icon-btn {
    justify-self: start;
    align-self: auto;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .legend-item {
    grid-template-columns: auto 1fr;
    gap: 0.45rem 0.6rem;
  }

  .legend-meta {
    grid-column: 2;
  }
}
