:root {
  --bg:           #e8d5b0;
  --card-bg:      #eddfc4;
  --accent:       #7a3006;
  --text:         #1e0e00;
  --text-dim:     #4a3010;
  --success:      #3a6820;
  --border:       #c4a872;
  --border-mid:   #d0b888;
  --border-gold:  #b89560;

  --tint-rgb:     130, 70, 10;
  --accent-rgb:   122, 48, 6;

  --font-display: 'IM Fell English', Georgia, serif;
  --font-body:    'EB Garamond', Georgia, serif;
  --font-mono:    'Fira Code', 'Courier New', monospace;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 1.5rem;
  font-size: clamp(16px, 1.1vw, 18px);
  line-height: 1.6;
}

.container {
  max-width: 56rem;
  margin: 0 auto;
}

h1 {
  text-align: center;
  font-family: var(--font-display);
  font-weight: normal;
  font-size: clamp(1.8rem, 4vw + 1rem, 3.5rem);
  margin-bottom: 0.4rem;
  color: var(--text);
  line-height: 1.05;
  letter-spacing: 0.01em;
}

.subtitle {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  font-size: 1rem;
  margin-bottom: 1rem;
  padding: 0 8px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-variant-caps: small-caps;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: normal;
  margin-bottom: 1rem;
}

.input-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
}

.input-row input[type="text"] {
  flex: 1;
  border-radius: 3px 0 0 3px;
  border-right: none;
}

.input-row button {
  border-radius: 0 3px 3px 0;
  border-left: none;
  width: auto;
}

input[type="text"],
textarea {
  display: block;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--text);
  outline: none;
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  font-family: var(--font-mono);
  resize: vertical;
  min-height: 120px;
  margin-top: 1rem;
  font-size: 0.9rem;
}

button {
  display: block;
  width: 100%;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
  font-family: var(--font-body);
  letter-spacing: 0.03em;
  color: #e8d5b0;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

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

.hidden {
  display: none;
}

.status {
  text-align: center;
  padding: 0.5rem;
  margin-bottom: 1rem;
  color: var(--text-dim);
  font-style: italic;
  transition: opacity 0.5s ease;
}

.status.dismissed {
  opacity: 0;
  pointer-events: none;
}

.status.loading::after {
  content: '';
  display: inline-block;
  width: 1em;
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40%      { content: '.'; }
  60%      { content: '..'; }
  80%, 100% { content: '...'; }
}

.results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@keyframes row-appear {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.mix-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: row-appear 0.4s ease-out both;
}

.mix-word {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 1.1rem;
  color: var(--accent);
}

.divider {
  display: none;
}

.blend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

@keyframes item-appear {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

.blend-item {
  background: rgba(var(--tint-rgb), 0.07);
  border: 1px solid rgba(var(--tint-rgb), 0.18);
  border-radius: 2px;
  padding: 0.2rem 0.6rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: #5e2c06;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  animation: item-appear 0.2s ease;
}

.blend-item:hover {
  border-color: var(--accent);
  background: rgba(var(--tint-rgb), 0.14);
}

.blend-item:active {
  transform: scale(0.97);
}

.blend-item.copied {
  background: rgba(58, 104, 32, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header h2 {
  margin-bottom: 0;
}

.save-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  width: auto;
}

.count {
  text-align: center;
  color: var(--success);
  font-style: italic;
  font-size: 1rem;
  margin-bottom: 1rem;
  opacity: 0;
}

.count.visible {
  opacity: 1;
}

.progress-bar {
  height: 3px;
  background: var(--border-mid);
  border-radius: 2px;
  margin-bottom: 1rem;
  overflow: hidden;
  opacity: 0;
}

.progress-bar.visible {
  opacity: 1;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
}

.settings-row {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.setting {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.setting input {
  width: 55px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.2rem 0.4rem;
  color: var(--text);
  text-align: center;
}

.setting input[type="checkbox"] {
  width: auto;
  margin-right: 2px;
  accent-color: var(--accent);
}

#weightValue {
  width: 50px;
}

.text-dim {
  color: var(--text-dim);
}

.weight-section {
  margin-bottom: 1.5rem;
}

.weight-section:last-child {
  margin-bottom: 0;
}

.weight-label {
  font-size: 0.75rem;
  font-variant-caps: small-caps;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-mid);
}

.hint {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.8rem;
  margin-top: 0.75rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hint.visible {
  opacity: 1;
}

/* Desktop layout */
@media (min-width: 600px) {
  body {
    padding: 2rem;
  }

  .subtitle {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
  }

  .card {
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
  }

  button {
    width: auto;
  }

  .mix-row {
    flex-direction: row;
    align-items: flex-start;
  }

  .mix-word {
    min-width: 120px;
    max-width: 200px;
    text-align: right;
    padding: 0.3rem 0;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .divider {
    display: block;
    width: 1px;
    background: var(--border-mid);
    border-radius: 1px;
    align-self: stretch;
    min-height: 2rem;
    flex-shrink: 0;
  }

  .blend-list {
    flex: 1;
  }
}

/* Pointer hover only */
@media (hover: hover) {
  button:hover {
    background: #5e2005;
    border-color: #5e2005;
    color: var(--bg);
  }
}
