:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #5f6f7a;
  --panel: #f7f4ec;
  --line: #d9d1c0;
  --button: #275f7a;
  --button-active: #7f4d2e;
  --bg: #dfe8d4;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top left, #d6e7f4 0%, #dfe8d4 42%, #c5d4c4 100%);
  color: var(--ink);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

body {
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  gap: 0;
}

.toolbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 16px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  background: rgba(16, 34, 49, 0.95);
  color: #f8fbff;
  box-shadow: 0 10px 30px rgba(16, 34, 49, 0.18);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  image-rendering: pixelated;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: flex;
  gap: 14px;
  color: #34444f;
  font-size: 14px;
  white-space: nowrap;
}

.stats strong {
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  gap: 8px;
    flex-wrap: wrap;
  }

  .session-ui {
    display: grid;
    gap: 10px;
    width: 100%;
    margin-top: 14px;
    padding: 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 18px;
  }

  .session-ui input,
  .session-ui select {
    width: 100%;
    min-height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.12);
    padding: 0 12px;
    background: rgba(255,255,255,0.08);
    color: white;
  }

  .session-ui button {
    width: 100%;
  }

  .session-info {
    color: #d2e9ff;
    font-size: 13px;
    line-height: 1.4;
  background: rgba(124, 213, 118, 0.95);
}

.palette {
  position: relative;
  margin: 20px;
  width: 240px;
  max-height: calc(100vh - 88px);
  overflow: auto;
  background: rgba(11, 25, 43, 0.82);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 16px;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(9, 18, 33, 0.28);
  backdrop-filter: blur(18px);
  z-index: 5;
}

.palette h2 {
  margin: 0 0 12px 0;
  font-size: 16px;
  letter-spacing: 0.04em;
  color: #d2e9ff;
  text-transform: uppercase;
}

.palette-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.palette-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  cursor: pointer;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.04);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.palette-item.selected {
  border-color: rgba(255, 206, 84, 0.9);
  background: rgba(255, 206, 84, 0.18);
  transform: translateX(2px);
}

.palette-item:hover {
  transform: translateX(2px);
  background: rgba(255,255,255,0.08);
}

.palette-item img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.12);
  padding: 6px;
  image-rendering: pixelated;
}

button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  background: rgba(82, 173, 219, 0.95);
  color: white;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 160ms ease, filter 160ms ease, background 160ms ease;
  cursor: pointer;
}

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

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

button[aria-pressed="true"] {
  background: rgba(255, 189, 89, 0.98);
  color: #163248;
}

.viewport {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(16, 34, 49, 0.12) 0%, transparent 24%),
              linear-gradient(#bdd7d9, #dfe8d4 42%),
              #dae5c7;
}

canvas {
  display: block;
  width: 100vw;
  height: calc(100vh - 67px);
  image-rendering: pixelated;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .palette {
    position: static;
    width: auto;
    margin: 14px;
  }

  .viewport {
    margin-top: 0;
  }
}

@media (max-width: 680px) {
  body {
    overflow: auto;
  }

  .toolbar {
    gap: 12px;
  }

  .actions {
    flex-wrap: wrap;
  }

  canvas {
    height: 60vh;
  }
}
