:root {
  color-scheme: dark;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --bg: #05060a;
  --panel: #11131a;
  --border: #1f232c;
  --accent: #5a7dff;
  --muted: #9aa1b5;
  --danger: #ff6b6b;
  --text: #f2f4f8;
}

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

body {
  margin: 0;
  background: radial-gradient(circle at top, #111526, #05060a 55%);
  background: -webkit-radial-gradient(circle at top, #111526, #05060a 55%);
  background: -moz-radial-gradient(circle at top, #111526, #05060a 55%);
  min-height: 100vh;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-rows: auto auto 1fr auto; /* header, primary-menu, bottom-row, footer */
  gap: 1rem;
  min-height: 100vh;
}

.layout-container {
  display: contents; /* delegate row sizing to .app grid */
}

.top-row.card {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.top-row .primary-color-input {
  flex: 0 0 auto;
}

.top-row .derived {
  flex: 0 0 auto;
}

.top-row .actions {
  flex: 0 0 auto;
}

.bottom-row {
  display: grid;
  grid-template-columns: 30% 1fr;
  gap: 1rem;
  min-height: 0; /* allow children to shrink within grid track */
  overflow: hidden; /* constrain columns to viewport height */
}

.column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  min-height: 0; /* enable independent scrolling within grid area */
  max-height: 100%;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

header p {
  margin: 0;
  color: var(--muted);
}

.badge {
  padding: 0.375rem 0.75rem;
  border-radius: 62.4375rem;
  background: rgba(90, 125, 255, 0.15);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.card {
  background: var(--panel);
  border: 0.0625rem solid var(--border);
  border-radius: 0.875rem;
  padding: 1rem;
  box-shadow: 0 1.25rem 2.8125rem rgba(0, 0, 0, 0.35);
}

.tab-content.active > .card {
  display: flex;
  flex-direction: column;
  flex-shrink: 0; /* prevent cards from shrinking */
}

/* Only apply flex: 1 to cards with textareas (JSON output) to maximize their height */
.tab-content.active > .card:has(textarea) {
  flex: 1;
  min-height: 0;
}

.primary-menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--panel);
  border: 0.0625rem solid var(--border);
  border-radius: 0.875rem;
  padding: 1rem;
  box-shadow: 0 1.25rem 2.8125rem rgba(0, 0, 0, 0.35);
}

.primary-color-input {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.primary-color-input label {
  margin-bottom: 0;
  white-space: nowrap;
}

.compliance-toggle-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex-shrink: 0;
  min-width: fit-content;
}

.compliance-toggle-wrapper label {
  font-size: 0.75rem;
  margin-bottom: 0;
  white-space: nowrap;
}

label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.375rem;
}

input,
select,
textarea,
button {
  font: inherit;
  color: inherit;
}

input,
select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  border: 0.0625rem solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

textarea {
  width: 100%;
  min-height: 13.75rem;
  border-radius: 0.625rem;
  border: 0.0625rem solid var(--border);
  background: #04050a;
  padding: 0.75rem;
  font-family: "JetBrains Mono", SFMono-Regular, Consolas, monospace;
  resize: vertical;
}

.tab-content.active > .card > textarea {
  flex: 1; /* fill available card height */
  min-height: 0; /* override default min-height */
  resize: none; /* disable manual resize to keep layout consistent */
}

.helper {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.color-input {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.color-input input {
  flex: 1;
}

.swatch {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.625rem;
  border: 0.0625rem solid var(--border);
  background: #222;
  flex-shrink: 0;
}

.swatch.small {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-row input[type="range"] {
  flex: 1;
}

.range-row input[type="number"] {
  max-width: 4.375rem;
}

.switch-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tint-switch {
  flex: 1;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  border: 0.0625rem solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-transition: all 0.15s;
  -moz-transition: all 0.15s;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  font-weight: 500;
}

.tint-switch:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.tint-switch.active {
  background: var(--accent);
  color: #05060a;
  border-color: var(--accent);
  font-weight: 600;
}

.status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.toggle-group {
  display: flex;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0.5rem;
  padding: 0.25rem;
}

.toggle-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 0.375rem;
  background: transparent !important;
  color: var(--muted);
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.toggle-btn.active {
  background: var(--accent) !important;
  color: #05060a;
}

/* Aliases for backwards compatibility */
.theme-toggle {
  display: flex;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0.5rem;
  padding: 0.25rem;
}

.theme-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 0.375rem;
  background: transparent !important;
  color: var(--muted);
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.theme-btn.active {
  background: var(--accent) !important;
  color: #05060a;
}

.output-format-toggle {
  display: flex;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0.5rem;
  padding: 0.25rem;
}

.format-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 0.375rem;
  background: transparent !important;
  color: var(--muted);
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.format-btn.active {
  background: var(--accent) !important;
  color: #05060a;
}

.pill {
  padding: 0.25rem 0.625rem;
  border-radius: 62.4375rem;
  background: rgba(255, 255, 255, 0.09);
  font-size: 0.75rem;
  color: var(--muted);
}

.scale-card,
.matrix-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.scale-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.scale-item {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  padding: 0.625rem;
  border-radius: 0.625rem;
  border: 0.0625rem solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.scale-meta {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  color: var(--muted);
}

.scale-meta code {
  font-family: "JetBrains Mono", SFMono-Regular, Consolas, monospace;
  color: var(--text);
  font-size: 0.75rem;
}

.matrix-grid {
  display: grid;
  overflow-x: auto;
  border-radius: 0.625rem;
  border: 0.0625rem solid rgba(255, 255, 255, 0.12);
}

.matrix-cell {
  padding: 0.5rem;
  border: 0.0625rem solid rgba(255, 255, 255, 0.05);
  font-size: 0.75rem;
  text-align: center;
  min-width: 4.375rem;
}

.matrix-cell.header {
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.625rem;
}

.matrix-cell.pass-strong {
  background: rgba(76, 175, 80, 0.25);
  color: var(--text);
  font-weight: 600;
}

.matrix-cell.pass-weak {
  background: rgba(90, 125, 255, 0.18);
  color: var(--text);
}

.matrix-cell.fail {
  background: rgba(255, 107, 107, 0.2);
  color: var(--text);
  opacity: 0.6;
}

.matrix-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top:1rem;
  justify-content: flex-end;
}

.button-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

button {
  padding: 0.625rem 1rem;
  border-radius: 0.625rem;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.2s ease;
}

button.primary {
  background: var(--accent);
  color: #05060a;
  font-weight: 600;
  
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Tab styles */
.tabs-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tabs-header {
  display: flex;
  gap: 0.25rem;
  border-bottom: 0.0625rem solid var(--border);
  margin-bottom: 0.75rem;
}

.tab-button {
  padding: 0.625rem 1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 0.125rem solid transparent;
  position: relative;
  margin-bottom: -1px;
  border-radius: 0; /* override button border-radius for tabs */
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-button ion-icon {
  font-size: 1.25rem;
}

.tab-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.tab-button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1; /* take all available height */
  min-height: 0; /* allow flex children to shrink */
  overflow-y: auto; /* scroll the tab content, not individual cards */
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.75rem;
  padding: 0; /* ensure no extra vertical space */
  line-height: 1.4; /* compact line height */
}
footer p {
  margin: 0; /* remove default paragraph margins expanding footer height */
}
input[type="color"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Fallback for browsers without color input support */
.no-color-input input[type="color"] {
  position: static;
  opacity: 1;
  width: 100%;
  height: 2.5rem;
  pointer-events: auto;
  border: 0.0625rem solid var(--border);
  border-radius: 0.25rem;
  background: var(--panel);
  color: var(--text);
  padding: 0.5rem;
  font-family: inherit;
}

#primaryColorPicker{
  position: absolute;
  opacity: 0; 
  width: 0; 
  height: 0; 
  pointer-events: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Responsive Design */
@media (max-width: 64em) {
  .container {
    grid-template-columns: 1fr;
  }
  
  .left-column,
  .right-column {
    max-height: none;
    overflow-y: visible;
  }
  
  .harmony-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 48em) {
  header {
    flex-direction: column;
    padding: 1rem;
  }
  
  header h1 {
    font-size: 1.5rem;
  }
  
  .button-container {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .button-container button {
    width: 100%;
  }

  .color-input {
    flex-direction: column;
    align-items: stretch;
  }

  .swatch {
    width: 100%;
    height: 2.25rem;
  }
  
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  
  .tab-button {
    min-width: 6.25rem;
    flex-shrink: 0;
  }
  
  .card {
    padding: 1rem;
  }
  
  .welcome-container {
    padding: 2rem 1rem;
  }
  
  .welcome-container h1 {
    font-size: 2rem;
  }
  
  .harmony-cards {
    grid-template-columns: 1fr;
  }
  
  .scale-grid {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  }
}

@media (max-width: 30em) {
  .container {
    padding: 0.5rem;
    gap: 0.5rem;
  }
  
  .card {
    padding: 0.75rem;
  }
  
  .welcome-container svg {
    width: 8rem;
    height: 8rem;
  }
  
  .welcome-cta {
    padding: 0.875rem 1.5rem;
    font-size: 0.875rem;
  }
  
  .matrix {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .scale-grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  }
}

/* Semantic preview styles */
.semantic-preview {
  max-height: 50rem;
  overflow-y: auto;
}

#semantic-preview-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.semantic-section {
  border: 0.0625rem solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  background: rgba(31, 35, 44, 0.4);
}

.semantic-section h3 {
  margin: 0 0 0.75rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.surface-example {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.surface-box {
  flex: 1;
  min-width: 9.375rem;
  border-radius: 0.5rem;
  padding: 1rem;
  border: 0.0625rem solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.surface-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

.text-hierarchy {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.text-sample {
  font-size: 0.8125rem;
  padding: 0.375rem 0;
  font-weight: 400;
}

.text-primary {
  font-weight: 600;
}

.text-secondary {
  font-weight: 500;
  opacity: 0.9;
}

.text-tertiary {
  opacity: 0.7;
}

.outline-example {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.outline-box {
  width: 5rem;
  height: 5rem;
  border-radius: 0.5rem;
  border-width: 0.125rem;
  border-style: solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  background: var(--panel);
}

.token-reference {
  font-size: 0.6875rem;
  font-family: "Courier New", monospace;
  color: var(--accent);
  margin-top: 0.25rem;
  opacity: 0.8;
}

/* Welcome Page Styles */
.welcome-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top, #111526, #05060a 55%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

.welcome-page footer {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  right: 1.5rem;
  text-align: center;
}

.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  max-width: 31.25rem;
  text-align: center;
}

.logo-placeholder svg {
  width: 7.5rem;
  height: 7.5rem;
}

.welcome-container h1 {
  font-size: 3rem;
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
}

.welcome-subtitle {
  font-size: 1.125rem;
  color: var(--muted);
  margin: 0;
  font-weight: 400;
}

.welcome-input-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.welcome-input-section label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.welcome-input-group {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  background: var(--panel);
  border: 0.0625rem solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  position: relative;
}

.welcome-picker-wrapper {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 0.5rem;
}

.welcome-color-picker {
  width: 5rem;
  height: 5rem;
  border: 0.0625rem solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
}

.welcome-hex-input {
  flex: 1;
  background: var(--bg);
  border: 0.0625rem solid var(--border);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.875rem;
  text-transform: uppercase;
}

.welcome-hex-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 0.125rem rgba(90, 125, 255, 0.15);
}

.welcome-swatch {
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 0.375rem;
  border: 0.0625rem solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.welcome-swatch:hover {
  border-color: var(--accent);
}

.welcome-cta {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.welcome-cta:hover {
  background: #7399ff;
  transform: translateY(-2px);
}

.welcome-cta:active {
  transform: translateY(0);
}

/* Harmony mode cards */
.harmony-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.harmony-card {
  border: 0.0625rem solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: var(--surface);
}

.harmony-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
  text-align: center;
}

.harmony-icon {
  width: auto;
  height: 6rem;
  display: block;
  margin-bottom: 1rem;
}

.harmony-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
  color: var(--text);
}

.harmony-header p {
  font-size: 0.75rem;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.4;
}

.harmony-description {
  min-height: 2.8em;
}

.harmony-swatches {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.75rem;
}

.harmony-swatch {
  flex: 1;
  height: 2.5rem;
  border: 0.125rem solid transparent;
  border-radius: 0.375rem;
  background: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.harmony-swatch .swatch-color {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0.25rem;
  pointer-events: none;
}

.harmony-swatch:hover {
  border-color: var(--accent-light);
  transform: translateY(-2px);
}

.harmony-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.125rem rgba(90, 125, 255, 0.15);
}

.harmony-swatch.active::after {
  content: '✓';
  position: absolute;
  top: 0.125rem;
  right: 0.125rem;
  width: 1rem;
  height: 1rem;
  background: var(--accent);
  color: white;
  font-size: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* ============================================================================ */
/* ERROR HANDLING & NOTIFICATIONS */
/* ============================================================================ */

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

.error-notification {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

input.error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 0.1875rem rgba(220, 38, 38, 0.1) !important;
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ============================================================================ */
/* ACCESSIBILITY - FOCUS INDICATORS */
/* ============================================================================ */

/* Global focus styles for keyboard navigation */
*:focus-visible {
  outline: 0.125rem solid var(--accent);
  outline-offset: 0.125rem;
}

button:focus-visible,
.tint-switch:focus-visible,
.harmony-card:focus-visible {
  outline: 0.125rem solid var(--accent);
  outline-offset: 0.125rem;
  box-shadow: 0 0 0 0.25rem rgba(90, 125, 255, 0.1);
}

input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
select:focus-visible {
  outline: 0.125rem solid var(--accent);
  outline-offset: 0.0625rem;
  border-color: var(--accent);
}

.welcome-swatch:focus-visible {
  outline: 0.125rem solid var(--accent);
  outline-offset: 0.125rem;
  box-shadow: 0 0 0 0.25rem rgba(90, 125, 255, 0.2);
}

/* Remove focus styles for mouse users */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Skip to main content link for screen readers */
.skip-to-main {
  position: absolute;
  left: -62.4375rem;
  z-index: 999;
  padding: 0.75rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 0.25rem;
}

.skip-to-main:focus {
  left: 0.75rem;
  top: 0.75rem;
}

/* Loading and animation states */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spin-icon {
  animation: spin 2s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.25rem;
}

.btn-spinner {
  display: inline-flex;
  align-items: center;
}

/* Empty state helper text */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-tertiary);
}

.empty-state ion-icon {
  font-size: 3rem;
  opacity: 0.3;
  display: block;
  margin: 0 auto 1rem;
}

.empty-state h3 {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.875rem;
  max-width: 25rem;
  margin: 0 auto;
}

/* Skeleton loading states */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--card-bg) 0%,
    var(--hover-bg) 50%,
    var(--card-bg) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 0.25rem;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-heading {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-block {
  height: 6.25rem;
  margin-bottom: 1rem;
}

/* Recently used colors */
.recent-colors {
  margin-top: 1rem;
}

.recent-colors-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.recent-color-swatch {
  width: 2rem;
  height: 2rem;
  border-radius: 0.25rem;
  border: 0.0625rem solid var(--line);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.recent-color-swatch:hover {
  transform: scale(1.1);
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.2);
}

.recent-color-swatch:focus {
  outline: 0.125rem solid var(--accent);
  outline-offset: 0.125rem;
}

/* Animations and transitions */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(0.625rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-1.25rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.tab-content {
  animation: fadeIn 0.3s ease;
}

.card {
  animation: scaleIn 0.3s ease;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
}

.color-pill,
.scale-item {
  animation: slideIn 0.2s ease;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.scale-item:hover {
  transform: translateY(-0.125rem);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

.empty-state {
  animation: fadeIn 0.5s ease;
}

.harmony-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.harmony-card:hover {
  transform: translateY(-0.25rem);
  box-shadow: 0 0.375rem 1rem rgba(0, 0, 0, 0.15);
}

button:not(:disabled) {
  transition: all 0.2s ease;
}

button:not(:disabled):hover {
  transform: translateY(-0.0625rem);
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.15);
}

button:not(:disabled):active {
  transform: translateY(0);
}

.toast {
  animation: slideIn 0.3s ease;
}

/* Utility classes for common inline styles */
.hidden {
  display: none;
}

.section-heading {
  margin: 0 0 0.75rem 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.subsection-label {
  font-size: 0.75rem;
  font-weight: normal;
  margin-bottom: 0.5rem;
  color: var(--muted);
}

.recently-used-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.options-heading {
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.option-section {
  margin-bottom: 0.75rem;
}

.option-label {
  font-size: 0.875rem;
  font-weight: normal;
  margin-bottom: 0.5rem;
}

.helper-no-margin {
  margin-top: 0;
}

.flex-gap-center {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* Palette Settings */
.section-header-with-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.palette-settings-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.2s ease;
}

.palette-settings-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(90, 125, 255, 0.1);
}

.palette-settings-btn:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(90, 125, 255, 0.2);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: -1;
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.modal-tab-btn {
  flex: 1;
  padding: 1rem;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.modal-tab-btn:hover {
  color: var(--text);
  background: rgba(90, 125, 255, 0.05);
}

.modal-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.modal-tab-content {
  display: none;
}

.modal-tab-content.active {
  display: block;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.modal-close-btn:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
}

/* Modal Controls */
.modal-control-group {
  margin-bottom: 1.5rem;
}

.modal-control-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.modal-control-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.number-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.625rem 1rem;
  color: var(--text);
  font-size: 0.875rem;
  width: 100px;
  transition: all 0.2s ease;
}

.number-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(90, 125, 255, 0.2);
}

.input-unit {
  font-size: 0.875rem;
  color: var(--muted);
}

.select-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.625rem 1rem;
  color: var(--text);
  font-size: 0.875rem;
  width: 100%;
  transition: all 0.2s ease;
  cursor: pointer;
}

.select-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(90, 125, 255, 0.2);
}

.select-input option {
  background: var(--panel);
  color: var(--text);
}

.modal-footer {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

.btn-primary,
.btn-secondary {
  padding: 0.625rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #4a6fe8;
  border-color: #4a6fe8;
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
}

.btn-secondary:hover {
  background: rgba(90, 125, 255, 0.1);
  color: var(--text);
}

/* Palette preview strip */
.palette-preview-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
  height: 48px;
}

.palette-preview-cell {
  height: 100%;
}

/* Dual slider for scale range */
.slider-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slider-track {
  position: relative;
  height: 48px;
  background: linear-gradient(90deg, var(--panel) 0%, var(--panel) 48%, rgba(90, 125, 255, 0.15) 48%, rgba(90, 125, 255, 0.15) 52%, var(--panel) 52%, var(--panel) 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: visible;
}

.slider-fill {
  position: absolute;
  height: 100%;
  top: 0;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 100%);
  opacity: 0.2;
  border-radius: 8px;
}

.slider-seed {
  position: absolute;
  width: 2px;
  height: 100%;
  top: 0;
  left: 50%;
  transform: translateX(-1px);
  background: var(--accent);
  opacity: 0.6;
}

.slider-inputs {
  display: flex;
  gap: 20px;
  justify-content: space-between;
}

.slider-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.slider-input-group label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.slider-input {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(90, 125, 255, 0.4);
  transition: box-shadow 0.2s;
}

.slider-input::-webkit-slider-thumb:hover {
  box-shadow: 0 0 12px rgba(90, 125, 255, 0.6);
}

.slider-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px rgba(90, 125, 255, 0.4);
  transition: box-shadow 0.2s;
}

.slider-input::-moz-range-thumb:hover {
  box-shadow: 0 0 12px rgba(90, 125, 255, 0.6);
}

.slider-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}



