:root {
  /* "Studio" — clean iOS-native light theme: cool white, ink-navy accent, soft cards. */
  --ink: #1b1c22;
  --muted: #6b7280;   /* darkened from #8b8e9a to meet WCAG AA contrast on white */
  --paper: #f7f8fb;
  --white: #ffffff;
  --line: #e8eaf1;
  --surface-soft: #f1f3f8;
  --accent: #26364f;
  --accent-soft: #eaedf4;
  --accent-text: #2c3e5c;
  --on-accent: #ffffff;
  --sage: var(--accent);
  --sage-dark: #1b1c22;
  --sand: #cdd4e2;
  --clay: #26364f;
  --shadow: 0 12px 30px rgba(30, 40, 70, 0.09);
  --cream: #f1f3f8;
  --text: var(--ink);
  --border: var(--line);
  --app-radius: 18px;
}

html[data-theme="dark"] {
  /* "Studio" dark: cool charcoal, soft blue accent. */
  --ink: #eef0f4;
  --muted: #9298a6;
  --paper: #14161b;
  --white: #1e2129;
  --line: #2c303b;
  --surface-soft: #191c23;
  --accent: #8fa6da;
  --accent-soft: #242c3b;
  --accent-text: #aabce4;
  --on-accent: #12141a;
  --sage: var(--accent);
  --sage-dark: var(--accent);
  --sand: #3a4254;
  --clay: #8fa6da;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  --cream: #1e2129;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
  /* "Damascus" (Apple system Arabic) is the chosen face; web fallbacks keep the
     look reasonable on Android/Windows where Damascus isn't installed. */
  font-family: "Damascus", "Geeza Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .65; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(38,54,79,.35);
  outline-offset: 3px;
}

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 20;
  width: 250px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  background: #1c1e24;
  color: #e6e8ee;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.35);
  font: 600 23px "Playfair Display", serif;
}
.brand strong { display: block; letter-spacing: 2px; }
.brand small, .profile-chip small { display: block; margin-top: 2px; color: #a6abbb; font-size: 10px; }
.main-nav { display: grid; gap: 7px; margin-top: 54px; }
.nav-item {
  width: 100%;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 9px;
  color: #b6bccb;
  background: transparent;
  text-align: right;
  transition: .2s ease;
}
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.09); }
.nav-item.active { box-shadow: inset -3px 0 var(--accent); }
.nav-icon { width: 22px; font-size: 19px; text-align: center; }
.sidebar-card {
  margin-top: auto;
  padding: 17px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
}
.sidebar-card .eyebrow { color: #a6abbb; }
.usage-row { margin: 10px 0 8px; display: flex; align-items: baseline; justify-content: space-between; }
.usage-row strong { font-size: 25px; }
.usage-row span { color: #a6abbb; font-size: 11px; }
.progress { height: 4px; overflow: hidden; border-radius: 4px; background: rgba(255,255,255,.13); }
.progress span { height: 100%; display: block; border-radius: inherit; background: var(--accent); }
.sidebar-card .text-button { margin-top: 10px; color: #b7c6ea; }
.profile-chip {
  margin-top: 14px;
  padding: 10px 4px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  border: 0;
  color: white;
  background: transparent;
  text-align: right;
}
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.13); }
.chevron { color: #8b909e; font-size: 22px; }

.main-content { margin-right: 250px; min-height: 100vh; }
.topbar {
  height: 76px;
  padding: 0 4.5vw;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.topbar-actions { display: flex; gap: 8px; }
.icon-button, .mobile-menu {
  width: 44px; height: 44px; flex: 0 0 44px; box-sizing: border-box; position: relative; border: 1px solid var(--line); border-radius: 50%; background: var(--white); color: var(--ink);
}
.icon-button i { width: 6px; height: 6px; position: absolute; top: 10px; right: 10px; border-radius: 50%; background: var(--clay); }
.weather { margin-right: auto; display: flex; align-items: center; gap: 10px; }
.weather-icon { color: var(--accent); font-size: 25px; }
.weather strong, .weather small { display: block; }
.weather small { color: var(--muted); font-size: 11px; }
.mobile-menu { display: none; }
.sidebar-backdrop { display: none; }

.page { display: none; padding: 44px 4.5vw 70px; animation: pageIn .35s ease; }
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(7px); } }
.page-intro, .section-heading {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px;
}
.eyebrow { display: block; margin-bottom: 6px; color: var(--sage); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(29px, 3.2vw, 43px); line-height: 1.25; }
h2 { margin-bottom: 6px; font-size: 22px; }
h3 { margin-bottom: 7px; font-size: 17px; }
p { color: var(--muted); line-height: 1.8; }
.page-intro p { margin-bottom: 0; }
.wardrobe-add-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.primary-button, .secondary-button, .square-button {
  min-height: 44px;
  padding: 0 19px;
  border-radius: 8px;
  font-weight: 600;
  transition: .2s ease;
}
.primary-button { border: 1px solid var(--accent); color: var(--on-accent); background: var(--accent); box-shadow: 0 8px 18px rgba(38,54,79,.18); }
.primary-button:hover { transform: translateY(-1px); opacity: .9; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: var(--white); }
.secondary-button:hover, .square-button:hover { border-color: var(--sage); }
.square-button { width: 45px; padding: 0; border: 1px solid var(--line); background: var(--white); font-size: 20px; }
.text-button { padding: 0; border: 0; color: var(--sage-dark); background: none; font-weight: 600; font-size: 12px; }
.full { width: 100%; }

.home-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, .75fr); gap: 22px; }
.today-card, .event-card, .insight-card, .chart-card {
  border: 1px solid var(--line); border-radius: 15px; background: var(--white); box-shadow: var(--shadow);
}
.today-card { padding: 27px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.match-pill { padding: 6px 10px; border-radius: 20px; color: var(--accent-text); background: var(--accent-soft); font-size: 11px; font-weight: 700; }
.outfit-stage {
  min-height: 290px;
  padding: 22px 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  gap: 15px;
}
.garment {
  position: relative;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  animation: itemIn .5s ease both;
}
.garment:nth-child(2) { animation-delay: .07s; }
.garment:nth-child(3) { animation-delay: .14s; }
@keyframes itemIn { from { opacity: 0; transform: translateY(15px); } }
.garment-art { width: 125px; height: 160px; position: relative; filter: drop-shadow(0 16px 13px rgba(0,0,0,.09)); }
.garment-art.shirt { clip-path: polygon(22% 10%, 39% 0, 61% 0, 78% 10%, 100% 30%, 84% 45%, 73% 34%, 73% 100%, 27% 100%, 27% 34%, 16% 45%, 0 30%); background: var(--item-color); }
.garment-art.pants { clip-path: polygon(15% 0, 85% 0, 82% 47%, 96% 100%, 56% 100%, 50% 49%, 44% 100%, 4% 100%, 18% 47%); background: var(--item-color); }
.garment-art.shoes { width: 150px; height: 90px; clip-path: polygon(5% 50%, 33% 42%, 45% 10%, 58% 15%, 66% 45%, 91% 55%, 100% 81%, 94% 94%, 11% 92%, 0 72%); background: var(--item-color); }
.garment-art.jacket { clip-path: polygon(23% 8%, 40% 0, 50% 7%, 60% 0, 77% 8%, 100% 29%, 84% 44%, 73% 35%, 76% 100%, 24% 100%, 27% 35%, 16% 44%, 0 29%); background: var(--item-color); }
.garment-art.dress { clip-path: polygon(30% 6%, 42% 0, 58% 0, 70% 6%, 62% 26%, 90% 100%, 10% 100%, 38% 26%); background: var(--item-color); }
.garment-art.accessory { clip-path: polygon(20% 20%, 80% 20%, 80% 80%, 20% 80%); background: var(--item-color); }
.garment small { color: var(--muted); }
.outfit-item-photo { width: 100%; max-width: 135px; height: 160px; display: block; object-fit: contain; border-radius: 10px; background: rgba(255,255,255,.52); box-shadow: 0 12px 25px rgba(0,0,0,.08); }
.outfit-reason { padding: 13px 15px; display: flex; gap: 10px; border-radius: 9px; background: var(--surface-soft); }
.outfit-reason p { margin: 0; font-size: 12px; line-height: 1.7; }
.score-breakdown { margin-top: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.score-factor { padding: 9px 10px; border: 1px solid rgba(38,54,79,.18); border-radius: 8px; background: rgba(255,255,255,.5); }
.score-factor span, .score-factor b { display: block; }
.score-factor span { color: var(--muted); font-size: 9px; }
.score-factor b { margin-top: 2px; color: var(--sage-dark); font-size: 13px; }
.spark { color: var(--sage); }
.card-actions { margin-top: 18px; display: flex; gap: 9px; }
.side-stack { display: grid; gap: 22px; }
.event-card, .insight-card { padding: 22px; }
.date-badge { width: 52px; height: 56px; display: grid; place-content: center; border-radius: 9px; color: var(--sage-dark); background: var(--accent-soft); text-align: center; font-size: 10px; }
.date-badge b { display: block; font-size: 19px; line-height: 1.1; }
.event-card > p { margin: 16px 0; font-size: 12px; }
.event-weather { margin-bottom: 18px; display: flex; gap: 7px; }
.event-weather span { padding: 5px 8px; border-radius: 5px; color: var(--muted); background: var(--paper); font-size: 11px; }
.insight-card { color: var(--on-accent); background: var(--sage-dark); }
.insight-card .eyebrow, .insight-card p { color: var(--on-accent); opacity: .72; }
.insight-card .text-button { color: var(--on-accent); opacity: .88; }
.insight-number { margin-top: 9px; font-size: 43px; font-weight: 700; }
.recent-section { margin-top: 46px; }
.looks-row, .saved-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.look-card { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--white); transition: .22s ease; }
.look-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.look-preview { height: 180px; padding: 24px; display: flex; align-items: flex-end; justify-content: center; gap: 8px; background: var(--surface-soft); }
.look-preview i { width: 45px; height: 110px; display: block; border-radius: 5px 5px 12px 12px; background: var(--c); box-shadow: 0 10px 18px rgba(0,0,0,.08); }
.look-preview i:last-child { height: 40px; border-radius: 50% 50% 15px 15px; }
.look-preview img { width: 72px; height: 100%; object-fit: cover; border-radius: 10px; box-shadow: 0 10px 18px rgba(0,0,0,.10); background: var(--white); }
.look-info { padding: 14px 16px; }
.look-info h3 { margin-bottom: 2px; font-size: 14px; }
.look-info span { color: var(--muted); font-size: 11px; }
.saved-look-items { min-height: 32px; margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.saved-look-actions { margin-top: 11px; display: flex; gap: 6px; }
.saved-look-actions button { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--sage-dark); background: var(--white); font-size: 10px; font-weight: 700; }
.saved-look-actions .remove-saved-outfit { color: var(--muted); }
.saved-look-actions .wear-saved-outfit { color: var(--accent-text); background: var(--accent-soft); }
.saved-look-actions button:hover { border-color: var(--sage); background: var(--paper); }

.toolbar { margin-bottom: 25px; display: flex; gap: 14px; justify-content: space-between; }
.search-box { min-width: 280px; padding: 0 13px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.search-box input { width: 100%; padding: 12px 0; border: 0; outline: none; background: transparent; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filter { padding: 9px 15px; border: 1px solid var(--line); border-radius: 20px; color: var(--muted); background: var(--white); }
.filter.active { color: white; border-color: var(--sage-dark); background: var(--sage-dark); }
.wardrobe-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.item-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.item-visual { height: 220px; position: relative; display: grid; place-items: center; background: var(--surface-soft); }
.item-visual .garment-art { transform: scale(.8); }
.item-photo { width: 100%; height: 100%; object-fit: cover; }
.item-number { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.88); font-size: 10px; font-weight: 700; }
.item-status { position: absolute; top: 12px; left: 12px; padding: 4px 7px; border-radius: 10px; color: var(--accent-text); background: var(--accent-soft); font-size: 9px; }
.item-state { position: absolute; right: 12px; bottom: 42px; padding: 5px 8px; border-radius: 10px; color: white; background: rgba(38,54,79,.82); font-size: 9px; }
.item-meta { padding: 13px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item-meta h3 { margin-bottom: 2px; font-size: 14px; }
.item-meta span { color: var(--muted); font-size: 10px; }
.delete-item {
  min-width: 58px;
  height: 32px;
  padding: 0 10px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--white);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.delete-item:hover { border-color: var(--sage); background: var(--surface-soft); }
.item-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.edit-item, .status-item { height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--sage-dark); background: var(--white); font-size: 10px; font-weight: 700; }
.edit-item:hover, .status-item:hover { border-color: var(--sage); }
.item-condition-select { width: auto; max-width: 118px; height: 32px; margin: 0; padding: 0 7px; font-size: 9px; font-weight: 700; }
.exclude-item { height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: var(--surface-soft); font-size: 10px; font-weight: 700; }

.stylist-layout { min-height: calc(100vh - 190px); display: grid; grid-template-columns: minmax(330px, .85fr) minmax(460px, 1.15fr); gap: 45px; align-items: center; }
.stylist-copy { max-width: 540px; }
.stylist-copy > p { max-width: 470px; }
.stylist-selection-summary { margin-top: 18px; display: grid; gap: 8px; }
.stylist-selection-summary[hidden] { display: none; }
.anchor-item-button { width: 100%; margin-top: 18px; padding: 13px 15px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--sage-dark); background: var(--surface-soft); text-align: right; }
.anchor-item-button > span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; color: white; background: var(--sage-dark); font-size: 17px; }
.anchor-item-button div { flex: 1; }
.anchor-item-button strong, .anchor-item-button small { display: block; }
.anchor-item-button strong { font-size: 13px; }
.anchor-item-button small { margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 500; }
.anchor-item-button > b { font-size: 18px; }
.anchor-item-button:hover { border-color: var(--sage-dark); background: #eef0f6; }
.stylist-context-tools { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stylist-context-card { min-width: 0; padding: 11px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.stylist-context-card .context-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--sage-dark); background: var(--accent-soft); font-weight: 700; }
.stylist-context-card strong, .stylist-context-card small { display: block; }
.stylist-context-card strong { font-size: 10px; }
.stylist-context-card small { margin-top: 2px; color: var(--muted); font-size: 8px; line-height: 1.45; }
.stylist-context-card > button { min-height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--sage-dark); background: var(--white); font-size: 9px; font-weight: 700; }
.fashion-source-links { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.fashion-source-links a { color: var(--sage-dark); font-size: 8px; text-decoration: underline; }
.pinned-item-banner { padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--accent-soft); }
.pinned-item-banner[hidden] { display: none; }
.excluded-banner { border-color: var(--line); background: var(--surface-soft); }
.excluded-banner strong { color: var(--muted); }
.pinned-item-banner span, .pinned-item-banner strong { display: block; }
.pinned-item-banner span { color: var(--muted); font-size: 9px; }
.pinned-item-banner strong { margin-top: 2px; color: var(--sage-dark); font-size: 12px; }
.pinned-item-banner button, .coordinate-item { min-height: 32px; padding: 0 10px; border: 1px solid var(--sage); border-radius: 7px; color: var(--sage-dark); background: var(--white); font-size: 10px; font-weight: 700; }
.coordinate-item { border-color: var(--sage-dark); color: white; background: var(--sage-dark); }
.coordinate-item:hover { background: #2a3446; }
.form-block { margin-top: 28px; }
.form-block > label, .refine-label, .form-row label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.occasion-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.occasion { min-height: 72px; display: grid; place-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--white); }
.occasion span { font-size: 20px; }
.occasion.active { color: var(--sage-dark); border-color: var(--sage); background: var(--surface-soft); }
.form-row { margin-top: 17px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select, input, textarea { width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; color: var(--ink); background: var(--white); }
select:focus, input:focus, textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(38,54,79,.1); }
.refine-label { margin-top: 17px; }
.refine-label span { color: var(--muted); font-weight: 400; }
.brand-field { margin-top: 17px; display: block; font-size: 12px; font-weight: 700; }
.metadata-details { margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.metadata-details summary { cursor: pointer; color: var(--sage-dark); font-size: 12px; font-weight: 700; }
.metadata-details[open] summary { margin-bottom: 8px; }
textarea { min-height: 78px; resize: vertical; }
.generate-button { width: 100%; margin-top: 12px; }
.generation-panel { min-height: 580px; padding: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-soft); }
.empty-generation { max-width: 310px; text-align: center; }
.orb { width: 100px; height: 100px; margin: 0 auto 22px; display: grid; place-items: center; border: 1px solid rgba(38,54,79,.2); border-radius: 50%; color: var(--sage-dark); background: rgba(255,255,255,.45); font-size: 30px; box-shadow: 0 15px 50px rgba(30,40,70,.1); }
.generated-result { width: 100%; }
.generated-result .outfit-stage { min-height: 310px; }
.generated-result .outfit-stage:has(.garment:nth-child(4)) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.result-top { display: flex; justify-content: space-between; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.loading-orb { animation: breathe 1s ease infinite alternate; }
@keyframes breathe { to { transform: scale(1.12); opacity: .55; } }
.stylist-chat-card { margin-top: 28px; padding: 26px; border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: 0 18px 45px rgba(30,40,70,.06); }
.chat-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.chat-heading h2 { margin: 4px 0 6px; }
.chat-heading p { max-width: 650px; margin: 0; }
.chat-status { padding: 7px 11px; display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; border-radius: 999px; color: var(--accent-text); background: var(--accent-soft); font-size: 10px; font-weight: 700; }
.chat-status i { width: 7px; height: 7px; border-radius: 50%; background: #3f7a45; box-shadow: 0 0 0 3px rgba(63,122,69,.14); }
.chat-messages { max-height: 430px; min-height: 190px; margin-top: 22px; padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); scroll-behavior: smooth; }
.chat-message { max-width: min(78%, 680px); display: flex; align-items: flex-start; gap: 10px; }
.chat-message > div { padding: 11px 14px; border: 1px solid var(--line); border-radius: 14px 4px 14px 14px; background: var(--white); }
.chat-message.user { margin-right: auto; flex-direction: row-reverse; }
.chat-message.user > div { color: white; border-color: var(--sage-dark); border-radius: 4px 14px 14px 14px; background: var(--sage-dark); }
.chat-message small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 9px; font-weight: 700; }
.chat-message.user small { color: rgba(255,255,255,.7); }
.chat-message p { margin: 0; color: inherit; font-size: 13px; line-height: 1.75; white-space: pre-wrap; }
.chat-avatar { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: white; background: var(--sage-dark); font: 700 13px "Playfair Display", serif; }
.chat-message.user .chat-avatar { color: var(--sage-dark); background: var(--sand); }
.chat-message.thinking p::after { content: "..."; display: inline-block; width: 18px; overflow: hidden; vertical-align: bottom; animation: typing-dots 1.1s steps(4, end) infinite; }
@keyframes typing-dots { from { width: 0; } }
.chat-suggestions { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 7px; }
.chat-suggestions button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--sage-dark); background: var(--surface-soft); font-size: 10px; font-weight: 700; }
.chat-suggestions button:hover { border-color: var(--sage); background: var(--surface-soft); }
.chat-composer { margin-top: 12px; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 9px; }
.chat-composer textarea { min-height: 54px; max-height: 150px; margin: 0; }
.chat-composer .primary-button { min-width: 105px; min-height: 54px; }
.sr-only { width: 1px; height: 1px; position: absolute; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.saved-grid { grid-template-columns: repeat(4, 1fr); }
.saved-grid .look-preview { height: 235px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.stats-grid article { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.stats-grid span, .stats-grid small { display: block; color: var(--muted); font-size: 11px; }
.stats-grid strong { display: block; margin: 8px 0 5px; font-size: 31px; }
.positive { color: #3f7a45 !important; }
.warning { color: #9a7d2e !important; }
.analytics-grid { margin-top: 18px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.analytics-intelligence-grid { margin-top: 18px; display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
.chart-card { padding: 24px; }
.bar-chart { height: 245px; padding-top: 30px; display: flex; align-items: flex-end; justify-content: space-around; border-bottom: 1px solid var(--line); }
.bar { width: 8%; position: relative; border-radius: 5px 5px 0 0; background: var(--sage); }
.bar span { position: absolute; bottom: -27px; right: 50%; transform: translateX(50%); color: var(--muted); font-size: 10px; }
.donut-wrap { min-height: 240px; display: flex; align-items: center; justify-content: space-around; gap: 20px; }
.donut { width: 150px; height: 150px; position: relative; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--sand) 0 33.33%, var(--sage-dark) 33.33% 66.66%, #5b6b8a 66.66% 91.66%, var(--clay) 91.66%); }
.donut::before { content: ""; width: 92px; height: 92px; position: absolute; border-radius: 50%; background: var(--white); }
.donut span { z-index: 1; font-size: 26px; font-weight: 700; text-align: center; }
.donut small { display: block; color: var(--muted); font-size: 9px; font-weight: 400; }
.legend { display: grid; gap: 12px; }
.legend span { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; }
.legend b { color: var(--ink); }
.sand { background: var(--sand); }.dark { background: var(--sage-dark); }.sage { background: #5b6b8a; }.clay { background: var(--clay); }
.gap-list, .memory-summary { margin-top: 18px; display: grid; gap: 9px; }
.gap-item, .memory-item { padding: 12px 13px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.gap-item strong, .gap-item span, .memory-item strong, .memory-item span { display: block; }
.gap-item span, .memory-item span { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.gap-item b { min-width: 58px; padding: 6px 8px; border-radius: 999px; color: var(--accent-text); background: var(--accent-soft); text-align: center; font-size: 10px; }
.memory-item { grid-template-columns: auto 1fr; }
.memory-item i { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--sage-dark); background: var(--accent-soft); font-style: normal; font-weight: 700; }

dialog { width: min(560px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 15px; background: var(--white); box-shadow: 0 25px 80px rgba(0,0,0,.22); }
dialog::backdrop { background: rgba(18,20,28,.62); backdrop-filter: blur(3px); }
dialog form { padding: 25px; }
.modal-heading { display: flex; justify-content: space-between; }
.close-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--paper); font-size: 23px; }
.upload-zone { min-height: 190px; position: relative; overflow: hidden; display: grid; place-items: center; align-content: center; gap: 4px; border: 1px dashed #c3c7d4; border-radius: 10px; background: var(--surface-soft); cursor: pointer; }
.upload-zone:hover { border-color: var(--sage); background: #eef0f6; }
.upload-zone input { width: 1px; height: 1px; position: absolute; opacity: 0; pointer-events: none; }
.upload-placeholder { display: grid; place-items: center; gap: 5px; text-align: center; }
.upload-placeholder > span:last-child { color: var(--muted); font-size: 10px; }
.upload-icon { color: var(--sage); font-size: 32px; }
.upload-zone.has-image { min-height: 72px; border-style: solid; }
.upload-zone.has-image .upload-icon { font-size: 23px; }
.photo-gallery { margin-top: 12px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.photo-gallery[hidden] { display: none; }
.photo-thumb { min-width: 0; position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.photo-thumb:first-child { box-shadow: 0 0 0 2px var(--sage); }
.photo-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.photo-thumb small { position: absolute; right: 5px; bottom: 5px; padding: 2px 5px; border-radius: 4px; color: white; background: rgba(28,30,38,.72); font-size: 8px; }
.remove-photo { width: 25px; height: 25px; position: absolute; top: 5px; left: 5px; display: grid; place-items: center; border: 0; border-radius: 50%; color: white; background: rgba(158,68,58,.88); font-size: 15px; line-height: 1; }
.bg-remove-photo { width: 25px; height: 25px; position: absolute; top: 5px; right: 5px; z-index: 2; display: grid; place-items: center; border: 0; border-radius: 50%; color: white; background: rgba(30,34,44,.82); font-size: 13px; line-height: 1; }
.bg-remove-photo:disabled { opacity: .55; }
.photo-thumb.bg-processing::after { content: ""; position: absolute; inset: 0; z-index: 1; background: rgba(20,22,28,.45); animation: bg-pulse 1s ease-in-out infinite; }
@keyframes bg-pulse { 0%, 100% { opacity: .35; } 50% { opacity: .7; } }
.add-more-photos { margin-top: 9px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--sage-dark); background: var(--white); font-size: 11px; font-weight: 700; }
.photo-count { position: absolute; right: 12px; bottom: 12px; padding: 5px 8px; border-radius: 12px; color: white; background: rgba(28,30,38,.72); font-size: 9px; font-weight: 700; }
.analysis-status { margin-top: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 9px; border-radius: 8px; color: var(--muted); background: var(--surface-soft); font-size: 11px; }
.analysis-status.analyzing { color: #5b6270; background: var(--surface-soft); }
.analysis-status.success { color: #2f6b39; background: #e2efe0; }
.analysis-status.warning { color: #8a6d24; background: #f4eedd; }
.analysis-status.error { color: #a4483a; background: #f3e2dd; }
.analysis-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: currentColor; opacity: .75; }
.analysis-status.analyzing .analysis-dot { animation: breathe .7s ease infinite alternate; }
.bulk-help { margin: 8px 0 18px; color: var(--muted); font-size: 12px; }
.bulk-summary { margin-top: 12px; padding: 10px 12px; border-radius: 8px; color: var(--muted); background: var(--surface-soft); font-size: 11px; }
.bulk-queue { max-height: 280px; margin-top: 12px; overflow: auto; display: grid; gap: 7px; }
.bulk-queue[hidden] { display: none; }
.bulk-row { padding: 9px 10px; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.bulk-row img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.bulk-row strong, .bulk-row small { display: block; }
.bulk-row strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.bulk-row small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.bulk-row b { color: var(--sage-dark); font-size: 10px; }
.bulk-row.error b { color: #a4483a; }
.bulk-row.success b { color: var(--accent-text); }
.toast [data-undo-delete] { margin-inline-start: 10px; padding: 4px 9px; border: 1px solid rgba(255,255,255,.55); border-radius: 6px; color: white; background: transparent; font-weight: 700; }
.analysis-fields { margin-top: 15px; padding: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.analysis-fields[hidden] { display: none; }
.analysis-fields span { min-width: 0; }
.analysis-fields .analysis-wide { grid-column: span 2; }
.analysis-fields small, .analysis-fields b { display: block; }
.analysis-fields small { color: var(--muted); font-size: 9px; }
.analysis-fields b { margin-top: 2px; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.brand-field > small { margin-top: 5px; display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
.modal-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 8px; }
.danger-button { min-height: 44px; padding: 0 19px; border: 1px solid #b04537; border-radius: 8px; color: white; background: #b04537; font-weight: 700; }
.danger-button:hover { background: #963a2e; }
.confirm-dialog { max-width: 430px; text-align: center; }
.confirm-dialog p { margin-bottom: 0; }
.confirm-dialog .modal-actions { justify-content: center; }
.confirm-icon { width: 48px; height: 48px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; color: #b04537; background: #f3e2dd; font-size: 24px; font-weight: 700; }
.feedback-dialog { max-width: 520px; }
.body-profile-dialog { max-width: 620px; }
.outfit-review-dialog { max-width: 620px; }
.outfit-review-upload { min-height: 250px; }
.outfit-review-upload img { width: 100%; max-height: 430px; object-fit: contain; border-radius: 9px; }
.outfit-review-upload.has-preview { padding: 8px; border-style: solid; }
.outfit-review-upload.has-preview .upload-placeholder { display: none; }
.outfit-review-result { margin-top: 14px; padding: 15px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.outfit-review-result h3 { margin: 0 0 5px; font-size: 20px; }
.outfit-review-result > p { margin: 0 0 12px; color: var(--muted); }
.review-score-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.review-score-line b { color: var(--sage-dark); font-size: 24px; }
.review-section { margin-top: 10px; }
.review-section strong { display: block; margin-bottom: 4px; }
.review-section ul { margin: 0; padding-inline-start: 20px; color: var(--muted); }
.review-quick-fix { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-soft); }

/* Home quick actions: قيّم لوكي + تسوّق معي */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.quick-action { display: flex; align-items: center; gap: 12px; text-align: start; padding: 14px 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--white); cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; }
.quick-action:hover { border-color: var(--sage-dark); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(38,54,79,.12); }
.quick-action-icon { font-size: 26px; line-height: 1; }
.quick-action strong { display: block; font-size: 15px; }
.quick-action small { color: var(--muted); font-size: 11px; line-height: 1.5; }
@media (max-width: 600px) { .quick-actions { grid-template-columns: 1fr; } }

/* Styling mode picker */
.styling-mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.styling-mode-options label { display: flex; align-items: center; gap: 8px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 11px; cursor: pointer; }
/* The global `input { width:100% }` rule (line ~342) makes these radios full-width,
   pushing the text label outside the card. Reset them to their natural size. */
.styling-mode-options input, .styling-hijab-options input { width: auto; margin: 0; padding: 0; flex: 0 0 auto; }
.styling-mode-options label:has(input:checked) { border-color: var(--sage-dark); background: var(--accent-soft); }
.styling-hijab-row { display: flex; flex-direction: column; gap: 9px; margin-bottom: 6px; }
.styling-hijab-row[hidden] { display: none; }
.styling-hijab-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.styling-hijab-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.styling-hijab-options label { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 8px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 13px; }
.styling-hijab-options label:has(input:checked) { border-color: var(--sage-dark); background: var(--accent-soft); }
.legal-links { margin: 12px 0 0; font-size: 11px; color: var(--muted); text-align: center; line-height: 1.7; }
.legal-links a { color: var(--accent-text); }

/* Shopping verdict accent */
.shopping-verdict { padding: 11px 13px; border-radius: 10px; }
.shopping-verdict.buy { background: #e2efe0; }
.shopping-verdict.buy b { color: #3f7a45; }
.shopping-verdict.maybe { background: #f4eedd; }
.shopping-verdict.maybe b { color: #9a7d2e; }
.shopping-verdict.skip { background: #f3e2dd; }
.shopping-verdict.skip b { color: #a4483a; }
.profile-privacy-note { margin: 0 0 15px; padding: 10px 12px; border-radius: 8px; color: var(--muted); background: var(--surface-soft); font-size: 11px; line-height: 1.7; }
.cloud-status { margin: -5px 18px 14px; padding: 7px 9px; border-radius: 7px; color: #a8adba; background: rgba(255,255,255,.05); font-size: 9px; line-height: 1.5; text-align: center; }
.cloud-status[data-state="online"] { color: #b8dcbb; background: rgba(120,175,120,.16); }
.cloud-status[data-state="syncing"] { color: #bcc9ea; }
.cloud-status[data-state="error"] { color: #f0c2b6; background: rgba(180,91,70,.14); }
.account-dialog { width: min(520px, calc(100vw - 32px)); }
.account-auth-actions { grid-template-columns: 1fr 1fr; }
.account-security-note { margin: 16px 0; padding: 15px; display: grid; gap: 5px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.account-security-note strong { font-size: 14px; }
.account-security-note span { color: var(--muted); font-size: 11px; line-height: 1.7; }
.account-danger { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.account-danger > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); list-style: revert; }
.account-danger > summary:hover { color: var(--ink); }
.account-danger .brand-field { margin: 12px 0; }
.account-danger-note { color: var(--muted); font-size: 11px; line-height: 1.7; margin-top: 8px; }
.account-link { display: inline-block; margin-top: 10px; padding: 4px 0; border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: underline; }
.account-link:hover { opacity: .8; }
#account-reset-panel .brand-field { margin: 12px 0; }
.body-profile-dialog label > span { color: var(--muted); font-size: 9px; font-weight: 400; }
.anchor-picker-dialog { width: min(760px, calc(100vw - 32px)); max-height: 88vh; padding: 24px; overflow: auto; }
.anchor-picker-dialog > p { margin: -5px 0 16px; color: var(--muted); font-size: 12px; }
.anchor-picker-filters { margin-bottom: 14px; display: flex; gap: 7px; flex-wrap: wrap; }
.anchor-picker-filters button { min-height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); background: var(--white); font-size: 10px; font-weight: 700; }
.anchor-picker-filters button.active { border-color: var(--sage-dark); color: white; background: var(--sage-dark); }
.anchor-picker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.anchor-choice { position: relative; padding: 8px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--white); text-align: right; overflow: hidden; }
.anchor-choice.selected { border: 2px solid var(--sage-dark); background: var(--accent-soft); }
.anchor-choice img, .anchor-choice .garment-art { width: 100%; height: 110px; border-radius: 7px; object-fit: contain; }
.anchor-choice img { background: var(--cream); }
.anchor-choice .garment-art { background: var(--item-color); filter: none; }
.anchor-choice strong, .anchor-choice small { display: block; }
.anchor-choice strong { margin-top: 7px; font-size: 11px; }
.anchor-choice small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.anchor-choice .anchor-check { position: absolute; top: 14px; left: 14px; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--sage-dark); font-size: 12px; }
.feedback-options { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.feedback-options label { padding: 10px 11px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); font-size: 11px; font-weight: 700; cursor: pointer; }
.feedback-options input { width: auto; margin: 0; }
.toast { position: fixed; z-index: 100; bottom: 25px; left: 25px; padding: 13px 18px; border-radius: 10px; color: white; background: #232833; box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.empty-state { grid-column: 1/-1; padding: 60px; text-align: center; color: var(--muted); }

/* Bottom tab bar — the primary mobile navigation (Studio app shell). Hidden on desktop. */
.tabbar { display: none; }
.tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 6px 0; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tab-item svg { width: 23px; height: 23px; }
.tab-item span { font-size: 10px; font-weight: 700; }
.tab-item.active { color: var(--accent); }

@media (max-width: 1100px) {
  .wardrobe-grid, .saved-grid { grid-template-columns: repeat(3, 1fr); }
  .stylist-layout { grid-template-columns: 1fr; }
  .stylist-copy { max-width: none; }
  .generation-panel { min-height: 500px; }
}
@media (max-width: 850px) {
  .sidebar { width: min(82vw, 300px); max-height: 100dvh; overflow-y: auto; z-index: 40; transform: translateX(100%); transition: .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    border: 0;
    background: rgba(18,20,28,.48);
    backdrop-filter: blur(2px);
  }
  .sidebar-backdrop.show { display: block; }
  .main-content { margin-right: 0; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .mobile-menu { display: block; margin-left: 12px; }
  .home-grid, .analytics-grid, .analytics-intelligence-grid { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  /* Tab bar replaces the drawer's nav list on mobile; the drawer keeps account + card. */
  .sidebar .main-nav { display: none; }
  .tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 30;
    display: flex; justify-content: space-around; align-items: center;
    padding: 9px 6px calc(9px + env(safe-area-inset-bottom));
    background: var(--white);
    background: color-mix(in srgb, var(--white) 90%, transparent);
    border-top: 1px solid var(--line);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
  }
}

/* iOS Safari auto-zooms (and reflows) the whole page whenever a focused form
   control has a computed font-size < 16px. Force 16px on EVERY touch device —
   any orientation, phones + tablets, and narrow windows — with !important so no
   smaller per-field size (e.g. .item-condition-select at 9px) can re-trigger it.
   Desktop (fine pointer, wide window) keeps its original type scale. */
@media (pointer: coarse), (max-width: 850px) {
  input, select, textarea { font-size: 16px !important; }
  .item-condition-select { max-width: none; height: auto; min-height: 32px; }
}
@media (max-width: 620px) {
  .page { padding: 26px 16px 54px; }
  .topbar { height: 66px; padding: 0 16px; position: sticky; top: 0; z-index: 12; }
  h1 { font-size: 29px; }
  h2 { font-size: 20px; }
  .page-intro, .section-heading, .toolbar { align-items: stretch; flex-direction: column; }
  .page-intro .primary-button, .page-intro .secondary-button { flex: 1; }
  .wardrobe-add-actions { width: 100%; }
  .looks-row, .wardrobe-grid, .saved-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .side-stack { grid-template-columns: 1fr; }
  .today-card, .stylist-chat-card, .chart-card { padding: 18px; }
  .generation-panel { min-height: 390px; padding: 18px; }
  .outfit-stage { grid-template-columns: repeat(3, minmax(0, 1fr)); min-height: 205px; padding: 14px 0; gap: 6px; }
  .garment { min-width: 0; min-height: 155px; gap: 6px; }
  .garment-art { transform: scale(.65); }
  .outfit-item-photo { height: 125px; }
  .garment small { font-size: 10px; text-align: center; line-height: 1.4; }
  .card-actions { flex-wrap: wrap; }
  .card-actions .primary-button, .card-actions .secondary-button { flex: 1; }
  .search-box { min-width: 0; }
  .filters { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 5px; scrollbar-width: thin; }
  .filter { flex: 0 0 auto; min-height: 42px; }
  .occasion-grid { grid-template-columns: 1fr 1fr; }
  .occasion { min-height: 62px; }
  .stats-grid, .form-row { grid-template-columns: 1fr; }
  .donut-wrap { flex-direction: column; }
  .analysis-fields { grid-template-columns: 1fr 1fr; }
  .score-breakdown, .feedback-options { grid-template-columns: 1fr 1fr; }
  .anchor-picker-grid { grid-template-columns: 1fr 1fr; }
  .stylist-context-tools { grid-template-columns: 1fr; }
  .stylist-context-card { min-height: 58px; }
  .chat-heading { flex-direction: column; }
  .chat-message { max-width: 92%; }
  .chat-suggestions button { min-height: 40px; padding-inline: 13px; }
  .chat-composer { grid-template-columns: 1fr; }
  .chat-composer .primary-button { width: 100%; min-height: 44px; }
  .generated-result .outfit-stage:has(.garment:nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-top { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  .item-meta { align-items: stretch; flex-direction: column; }
  .item-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .item-actions button, .item-condition-select { width: 100%; max-width: none; min-height: 42px; }
  .item-condition-select { grid-column: 1 / -1; }
  .text-button { min-height: 40px; display: inline-flex; align-items: center; }
  dialog { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
  dialog form { padding: 19px; }
  .anchor-picker-dialog { width: 100%; max-height: calc(100dvh - 24px); padding: 19px; }
  .anchor-picker-dialog .modal-actions { position: sticky; bottom: -19px; z-index: 2; margin-inline: -19px; padding: 13px 19px 19px; background: linear-gradient(transparent, var(--white) 25%); }
  .anchor-picker-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .anchor-picker-filters button { min-height: 40px; flex: 0 0 auto; }
  .anchor-choice { min-height: 178px; }
  .anchor-choice img, .anchor-choice .garment-art { height: 105px; }
  .modal-actions .primary-button, .modal-actions .secondary-button, .modal-actions .danger-button { min-height: 44px; }
  .photo-gallery { grid-template-columns: repeat(3, 1fr); }
  .toast { right: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); left: 12px; text-align: center; }
}
@media (max-width: 520px) {
  .looks-row, .wardrobe-grid, .saved-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .today-card { padding: 18px; }
  .score-breakdown, .feedback-options, .analysis-fields { grid-template-columns: 1fr; }
  .analysis-fields .analysis-wide { grid-column: auto; }
  .weather small { display: none; }
  .anchor-item-button { padding: 11px; }
  .anchor-item-button > span { width: 32px; height: 32px; }
  .anchor-item-button small { font-size: 9px; }
}

/* ===== English / LTR layout overrides ===== */
[dir="ltr"] .sidebar { inset: 0 auto 0 0; }
[dir="ltr"] .main-content { margin-right: 0; margin-left: 250px; }
[dir="ltr"] .nav-item, [dir="ltr"] .profile-chip { text-align: left; }
[dir="ltr"] .nav-item.active { box-shadow: inset 3px 0 var(--accent); }
[dir="ltr"] .weather { margin-right: 0; margin-left: auto; }
@media (max-width: 850px) {
  [dir="ltr"] .main-content { margin-left: 0; }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  [dir="ltr"] .sidebar.open { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Dark theme: elements that hardcode light surfaces/tints bypass the CSS-variable
   flip, so they'd show as bright patches with unreadable text. Remap them here. */
html[data-theme="dark"] .outfit-reason,
html[data-theme="dark"] .item-visual,
html[data-theme="dark"] .generation-panel,
html[data-theme="dark"] .chat-messages,
html[data-theme="dark"] .upload-zone,
html[data-theme="dark"] .photo-thumb,
html[data-theme="dark"] .anchor-item-button { background: var(--surface-soft); }
html[data-theme="dark"] .upload-zone { border-color: var(--line); }
html[data-theme="dark"] .upload-zone:hover,
html[data-theme="dark"] .anchor-item-button:hover { background: var(--cream); }
html[data-theme="dark"] .date-badge { background: var(--accent-soft); color: var(--accent-text); }
html[data-theme="dark"] .review-section ul,
html[data-theme="dark"] .styling-hijab-row { color: var(--muted); }
html[data-theme="dark"] .legal-links { color: var(--muted); }
html[data-theme="dark"] .legal-links a { color: var(--accent-text); }

/* Status / verdict tints -> translucent so they blend onto the dark surface */
html[data-theme="dark"] .item-status,
html[data-theme="dark"] .chat-status { color: var(--accent-text); background: rgba(143,166,218,.16); }
html[data-theme="dark"] .analysis-status.analyzing { color: #aeb4c4; background: rgba(150,158,178,.16); }
html[data-theme="dark"] .analysis-status.success { color: #82cf8b; background: rgba(120,175,120,.16); }
html[data-theme="dark"] .analysis-status.warning { color: #e2b878; background: rgba(185,145,75,.18); }
html[data-theme="dark"] .analysis-status.error,
html[data-theme="dark"] .bulk-row.error b { color: #e69684; background: transparent; }
html[data-theme="dark"] .analysis-status.error { background: rgba(185,95,75,.18); }
html[data-theme="dark"] .review-quick-fix { background: rgba(143,166,218,.12); }
html[data-theme="dark"] .shopping-verdict.buy { background: rgba(120,175,120,.16); }
html[data-theme="dark"] .shopping-verdict.buy b { color: #82cf8b; }
html[data-theme="dark"] .shopping-verdict.maybe { background: rgba(185,145,75,.16); }
html[data-theme="dark"] .shopping-verdict.maybe b { color: #e2b878; }
html[data-theme="dark"] .shopping-verdict.skip { background: rgba(185,95,75,.16); }
html[data-theme="dark"] .shopping-verdict.skip b { color: #e69684; }
html[data-theme="dark"] .confirm-icon { color: #e69684; background: rgba(185,95,75,.18); }
html[data-theme="dark"] .positive { color: #82cf8b !important; }
html[data-theme="dark"] .warning { color: #e2b878 !important; }
html[data-theme="dark"] .exclude-item { color: var(--muted); background: rgba(150,158,178,.12); border-color: var(--line); }
html[data-theme="dark"] .excluded-banner { background: rgba(150,158,178,.12); border-color: var(--line); }
html[data-theme="dark"] .excluded-banner strong,
html[data-theme="dark"] .delete-item { color: var(--muted); }
html[data-theme="dark"] .delete-item:hover { background: rgba(150,158,178,.16); border-color: var(--line); }

/* Studio dark: neutralise translucent-white fills that would show as bright patches. */
html[data-theme="dark"] .outfit-item-photo { background: var(--surface-soft); }
html[data-theme="dark"] .score-factor { background: var(--surface-soft); border-color: var(--line); }
html[data-theme="dark"] .orb { background: var(--surface-soft); border-color: var(--line); }
html[data-theme="dark"] .item-number { background: rgba(20,22,28,.82); color: var(--ink); }
