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

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --border: #e0ddd8;
  --text: #2c2c2c;
  --text-secondary: #6b6b6b;
  --accent: #4A90D9;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* Input section */
.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.color-picker-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.color-picker-wrap input[type="color"] {
  width: 52px;
  height: 52px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 2px;
  background: none;
}

.color-picker-wrap label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.hex-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hex-input-wrap label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.hex-input-wrap input {
  width: 100px;
  padding: 0.5rem 0.6rem;
  font-size: 1rem;
  font-family: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.rgb-inputs {
  display: flex;
  gap: 0.5rem;
}

.rgb-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rgb-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.rgb-field input {
  width: 56px;
  padding: 0.5rem 0.4rem;
  font-size: 0.95rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  -moz-appearance: textfield;
}

.rgb-field input::-webkit-inner-spin-button,
.rgb-field input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#mixBtn {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--text);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

#mixBtn:hover {
  background: #444;
}

#mixBtn:active {
  background: #222;
}

/* Results */
.results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.results.hidden {
  display: none;
}

.swatches {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.swatch-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  width: 100px;
  height: 100px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
}

.swatch-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.swatch-hex {
  font-size: 0.85rem;
  font-family: "SF Mono", SFMono-Regular, Consolas, monospace;
  color: var(--text);
}

.swatch-arrow {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.delta-e {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  background: var(--bg);
}

.delta-e .de-value {
  font-weight: 700;
}

.delta-e.excellent { border-left: 4px solid #2ecc71; }
.delta-e.good      { border-left: 4px solid #82c91e; }
.delta-e.fair      { border-left: 4px solid #f1c40f; }
.delta-e.rough     { border-left: 4px solid #e67e22; }
.delta-e.poor      { border-left: 4px solid #e74c3c; }

/* Ratios */
.results h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  margin-top: 0.5rem;
}

.ratios {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

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

.ratio-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.ratio-name {
  width: 95px;
  font-size: 0.9rem;
  font-weight: 500;
}

.ratio-bar-bg {
  flex: 1;
  height: 22px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.ratio-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.ratio-percent {
  width: 40px;
  text-align: right;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: "SF Mono", SFMono-Regular, Consolas, monospace;
}

/* Instructions */
.instructions {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.instructions li {
  font-size: 0.9rem;
  line-height: 1.5;
}

.instructions li:last-child {
  list-style: none;
  margin-left: -1.25rem;
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: #fef9e7;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: #7d6608;
  border: 1px solid #f9e79f;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

footer p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 1rem 0.75rem;
  }

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

  .color-picker-wrap {
    flex-direction: row;
    justify-content: flex-start;
  }

  .hex-input-wrap input {
    width: 100%;
  }

  .rgb-inputs {
    width: 100%;
  }

  .rgb-field {
    flex: 1;
  }

  .rgb-field input {
    width: 100%;
  }

  .swatch {
    width: 80px;
    height: 80px;
  }
}
