:root {
  --bg-top: #f3ede2;
  --bg-bottom: #dfebf1;
  --panel: rgba(255, 251, 247, 0.88);
  --panel-border: rgba(30, 48, 80, 0.14);
  --ink: #1b263b;
  --muted: #5b6472;
  --accent: #d16666;
  --accent-strong: #b34d4d;
  --grid-line: rgba(27, 38, 59, 0.14);
  --shadow: 0 18px 40px rgba(27, 38, 59, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Chivo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 30%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.app-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top, 0px)) 0 calc(48px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
}

.hero {
  grid-column: 1 / -1;
  padding: 12px 6px 4px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.hero h1 {
  margin: 0;
  max-width: 12ch;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 0.95;
}

.hero-copy {
  margin: 14px 0 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 1.05rem;
}

.top-nav {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.install-tip {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-decoration: none;
  border: 1px solid rgba(27, 38, 59, 0.12);
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.controls-panel,
.gallery-panel {
  padding: 24px;
}

.section-title h2,
.canvas-header h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
}

.section-title p,
.canvas-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.section-title.compact {
  margin-top: 24px;
}

.grid-form,
.follow-panel {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.grid-form label,
.color-input-wrap,
.follow-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.grid-form input,
.color-input-wrap input,
.follow-panel input {
  width: 100%;
  border: 1px solid rgba(27, 38, 59, 0.16);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.grid-form button,
.secondary {
  background: var(--accent);
  color: #fffaf8;
  font-weight: 700;
}

.secondary {
  align-self: end;
}

.ghost {
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  border: 1px solid rgba(27, 38, 59, 0.12);
}

.danger {
  color: var(--accent-strong);
}

.small-button {
  padding: 10px 14px;
}

.palette {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 10px;
}

.swatch {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  border: 3px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(27, 38, 59, 0.12);
}

.swatch.active {
  border-color: var(--ink);
}

.swatch.active::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.custom-color-row,
.actions {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

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

.inline-note,
.account-summary {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.inline-note[data-mode="success"] {
  color: #1f6f50;
}

.inline-note[data-mode="warning"] {
  color: #9c4f28;
}

.canvas-panel {
  padding: 24px;
  min-width: 0;
}

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

.canvas-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.row-pill,
.active-color-card {
  display: grid;
  gap: 6px 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(27, 38, 59, 0.1);
}

.row-pill span,
.active-color-card span,
.active-color-card code {
  color: var(--muted);
  font-size: 0.9rem;
}

.row-pill strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.4rem;
}

.active-color-card {
  grid-template-columns: auto auto;
}

.active-color-preview {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(27, 38, 59, 0.14);
  background: #264653;
}

.grid-frame {
  margin-top: 20px;
  padding: 18px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(250, 246, 241, 0.96)),
    repeating-linear-gradient(
      45deg,
      rgba(209, 102, 102, 0.04),
      rgba(209, 102, 102, 0.04) 12px,
      rgba(38, 70, 83, 0.03) 12px,
      rgba(38, 70, 83, 0.03) 24px
    );
  border: 1px solid rgba(27, 38, 59, 0.08);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(20, minmax(18px, 1fr));
  width: max-content;
  border-top: 1px solid var(--grid-line);
  border-left: 1px solid var(--grid-line);
  background: white;
}

.grid-cell {
  width: min(28px, 5vw);
  height: min(28px, 5vw);
  min-width: 18px;
  min-height: 18px;
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
  border-radius: 0;
  padding: 0;
  background: #ffffff;
  position: relative;
  overflow: visible;
  transition: box-shadow 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.cell-symbol-img {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.symbol-palette {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 10px;
}

.symbol-swatch {
  padding: 4px;
  background: rgba(255, 255, 255, 0.7);
}

.symbol-swatch img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.grid-cell[data-active-row="true"] {
  box-shadow: inset 0 0 0 2px rgba(209, 102, 102, 0.7);
  filter: saturate(1.05);
}

.chart-grid[data-follow-mode="true"] .grid-cell[data-active-row="false"] {
  opacity: 0.58;
}

.grid-cell:hover,
.grid-cell:focus-visible {
  outline: 2px solid rgba(209, 102, 102, 0.35);
  outline-offset: -2px;
}

.gallery-shell {
  grid-template-columns: 1fr;
}

.design-list {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.design-card,
.empty-state {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(27, 38, 59, 0.1);
}

.design-card h3 {
  margin: 14px 0 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
}

.design-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.design-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.accent-link {
  background: var(--accent);
  color: #fffaf8;
  border-color: transparent;
}

.design-preview {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(27, 38, 59, 0.06);
}

.design-preview span {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 3px;
}

.follow-shell {
  grid-template-columns: 1fr;
  width: min(900px, calc(100% - 20px));
}

.follow-hero {
  padding-bottom: 0;
}

.follow-panel-shell {
  padding: 18px;
}

.follow-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.follow-row-pill {
  min-width: 120px;
}

.follow-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.follow-tip-card {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(27, 38, 59, 0.1);
}

.follow-tip-card strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
}

.follow-tip-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.follow-grid-frame {
  margin-top: 18px;
}

.follow-cell {
  cursor: default;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .canvas-header {
    flex-direction: column;
  }

  .canvas-badges {
    width: 100%;
    justify-content: flex-start;
  }

  .grid-cell {
    width: min(24px, 6vw);
    height: min(24px, 6vw);
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 16px, 100%);
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }

  .hero {
    padding-inline: 2px;
  }

  .hero h1 {
    max-width: none;
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .controls-panel,
  .canvas-panel,
  .gallery-panel {
    padding: 16px;
    border-radius: 20px;
  }

  .top-nav {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .grid-frame {
    padding: 12px;
    border-radius: 20px;
  }

  .grid-cell {
    width: 24px;
    height: 24px;
  }

  .design-list {
    grid-template-columns: 1fr;
  }

  .follow-toolbar {
    align-items: stretch;
  }

  .follow-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }
}
