/* Layout: one narrow phone column, choices on top, the outfit card below, tabs pinned to the bottom. */
:root {
  --bg: #faf4f6;
  --surface: #ffffff;
  --soft: #f3e4ec;
  --ink: #2a1726;
  --muted: #6e5a69;
  --line: rgba(42, 23, 38, 0.14);
  --accent: #8e2f62;
  --accent-ink: #ffffff;
  --good: #2f6b4c;
  --warn: #a8402a;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  --tab-height: 76px;
  --bar-shadow: rgba(42, 23, 38, 0.1);
  --outline: rgba(30, 14, 26, 0.5);
  --backdrop: rgba(30, 14, 26, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #19111a;
    --surface: #241925;
    --soft: #33222f;
    --ink: #f4eaf0;
    --muted: #b9a6b4;
    --line: rgba(244, 234, 240, 0.16);
    --accent: #e59bc3;
    --accent-ink: #2a1023;
    --good: #8cc7a3;
    --warn: #f0957f;
    --bar-shadow: rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #19111a;
  --surface: #241925;
  --soft: #33222f;
  --ink: #f4eaf0;
  --muted: #b9a6b4;
  --line: rgba(244, 234, 240, 0.16);
  --accent: #e59bc3;
  --accent-ink: #2a1023;
  --good: #8cc7a3;
  --warn: #f0957f;
  --bar-shadow: rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 34rem;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 20px calc(var(--tab-height) + 32px + env(safe-area-inset-bottom, 0px));
}

main {
  display: grid;
  gap: 24px;
}

/* Masthead */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 2rem;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.today-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1.5px solid var(--warn);
  border-radius: var(--radius);
  color: var(--warn);
  font-size: 0.9rem;
}

.screen {
  display: grid;
  gap: 24px;
}

.laundry-link {
  min-height: 48px;
  padding: 10px 16px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.laundry-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.laundry-section,
.laundry-add {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.empty-note {
  margin: 0;
  color: var(--muted);
}

.laundry-add label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.laundry-add-row {
  display: flex;
  gap: 8px;
}

.laundry-add-row select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 10px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.laundry-add-row select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wash-after {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.wash-after select {
  min-height: 36px;
  padding: 4px 8px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.wash-after select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sample-note {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--soft);
}

.sample-note p {
  margin: 0;
  font-weight: 600;
}

/* Choice chips (radio and checkbox inputs styled as pills) */
.context-form,
.sheet-form {
  display: grid;
  gap: 18px;
}

.choice-group {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.choice-group legend,
.field label {
  padding: 0;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.legend-note {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  position: relative;
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chip span:hover {
  border-color: var(--accent);
}

.chip input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.weather-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
}

.weather-status .hint {
  flex: 1 1 14rem;
  margin: 0;
}

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1.5px dashed var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.chip-toggle:hover {
  border-color: var(--accent);
}

.chip-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip-toggle.is-active {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
}

.chip-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}

.chip-toggle[aria-expanded="true"] .chip-arrow {
  transform: rotate(90deg);
}

.occasion-plans {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--soft);
}

@media (prefers-reduced-motion: reduce) {
  .chip-arrow {
    transition: none;
  }
}

.body-check {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--soft);
}

.body-check p {
  margin: 0;
  font-weight: 600;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Outfit card */
.outfit {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  display: grid;
  gap: 16px;
}

.outfit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  text-wrap: balance;
}

.rules {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.pieces {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.piece {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 12px;
  border-top: 1px solid var(--line);
}

.piece-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.piece-slot {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.piece-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.piece-tags {
  font-size: 0.82rem;
  color: var(--muted);
}

.piece.is-missing .piece-name {
  font-family: var(--font-body);
  font-size: 0.98rem;
  color: var(--warn);
}

.empty-state {
  display: grid;
  gap: 12px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

/* Buttons */
.primary-button,
.secondary-button,
.small-button {
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
}

.primary-button {
  min-height: 48px;
  padding: 10px 20px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
}

.secondary-button {
  min-height: 44px;
  padding: 8px 16px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
}

.small-button {
  flex-shrink: 0;
  min-height: 40px;
  padding: 6px 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
}

.small-button:hover,
.secondary-button:hover {
  border-color: var(--accent);
}

.small-button.is-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.small-button.is-confirming {
  border-color: var(--warn);
  color: var(--warn);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.small-button:focus-visible,
.tab:focus-visible,
input[type="text"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.field {
  display: grid;
}

.field input,
.field select {
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.added-confirmation {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--good);
  font-weight: 600;
}

.added-confirmation::before {
  content: "✓";
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--good);
  color: var(--surface);
  font-size: 0.85rem;
}

.field-error {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--warn);
}

/* Closet list */
.closet {
  display: grid;
  gap: 20px;
}

.closet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.closet-count {
  color: var(--muted);
  font-size: 0.9rem;
}

.category-group h3 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.piece-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex-shrink: 0;
}

.piece.is-in-laundry .piece-name,
.piece.is-in-laundry .piece-tags {
  opacity: 0.55;
}

.sample-tag {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--soft);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  vertical-align: middle;
}

.laundry-tag {
  color: var(--accent);
}

.repeat-note {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--warn);
}

.comfy-mark {
  color: var(--good);
  font-weight: 600;
}

/* Tab bar and toast */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px max(12px, calc((100% - 34rem) / 2)) calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px var(--bar-shadow);
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 60px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-icon {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab[aria-current="page"] {
  background: var(--soft);
  color: var(--accent);
}

.tab[aria-current="page"] .tab-icon {
  stroke-width: 2.2;
}

.tab-badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 6px);
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-height) + 20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.92rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

/* Drawings of clothes */
.tile {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 14px;
  background: var(--soft);
}

.tile-small {
  width: 52px;
  height: 52px;
  border-radius: 12px;
}

.tile-large {
  width: 72px;
  height: 72px;
}

.tile-card {
  width: 100%;
  aspect-ratio: 1;
  max-width: 100%;
}

.drawing {
  width: 78%;
  height: 78%;
}

.drawing .fill {
  fill: var(--piece-color);
  stroke: var(--outline);
  stroke-width: 1.4;
  stroke-linejoin: round;
}

.drawing .line {
  fill: none;
  stroke: var(--outline);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.72rem;
  font-weight: 700;
}

/* My closet: search, filters, and the grid of cards */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.closet-tools {
  display: grid;
  gap: 12px;
}

.search-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.search-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.filter-chip {
  flex-shrink: 0;
  min-height: 40px;
  padding: 6px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.filter-chip:focus-visible,
.piece-card:focus-visible,
.add-fab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 480px) {
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.piece-card {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
  padding: 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.piece-card:hover {
  border-color: var(--accent);
}

.card-name {
  padding-inline: 2px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding-inline: 2px;
  font-size: 0.78rem;
  color: var(--muted);
}

.card-meta .sample-tag {
  margin-left: 0;
}

.add-fab {
  position: fixed;
  right: max(16px, calc((100% - 34rem) / 2));
  bottom: calc(var(--tab-height) + 16px + env(safe-area-inset-bottom, 0px));
  min-height: 52px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 700;
  box-shadow: 0 8px 22px var(--bar-shadow);
  cursor: pointer;
}

.backup-section {
  display: grid;
  gap: 10px;
  margin-bottom: 72px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.backup-section .hint {
  margin: 0;
}

.file-button {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.file-button:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.backup-status {
  display: grid;
  gap: 10px;
}

.backup-status:empty {
  display: none;
}

.backup-status p {
  margin: 0;
}

/* Add / edit sheet that slides up from the bottom */
.sheet {
  width: 100%;
  max-width: 34rem;
  max-height: 92vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  color: var(--ink);
}

.sheet::backdrop {
  background: var(--backdrop);
}

.sheet-form {
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sheet-head .section-title {
  flex: 1;
}

.swatch-chip span {
  min-height: 40px;
  padding: 6px 12px 6px 8px;
  gap: 6px;
  font-size: 0.88rem;
}

.swatch-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--outline);
}

.color-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 14px 4px 6px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.color-pick.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.color-pick input {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--outline);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.color-pick input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-pick input::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

.color-pick input::-moz-color-swatch {
  border: 0;
  border-radius: 50%;
}

.color-pick:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.swatch-dot.is-auto {
  background: conic-gradient(#b8323a, #e0b743, #4f7d55, #3f6fb5, #7a58a0, #b8323a);
}

.sheet-remove:empty {
  display: none;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .chip span {
    transition: none;
  }
}
