:root {
  --accent: #e07a5f;
  --primary: #5c4033;
  --secondary: #d2b48c;
  --bg: #efe3cf;
  --paper: #fbf3e4;
  --ink: #3d2b1f;
  --teal: #4a9b8f;
  --lavender: #9b8fb8;
  --mustard: #d9a441;
  --coral: #e07a5f;
  --brass: #c9a227;
  --shadow: rgba(61,43,31,.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 140px;
}

/* ---------- Section headers ---------- */
.section {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 14px 4px 8px;
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  height: calc(66px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #7a5a43, #5c4033);
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 0 6px calc(env(safe-area-inset-bottom) + 14px);
  z-index: 20;
  border-top: 2px solid #8a674b;
}

.tab {
  position: relative;
  width: 44px;
  height: 62px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* wooden hanger body */
.tab::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 38px;
  border-radius: 15px 15px 6px 6px;
  background: linear-gradient(180deg, #a5825c, #8a674b);
  box-shadow: inset 0 2px 2px rgba(255,255,255,.25), 0 2px 3px var(--shadow);
  transition: transform .15s ease, filter .15s ease;
}

.tab::after {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 12px;
  border-radius: 3px;
  background: #5f4634;
}

/* fabric swatch + clothespin for active */
.tab .swatch {
  position: absolute;
  top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 34px; height: 20px;
  border-radius: 3px;
  display: none;
}
.tab.active .swatch { display: block; }
.tab.active::before {
  filter: brightness(1.06);
  transform: translateX(-50%) translateY(-2px);
}

.shelf {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom) + 6px);
  left: 0; right: 0;
  height: 8px;
  background: linear-gradient(180deg, #8a674b, #6b4e37);
  border-radius: 3px;
}

/* ---------- Rack dashboard ---------- */
.rack {
  background: linear-gradient(180deg, #d9c39e, #c8ae85);
  border-radius: 14px;
  padding: 14px 12px 12px;
  box-shadow: inset 0 2px 3px rgba(255,255,255,.4), 0 6px 14px var(--shadow);
  position: relative;
}
.metal-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #c7ccd4, #8d94a0);
  box-shadow: inset 0 1px 2px rgba(255,255,255,.6), 0 2px 3px rgba(0,0,0,.25);
  margin-bottom: 10px;
}

.counters {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 4px 0 14px;
}
.disc {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #d9c39e, #a8855f);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.4), 0 4px 6px var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.disc::before {
  content: "";
  position: absolute;
  top: -18px;
  width: 4px; height: 18px;
  background: #c2b29a;
}
.disc .count {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  line-height: 1;
}
.disc .label {
  font-size: 10px;
  color: #f6e9d2;
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
  letter-spacing: .04em;
}
.disc .star {
  color: #f5d467;
  font-size: 14px;
  line-height: 1;
  margin-top: 2px;
}
.sway { animation: sway 5s ease-in-out infinite; transform-origin: top center; }
.disc:nth-child(2) { animation-delay: 1.2s; }
@keyframes sway {
  0%,100% { transform: rotate(0deg); }
  50% { transform: rotate(3deg); }
}

/* ---------- Garment tag cards ---------- */
.card {
  position: relative;
  background: var(--paper);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: 0 3px 7px var(--shadow);
  overflow: hidden;
  transform: translateX(0);
  transition: transform .25s ease, opacity .25s ease;
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 12px; right: 12px;
  height: 14px;
  background: repeating-linear-gradient(90deg, transparent 0 10px, #e8dcc3 10px 13px, transparent 13px 20px);
  border-radius: 4px 4px 0 0;
}
.card.swiped { transform: translateX(-72px); }
.card.removing { transform: translateX(-100%); opacity: 0; }

.card-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.sil {
  flex: 0 0 auto;
  width: 46px; height: 46px;
}

.card .name {
  font-size: 16px;
  font-weight: 700;
  font-family: "Comic Sans MS", "Segoe Print", cursive;
  line-height: 1.2;
}
.card .type {
  font-size: 12px;
  color: #8a6a4f;
  text-transform: capitalize;
}
.dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.15);
  margin-left: auto;
}
.star-brad {
  position: absolute;
  top: 4px; right: 6px;
  font-size: 12px;
  color: var(--brass);
  text-shadow: 0 1px 1px rgba(0,0,0,.3);
}

.delete-zone {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 72px;
  background: #d64545;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

/* ---------- Add form ---------- */
.form {
  padding-top: 6px;
}
.form label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 16px 4px 8px;
}
.input-name {
  width: 100%;
  font-size: 22px;
  font-weight: 700;
  font-family: "Comic Sans MS", "Segoe Print", cursive;
  padding: 12px 14px;
  border: 2px solid var(--secondary);
  border-radius: 10px;
  background: #fffdf7;
  color: var(--ink);
  outline: none;
}
.input-name:focus { border-color: var(--primary); }

.type-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
}
.type-opt {
  flex: 0 0 auto;
  width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 10px;
  background: #fffdf7;
  border: 2px solid var(--secondary);
  cursor: pointer;
}
.type-opt svg { width: 30px; height: 30px; }
.type-opt span { font-size: 11px; color: #8a6a4f; }
.type-opt.sel { border-color: var(--primary); background: #f3e8d3; }
.type-opt.sel span { color: var(--primary); font-weight: 700; }

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 2px;
}
.color-opt {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.2);
}
.color-opt.sel { border-color: var(--primary); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px 4px;
}
.star-btn {
  background: none;
  border: none;
  font-size: 34px;
  color: #c9b8a0;
  cursor: pointer;
  line-height: 1;
}
.star-btn.on { color: var(--brass); }

.save-hanger {
  display: block;
  margin: 18px auto 8px;
  background: none;
  border: none;
  cursor: pointer;
}
.save-hanger svg { width: 64px; height: 64px; }

/* ---------- Search ---------- */
.search-bar {
  width: 100%;
  font-size: 16px;
  padding: 12px 14px 12px 38px;
  border-radius: 12px;
  border: 2px solid var(--secondary);
  background: #fffdf7 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a6a4f' stroke-width='2'><circle cx='11' cy='11' r='7'/><line x1='16.5' y1='16.5' x2='21' y2='21'/></svg>") no-repeat 12px center;
  background-size: 18px;
  color: var(--ink);
  outline: none;
}
.empty {
  text-align: center;
  color: #8a6a4f;
  padding: 40px 0;
  font-family: "Comic Sans MS", cursive;
}

/* ---------- Modal & toast ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(40,25,15,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.modal-card {
  background: var(--paper);
  border-radius: 14px;
  padding: 20px;
  width: 80%;
  max-width: 300px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.modal-title { font-weight: 700; margin-bottom: 6px; }
.modal-name { color: #8a6a4f; margin-bottom: 16px; font-family: "Comic Sans MS", cursive; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions button {
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
.btn-ghost { background: #e6dcc6; color: var(--ink); }
.btn-danger { background: #d64545; color: #fff; }

.toast {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 50;
  box-shadow: 0 4px 10px rgba(0,0,0,.3);
}