:root {
  --bg-page: #1f2937;
  --bg-surface: #ffffff;
  --text-main: #111827;
  --text-light: #ffffff;
  --border: #d1d5db;
  --border-soft: #e5e7eb;
  --hover: #f9fafb;

  --radius-md: 0.375rem;

  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.25rem;
  --space-xl: 2rem;

  --font-sm: 0.875rem;
  --font-base: 1rem;

  --control-height: 2.625rem;
  --container-max: 34.375rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  padding: var(--space-lg);
  font-family: Inter, Arial, sans-serif;
  font-size: var(--font-base);
  line-height: 1.5;
  background: var(--bg-page);
  color: var(--text-light);
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: var(--space-xl) auto;
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

#color-input {
  width: 3.75rem;
  height: var(--control-height);
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

#mode-select,
#get-scheme-btn {
  height: var(--control-height);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: var(--font-sm);
}

#mode-select {
  flex: 1;
  min-width: 0;
  padding: 0 var(--space-sm);
  background: var(--bg-surface);
  color: var(--text-main);
}

#get-scheme-btn {
  padding: 0 var(--space-md);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
}

#get-scheme-btn:hover,
#get-scheme-btn:focus-visible {
  background: var(--hover);
}

.scheme-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  min-height: 26.25rem;
}

.color-column {
  display: flex;
  flex-direction: column;
}

.color-block {
  flex: 1;
  min-height: 21.875rem;
}

.hex-value {
  padding: 0.875rem 0.375rem;
  font-size: var(--font-sm);
  text-align: center;
  border-top: 1px solid var(--border-soft);
  cursor: pointer;
  word-break: break-word;
}

.hex-value:hover,
.hex-value:focus-visible {
  background: var(--hover);
}

/* Tablet */
@media (max-width: 48rem) {
  body {
    padding: var(--space-md);
  }

  .container {
    margin: var(--space-lg) auto;
  }

  .controls {
    display: grid;
    grid-template-columns: 3.5rem 1fr;
    gap: var(--space-sm);
  }

  #color-input {
    width: 100%;
  }

  #mode-select {
    width: 100%;
  }

  #get-scheme-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .scheme-container {
    min-height: 22rem;
  }

  .color-block {
    min-height: 18rem;
  }
}

/* Mobile */
@media (max-width: 30rem) {
  body {
    padding: var(--space-sm);
  }

  .container {
    margin: var(--space-md) auto;
    border-radius: 0.25rem;
  }

  .controls {
    padding: var(--space-md);
    grid-template-columns: 3.25rem 1fr;
    gap: var(--space-sm);
  }

  #color-input,
  #mode-select,
  #get-scheme-btn {
    min-height: 2.75rem;
  }

  #get-scheme-btn {
    padding: 0 var(--space-sm);
  }

  .scheme-container {
    grid-template-columns: repeat(5, minmax(4.5rem, 1fr));
    min-height: 18rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .color-column {
    min-width: 4.5rem;
    flex-direction: column;
  }

  .color-block {
    min-height: 14rem;
  }

  .hex-value {
    min-height: 3.5rem;
    padding: var(--space-xs);
    font-size: 0.75rem;
    border-left: none;
    border-top: 1px solid var(--border-soft);
  }
}
