/* ============================================================
   ClosetMate 3D — Wardrobe management interface
   ============================================================ */

:root {
  --bg: #F3F5F7;
  --surface: #FFFFFF;
  --surface-glass: #FFFFFF;
  --ink: #182739;
  --ink-muted: #516172;
  --border: #DCE3EA;
  --accent: #304A65;
  --accent-soft: #EEF3F8;
  --sage: #347057;
  --sage-soft: #E8F2EC;
  --amber: #986220;
  --amber-soft: #FDF3E3;
  --rose: #9B3548;
  --rose-soft: #FCEBEF;
  --radius-xl: 12px;
  --radius-lg: 9px;
  --radius-md: 7px;
  --shadow-3d: 0 14px 34px -10px rgba(38, 26, 18, 0.14), 0 4px 10px -2px rgba(38, 26, 18, 0.06);
  --shadow-card: 0 1px 2px rgba(24, 39, 57, 0.06);
  --spring: cubic-bezier(0.22, 1, 0.36, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans Thai', 'Leelawadee UI', Thonburi, system-ui, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

.icon-library { position: absolute; inset: 0 auto auto 0; pointer-events: none; }
.ui-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid #4473a2;
  outline-offset: 3px;
}

.workspace-width, .main-content {
  width: min(100% - 72px, 1280px);
  margin-inline: auto;
}
.app-shell { min-height: 100dvh; }
.top-header { background: #162538; color: #fff; }
.header-row {
  min-height: 77px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand-wrap, .header-tools { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 41px;
  height: 41px;
  border: 1px solid #52667c;
  border-radius: 8px;
  color: #edf5fc;
  background: #24394f;
}
.brand-mark .ui-icon { width: 24px; height: 24px; }
.brand-title {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  font-size: 1.15rem;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.brand-sub { margin: 3px 0 0; font-size: .75rem; color: #b8c9da; }
.header-print {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #516479;
  border-radius: 7px;
  background: transparent;
  color: #eef4fa;
  cursor: pointer;
  white-space: nowrap;
}
.header-print:hover { background: #26394e; }
.header-print .ui-icon { width: 17px; height: 17px; }
.search-wrap { position: relative; width: clamp(215px, 27vw, 340px); color: #d9e4ef; }
.search-icon, .search-clear { position: absolute; top: 50%; transform: translateY(-50%); }
.search-icon { left: 12px; pointer-events: none; }
.search-icon .ui-icon { width: 17px; height: 17px; }
.search-input {
  width: 100%;
  height: 40px;
  padding: 0 39px;
  border: 1px solid #435970;
  border-radius: 7px;
  background: #20334a;
  color: #fff;
  font-size: .84rem;
}
.search-input::placeholder { color: #bbcad8; }
.search-input::-webkit-search-cancel-button { appearance: none; }
.search-clear { right: 6px; padding: 5px 8px; border: 0; background: transparent; cursor: pointer; }
.nav-bar { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--border); }
.workspace-nav { display: flex; gap: 18px; align-items: stretch; }
.workspace-nav .nav-item {
  min-height: 49px;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 0 9px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-size: .84rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.workspace-nav .nav-item:hover { color: var(--accent); background: #f6f8fa; }
.workspace-nav .nav-item.active { color: var(--accent); border-color: var(--accent); }
.workspace-nav .ui-icon { width: 17px; height: 17px; }
.workspace-nav .nav-scan { margin-left: auto; }
.workspace-nav .nav-add { color: var(--accent); }

.main-content { padding: 28px 0 50px; }
.view-section { display: none; }
.view-section.active { display: block; }
.page-heading, .section-head, .panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.page-heading { margin-bottom: 20px; }
.page-heading h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.18rem); line-height: 1.3; letter-spacing: -.025em; }
.page-heading p, .section-hint, .panel-heading p { margin: 5px 0 0; color: var(--ink-muted); font-size: .86rem; }
.section-head { margin: 0 0 16px; }
.section-title { margin: 0; font-size: 1.28rem; }
.text-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 4px;
  border: 0;
  color: var(--accent);
  background: none;
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
  white-space: nowrap;
}
.text-action-btn:hover { text-decoration: underline; }
.text-action-btn .ui-icon { width: 15px; height: 15px; }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-pill-3d {
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 12px 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.stat-pill-3d:hover { border-color: #7c9ab9; background: #f9fbfd; }
.stat-num { font: 750 1.82rem/1.12 "Plus Jakarta Sans", "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; }
.stat-lbl { color: var(--ink-muted); font-size: .8rem; font-weight: 600; }
.stat-available .stat-num { color: var(--sage); }
.stat-laundry .stat-num { color: var(--amber); }

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.84fr) minmax(0, 1fr);
  gap: 20px;
}
.workspace-panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.panel-heading { min-height: 73px; padding: 13px 17px; border-bottom: 1px solid var(--border); }
.panel-heading h2 { margin: 0; font-size: 1.1rem; }
.panel-heading p { margin-top: 3px; font-size: .78rem; }
.wardrobe-stage { padding: 14px; }
.cabinet-visual, .cabinet-detail-visual {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(290px, 27vw, 375px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d4dade;
  border-radius: 7px;
  background: #c8cdd1;
}
.cabinet-visual { cursor: pointer; }
.cabinet-visual img, .cabinet-detail-visual img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.cabinet-visual img.cabinet-reveal { opacity: 0; transition: opacity .22s ease; }
.cabinet-visual.is-open img.cabinet-reveal { opacity: 1; }
.model-caption {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  color: #354659;
  background: #f2f5f6;
  font-size: .68rem;
  font-weight: 550;
}
.cabinet-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 2px 2px;
}
.cabinet-summary h3 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.cabinet-summary p, .hero-loc { display: flex; align-items: center; gap: 4px; margin: 4px 0 0; color: var(--ink-muted); font-size: .8rem; }
.cabinet-summary p .ui-icon, .hero-loc .ui-icon { width: 15px; height: 15px; }
.cabinet-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 7px; }
.cabinet-actions .btn-primary, .cabinet-actions .btn-secondary { flex: 0 0 auto; white-space: nowrap; }
.closet-sidebar { display: flex; flex-direction: column; }
.sidebar-count {
  color: var(--ink-muted);
  background: #eef2f6;
  border-radius: 5px;
  padding: 4px 8px;
  flex: 0 0 auto;
  font-size: .7rem;
  font-weight: 650;
}
.closet-preview-list { display: grid; gap: 6px; align-content: start; padding: 12px; max-height: 350px; overflow: auto; }
.closet-preview-option {
  width: 100%;
  min-width: 0;
  min-height: 63px;
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid transparent;
  border-bottom-color: #edf0f3;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.closet-preview-option:hover { background: #f5f8fb; }
.closet-preview-option[aria-pressed="true"] { border-color: #c3d3e3; background: #edf3f9; color: var(--accent); }
.closet-preview-option > .ui-icon { width: 16px; height: 16px; color: #5d7590; }
.closet-list-icon, .closet-row-icon {
  width: 36px;
  height: 36px;
  border: 1px solid #dce4ec;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: #f3f6fa;
  flex: 0 0 auto;
}
.closet-preview-label { display: grid; gap: 3px; min-width: 0; }
.closet-preview-label strong { font-size: .82rem; overflow-wrap: anywhere; }
.closet-preview-label > span { color: var(--ink-muted); font-size: .7rem; }
.list-empty { padding: 8px; margin: 0; color: var(--ink-muted); font-size: .82rem; }
.sidebar-actions { display: grid; gap: 8px; padding: 13px; margin-top: auto; border-top: 1px solid var(--border); }
.recent-heading { margin-top: 23px; }

.detail-nav-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.detail-nav-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.back-pill-btn, .pill-outline-btn {
  min-height: 39px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
}
.back-pill-btn:hover, .pill-outline-btn:hover { background: var(--accent-soft); }
.closet-hero-3d {
  display: grid;
  grid-template-columns: minmax(0, 1.34fr) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  padding: 16px;
  margin: 0 0 25px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.cabinet-detail-visual { height: clamp(290px, 32vw, 420px); }
.cabinet-detail-visual img { object-fit: contain; background: #b1b5b7; }
.hero-content { min-width: 0; padding: 8px; }
.closet-code { color: var(--accent); font-family: ui-monospace, Consolas, monospace; font-size: .86rem; letter-spacing: .025em; font-weight: 700; }
.hero-title { margin: 6px 0; font-size: clamp(1.15rem, 2.6vw, 1.9rem); overflow-wrap: anywhere; }
.hero-notes { color: var(--ink-muted); margin: 13px 0 0; font-size: .86rem; overflow-wrap: anywhere; }
.hero-stats { margin: 18px 0 2px; }
.hero-stats > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: .86rem; }
.hero-stats dt { color: var(--ink-muted); }
.hero-stats dd { margin: 0; font-weight: 700; }

/* ============================================================
   Clothing inventory
   ============================================================ */
.clothes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 13px;
}

.cloth-card-3d {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.26s var(--spring), box-shadow 0.26s ease;
  } 

.cloth-media {
  position: relative;
  aspect-ratio: 4 / 4.4;
  background: #EEF2F5;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.cloth-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s var(--spring);
}
.cloth-card-3d:hover .cloth-media img {
  transform: scale(1.04);
}
.cloth-placeholder-art {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: color-mix(in srgb, var(--item-color, #71859B) 17%, #EFF2F5);
}
.cloth-placeholder-art .art-emoji {
  font-size: 42px;
  color: #51677c;
}
.cloth-placeholder-art .art-color-pill {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  background: rgba(255,255,255,0.86);
  color: var(--ink);
}

.fav-float-btn {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  transition: transform 0.25s var(--bounce);
}
.fav-float-btn.pop {
  transform: scale(1.3);
}

.status-float-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 0.67rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}
.st-available { background: rgba(232, 242, 236, 0.94); color: var(--sage); }
.st-wearing   { background: #EEF3F8; color: var(--accent); }
.st-laundry   { background: rgba(253, 243, 227, 0.94); color: var(--amber); }

.cloth-body {
  padding: 10px 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.cloth-title {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cloth-closet-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.71rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cloth-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 4px;
}
.color-dot-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--ink-muted);
}
.color-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.16);
  display: inline-block;
}
.wear-mini {
  font-size: 0.68rem;
  color: var(--ink-muted);
}

/* ============================================================
   Closets Tab List Cards
   ============================================================ */
.closets-list-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.closet-row-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  transition: transform 0.2s var(--bounce);
}
.closet-row-card:active { transform: scale(0.98); }

.closet-row-info {
  flex: 1;
  min-width: 0;
}
.closet-row-info h3 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
}
.closet-row-info p {
  margin: 2px 0 6px;
  font-size: 0.76rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.closet-row-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mini-pill {
  font-size: 0.69rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  background: #EEF3F8;
  color: var(--ink);
}
.closet-row-qr-btn {
  border: 1px solid var(--border);
  background: #F4F7FA;
  border-radius: var(--radius-md);
  padding: 9px 11px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   Filters (Chips & Segmented Control)
   ============================================================ */
.chip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}
.chip-scroll::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--spring);
}
.chip.active {
  background: var(--ink);
  color: #FFF;
  border-color: var(--ink);
  box-shadow: none;
}

.status-segment {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  background: #E9EEF3;
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}
.seg-btn {
  border: none;
  background: transparent;
  padding: 7px 4px;
  border-radius: 11px;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.22s var(--spring);
}
.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}

/* ============================================================
   Spring Bottom Sheet Modals
   ============================================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 27, 40, 0.54);
  backdrop-filter: blur(5px);
  z-index: 80;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 540px);
  max-height: 90dvh;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -16px 46px rgba(0, 0, 0, 0.22);
  z-index: 90;
  display: flex;
  flex-direction: column;
  animation: sheetSlideUp 0.36s var(--spring);
  padding-bottom: var(--safe-bottom);
}
@keyframes sheetSlideUp {
  from { transform: translate(-50%, 100%); }
  to   { transform: translate(-50%, 0); }
}

.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 99px;
  background: #D8E0E8;
  margin: 10px auto 4px;
  flex-shrink: 0;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.sheet-header h3 { margin: 0; font-size: 1.02rem; font-weight: 700; }
.sheet-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #EEF2F6;
  font-size: 14px;
  cursor: pointer;
}
.sheet-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
}

/* ============================================================
   Forms & Buttons
   ============================================================ */
.form-group { margin-bottom: 13px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 5px;
}
.text-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  border: 1.5px solid #DCE3EA;
  background: #FAFBFC;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.text-input:focus {
  border-color: var(--accent);
  background: #FFF;
}

.color-input-combo {
  display: flex;
  gap: 8px;
  align-items: center;
}
.color-swatch-input {
  width: 44px;
  height: 44px;
  border: 1.5px solid #DCE3EA;
  border-radius: 12px;
  padding: 3px;
  background: #FFF;
  cursor: pointer;
  flex-shrink: 0;
}

.photo-picker-wrap { margin-bottom: 14px; text-align: center; }
.photo-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 175px;
  border-radius: var(--radius-lg);
  border: 2px dashed #CDD7E2;
  background: #F4F7FA;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--ink-muted);
}
.photo-ico { font-size: 32px; }
.photo-placeholder strong { font-size: 0.88rem; color: var(--ink); }
.photo-placeholder span   { font-size: 0.73rem; }
.photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.btn-remove-photo {
  margin-top: 8px;
  border: none;
  background: var(--rose-soft);
  color: var(--rose);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 99px;
  cursor: pointer;
}

.emoji-picker, .theme-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.emoji-opt {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  border: 1.5px solid #DCE3EA;
  background: #F4F7FA;
  font-size: 20px;
  cursor: pointer;
}
.emoji-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.08);
}
.theme-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.16);
}
.theme-dot.active {
  border-color: var(--ink);
  transform: scale(1.12);
}

.btn-primary, .btn-primary-full, .btn-primary-sm, .btn-secondary, .btn-danger-ghost {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 41px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary, .btn-primary-full, .btn-primary-sm { background: var(--accent); color: #fff; }
.btn-primary:hover, .btn-primary-full:hover, .btn-primary-sm:hover { background: #243951; }
.btn-primary-full, .btn-danger-ghost { width: 100%; }
.btn-primary-full { min-height: 45px; }
.btn-secondary { color: var(--accent); background: var(--surface); border-color: #cdd9e5; }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-danger-ghost { margin-top: 10px; color: var(--rose); background: var(--rose-soft); }
.btn-primary:disabled, .btn-primary-full:disabled, .btn-primary-sm:disabled { opacity: .65; cursor: wait; }
.btn-primary .ui-icon, .btn-primary-sm .ui-icon, .btn-secondary .ui-icon { width: 16px; height: 16px; }

/* ============================================================
   Live QR Scanner Styles
   ============================================================ */
.scanner-frame-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #1A1715;
  min-height: 250px;
}
.qr-reader-box { width: 100%; }
.scanner-laser {
  position: absolute;
  left: 12%;
  right: 12%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #9FC5E6, transparent);
  box-shadow: 0 0 14px #9FC5E6;
  top: 20%;
  animation: scanLaser 2.2s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes scanLaser {
  from { top: 18%; }
  to   { top: 82%; }
}
.scanner-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin: 12px 0 16px;
}
.manual-qr-box {
  background: #F4F7FA;
  padding: 13px;
  border-radius: 16px;
  border: 1px solid var(--border);
}
.manual-qr-row {
  display: flex;
  gap: 8px;
}

/* ============================================================
   3D Flippable QR Pass Card
   ============================================================ */
.qr-pass-body { text-align: center; }
.qr-flip-hint {
  margin: 0 0 12px;
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.qr-card-3d-scene {
  width: 280px;
  height: 350px;
  margin: 0 auto 18px;
  perspective: 1000px;
  cursor: pointer;
}
.qr-card-3d-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.7s var(--spring);
}
.qr-card-3d-inner.is-flipped {
  transform: rotateY(180deg);
}
.qr-card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  backface-visibility: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 36px -10px rgba(31,27,24,0.22);
}
.qr-card-front {
  background: #FFFFFF;
  border: 1px solid var(--border);
}
.qr-front-badge {
  font-size: 30px;
  margin-bottom: 4px;
}
.qr-card-front h4 { margin: 0; font-size: 1rem; }
.qr-loc { margin: 2px 0 12px; font-size: 0.76rem; color: var(--ink-muted); }
.qr-canvas-holder {
  background: #FFF;
  padding: 12px;
  border-radius: 16px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  display: inline-block;
}
.qr-code-pill {
  margin-top: 12px;
  font-family: 'Plus Jakarta Sans', monospace;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: var(--ink);
  color: #FFF;
  padding: 5px 14px;
  border-radius: 99px;
}

.qr-card-back {
  background: #23374E;
  color: #F3F7FA;
  transform: rotateY(180deg);
  text-align: left;
  align-items: flex-start;
  gap: 8px;
}
.qr-back-title { font-weight: 800; font-size: 1rem; color: #E5EFF9; }
.qr-card-back p { margin: 0; font-size: 0.82rem; opacity: 0.92; }
.qr-back-url {
  margin-top: auto;
  width: 100%;
  font-size: 0.68rem;
  word-break: break-all;
  background: rgba(255,255,255,0.1);
  padding: 8px 10px;
  border-radius: 10px;
}
.qr-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ============================================================
   Outfit Detail Sheet & Move Closet List
   ============================================================ */
.detail-hero-img {
  width: 100%;
  max-height: 290px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}
.detail-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.detail-title-row h3 { margin: 0; font-size: 1.15rem; }
.detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0 14px;
}
.info-chip {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 99px;
  background: #EEF3F8;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.status-toggle-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.st-btn {
  border: 1.5px solid #DCE3EA;
  background: #F4F7FA;
  padding: 10px 6px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.st-btn.active-available { border-color: var(--sage); background: var(--sage-soft); color: var(--sage); }
.st-btn.active-wearing   { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.st-btn.active-laundry   { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }

.detail-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 14px;
}

.move-option-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  margin-bottom: 9px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: #F4F7FA;
  text-align: left;
  cursor: pointer;
}
.move-option-btn.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Empty State & Skeleton Shimmer */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 36px 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px dashed #CDD7E2;
  color: var(--ink-muted);
}
.empty-state .empty-ico { font-size: 40px; margin-bottom: 8px; display: block; }

.skeleton-card {
  height: 220px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, #E9EFF4 25%, #F4F7FA 50%, #E9EFF4 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(calc(100% - 32px), 420px);
  pointer-events: none;
}
.toast {
  background: rgba(31, 27, 24, 0.92);
  color: #FFF;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 12px 26px rgba(0,0,0,0.24);
  animation: toastIn 0.3s var(--bounce);
}
.toast.toast-error { background: #B83B52; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-14px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   Print QR Sticker Sheet Styles
   ============================================================ */
.print-qr-sheet { display: none; }

@media print {
  body { background: #FFF !important; }
  .app-shell, .bottom-sheet, .sheet-backdrop, .toast-container { display: none !important; }
  .print-qr-sheet {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    padding: 12px;
  }
  .print-sticker-card {
    border: 2px dashed #999;
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    break-inside: avoid;
  }
  .print-sticker-card h4 { margin: 6px 0 2px; font-size: 16px; }
  .print-sticker-card p  { margin: 0 0 10px; font-size: 12px; color: #555; }
  .print-sticker-qr { display: flex; justify-content: center; margin: 8px 0; }
  .print-sticker-code { font-family: monospace; font-weight: bold; font-size: 13px; }
}


/* Shared component refinements and responsive layout. */
.cabinet-visual, .cabinet-detail-visual { background: linear-gradient(#686a6b, #c4c6c7); }
.cabinet-visual img, .cabinet-detail-visual img {
  inset: 0 auto auto 50%;
  width: auto;
  max-width: 100%;
  transform: translateX(-50%);
  object-fit: contain;
  background: transparent;
  mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
}
.clothes-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cloth-media { aspect-ratio: 4 / 3; }
.cloth-card-3d:hover { border-color: #afc1d3; }
.cloth-card-3d h3 { font-size: .93rem; }
.cloth-placeholder-art .ui-icon { width: 43px; height: 43px; stroke-width: 1.15; }
.cloth-placeholder-art .art-color-pill { display: none; }
.cloth-closet-tag { display: block; }
.fav-float-btn[aria-pressed="true"] .ui-icon, #detailFavBtn[aria-pressed="true"] .ui-icon { fill: var(--rose); stroke: var(--rose); }
.fav-float-btn .ui-icon { width: 17px; height: 17px; }
.fav-float-btn.pop { transform: none; }
.status-float-badge { border-radius: 4px; }
.closet-row-card { cursor: auto; }
.closet-row-card:active { transform: none; }
.closet-row-icon { width: 44px; height: 44px; }
.closet-name-link { padding: 0; border: 0; background: none; color: var(--accent); font-size: inherit; font-weight: inherit; text-align: left; cursor: pointer; }
.closet-name-link:hover { text-decoration: underline; }
.closet-row-qr-btn:hover { background: var(--accent-soft); }
.icon-btn-3d { width: 39px; height: 39px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; }
.bottom-sheet { border-radius: 12px 12px 0 0; }
.qr-card-3d-scene { width: min(100%, 285px); }
.qr-card-face { box-shadow: 0 2px 7px rgba(24, 39, 57, .12); }
.qr-front-badge { color: var(--accent); }
.qr-front-badge .ui-icon { width: 29px; height: 29px; }
.qr-canvas-holder { border-radius: 6px; box-shadow: none; }
.qr-code-pill { border-radius: 5px; }
.empty-state .empty-ico .ui-icon { width: 33px; height: 33px; }
.empty-state p { margin: 5px 0 0; font-size: .83rem; }

.cabinet-media { position: relative; isolation: isolate; }
.cabinet-visual { touch-action: pan-y pinch-zoom; }
.cabinet-visual img { user-select: none; pointer-events: none; }
.cabinet-step, .cabinet-position, .cabinet-demo-hint {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: #f7fafb;
  border: 1px solid #d5dee6;
}
.cabinet-step {
  z-index: 1;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px #16253820;
}
.cabinet-step:hover { background: #e7eff6; }
.step-previous { left: 11px; }
.step-previous .ui-icon { transform: rotate(180deg); }
.step-next { right: 11px; }
.cabinet-position {
  top: 10px;
  right: 10px;
  min-height: 26px;
  border-radius: 6px;
  padding: 1px 8px;
  font-size: .74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.cabinet-demo-hint {
  bottom: 9px;
  left: 50%;
  transform: translateX(-50%);
  gap: 5px;
  padding: 3px 8px;
  min-height: 27px;
  border-radius: 5px;
  font-size: .73rem;
  font-weight: 650;
  white-space: nowrap;
  pointer-events: none;
}
.cabinet-demo-hint .ui-icon { width: 14px; height: 14px; }
.cabinet-summary-info { min-width: 0; }
.cabinet-summary .closet-code { display: block; margin-bottom: 3px; font-size: .73rem; color: #375a72; }
.cabinet-skeleton { height: 220px; }
.stats-section { margin-top: 19px; }
.stats-section .section-head { margin-bottom: 9px; }
.stats-section .stats-strip { margin-bottom: 0; }
.retry-load { display: flex; width: max-content; max-width: 100%; margin: 11px auto 0; }
.form-message { margin: 9px 0 0; color: var(--rose); }
.manual-qr-row .text-input { min-width: 0; }
.manual-qr-row button { white-space: nowrap; }
.scanner-hint { margin-top: 0; }
#btnRetryCamera { margin-bottom: 12px; }
#qrPassCanvasHolder { min-height: 48px; font-size: .82rem; }
.cloth-title-link {
  display: block;
  overflow-wrap: anywhere;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

/* The bottom bar, stack and touch targets are the default screen layout. */
@media screen {
  .workspace-width, .main-content { width: min(100% - 32px, 680px); }
  .app-shell { padding-bottom: calc(67px + var(--safe-bottom)); }
  .header-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    padding-block: 11px 12px;
  }
  .brand-wrap { gap: 9px; grid-column: 1; grid-row: 1; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-mark .ui-icon { width: 21px; height: 21px; }
  .brand-title { font-size: 1.07rem; }
  .brand-sub { font-size: .68rem; margin-top: 1px; }
  .header-tools { display: contents; }
  .search-wrap { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .search-input { height: 44px; font-size: 1rem; }
  .search-clear, .header-print { min-width: 44px; min-height: 44px; }
  .header-print { grid-column: 2; grid-row: 1; justify-content: center; padding-inline: 9px; font-size: .78rem; }
  .nav-bar {
    position: fixed;
    inset: auto 0 0;
    z-index: 60;
    padding-bottom: var(--safe-bottom);
    border-top: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 0 -4px 16px #1625380c;
  }
  .workspace-nav { width: min(100%, 680px); gap: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .workspace-nav .nav-item {
    min-width: 0;
    min-height: 66px;
    padding: 5px 1px 4px;
    flex-direction: column;
    gap: 4px;
    font-size: .68rem;
    border-bottom: 0;
    border-top: 2px solid transparent;
  }
  .workspace-nav .nav-item.active { background: #edf3f8; border-top-color: var(--accent); color: #193956; }
  .workspace-nav .ui-icon { width: 20px; height: 20px; }
  .workspace-nav .nav-scan { margin-left: 0; color: #165b53; }
  .workspace-nav .nav-scan .ui-icon {
    width: 38px;
    height: 34px;
    padding: 7px;
    margin-top: -8px;
    border-radius: 8px;
    background: #16665d;
    color: #fff;
  }
  .main-content { padding: 17px 0 22px; }
  .page-heading { align-items: center; gap: 8px; margin-bottom: 12px; }
  .page-heading h1 { font-size: 1.53rem; }
  .page-heading p, .section-hint { font-size: .79rem; }
  .page-heading .btn-primary-sm { flex-shrink: 0; padding-inline: 9px; }
  .home-layout, .closet-hero-3d { grid-template-columns: 1fr; gap: 11px; }
  .closet-sidebar, .cabinet-panel > .panel-heading { display: none; }
  .wardrobe-stage { padding: 8px; }
  .cabinet-visual, .cabinet-detail-visual { height: clamp(192px, 53vw, 330px); }
  .cabinet-summary { align-items: stretch; flex-direction: column; padding: 11px 4px 4px; }
  .cabinet-summary h3 { font-size: 1.08rem; }
  .cabinet-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px; }
  .btn-primary, .btn-primary-full, .btn-primary-sm, .btn-secondary, .btn-danger-ghost,
  .back-pill-btn, .pill-outline-btn, .closet-row-qr-btn, .sheet-close, .text-action-btn,
  .chip, .seg-btn, .st-btn, #detailFavBtn { min-height: 44px; }
  .sheet-close, #detailFavBtn { min-width: 44px; }
  .text-input, .search-input { font-size: 16px; }
  .stats-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .stat-pill-3d { min-height: 66px; padding: 8px 3px; align-items: center; text-align: center; }
  .stat-num { font-size: 1.44rem; }
  .stat-lbl { font-size: .69rem; }
  .section-title { font-size: 1.08rem; }
  .recent-heading { margin-top: 15px; margin-bottom: 9px; }
  .clothes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .cloth-meta-row { flex-wrap: wrap; gap: 4px; }
  .fav-float-btn { width: 44px; height: 44px; top: 4px; right: 4px; }
  .closet-hero-3d { padding: 9px; margin-bottom: 15px; }
  .hero-content { padding: 3px; }
  .hero-stats { margin-top: 10px; }
  .hero-stats > div { padding-block: 6px; }
  .bottom-sheet { max-height: min(90dvh, calc(100dvh - max(12px, env(safe-area-inset-top)))); }
  .sheet-body { overscroll-behavior: contain; }
  .toast-container { bottom: calc(78px + var(--safe-bottom)); top: auto; }
  .status-segment { display: flex; overflow-x: auto; padding: 4px; }
  .seg-btn { flex: 1 0 auto; padding-inline: 8px; white-space: nowrap; }
  .view-section.active { animation: view-enter .19s ease-out; }
}

@keyframes view-enter {
  from { opacity: .76; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@media screen and (min-width: 761px) {
  .app-shell { padding-bottom: 0; }
  .workspace-width, .main-content { width: min(100% - 64px, 1280px); }
  .header-row { display: flex; padding: 0; }
  .brand-mark { width: 41px; height: 41px; }
  .header-tools { display: flex; }
  .search-wrap { width: clamp(215px, 27vw, 340px); }
  .nav-bar { position: static; border: 0; border-bottom: 1px solid var(--border); box-shadow: none; }
  .workspace-nav { display: flex; gap: 18px; }
  .workspace-nav .nav-item { min-height: 49px; padding: 0 9px; flex-direction: row; gap: 7px; border-top: 0; border-bottom: 2px solid transparent; font-size: .84rem; }
  .workspace-nav .nav-item.active { border-bottom-color: var(--accent); background: #f6f8fa; }
  .workspace-nav .nav-scan { margin-left: auto; order: 1; }
  .workspace-nav .nav-add { order: 2; }
  .workspace-nav .nav-scan .ui-icon { width: 20px; height: 20px; padding: 0; margin: 0; color: currentColor; background: none; }
  .main-content { padding: 26px 0 48px; }
  .page-heading h1 { font-size: clamp(1.7rem, 3vw, 2.15rem); }
  .page-heading { margin-bottom: 17px; }
  .home-layout { grid-template-columns: minmax(0, 1.84fr) minmax(0, 1fr); gap: 18px; }
  .closet-sidebar, .cabinet-panel > .panel-heading { display: flex; }
  .closet-hero-3d { grid-template-columns: minmax(0, 1.34fr) minmax(0, 1fr); gap: 18px; padding: 14px; }
  .wardrobe-stage { padding: 12px; }
  .cabinet-visual, .cabinet-detail-visual { height: clamp(285px, 28vw, 380px); }
  .cabinet-summary { flex-direction: row; align-items: center; }
  .cabinet-actions { display: flex; }
  .stats-strip { gap: 10px; }
  .stat-pill-3d { align-items: flex-start; padding-inline: 13px; }
  .stats-section { margin-top: 15px; }
  .clothes-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .toast-container { top: 20px; bottom: auto; }
  .bottom-sheet {
    top: 50%;
    bottom: auto;
    width: min(560px, 92vw);
    transform: translate(-50%, -50%);
    border-radius: 12px;
    padding-bottom: 0;
    animation: fadeIn .17s ease;
  }
  .sheet-handle { display: none; }
  .sheet-header { padding-block: 12px; }
}

@media screen and (min-width: 1080px) {
  #homeRecentGrid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .clothes-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media screen and (max-width: 355px) {
  .workspace-width, .main-content { width: calc(100% - 22px); }
  .workspace-nav { width: 100%; }
  .page-heading h1 { font-size: 1.32rem; }
  .page-heading p, .stat-lbl { font-size: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
