/* ============ AJOSSI App Dashboard Styles ============ */
body, html {
  height: 100%;
  margin: 0;
  overflow: hidden; /* Prevent full body scroll, handle scroll in panels */
}

.app-layout {
  display: flex;
  height: 100vh;
  background: var(--paper-2);
}

/* Sidebar Nav */
.app-nav {
  width: 80px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
  z-index: 10;
}
.nav-brand .logo {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 40px;
}
.nav-brand .logo::before {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}
.nav-brand .dot {
  width: 6px; height: 6px; background: var(--coral); border-radius: 50%; margin-top: 4px;
}
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  transition: color 0.2s;
}
.nav-item svg {
  width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2;
}
.nav-item:hover, .nav-item.active {
  color: var(--coral-deep);
}
.theme-toggle {
  margin-top: auto;
}

/* Main Content Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-header {
  padding: 24px 32px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.user-greeting h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}
.user-greeting p {
  font-size: 14px;
  color: var(--ink-soft);
}

.app-content {
  flex: 1;
  display: flex;
  padding: 24px;
  gap: 24px;
  overflow-y: auto;
}

/* Panels */
.setup-panel {
  flex: 0 0 320px;
}
.fitting-panel {
  flex: 1;
  min-width: 400px;
}
.recommend-panel {
  flex: 0 0 360px;
}
.direct-fit .setup-panel {
  display: none;
}
.direct-fit .fitting-panel {
  flex: 1.3;
}
.direct-fit .recommend-panel {
  flex: 0 0 380px;
}
.direct-fit .upload-btn-wrapper .btn {
  box-shadow: 0 10px 30px color-mix(in srgb, var(--coral) 24%, transparent);
}

.card {
  background: var(--cream-card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  height: 100%;
  overflow-y: auto;
}
.canvas-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
}

/* Forms & Chips */
.form-group {
  margin-top: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-chip {
  padding: 8px 14px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 100px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: 0.2s;
}
.filter-chip:hover {
  border-color: var(--coral);
}
.filter-chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* Canvas Area */
.canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.canvas-header h2 { font-size: 22px; }
.canvas-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
}
.upload-btn-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
}
.upload-btn-wrapper input[type=file] {
  font-size: 100px;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  cursor: pointer;
}
.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}
.hair-style-picker {
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.hair-style-picker > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hair-style-picker b { font-size: 12px; color: var(--ink-soft); }
.hair-style-picker span { font-size: 10px; color: var(--muted); }
.hair-style-options { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.hair-style-option {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--paper);
  color: var(--ink-soft);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}
.hair-style-option.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.fitting-area {
  flex: 1;
  min-height: 430px;
  background: var(--paper);
  border: 2px dashed var(--line);
  border-radius: 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.fitting-area.upload-ready {
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.upload-surface-button {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.fitting-area.upload-ready:hover,
.fitting-area.upload-ready:focus-within {
  border-color: var(--coral);
  background: color-mix(in srgb, var(--coral) 6%, var(--paper));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--coral) 12%, transparent);
  outline: none;
}
.fitting-area.upload-ready:hover .placeholder-txt,
.fitting-area.upload-ready:focus-within .placeholder-txt {
  color: var(--ink-soft);
}
.placeholder-txt {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}
.comparison-stage {
  width: 100%;
  height: 100%;
  min-height: 426px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(190px, .9fr);
  gap: 12px;
}
.comparison-stage[hidden] { display: none; }
.person-preview,
.look-preview {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--cream-card);
  overflow: hidden;
}
.person-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
#basePhoto {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.person-preview figcaption {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 9px;
  border-radius: 99px;
  color: #fff;
  background: rgba(24, 21, 18, .72);
  font-size: 11px;
  font-weight: 700;
}
.look-preview {
  padding: 14px;
  overflow-y: auto;
}
.look-preview-empty {
  height: 100%;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.look-preview-empty b { color: var(--ink-soft); font-size: 14px; }
.look-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.look-preview-head b { color: var(--coral-deep); }
.look-preview-items { display: grid; gap: 10px; }
.look-preview-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.look-preview-item b {
  display: block;
  font-size: 12px;
  line-height: 1.35;
}
.look-preview-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10.5px;
}
.look-item-visual {
  position: relative;
  width: 76px;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 10px;
  background: var(--paper-2);
}
.look-item-visual .thumb-svg,
.look-item-visual .rec-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.look-preview-reason {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.55;
}
.tryon-button {
  width: 100%;
  margin-top: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: center;
}
.tryon-button small {
  font-size: 9.5px;
  font-weight: 500;
  opacity: .72;
}
.tryon-status {
  margin-top: 10px;
  border-radius: 11px;
  font-size: 11px;
  line-height: 1.5;
}
.tryon-status.working,
.tryon-status.error {
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 9px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.tryon-status b,
.tryon-status small { grid-column: 2; }
.tryon-status small { color: var(--muted); }
.tryon-status.error { color: #b42318; background: #fff3f1; border-color: #f1b7af; }
.tryon-progress-track {
  grid-column: 1 / -1;
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 76%, transparent);
}
.tryon-progress-track i {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral-deep), var(--coral));
  transition: width .8s ease;
}
.tryon-spinner {
  grid-row: 1 / span 2;
  width: 20px;
  height: 20px;
  border: 2px solid color-mix(in srgb, var(--coral) 25%, transparent);
  border-top-color: var(--coral-deep);
  border-radius: 50%;
  animation: tryonSpin .8s linear infinite;
}
@keyframes tryonSpin { to { transform: rotate(360deg); } }
.tryon-result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.tryon-result-head div { display: flex; flex-direction: column; gap: 2px; }
.tryon-result-head span { font-size: 12px; color: var(--coral-deep); font-weight: 700; }
.tryon-result-head b { font-size: 10px; color: var(--muted); }
.tryon-result-head small { color: var(--muted); font-size: 10px; }
.tryon-result-image {
  display: block;
  width: 100%;
  border-radius: 11px;
  background: var(--paper-2);
}
.tryon-disclaimer {
  margin-top: 9px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}
.tryon-again { width: 100%; margin-top: 10px; justify-content: center; }
.comparison-notice {
  margin-top: 20px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--coral) 35%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--coral) 7%, var(--paper));
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 11px;
  line-height: 1.5;
  color: var(--coral-deep);
}
.comparison-notice strong { flex: 0 0 auto; color: var(--ink); }

/* Recs List */
.recs-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.empty-recs {
  text-align: center;
  padding: 60px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.rec-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  transition: 0.2s;
  cursor: pointer;
}
.rec-card:hover {
  border-color: var(--coral);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.rec-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--coral-deep);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.rec-items {
  display: flex;
  gap: 12px;
}
.r-item {
  flex: 1;
  text-align: center;
}
.r-thumb {
  aspect-ratio: 1/1;
  background: var(--paper-2);
  border-radius: 12px;
  margin-bottom: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.r-thumb img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}
.r-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

/* Responsive */
@media(max-width: 960px) {
  .app-content {
    flex-direction: column;
    overflow-y: auto;
  }
  .setup-panel, .recommend-panel, .fitting-panel {
    flex: auto;
    min-width: 100%;
  }
  .fitting-panel {
    height: auto;
  }
  .app-layout {
    flex-direction: column;
  }
  .app-nav {
    width: 100%;
    flex-direction: row;
    height: 60px;
    padding: 0 20px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    justify-content: space-between;
  }
  .nav-brand { margin-bottom: 0; }
  .nav-brand .logo { flex-direction: row; gap: 0; font-size: 0; margin-bottom: 0; }
  .nav-brand .logo::before { width: 36px; height: 36px; }
  .nav-brand .dot { display: none; }
  .nav-menu { flex-direction: row; width: auto; gap: 20px; }
  .theme-toggle { margin-top: 0; }
  .direct-fit .recommend-panel, .direct-fit .fitting-panel {
    flex: auto;
  }
}

@media(max-width: 560px) {
  .app-header { padding: 22px 20px; }
  .app-content { padding: 16px; gap: 16px; }
  .card { padding: 18px; }
  .canvas-card { min-height: 0; }
  .canvas-header { align-items: flex-start; flex-wrap: wrap; }
  .hair-style-picker { align-items: flex-start; flex-direction: column; }
  .hair-style-options { justify-content: flex-start; }
  .canvas-actions { order: 3; width: 100%; justify-content: flex-end; }
  .fitting-area { min-height: 0; }
  .comparison-stage {
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 54vh) auto;
  }
  .look-preview { overflow: visible; }
  .comparison-notice { flex-direction: column; gap: 3px; }
}

/* Toast Notification System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
  pointer-events: none;
}
.toast-message {
  background: var(--ink);
  color: var(--paper);
  padding: 14px 24px;
  border-radius: 12px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.toast-message.show {
  transform: translateY(0);
  opacity: 1;
}
.toast-message.success {
  border-left: 4px solid var(--coral);
}
.toast-message.error {
  border-left: 4px solid #ef4444;
}

/* ===== 대시보드 리디자인 ===== */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 28px 32px;
}
.dash-header .kicker { margin-bottom: 6px; }
.dash-header .user-greeting h1 { font-size: 26px; }
.dash-stats { display: flex; gap: 10px; }
.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 84px;
  padding: 10px 16px;
  background: var(--cream-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  transition: 0.2s;
}
.stat-chip:hover { border-color: var(--coral); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-chip .stat-num { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-chip .stat-label { font-size: 11px; font-weight: 600; color: var(--muted); }
.stat-chip.accent { background: var(--ink); border-color: var(--ink); }
.stat-chip.accent .stat-label { color: var(--paper); }
.stat-chip.accent:hover { background: var(--coral-deep); border-color: var(--coral-deep); }

.step-head { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  font-size: 15px;
  font-weight: 700;
  color: var(--coral-deep);
  border: 1.5px solid color-mix(in srgb, var(--coral) 45%, transparent);
  border-radius: 10px;
  padding: 4px 9px;
  line-height: 1.2;
  flex-shrink: 0;
  margin-top: 2px;
}
.step-head h2 { font-size: 19px; }
.step-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.rec-panel-head { margin-bottom: 16px; }
.rec-panel-head .kicker { margin-bottom: 4px; }
.rec-panel-head h2 { font-size: 21px; }

.match-badge {
  float: right;
  font-size: 11px;
  font-weight: 700;
  color: var(--coral-deep);
  background: color-mix(in srgb, var(--coral) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--coral) 35%, transparent);
  padding: 2px 9px;
  border-radius: 100px;
}
.thumb-svg { width: 78%; height: 78%; display: grid; place-items: center; }
.thumb-svg svg { width: 100%; height: 100%; }
.r-thumb { background: var(--paper); border: 1px solid var(--line); }
.r-thumb .rec-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.rec-reason { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.45; }
.rec-reason small { display: block; margin-top: 5px; color: var(--coral-deep); font-weight: 700; }

.placeholder-txt { line-height: 1.6; }

/* App Canvas Actions */
.canvas-actions {
  position: static;
  margin-left: auto;
  order: 3;
  display: flex;
  gap: 8px;
  z-index: 10;
}
.canvas-action-btn {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  transition: 0.2s;
  box-shadow: var(--shadow-sm);
}
.canvas-action-btn:hover {
  background: var(--paper);
  color: var(--coral);
  transform: translateY(-2px);
}
