.colour-page {
  padding: 104px 16px 36px;
}

.colour-shell {
  width: min(94vw, 980px);
  display: grid;
  gap: 16px;
}

.colour-card {
  border: 1px solid rgba(158, 190, 255, 0.3);
  border-radius: 14px;
  background: rgba(8, 16, 35, 0.78);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(6px);
  padding: 20px;
}

.colour-intro h1,
.section-heading h2 {
  margin: 4px 0 8px;
}

.colour-intro p:last-child {
  margin: 0;
  color: rgba(233, 238, 252, 0.84);
}

.colour-kicker {
  margin: 0;
  color: #8fd8ff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.section-heading,
.palette-heading,
.copy-row,
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  font-size: 1.25rem;
}

.format-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
}

.tool-button,
.mode-button,
.primary-button,
.theme-select select {
  border: 1px solid rgba(158, 190, 255, 0.32);
  border-radius: 8px;
  color: #e9eefc;
  font: inherit;
}

.tool-button {
  min-width: 40px;
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.tool-button:hover,
.mode-button:hover {
  background: rgba(79, 172, 254, 0.22);
}

.quiet-button {
  min-width: auto;
  color: #d6def9;
}

.underlined {
  text-decoration: underline;
}

.struck {
  text-decoration: line-through;
}

.toolbar-hint {
  color: rgba(214, 222, 249, 0.7);
  font-size: 0.84rem;
  margin-left: 4px;
}

.palette-heading {
  margin: 18px 0 10px;
}

.palette-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.palette-modes {
  display: flex;
  padding: 3px;
  border: 1px solid rgba(158, 190, 255, 0.22);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.18);
}

.mode-button {
  padding: 6px 11px;
  background: transparent;
  border-color: transparent;
  cursor: pointer;
  font-size: 0.84rem;
}

.mode-button.is-active {
  background: linear-gradient(135deg, #4f46e5, #3b82f6);
  color: white;
}

.colour-palette {
  display: grid;
  grid-template-columns: repeat(8, minmax(30px, 1fr));
  gap: 7px;
}

.swatch {
  position: relative;
  min-width: 0;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 7px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.swatch:hover,
.swatch:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 0 0 2px #8fd8ff, 0 5px 12px rgba(0, 0, 0, 0.28);
}

.swatch-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.palette-hint {
  margin: 10px 0 0;
  color: rgba(214, 222, 249, 0.62);
  font-size: 0.78rem;
}

.swatch-cell {
  position: relative;
  min-width: 0;
}

.swatch-cell > .swatch {
  width: 100%;
}

.swatch-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 2;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 2px solid #0b1224;
  border-radius: 50%;
  background: conic-gradient(#f87171, #fbbf24, #4ade80, #38bdf8, #818cf8, #e879f9, #f87171);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: transform 120ms ease;
}

.swatch-badge:hover,
.swatch-badge:focus-visible,
.swatch-options.is-open .swatch-badge {
  transform: scale(1.25);
  outline: none;
}

.swatch-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  display: grid;
  gap: 8px;
  min-width: 190px;
  padding: 12px;
  border: 1px solid rgba(158, 190, 255, 0.4);
  border-radius: 10px;
  background: rgba(10, 18, 38, 0.98);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms;
}

.swatch-popover::before {
  content: '';
  position: absolute;
  top: -12px;
  right: 0;
  left: 0;
  height: 12px;
}

.swatch-options.is-open .swatch-popover {
  visibility: visible;
  opacity: 1;
  transform: none;
}

.popover-title {
  margin: 0;
  color: #8fd8ff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.popover-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: rgba(214, 222, 249, 0.88);
  font-size: 0.84rem;
}

.popover-field input[type="color"] {
  width: 46px;
  height: 28px;
  padding: 2px;
  border: 1px solid rgba(158, 190, 255, 0.36);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.popover-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.popover-field input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

.popover-field input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 4px;
}

.popover-actions {
  display: flex;
  gap: 6px;
}

.popover-button {
  flex: 1;
  padding: 6px 9px;
  border: 1px solid rgba(158, 190, 255, 0.32);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #e9eefc;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.popover-button:hover:not(:disabled) {
  background: rgba(79, 172, 254, 0.22);
}

.popover-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.popover-list {
  display: grid;
  gap: 8px;
}

.popover-row {
  align-items: center;
}

.popover-row .popover-field {
  flex: 1;
}

.popover-remove {
  flex: 0 0 auto;
  width: 28px;
  padding: 4px 0;
}

.editor-frame {
  margin-top: 16px;
  border: 1px solid rgba(158, 190, 255, 0.42);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(8, 16, 35, 0.92);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
}

.text-editor {
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  outline: none;
  color: #ecf2ff;
  font: 0.96rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.text-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(79, 172, 254, 0.48);
}

.text-editor:empty::before {
  content: "Type your message here...";
  color: rgba(214, 222, 249, 0.48);
  pointer-events: none;
}

.editor-footer {
  min-height: 34px;
  padding: 0 11px;
  border-top: 1px solid rgba(158, 190, 255, 0.16);
  color: rgba(214, 222, 249, 0.68);
  font-size: 0.78rem;
}

.copy-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 14px;
}

.primary-button {
  padding: 10px 15px;
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.82), rgba(79, 70, 229, 0.86));
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(59, 130, 246, 0.2);
}

.primary-button:hover {
  filter: brightness(1.1);
}

.status-message {
  min-height: 1.2em;
  margin: 0;
  color: #a7f3d0;
  font-size: 0.88rem;
}

.status-message.is-error {
  color: #fca5a5;
}

.theme-select {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(214, 222, 249, 0.82);
  font-size: 0.84rem;
}

.theme-select select {
  padding: 7px 9px;
  background: rgba(8, 16, 35, 0.9);
}

.message-preview {
  min-height: 80px;
  margin-top: 12px;
  padding: 14px;
  border-radius: 10px;
  font: 0.92rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  transition: background-color 140ms ease, color 140ms ease;
}

.message-preview.theme-dark {
  background: #313338;
  color: #dbdee1;
}

.message-preview.theme-light {
  background: #f2f3f5;
  color: #313338;
}

.format-help {
  margin-top: 14px;
  color: rgba(214, 222, 249, 0.83);
  font-size: 0.88rem;
}

.format-help summary {
  color: #8fd8ff;
  cursor: pointer;
  font-weight: 700;
}

.format-help p {
  margin: 10px 0 0;
  line-height: 1.5;
}

@media (max-width: 720px) {
  .colour-page {
    padding: 88px 10px 24px;
  }

  .colour-shell {
    width: 100%;
  }

  .colour-card {
    padding: 15px;
  }

  .toolbar-hint {
    flex-basis: 100%;
    margin: 2px 0 0;
  }

  .section-heading {
    align-items: flex-start;
  }
}

@media (max-width: 420px) {
  .colour-palette {
    grid-template-columns: repeat(4, minmax(40px, 1fr));
  }

  .swatch-cell:nth-child(4n + 3) .swatch-popover,
  .swatch-cell:nth-child(4n) .swatch-popover {
    right: 0;
    left: auto;
  }

  .palette-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .theme-select {
    align-items: flex-start;
    flex-direction: column;
  }
}
