@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400&family=DM+Sans:wght@300;400;500&display=swap');

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

:root {
  --bg:           #F5EDE6;
  --bg-warm:      #EDE3DA;
  --surface:      #FFFFFF;
  --primary:      #2C2320;
  --primary-soft: #3E332F;
  --accent:       #C5956E;
  --accent-light: #F2E4D8;
  --accent-muted: #D4B49A;
  --text:         #2C2320;
  --text-muted:   #8A7A70;
  --text-light:   #B5A49A;
  --border:       #E4D8CE;
  --border-light: #EDE5DC;
  --step-bg:      #FBF7F4;
  --shadow-sm:    0 1px 4px rgba(44,35,32,0.07);
  --shadow-md:    0 4px 16px rgba(44,35,32,0.10);
  --radius-sm:    8px;
  --radius-md:    16px;
  --radius-lg:    24px;
  --font-serif:   'Cormorant Garamond', Georgia, serif;
  --font-sans:    'DM Sans', system-ui, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--primary);
  display: block;
}

.logo-sub {
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-top: 1px;
  display: block;
}

nav {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3px;
  gap: 2px;
}

.nav-btn {
  padding: 6px 14px;
  border: none;
  border-radius: calc(var(--radius-lg) - 3px);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-btn.active {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}

/* ── PAGES ── */
.page { display: none; padding: 28px 20px 56px; max-width: 680px; margin: 0 auto; }
.page.active { display: block; }

/* ── SELECTOR CARD ── */
.selector-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.section-label {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 10px;
}

.selector-card h2 {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text);
  margin-bottom: 14px;
}

/* ── CHOICE BUTTONS ── */
.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }

.choice-btn {
  padding: 7px 16px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.18s;
  min-height: 36px;
}

.choice-btn:hover { border-color: var(--accent-muted); color: var(--text); }
.choice-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }

/* ── PRIMARY BUTTON ── */
.primary-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.83rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.primary-btn:hover { background: var(--primary-soft); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.primary-btn:active { transform: translateY(0); }

.secondary-btn {
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s;
}

.secondary-btn:hover { border-color: var(--text-muted); color: var(--text); }

/* ── LOADING ── */
#loading { text-align: center; padding: 56px 0; color: var(--text-muted); }
#loading p { font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; margin-top: 14px; }
.spinner { width: 28px; height: 28px; border: 1.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESULT SECTION ── */
#result-section { margin-top: 20px; }

.routine-banner {
  background: var(--accent-light);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 16px;
}

.routine-meta-label {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ── STEP FLOW ── */
.step-flow {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding: 8px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.step-flow::-webkit-scrollbar { height: 4px; }
.step-flow::-webkit-scrollbar-track { background: transparent; }
.step-flow::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.step-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 12px 12px;
  min-width: 130px;
  max-width: 140px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
  position: relative;
}

.step-card:hover { box-shadow: var(--shadow-md); }

.step-num {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 10px;
}

.step-sun {
  font-size: 0.75rem;
  color: #E8A44A;
  margin-bottom: 4px;
}

.step-circle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--step-bg);
  border: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.step-circle img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.step-circle svg {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
}

.step-product-name {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
  margin-bottom: 3px;
  color: var(--text);
}

.step-brand {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 10px;
}

.step-type-tag {
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 10px;
}

.step-swap {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg);
  cursor: pointer;
  appearance: auto;
}

.step-swap:focus { outline: none; border-color: var(--accent-muted); }

/* Arrow between steps */
.step-arrow {
  display: flex;
  align-items: center;
  padding: 0 6px;
  margin-top: 35px;
  flex-shrink: 0;
  color: var(--border);
  font-size: 1.4rem;
  line-height: 1;
}

/* ── STEP NOTES ── */
.step-notes-area {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.step-note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.step-note-num {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  padding-top: 2px;
}

.step-note-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── SAVE ROUTINE BAR ── */
.save-routine-bar {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.save-routine-bar input {
  flex: 1;
  min-width: 180px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--text);
  background: var(--surface);
}

.save-routine-bar input:focus { outline: none; border-color: var(--accent-muted); }
.save-routine-bar .primary-btn { width: auto; margin-top: 0; padding: 10px 20px; font-size: 0.78rem; }

/* ── PRODUCT IMG ── */
.product-img { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; background: var(--bg); border: 1px solid var(--border-light); flex-shrink: 0; }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border-light); margin: 8px 0 18px; }

/* ── ROUTINES PAGE ── */
.inventory-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.inventory-title { font-family: var(--font-serif); font-size: 1.8rem; font-weight: 300; letter-spacing: 0.02em; }
.inventory-header .primary-btn { width: auto; padding: 10px 20px; font-size: 0.78rem; margin-top: 0; }

.routine-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}

.routine-card .routine-name { font-family: var(--font-serif); font-size: 1rem; font-weight: 500; margin-bottom: 4px; }
.routine-card .routine-meta { font-size: 0.72rem; color: var(--text-light); letter-spacing: 0.06em; margin-bottom: 10px; }
.routine-card .routine-steps { font-size: 0.82rem; color: var(--text-muted); white-space: pre-wrap; line-height: 1.6; max-height: 100px; overflow: hidden; }
.routine-card .routine-steps.expanded { max-height: none; }
.routine-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── INVENTORY PAGE ── */
#product-list { display: grid; gap: 10px; }

.inventory-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  transition: box-shadow 0.2s;
}

.inventory-card:hover { box-shadow: var(--shadow-md); }
.inventory-card .info .name { font-family: var(--font-serif); font-size: 1rem; font-weight: 500; margin-bottom: 3px; }
.inventory-card .info .meta { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-light); margin-bottom: 5px; }
.inventory-card .info .key-ing { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }
.card-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: flex-start; padding-top: 2px; }

.icon-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.18s;
  min-height: 32px;
}

.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn.delete:hover { border-color: #C0392B; color: #C0392B; background: #FEF2F2; }

/* ── MODAL ── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,35,32,0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 540px) { #modal-overlay { align-items: center; padding: 24px; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 26px 22px 32px;
  width: 100%;
  max-width: 580px;
  max-height: 92dvh;
  overflow-y: auto;
}

@media (min-width: 540px) { .modal { border-radius: var(--radius-md); } }

.modal-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.modal h3 { font-family: var(--font-serif); font-size: 1.4rem; font-weight: 400; font-style: italic; }

.modal label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 12px;
}

.modal input, .modal textarea, .modal select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  width: 100%;
  transition: border-color 0.18s;
}

.modal input:focus, .modal textarea:focus, .modal select:focus { outline: none; border-color: var(--accent-muted); }
.modal textarea { resize: vertical; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .primary-btn { margin-top: 0; flex: 1; }

.form-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; }
.form-divider span { font-size: 0.68rem; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.form-divider::before, .form-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }

.empty-state { text-align: center; padding: 56px 0; }
.empty-state p { font-size: 0.85rem; color: var(--text-light); line-height: 1.7; }

/* ── FILTER BAR ── */
#routines-filter { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .page { padding: 20px 14px 48px; }
  header { padding: 0 16px; }
  .logo-name { font-size: 1.1rem; }
  .nav-btn { padding: 5px 10px; font-size: 0.72rem; }
}
