:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.975 0.006 188);
  --surface-strong: oklch(0.94 0.018 188);
  --ink: oklch(0.19 0.028 218);
  --muted: oklch(0.46 0.032 218);
  --line: oklch(0.88 0.014 218);
  --primary: oklch(0.47 0.105 188);
  --primary-strong: oklch(0.38 0.11 188);
  --accent: oklch(0.58 0.145 33);
  --success: oklch(0.47 0.12 150);
  --warning: oklch(0.62 0.13 75);
  --danger: oklch(0.52 0.16 25);
  --shadow: 0 8px 20px oklch(0.3 0.035 218 / 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --focus: 0 0 0 3px oklch(0.72 0.1 188 / 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, oklch(0.98 0.008 188), var(--bg) 360px);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px 28px 24px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--primary-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: 2.5rem;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.25;
}

h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.lead {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.save-card {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 230px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.save-card strong,
.save-card span {
  display: block;
}

.save-card strong {
  font-size: 0.9rem;
}

.save-card span:last-child {
  color: var(--muted);
  font-size: 0.8rem;
}

.save-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--warning);
}

.save-dot.is-saved {
  background: var(--success);
}

.save-dot.is-error {
  background: var(--danger);
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 28px 40px;
}

.summary-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.55fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary-strong);
  color: white;
}

.summary-panel .kicker,
.summary-panel p {
  color: oklch(0.94 0.02 188);
}

.summary-main h2 {
  font-size: 2.2rem;
  line-height: 1;
}

.summary-main p:last-child {
  margin: 10px 0 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-grid div {
  padding: 14px;
  border: 1px solid oklch(0.78 0.04 188 / 0.55);
  border-radius: var(--radius-sm);
  background: oklch(1 0 0 / 0.08);
}

.summary-grid span {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
}

.summary-grid p {
  margin: 4px 0 0;
  font-size: 0.82rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.42fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.left-column {
  display: grid;
  gap: 20px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.sticky-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.secondary-button,
.filter,
.package-card button,
.dependency-action {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-weight: 700;
}

.secondary-button {
  padding: 9px 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.filter {
  padding: 8px 10px;
  color: var(--muted);
}

.filter.is-active {
  border-color: var(--primary);
  background: oklch(0.94 0.03 188);
  color: var(--primary-strong);
}

.clear-button {
  color: var(--danger);
}

.package-list,
.dependency-list,
.module-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.package-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.package-card.is-active {
  border-color: var(--primary);
  background: oklch(0.94 0.028 188);
}

.package-chip,
.module-status span,
.dependency-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.package-chip {
  margin-bottom: 8px;
  background: var(--bg);
  color: var(--primary-strong);
}

.package-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.package-card__meta {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.package-card__meta strong {
  white-space: nowrap;
}

.package-card button {
  padding: 8px 10px;
}

.package-card.is-active button {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.dependency-list {
  padding-top: 0;
}

.dependency-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.dependency-item h3 {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.dependency-item p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.dependency-pill {
  background: oklch(0.94 0.026 75);
  color: oklch(0.33 0.08 75);
}

.dependency-action {
  margin-top: 10px;
  padding: 8px 10px;
}

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

.module-list {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.module-card {
  display: grid;
  align-content: start;
  min-height: 276px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.module-card.is-selected {
  border-color: var(--primary);
  background: oklch(0.965 0.016 188);
}

.module-card.is-included {
  border-color: oklch(0.74 0.07 150);
}

.module-card.is-blocked {
  background: oklch(0.975 0.012 65);
}

.module-top {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.module-top label {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
  font-weight: 800;
}

.module-top input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fake-check {
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.module-top input:checked + .fake-check {
  border-color: var(--primary);
  background:
    linear-gradient(135deg, transparent 42%, white 43% 56%, transparent 57%),
    var(--primary);
}

.module-title {
  overflow-wrap: anywhere;
}

.module-price {
  white-space: nowrap;
  color: var(--primary-strong);
  font-weight: 800;
}

.module-description {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.module-details {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.detail-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  font-size: 0.86rem;
  line-height: 1.35;
}

.detail-row strong {
  color: var(--ink);
}

.detail-row span {
  color: var(--muted);
}

.module-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: end;
  margin-top: 16px;
}

.module-status span[data-kind="active"],
.module-status span[data-kind="included"] {
  background: oklch(0.9 0.05 150);
  color: oklch(0.31 0.09 150);
}

.module-status span[data-kind="blocked"] {
  background: oklch(0.91 0.05 75);
  color: oklch(0.31 0.08 75);
}

.module-status span[data-kind="addon"] {
  background: oklch(0.92 0.04 188);
  color: var(--primary-strong);
}

.review-panel {
  margin-top: 20px;
  padding: 18px;
}

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(280px, 0.8fr);
  gap: 18px;
  margin-top: 16px;
}

.review-grid ul {
  min-height: 180px;
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.review-grid li + li {
  margin-top: 8px;
}

textarea {
  width: 100%;
  min-height: 190px;
  margin-top: 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.5;
}

textarea::placeholder {
  color: oklch(0.42 0.03 218);
}

.dependency-dialog {
  width: min(760px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.dependency-dialog::backdrop {
  background: oklch(0.18 0.03 218 / 0.46);
  backdrop-filter: blur(2px);
}

.dependency-dialog__surface {
  display: grid;
  gap: 16px;
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 14px 32px oklch(0.16 0.035 218 / 0.18);
}

.dependency-dialog__head {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.dependency-dialog__intro {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.dependency-dialog__list {
  display: grid;
  gap: 10px;
}

.dependency-dialog__item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.dependency-dialog__item-head {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.dependency-dialog__item-head strong {
  white-space: nowrap;
  color: var(--primary-strong);
}

.dependency-dialog__item p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.dependency-dialog__details {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 8px 10px;
  margin: 12px 0 0;
  font-size: 0.88rem;
  line-height: 1.35;
}

.dependency-dialog__details dt {
  color: var(--ink);
  font-weight: 800;
}

.dependency-dialog__details dd {
  margin: 0;
  color: var(--muted);
}

.dependency-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding-top: 2px;
}

.primary-button,
.text-button,
.icon-button {
  border-radius: var(--radius-sm);
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--primary);
  padding: 10px 13px;
  background: var(--primary);
  color: white;
}

.text-button {
  border: 0;
  padding: 10px 8px;
  background: transparent;
  color: var(--danger);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
}

@media (max-width: 1020px) {
  .topbar,
  .summary-panel,
  .content-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .save-card {
    width: 100%;
  }
}

@media (max-width: 680px) {
  .topbar,
  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  h1 {
    font-size: 2rem;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .filters {
    justify-content: start;
  }

  .module-actions {
    justify-content: start;
  }

  .package-card {
    grid-template-columns: 1fr;
  }

  .package-card__meta {
    justify-items: start;
  }

  .dependency-dialog__surface {
    padding: 16px;
  }

  .dependency-dialog__head,
  .dependency-dialog__item-head,
  .dependency-dialog__actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dependency-dialog__details {
    grid-template-columns: 1fr;
  }
}

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