/* ============================================================
   Expert Panel — Stylesheet
   Design system aligned with APL landing page
   ============================================================ */

/* ─── DESIGN TOKENS ─── */
:root {
  --bg: #f2f1ef;
  --surface: #e9e8e5;
  --surface2: #dddbd7;
  --border: rgba(0,0,0,0.09);
  --text: #1a1916;
  --text-muted: #5c5a56;
  --text-dim: #9b9890;
  --accent: #a07840;
  --accent2: #c49656;
  --coral: #b85f44;
  --rose: #a45a6e;
  --sage: #4d7d65;
  --warm: rgba(160,120,64,0.10);
  --mono: 'DM Mono', monospace;
  --serif: 'Noto Serif KR', serif;
  --sans: 'Noto Sans KR', 'Noto Sans JP', 'Noto Sans SC', sans-serif;
  --header-bg: rgba(242,241,239,0.92);
  --shadow: 0 2px 20px rgba(0,0,0,0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.2s ease;
  --sidebar-w: 280px;
  --header-h: 56px;

  /* Status indicators */
  --status-pending: #e74c3c;
  --status-progress: #f39c12;
  --status-done: #27ae60;
}

/* ─── DARK THEME ─── */
[data-theme="dark"] {
  --bg: #1a1a1a;
  --surface: #2a2a2a;
  --surface2: #222222;
  --border: #404040;
  --text: #e0e0e0;
  --text-muted: #aaaaaa;
  --text-dim: #777777;
  --accent: #c4a484;
  --accent2: #d4b898;
  --coral: #d4836a;
  --rose: #c97b8f;
  --sage: #7a9e8a;
  --warm: rgba(196,164,132,0.12);
  --header-bg: rgba(26,26,26,0.92);
  --shadow: 0 2px 20px rgba(0,0,0,0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #1a1a1a; --surface: #2a2a2a; --surface2: #222222;
    --border: #404040; --text: #e0e0e0; --text-muted: #aaaaaa;
    --text-dim: #777777; --accent: #c4a484; --accent2: #d4b898;
    --coral: #d4836a; --rose: #c97b8f; --sage: #7a9e8a;
    --warm: rgba(196,164,132,0.12);
    --header-bg: rgba(26,26,26,0.92);
    --shadow: 0 2px 20px rgba(0,0,0,0.3);
  }
}


/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ─── GRAIN OVERLAY ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.25;
}
[data-theme="dark"] body::before { opacity: 0.5; }


/* ─── HEADER ─── */
.panel-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

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

.header-logo {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.header-logo span {
  color: var(--text-dim);
  font-weight: 300;
}

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

.header-user {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}


/* ─── LANGUAGE SWITCHER ─── */
.lang-switcher {
  position: relative;
}

.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }

.lang-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 200;
  min-width: 100px;
}
.lang-dropdown.open { display: block; }

.lang-option {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
.lang-option:hover { background: var(--warm); }
.lang-option.active { color: var(--accent); font-weight: 500; }


/* ─── THEME TOGGLE ─── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }


/* ─── ICON BUTTON (generic) ─── */
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  transition: all var(--transition);
}
.icon-btn:hover { border-color: var(--coral); color: var(--coral); }


/* ─── APP LAYOUT ─── */
.app-layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}


/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
}

.sidebar-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 10px;
  line-height: 1.7;
}

.sidebar-photo {
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface2);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
}
.sidebar-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sidebar-photo .placeholder {
  font-size: 40px;
  color: var(--text-dim);
  opacity: 0.4;
}

.sidebar-info { display: flex; flex-direction: column; gap: 8px; }

.sidebar-name {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--warm);
  color: var(--accent);
  letter-spacing: 0.5px;
}
.meta-badge.status-pending   { background: rgba(231,76,60,0.12);  color: var(--status-pending); }
.meta-badge.status-progress  { background: rgba(243,156,18,0.12); color: var(--status-progress); }
.meta-badge.status-done      { background: rgba(39,174,96,0.12);  color: var(--status-done); }

.sidebar-detail {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-detail dt { color: var(--text-dim); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-detail dd { margin: 0 0 6px; }

.sidebar-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}


/* ─── MAIN CONTENT ─── */
.main-content {
  flex: 1;
  padding: 20px 28px;
  overflow-y: auto;
  min-width: 0;
  max-width: 860px;
  margin: 0 auto;
}


/* ─── TAB NAVIGATION ─── */
.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}


/* ─── TAB PANELS ─── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }


/* ─── SECTION CARDS ─── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.section-title {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-subtitle {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 12px;
}


/* ─── DASHBOARD: STATS ROW ─── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}


/* ─── DASHBOARD: FILTERS ─── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

.filter-input {
  flex: 1;
  min-width: 180px;
}


/* ─── DASHBOARD: CUSTOMER QUEUE ─── */
.queue-group {
  margin-bottom: 20px;
}

.queue-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
}

.queue-group-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.queue-group-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.queue-group-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}

.queue-group-chevron {
  font-size: 12px;
  color: var(--text-dim);
  transition: transform var(--transition);
}
.queue-group.collapsed .queue-group-chevron { transform: rotate(-90deg); }
.queue-group.collapsed .queue-list { display: none; }

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}

.queue-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.queue-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.queue-card.selected { border-color: var(--accent); background: var(--warm); }

.queue-card-name {
  font-size: 14px;
  font-weight: 400;
  flex: 1;
}

.queue-card-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}


/* ─── COLOR ANALYSIS: TYPE GRID ─── */
.color-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.season-column { display: flex; flex-direction: column; gap: 8px; }

.season-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
  padding: 6px 0;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.color-type-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 12px;
}
.color-type-card:hover { border-color: var(--accent); }
.color-type-card.selected {
  border-color: var(--accent);
  background: var(--warm);
  font-weight: 500;
}

.color-type-swatch {
  width: 16px; height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--border);
}


/* ─── COLOR ANALYSIS: TONE TABLE ─── */
.tone-table-wrap {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
}

.tone-table-wrap img {
  width: 100%;
  display: block;
  border-radius: var(--radius);
}

.tone-marker {
  position: absolute;
  width: 26px; height: 26px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
  opacity: 0.4;
}
.tone-marker:hover { opacity: 0.8; transform: translate(-50%, -50%) scale(1.15); }
.tone-marker.tone-main {
  opacity: 1;
  border-color: var(--coral);
  box-shadow: 0 0 6px rgba(184,95,68,0.5);
}
.tone-marker.tone-sub {
  opacity: 1;
  border-color: var(--accent);
  box-shadow: 0 0 6px rgba(160,120,64,0.4);
}
.tone-marker.tone-point {
  opacity: 1;
  border-color: var(--sage);
  box-shadow: 0 0 6px rgba(77,125,101,0.4);
}

.tone-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.tone-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.tone-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid;
}
.tone-legend-dot.main  { border-color: var(--coral); }
.tone-legend-dot.sub   { border-color: var(--accent); }
.tone-legend-dot.point { border-color: var(--sage); }


/* ─── COLOR ANALYSIS: INDICATORS ─── */
.indicator-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.indicator-group { display: flex; flex-direction: column; gap: 6px; }

.indicator-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

.indicator-options {
  display: flex;
  gap: 4px;
}

.indicator-opt {
  flex: 1;
  padding: 6px 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}
.indicator-opt:hover { border-color: var(--accent); }
.indicator-opt.selected {
  background: var(--warm);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}


/* ─── COLOR ANALYSIS: PALETTES ─── */
.palette-section {
  margin-bottom: 16px;
}

.palette-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.palette-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.palette-chip {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
}
.palette-chip:hover { transform: scale(1.15); }
.palette-chip .remove-chip {
  position: absolute;
  top: -6px; right: -6px;
  width: 14px; height: 14px;
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 9px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.palette-chip:hover .remove-chip { display: flex; }

.palette-add {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 16px;
  transition: all var(--transition);
}
.palette-add:hover { border-color: var(--accent); color: var(--accent); }


/* ─── COLOR ANALYSIS: MAKEUP KEYWORDS ─── */
.keyword-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keyword-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.keyword-tag:hover { border-color: var(--accent); }
.keyword-tag.selected {
  background: var(--warm);
  border-color: var(--accent);
  color: var(--accent);
}

.keyword-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}


/* ─── SHAPE ANALYSIS: TYPE SELECTORS ─── */
.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

.shape-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  font-size: 12px;
}
.shape-card:hover { border-color: var(--accent); }
.shape-card.selected {
  border-color: var(--accent);
  background: var(--warm);
  font-weight: 500;
}

.shape-icon {
  font-size: 28px;
  color: var(--text-dim);
}


/* ─── SHAPE ANALYSIS: FEATURE NOTES ─── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}


/* ─── SHAPE ANALYSIS: RECOMMENDATION GRIDS ─── */
.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.rec-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.rec-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.rec-item .rec-label {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.rec-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  gap: 4px;
  transition: all var(--transition);
}
.rec-upload:hover { border-color: var(--accent); color: var(--accent); }


/* ─── SHAPE: CLOTHING RECS ─── */
.clothing-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.clothing-tab {
  padding: 6px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.clothing-tab:hover { border-color: var(--accent); }
.clothing-tab.active {
  background: var(--warm);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.clothing-panel { display: none; }
.clothing-panel.active { display: block; }

.best-worst-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.best-col .section-subtitle { color: var(--sage); }
.worst-col .section-subtitle { color: var(--coral); }


/* ─── STYLE GUIDE: KEYWORDS ─── */
.style-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.style-keyword {
  padding: 8px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.style-keyword:hover { border-color: var(--accent); }
.style-keyword.selected {
  background: var(--warm);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}


/* ─── STYLE GUIDE: OCCASION PACKAGES ─── */
.occasion-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.occasion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.occasion-header:hover { background: var(--warm); }

.occasion-title {
  font-size: 14px;
  font-weight: 400;
}

.occasion-chevron {
  font-size: 12px;
  color: var(--text-dim);
  transition: transform var(--transition);
}
.occasion-card.expanded .occasion-chevron { transform: rotate(90deg); }

.occasion-body {
  display: none;
  padding: 0 16px 16px;
}
.occasion-card.expanded .occasion-body { display: block; }


/* ─── STYLE GUIDE: RECOMMENDATION LISTS ─── */
.rec-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rec-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.rec-list-item .remove-item {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}
.rec-list-item .remove-item:hover { color: var(--coral); }

.add-item-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}


/* ─── STYLE GUIDE: IMAGE GALLERY ─── */
.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.gallery-item {
  aspect-ratio: 3/4;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-item:hover { box-shadow: var(--shadow); }

.gallery-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3/4;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  gap: 6px;
  transition: all var(--transition);
}
.gallery-upload:hover { border-color: var(--accent); color: var(--accent); }


/* ─── FORM CONTROLS ─── */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 300;
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239b9890'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

.form-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}


/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 11px;
}

.btn-full { width: 100%; }


/* ─── MODALS ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow);
}

.modal-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-body {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}


/* ─── IMAGE PREVIEW MODAL ─── */
.preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 600;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.preview-overlay.open { display: flex; }
.preview-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
}


/* ─── TOAST NOTIFICATION ─── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s ease;
  max-width: 340px;
}

.toast.success { border-left: 3px solid var(--sage); }
.toast.error   { border-left: 3px solid var(--coral); }
.toast.info    { border-left: 3px solid var(--accent); }

.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(12px); }
}


/* ─── LOADING OVERLAY ─── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 700;
  align-items: center;
  justify-content: center;
}
.loading-overlay.active { display: flex; }

.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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


/* ─── DIVIDER ─── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}


/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 13px;
}
.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}


/* ─── COLOR PICKER POPUP ─── */
.color-picker-popup {
  display: none;
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  z-index: 300;
}
.color-picker-popup.open { display: block; }

.color-picker-popup input[type="color"] {
  width: 100%;
  height: 40px;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
}


/* ─── SCROLL REVEAL ─── */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}


/* ─── RESPONSIVE ─── */
@media (max-width: 1200px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .indicator-row { grid-template-columns: repeat(2, 1fr); }
  .color-type-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    position: relative;
    top: 0;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
    gap: 12px;
  }

  .sidebar-photo { width: 60px; height: 60px; aspect-ratio: 1; }
  .sidebar-actions { margin-top: 0; border-top: none; padding-top: 0; flex-direction: row; }

  .main-content { padding: 16px; }

  .stats-row { grid-template-columns: 1fr 1fr; }
  .best-worst-row { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
  .indicator-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .panel-header { padding: 0 12px; }
  .header-user { display: none; }
  .tab-btn { padding: 8px 12px; font-size: 12px; }
  .stats-row { grid-template-columns: 1fr; }
  .color-type-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .drawer-panel { width: 100vw; max-width: 100vw; }
  .drawer-body { padding: 12px; }
  .drawer-type-grid { grid-template-columns: 1fr; }
}


/* ============================================================
   SLIDE DRAWER
   ============================================================ */

/* ─── Section title flex (support Browse button) ─── */
.section-title { display: flex; align-items: center; gap: 8px; }
.section-title .btn { margin-left: auto; flex-shrink: 0; }
.section-subtitle { display: flex; align-items: center; gap: 8px; }
.section-subtitle .btn { margin-left: auto; flex-shrink: 0; }

/* ─── Panel (YouTube Shorts style — flex child, no overlay) ─── */
.drawer-panel {
  width: 0;
  min-width: 0;
  flex-shrink: 0;
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  background: var(--surface);
  border-left: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-left-color 0.3s ease;
}
.drawer-panel.open {
  width: 480px;
  min-width: 480px;
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
}

[data-theme="dark"] .drawer-panel.open {
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}

/* ─── Drawer inner content min-width (prevents collapse) ─── */
.drawer-header,
.drawer-body { min-width: 480px; }

/* ─── Header ─── */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-title {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.drawer-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
}
.drawer-close:hover {
  border-color: var(--coral);
  color: var(--coral);
}

/* ─── Body ─── */
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.drawer-body::-webkit-scrollbar { width: 4px; }
.drawer-body::-webkit-scrollbar-track { background: transparent; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Drawer internal: Gender tabs ─── */
.drawer-gender-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.drawer-gender-tab {
  flex: 1;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.drawer-gender-tab:hover { border-color: var(--accent); color: var(--accent); }
.drawer-gender-tab.active {
  background: var(--warm);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

/* ─── Drawer internal: Season tabs ─── */
.drawer-season-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.drawer-season-tab {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.drawer-season-tab:hover { border-color: var(--accent); }
.drawer-season-tab.active { font-weight: 500; }

/* ─── Drawer internal: Type list ─── */
.drawer-type-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.drawer-type-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.drawer-type-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.drawer-type-card.selected {
  border-color: var(--accent);
  border-width: 2px;
  background: var(--warm);
}
.drawer-type-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.drawer-type-name {
  font-size: 14px;
  color: var(--text);
}
.drawer-type-check {
  margin-left: auto;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

/* ─── Drawer internal: Image grid ─── */
.drawer-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.drawer-image-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}
.drawer-image-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.drawer-image-card.selected {
  border-color: var(--accent);
  border-width: 2px;
  box-shadow: 0 0 0 2px var(--warm);
}
.drawer-image-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.drawer-image-label {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  font-family: var(--mono);
}

/* ─── Drawer internal: Preview area ─── */
.drawer-preview {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.drawer-preview-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* ─── Drawer internal: Placeholder ─── */
.drawer-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ─── Drawer internal: Footer action ─── */
.drawer-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ─── Selected type preview card (Color tab main body) ─── */
.selected-type-preview {
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.preview-type-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.preview-type-name {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.preview-type-season {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

/* ─── Face shape description panel ─── */
.shape-description {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ─── Style preview sentence ─── */
.style-preview-sentence {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--warm);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--accent);
  font-style: italic;
}

/* ─── Responsive: Drawer ─── */
@media (max-width: 768px) {
  .drawer-panel {
    position: fixed;
    top: 0; right: 0;
    width: 0; min-width: 0;
    height: 100vh;
  }
  .drawer-panel.open {
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    z-index: 451;
  }
  .drawer-header,
  .drawer-body { min-width: 100vw; }
}
