:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-subtle: #efece5;
  --mat-top: #f1eee7;
  --mat-bottom: #e6e1d7;
  --border: #e4dfd5;
  --border-strong: #cfc8ba;
  --ink: #191816;
  --ink-muted: #69655d;
  --accent: #1d3b32;
  --accent-hover: #142b24;
  --accent-soft: #e6efec;
  --danger: #9e2a2b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(25, 24, 22, 0.05);
  --shadow-md: 0 8px 26px rgba(25, 24, 22, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body.auth-pending .topbar,
body.auth-pending .container {
  visibility: hidden;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 5px;
  font-size: 12.5px;
}

.user-avatar,
.user-avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.user-avatar {
  object-fit: cover;
  border: 1px solid var(--border);
}

.user-avatar-fallback {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.user-name {
  font-weight: 500;
  color: var(--ink);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-signout {
  border: none;
  background: var(--surface-subtle);
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-signout:hover {
  background: #f8e5e5;
  color: var(--danger);
}

.hidden {
  display: none !important;
}

/* ==================== HEADER ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(246, 244, 239, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

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

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: block;
  flex-shrink: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.brand h1 {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0.01em;
}

.brand-sub {
  margin: 3px 0 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.tabs {
  display: flex;
  background: var(--surface-subtle);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  gap: 4px;
}

.tab {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.16s ease;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.badge {
  background: var(--surface-subtle);
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
}

.tab.active .badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 999px;
  font-family: inherit;
}

.key-pill {
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.key-pill:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d97706;
}

.status-pill.online .status-dot {
  background: #15803d;
}

.status-pill.offline .status-dot {
  background: var(--danger);
}

/* ==================== LAYOUT ==================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 26px 28px 64px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ==================== STUDIO PROMPT BAR ==================== */
.studio-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

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

.prompt-input-wrap {
  flex: 1 1 360px;
}

input[type="text"],
input[type="search"],
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

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

.prompt-input-wrap input {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 7px 13px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--surface-subtle);
  border-color: var(--ink);
}

.btn-ghost-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(158, 42, 43, 0.35);
  border-radius: 9px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-ghost-danger:hover {
  background: rgba(158, 42, 43, 0.08);
}

.studio-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

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

.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink-muted);
  border-radius: 999px;
  padding: 6px 13px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.anchor-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  border: 1px solid rgba(29, 59, 50, 0.28);
  color: var(--accent);
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.anchor-pill img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
}

.anchor-pill button {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.model-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.model-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.model-bar select {
  padding: 7px 11px;
  font-size: 12.5px;
}

.model-note-input {
  flex: 1 1 240px;
  padding: 7px 12px !important;
  font-size: 12.5px !important;
}

/* ==================== BANNERS ==================== */
.generating-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(29, 59, 50, 0.25);
  color: var(--accent);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
}

.generating-banner span {
  display: block;
  font-size: 13px;
  opacity: 0.85;
  margin-top: 2px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(29, 59, 50, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-banner {
  background: #fdecec;
  border: 1px solid #f5c2c2;
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 14px;
}

/* ==================== OUTFIT LOOKBOOK GRID ==================== */
.outfit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
  gap: 24px;
}

@media (max-width: 640px) {
  .outfit-grid {
    grid-template-columns: 1fr;
  }
}

.outfit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

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

/* Studio Flat-Lay & Full-Body Model Stage */
.stage-wrapper {
  position: relative;
  border-bottom: 1px solid var(--border);
  background: radial-gradient(circle at 50% 35%, var(--mat-top) 0%, var(--mat-bottom) 100%);
}

.stage-mode-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 8;
  display: inline-flex;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.stage-mode-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.stage-mode-btn:hover {
  color: var(--ink);
}

.stage-mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.stage-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 450px;
}

@media (max-width: 560px) {
  .stage-split {
    grid-template-columns: 1fr;
  }
}

.flatlay-stage {
  background: transparent;
  padding: 46px 18px 18px;
  min-height: 450px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  position: relative;
}

.stage-split .flatlay-stage {
  border-right: 1px solid var(--border);
  padding: 46px 10px 14px;
}

.stage-split .flatlay-piece img {
  max-height: 138px;
}

.stage-split .flatlay-row.ground-row .flatlay-piece img {
  max-height: 66px;
}

.model-stage {
  position: relative;
  min-height: 450px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eae6de;
  overflow: hidden;
}

.model-stage img.model-photo {
  width: 100%;
  height: 560px;
  object-fit: contain;
  background: #edeae3;
  display: block;
  cursor: zoom-in;
}

.stage-split .model-stage img.model-photo {
  height: 450px;
  object-fit: cover;
  object-position: center top;
}

.model-placeholder {
  padding: 52px 24px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 310px;
}

.model-placeholder p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.48;
}

.model-rendering-overlay {
  position: absolute;
  inset: 0;
  background: rgba(246, 244, 239, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  z-index: 6;
}

.model-rendering-overlay strong {
  color: var(--accent);
  font-size: 14px;
}

.model-rendering-overlay span {
  font-size: 12px;
  color: var(--ink-muted);
  max-width: 280px;
}

.model-stage-actions {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  gap: 6px;
}

.model-pill-btn {
  border: 1px solid rgba(25, 24, 22, 0.2);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.model-pill-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.stale-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.btn-tryon {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}

.btn-tryon:hover {
  background: var(--accent-hover);
  color: #fff;
  border-color: var(--accent-hover);
}

/* Gemini Key Modal & Lightbox */
.key-modal-card {
  max-width: 520px;
  padding: 26px;
}

.modal-serif-title {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 28px;
  font-weight: 400;
}

.modal-desc {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}

.modal-desc a {
  color: var(--accent);
  font-weight: 600;
}

.key-status-box {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  background: var(--surface-subtle);
  color: var(--ink-muted);
}

.key-status-box.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.lightbox-modal-card {
  max-width: 960px;
  padding: 22px;
}

.lightbox-body {
  display: grid;
  grid-template-columns: minmax(320px, 470px) 1fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 760px) {
  .lightbox-body {
    grid-template-columns: 1fr;
  }
}

.lightbox-photo {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: #edeae3;
}

.lightbox-refs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.lightbox-ref-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
}

.lightbox-ref-card img {
  height: 92px;
  max-width: 100%;
  object-fit: contain;
}

.lightbox-ref-card span {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  color: var(--ink);
  font-weight: 500;
}

.flatlay-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.flatlay-row.upper-row {
  min-height: 170px;
}

.flatlay-row.lower-row {
  min-height: 145px;
}

.flatlay-row.ground-row {
  min-height: 78px;
}

.flatlay-piece {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 14px;
  padding: 6px;
  transition: transform 0.18s ease, background 0.18s ease;
  flex: 1 1 0;
  max-width: 220px;
}

.flatlay-row.upper-row.single .flatlay-piece {
  max-width: 240px;
}

.flatlay-row.lower-row .flatlay-piece {
  max-width: 225px;
}

.flatlay-row.ground-row .flatlay-piece {
  max-width: 175px;
}

.flatlay-piece:hover {
  transform: translateY(-3px) scale(1.02);
  background: rgba(255, 255, 255, 0.55);
}

.flatlay-piece img {
  max-width: 100%;
  max-height: 168px;
  object-fit: contain;
  filter: drop-shadow(0 12px 16px rgba(25, 24, 22, 0.16));
  user-select: none;
}

.flatlay-row.lower-row .flatlay-piece img {
  max-height: 158px;
}

.flatlay-row.ground-row .flatlay-piece img {
  max-height: 82px;
}

.flatlay-row.ground-row .flatlay-piece.acc-piece {
  max-width: 96px;
}

.flatlay-row.ground-row .flatlay-piece.acc-piece img {
  max-height: 62px;
}

.add-acc-chip {
  border-style: dashed !important;
  color: var(--accent) !important;
  font-weight: 500;
}

.piece-slot-tag {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(25, 24, 22, 0.82);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.flatlay-piece:hover .piece-slot-tag {
  opacity: 1;
}

/* Outfit Card Body */
.outfit-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

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

.outfit-title {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 26px;
  font-weight: 400;
  line-height: 1.1;
}

.palette-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-top: 4px;
  flex-shrink: 0;
}

.color-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.16);
}

.outfit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-pill {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
  background: var(--surface-subtle);
  padding: 4px 10px;
  border-radius: 999px;
}

.outfit-rationale {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
}

.outfit-tip {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 8px 12px;
  border-radius: 10px;
}

.piece-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}

.legend-chip {
  font-size: 11.5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 9px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: border-color 0.14s ease;
}

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

.legend-chip span {
  color: var(--ink-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.outfit-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.outfit-actions-left,
.outfit-actions-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-heart.saved {
  background: #fdf0ee;
  border-color: #d97067;
  color: #a93226;
}

/* ==================== CLOSET TAB ==================== */
.closet-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.closet-toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-add-header {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 999px;
}

/* Google Auth Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: radial-gradient(circle at top, #fbf9f5 0%, var(--bg) 65%);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 30px 28px;
  width: 100%;
  max-width: 410px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(25, 24, 22, 0.08);
}

.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: block;
  margin: 0 auto 14px;
  box-shadow: 0 6px 18px rgba(29, 59, 50, 0.18);
}

.auth-domain {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  font-weight: 600;
}

.auth-title {
  margin: 0;
  font-size: 32px;
}

.auth-sub {
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}

.btn-google {
  margin-top: 24px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: #1f1f1f;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.btn-google:hover {
  background: #faf9f6;
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(25, 24, 22, 0.08);
}

.btn-google:active {
  transform: translateY(1px);
}

.btn-google.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.google-g-icon {
  flex-shrink: 0;
}

.oauth-setup-box {
  margin-top: 16px;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.45;
}

.oauth-setup-box strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
  font-size: 12.5px;
}

.oauth-setup-box p {
  margin: 0 0 8px;
}

.oauth-uri-code {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
}

.auth-footnote {
  margin: 20px 0 0;
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.45;
}

/* Upload Modal */
.upload-modal-card {
  max-width: 540px;
  padding: 26px;
}

.upload-dropzone {
  margin-top: 16px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  min-height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 18px;
  transition: border-color 0.16s ease, background 0.16s ease;
  text-align: center;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
}

.upload-empty strong {
  color: var(--ink);
  font-size: 14px;
}

.upload-empty span {
  font-size: 12px;
  max-width: 300px;
}

.upload-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 24px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.upload-preview {
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 10px;
}

.upload-checks {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink);
}

.upload-checks label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.closet-search {
  flex: 1 1 300px;
}

.view-toggle {
  display: inline-flex;
  background: var(--surface-subtle);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.toggle-btn {
  border: none;
  background: transparent;
  padding: 7px 13px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
}

.toggle-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

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

.closet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 16px;
}

.garment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  position: relative;
}

.garment-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.garment-card.in-laundry {
  opacity: 0.52;
}

.garment-thumb {
  height: 215px;
  background: linear-gradient(180deg, var(--mat-top), var(--mat-bottom));
  display: grid;
  place-items: center;
  padding: 14px;
  position: relative;
}

.garment-thumb.reoriented-mode {
  padding: 0;
  background: #e9e6df;
}

.garment-thumb img {
  max-width: 100%;
  max-height: 185px;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.12));
}

.garment-thumb.reoriented-mode img {
  width: 100%;
  height: 100%;
  max-height: 215px;
  object-fit: cover;
  filter: none;
}

.quick-rotate {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s ease, background 0.14s ease;
}

.garment-card:hover .quick-rotate {
  opacity: 1;
}

.quick-rotate:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.garment-info {
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.garment-slot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.slot-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.swatches {
  display: flex;
  gap: 3px;
}

.swatch-xs {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.16);
}

.garment-name {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
}

.garment-sub {
  font-size: 12px;
  color: var(--ink-muted);
}

/* ==================== MODALS ==================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 19, 17, 0.5);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.item-modal-card {
  max-width: 820px;
  padding: 26px;
}

.swap-modal-card {
  max-width: 780px;
  padding: 24px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.item-modal-grid {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 24px;
}

@media (max-width: 720px) {
  .item-modal-grid {
    grid-template-columns: 1fr;
  }
}

.inspector-preview {
  background: radial-gradient(circle, var(--mat-top), var(--mat-bottom));
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  min-height: 320px;
  display: grid;
  place-items: center;
  padding: 18px;
}

.inspector-preview img {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.16));
}

.inspector-rot-bar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}

.inspector-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 11px;
  font-size: 13px;
}

.inspector-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* Swap Modal */
.swap-header h3 {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 26px;
  font-weight: 400;
}

.swap-header p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.swap-controls {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}

.swap-controls input {
  flex: 1;
}

.swap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 4px;
}

.swap-candidate {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: all 0.14s ease;
}

.swap-candidate:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.swap-candidate.current {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
}

.swap-candidate img {
  height: 110px;
  max-width: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
}

.swap-candidate .cand-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
}

/* Saved empty state */
.saved-header {
  margin-bottom: 18px;
}

.saved-header h2 {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 30px;
  font-weight: 400;
}

.saved-header p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 11px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.balance-pill {
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.balance-pill:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.balance-pill.funded {
  border-color: #b7d7c9;
  background: #f0f8f4;
  color: var(--accent);
}

.balance-pill.funded .status-dot {
  background: #2e8b57;
}

.balance-pill.empty {
  border-color: #e5c3b8;
  background: #fdf4f1;
  color: #8f3123;
}

.balance-pill.empty .status-dot {
  background: #c2410c;
}

/* Admin Users & Balance Modals */
.admin-modal-card {
  max-width: 780px;
  padding: 26px;
}

.admin-precredit-box {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.admin-precredit-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.admin-precredit-row input {
  flex: 1 1 150px;
  padding: 8px 10px;
  font-size: 13px;
}

.admin-section {
  margin-top: 18px;
}

.admin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.admin-section-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.admin-users-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

.admin-user-row {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-user-info {
  min-width: 200px;
  flex: 1;
}

.admin-user-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.admin-user-email {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.admin-user-meta {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 4px;
}

.role-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-badge.admin {
  background: var(--accent-soft);
  color: var(--accent);
}

.role-badge.pending {
  background: #f3ede0;
  color: #7c5c1f;
}

.admin-user-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bal-amount {
  font-size: 15px;
  font-weight: 600;
  min-width: 62px;
  text-align: right;
  margin-right: 4px;
}

.bal-amount.zero {
  color: #9e2a2b;
}

.bal-amount.positive {
  color: var(--accent);
}

.btn-topup {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-topup:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.custom-bal-input {
  width: 72px;
  padding: 5px 7px;
  font-size: 12px;
}

.balance-hero {
  margin-top: 14px;
  padding: 18px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  text-align: center;
}

.balance-hero.empty {
  background: #fdf6f3;
  border-color: #ead0c6;
}

.balance-hero-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.balance-hero-value {
  display: block;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 42px;
  font-weight: 400;
  line-height: 1.1;
  margin: 4px 0 6px;
  color: var(--ink);
}

.balance-hero-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.45;
}

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.tx-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}

.tx-delta.pos {
  color: #1f6f4a;
  font-weight: 600;
}

.tx-delta.neg {
  color: #9e2a2b;
  font-weight: 600;
}

.saved-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Custom Outfit Builder Modal */
.builder-modal-card {
  max-width: 980px;
  padding: 24px;
}

.builder-layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 20px;
  margin-top: 16px;
  align-items: start;
}

.builder-preview-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.builder-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.builder-slot-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.builder-slot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.builder-slot-row:hover {
  border-color: var(--border-strong);
}

.builder-slot-row.active-slot {
  border-color: var(--accent);
  background: #f5f9f7;
}

.builder-slot-thumb {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--surface-subtle);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 16px;
  color: var(--ink-muted);
}

.builder-slot-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.builder-slot-info {
  flex: 1;
  min-width: 0;
}

.builder-slot-kicker {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.builder-slot-val {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.builder-slot-val.placeholder {
  color: var(--ink-muted);
  font-weight: 400;
}

.builder-slot-clear {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.builder-slot-clear:hover {
  background: #f8e5e5;
  color: var(--danger);
}

.builder-acc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.builder-acc-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
}

.builder-acc-chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
}

.builder-live-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.builder-actions,
.builder-actions-sub {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.builder-picker-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.builder-picker-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.builder-slot-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.builder-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 10px;
  max-height: 54vh;
  overflow-y: auto;
  padding-right: 4px;
}

.builder-cand {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.12s ease;
}

.builder-cand:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.builder-cand.selected {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
}

.builder-cand-check {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.builder-cand img {
  height: 98px;
  max-width: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto 7px;
}

.builder-cand-name {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink);
}

.builder-cand-meta {
  font-size: 10.5px;
  color: var(--ink-muted);
  margin-top: 2px;
}

@media (max-width: 820px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }
  .builder-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 44vh;
  }
}

/* Mobile-First Responsive Overrides (kept last so they take precedence) */
@media (max-width: 720px) {
  .topbar-inner {
    padding: 10px 14px;
    gap: 10px;
  }
  .brand h1 {
    font-size: 21px;
  }
  .brand-sub {
    display: none;
  }
  .tabs {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
  .tab {
    flex: 1;
    justify-content: center;
    padding: 8px 8px;
    font-size: 12.5px;
  }
  .key-pill {
    padding: 6px 10px;
    font-size: 11px;
  }
  .user-name {
    display: none;
  }
  .btn-signout {
    padding: 4px 8px;
    font-size: 11px;
  }
  .auth-card {
    padding: 28px 20px 22px;
  }
  .container {
    padding: 14px 14px 48px;
  }
  .studio-bar {
    padding: 14px;
    border-radius: var(--radius-md);
  }
  .prompt-row select,
  .prompt-row .btn-primary {
    flex: 1 1 110px;
  }
  .model-bar select {
    flex: 1 1 140px;
  }
  .closet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .garment-thumb {
    height: 165px;
    padding: 10px;
  }
  .garment-thumb img {
    max-height: 145px;
  }
  .garment-info {
    padding: 9px 10px;
  }
  .garment-name {
    font-size: 12.5px;
  }
  .garment-sub {
    font-size: 11px;
  }
  .modal {
    padding: 10px;
  }
  .item-modal-card,
  .swap-modal-card,
  .upload-modal-card,
  .key-modal-card {
    padding: 18px;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .swap-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
