* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --header-height: 64px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.controls-bar {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  border-top: 1px solid #e5e5e5;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hint {
  font-size: 13px;
  line-height: 1.6;
  color: #888;
}

kbd {
  display: inline-block;
  vertical-align: middle;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 1px 6px 3px;
  margin: 0 2px;
  line-height: 1;
  font-size: 12px;
  font-family: inherit;
}

.nav-controls {
  display: flex;
  gap: 6px;
}

/* Shared chip chrome for the toolbar controls: nav arrows, old-names
   toggle, and Generate all read as one family of buttons. */
.nav-btn,
.old-toggle,
.set-select,
#generate-btn {
  height: 34px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  transition: background 0.15s, border-color 0.15s;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  font-size: 15px;
  color: #333;
  cursor: pointer;
}

.nav-btn .btn-icon {
  width: 16px;
  height: 16px;
  margin-right: 0;
}

.nav-btn:hover:not(:disabled) {
  background: #f2f2f2;
  border-color: #d5d5d5;
}

.nav-btn:disabled {
  color: #ccc;
  cursor: default;
}

.old-toggle {
  font-size: 12px;
  font-weight: 600;
  color: #444;
  cursor: pointer;
  user-select: none;
  padding: 0 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

.set-select {
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  padding-right: 26px;
}

.set-select:hover {
  background-color: #f2f2f2;
  border-color: #d5d5d5;
}

.old-toggle:hover {
  background: #f9f9f9;
  border-color: #d5d5d5;
}

#generate-btn {
  background: #111;
  border-color: #111;
  color: #fff;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

#generate-btn:hover {
  background: #333;
  border-color: #333;
}

#palette {
  flex: 1;
  display: flex;
  min-height: 0;
}

.swatch {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 48px;
  cursor: pointer;
  position: relative;
  transition: flex 0.2s;
}

.swatch:hover {
  flex: 1.15;
}

@keyframes swatch-enter {
  from {
    clip-path: inset(0 0 100% 0);
  }
  to {
    clip-path: inset(0 0 0% 0);
  }
}

/* Mobile's left-to-right reveal fades through a soft gradient band
   instead of a hard clip edge, so --reveal is animated (via @property,
   which makes a custom property interpolatable) rather than clip-path. */
@property --reveal {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

@keyframes swatch-enter-horizontal {
  from {
    --reveal: 0%;
  }
  to {
    --reveal: 114%;
  }
}

.swatch.swatch-enter {
  animation: swatch-enter 0.55s cubic-bezier(0.65, 0, 0.35, 1) backwards;
}

.swatch .info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 0 16px;
  user-select: none;
}

.swatch .name-row {
  display: contents;
}

.swatch .name {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.1px;
  line-height: 1.15;
}

.swatch .code {
  display: inline-block;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.25);
}

.swatch .hex {
  font-size: 10px;
  font-weight: 700;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.7;
}

.swatch .lock-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
}

.swatch .lock-btn .btn-icon {
  width: 20px;
  height: 20px;
  margin-right: 0;
  vertical-align: middle;
}

.swatch:hover .lock-btn,
.swatch.locked .lock-btn {
  opacity: 1;
}

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #111;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  transition: transform 0.25s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 640px) {
  .brand {
    display: none;
  }

  .controls-bar {
    height: auto;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 14px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .controls {
    gap: 6px;
  }

  .action-bar {
    gap: 4px;
  }

  .nav-controls {
    gap: 4px;
  }

  .nav-btn,
  .old-toggle,
  .set-select,
  #generate-btn {
    height: 30px;
  }

  .nav-btn {
    width: 30px;
    font-size: 13px;
  }

  .old-toggle {
    padding: 0 8px;
    font-size: 11px;
  }

  .set-select {
    padding: 0 20px 0 6px;
    background-position: right 4px center;
    font-size: 11px;
  }

  #generate-btn {
    padding: 0 10px;
    font-size: 12px;
  }

  #palette {
    flex-direction: column;
  }

  .swatch.swatch-enter {
    animation-name: swatch-enter-horizontal;
    animation-fill-mode: both;
    -webkit-mask-image: linear-gradient(to right, black calc(var(--reveal) - 14%), transparent var(--reveal));
    mask-image: linear-gradient(to right, black calc(var(--reveal) - 14%), transparent var(--reveal));
  }

  .swatch {
    align-items: flex-start;
    justify-content: center;
    padding-bottom: 0;
  }

  .swatch .info {
    align-items: flex-start;
    text-align: left;
    gap: 6px;
  }

  .swatch .name-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
  }

  .swatch .name {
    font-size: 14px;
  }

  .swatch .hex::before {
    content: "\2022";
    margin-right: 6px;
    opacity: 0.6;
  }

  .swatch .code {
    font-size: 22px;
    padding: 7px 15px;
  }

  .hint {
    display: none;
  }
}
