:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f1ea;
  color: #172033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
}

body.home-page {
  overflow: auto;
  background: #f7f5ef;
}

button,
input {
  font: inherit;
}

.home {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.home-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 72px);
  color: #172033;
}

.home-nav strong {
  font-size: 22px;
}

.home-nav a {
  color: #334155;
  text-decoration: none;
  font-weight: 700;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr);
  align-items: center;
  gap: clamp(28px, 5vw, 76px);
  padding: 20px clamp(20px, 5vw, 72px) 64px;
}

.hero-copy {
  max-width: 660px;
}

.eyebrow {
  margin: 0 0 12px;
  color: #2563eb;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0;
  color: #111827;
  font-size: clamp(54px, 8vw, 112px);
  line-height: 0.92;
}

.lead {
  max-width: 560px;
  margin: 24px 0 0;
  color: #475569;
  font-size: 20px;
  line-height: 1.55;
}

.home-actions {
  display: grid;
  gap: 14px;
  margin-top: 34px;
}

.primary-action,
.join-form button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: #172033;
  color: #ffffff;
  padding: 0 22px;
  font-weight: 800;
  cursor: pointer;
}

.primary-action {
  width: fit-content;
  background: #2563eb;
}

.join-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  max-width: 640px;
}

.join-form input {
  min-width: 0;
  min-height: 52px;
  border: 1px solid rgba(23, 32, 51, 0.16);
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  padding: 0 16px;
  box-shadow: 0 10px 30px rgba(23, 32, 51, 0.06);
}

.home-preview {
  overflow: hidden;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 8px;
  background: #202a3a;
  box-shadow: 0 28px 80px rgba(23, 32, 51, 0.2);
}

.preview-toolbar {
  display: flex;
  gap: 9px;
  padding: 14px;
  background: #202a3a;
}

.preview-toolbar span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f7c948;
}

.preview-toolbar span:nth-child(2) {
  background: #38bdf8;
}

.preview-toolbar span:nth-child(3) {
  background: #fb7185;
}

.preview-board {
  position: relative;
  min-height: 440px;
  background: #fbfaf7;
  background-image:
    linear-gradient(rgba(32, 42, 58, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 42, 58, 0.07) 1px, transparent 1px);
  background-size: 32px 32px;
}

.preview-board svg {
  width: 100%;
  height: 100%;
  min-height: 440px;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-board path:first-child {
  stroke: #2563eb;
  stroke-width: 12;
}

.preview-board path:nth-child(2) {
  stroke: #dc2626;
  stroke-width: 8;
}

.preview-board path:nth-child(3) {
  stroke: #16a34a;
  stroke-width: 10;
}

.preview-board circle {
  stroke: #f59e0b;
  stroke-width: 9;
}

.formula,
.note {
  position: absolute;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: #172033;
  padding: 0 12px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.08);
}

.formula {
  top: 28px;
  left: 28px;
}

.note {
  right: 30px;
  bottom: 34px;
  color: #475569;
}

.shell {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  height: 100vh;
  width: 100vw;
}

.toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 10px;
  background: #202a3a;
  border-right: 1px solid rgba(23, 32, 51, 0.18);
}

.tool-group,
.swatches {
  display: grid;
  gap: 8px;
}

.tool,
.action,
.danger {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 8px;
  background: #344057;
  color: #f8fafc;
  font-size: 24px;
  cursor: pointer;
}

.tool.active {
  background: #f7c948;
  color: #172033;
}

.danger {
  margin-top: auto;
  background: #ba1a1a;
}

.action {
  background: #475569;
}

.color {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #344057;
}

.color input {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
}

.swatches {
  grid-template-columns: repeat(2, 20px);
  justify-content: center;
  width: 48px;
  padding: 8px 0;
  border-radius: 8px;
  background: #344057;
}

.swatch {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(248, 250, 252, 0.55);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
}

.swatch.active {
  border-color: #f8fafc;
  box-shadow: 0 0 0 2px #f7c948;
}

.range {
  display: flex;
  align-items: center;
  width: 48px;
  height: 132px;
  border-radius: 8px;
  background: #344057;
}

.range input {
  width: 130px;
  transform: rotate(-90deg);
}

.board-wrap {
  position: relative;
  min-width: 0;
  background: #151a1d;
}

.topbar {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.topbar div {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.08);
}

.board-settings {
  position: relative;
  margin-left: auto;
  pointer-events: auto;
}

.board-settings summary {
  display: flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #172033;
  padding: 0 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.08);
  list-style: none;
}

.board-settings summary::-webkit-details-marker {
  display: none;
}

.board-settings[open] summary {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.board-settings[open]::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
}

.board-theme,
.grid-setting {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid rgba(23, 32, 51, 0.14);
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  padding: 0 10px;
}

.board-theme {
  position: absolute;
  top: 40px;
  right: 0;
  width: 230px;
  border-bottom: 0;
}

.grid-setting {
  position: absolute;
  top: 82px;
  right: 0;
  width: 230px;
  border-bottom-right-radius: 8px;
  border-bottom-left-radius: 8px;
  box-shadow: 0 14px 30px rgba(23, 32, 51, 0.14);
}

.grid-setting input {
  width: 18px;
  height: 18px;
}

.board-theme span,
.grid-setting span {
  font-size: 13px;
  font-weight: 800;
}

.board-theme select {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: #172033;
  font-weight: 700;
  cursor: pointer;
}

#status {
  color: #5f6b7a;
  font-size: 14px;
}

#copy {
  min-height: 40px;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  padding: 0 14px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.08);
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

#board.selecting {
  cursor: cell;
}

#board.moving {
  cursor: move;
}

@media (max-width: 720px) {
  .home-hero {
    grid-template-columns: 1fr;
    padding-bottom: 34px;
  }

  .hero-copy h1 {
    font-size: 58px;
  }

  .lead {
    font-size: 18px;
  }

  .join-form {
    grid-template-columns: 1fr;
  }

  .primary-action {
    width: 100%;
  }

  .home-preview {
    display: none;
  }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 88px;
  }

  .toolbar {
    grid-row: 2;
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-top: 1px solid rgba(23, 32, 51, 0.18);
    scrollbar-width: thin;
  }

  .tool-group,
  .swatches {
    display: flex;
    flex: 0 0 auto;
  }

  .swatches {
    width: auto;
    height: 44px;
    padding: 0 8px;
    align-items: center;
  }

  .tool,
  .action,
  .danger,
  .color {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  .color input {
    width: 30px;
    height: 30px;
  }

  .swatch {
    width: 18px;
    height: 18px;
  }

  .range {
    flex: 0 0 auto;
    width: 120px;
    height: 44px;
  }

  .range input {
    width: 100px;
    transform: none;
  }

  .danger {
    flex: 0 0 auto;
    margin-top: 0;
  }

  .custom-color,
  .action {
    flex: 0 0 auto;
  }

  .topbar {
    top: 10px;
    left: 10px;
    right: 10px;
    align-items: flex-start;
    gap: 8px;
  }

  .topbar div {
    flex-direction: column;
    gap: 0;
    padding: 7px 9px;
  }

  .topbar strong {
    font-size: 14px;
  }

  #status {
    font-size: 12px;
  }

  #copy,
  .board-settings summary {
    min-height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }

  #copy {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .board-settings {
    margin-left: 0;
  }

  .board-theme,
  .grid-setting {
    width: 218px;
  }

  .board-theme {
    top: 36px;
  }

  .grid-setting {
    top: 78px;
  }
}
