/* ---------------------------------------------------------------
   huafu AI Atelier — design tokens & shared components
   monochrome studio system (reference: OpenFashion)
   --------------------------------------------------------------- */
:root {
  --ink: #0a0a0a;
  --ink-2: #3d3d3b;
  --ink-3: #767671;
  --ink-4: #a3a39c;
  --paper: #f6f5f1;
  --paper-2: #efeeea;
  --paper-3: #e4e3dd;
  --card: #ffffff;
  --white: #ffffff;
  --line: #e6e5e0;
  --line-2: #d6d5cf;
  --line-strong: #b8b7b0;

  /* legacy accent tokens — mapped to ink so the whole app stays monochrome */
  --red: #0a0a0a;
  --red-deep: #000000;
  --red-soft: #efeeea;
  --gold: #8a6a3f;
  --ok: #2f6b4f;
  --warn: #a5741f;

  --font: "Inter", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --display: "Archivo", "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC", serif;
  --mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(10, 10, 10, .04);
  --shadow-sm: 0 6px 18px -12px rgba(10, 10, 10, .18);
  --shadow-md: 0 18px 40px -24px rgba(10, 10, 10, .28), 0 2px 6px -3px rgba(10, 10, 10, .06);
  --shadow-lg: 0 40px 90px -40px rgba(10, 10, 10, .45), 0 10px 26px -16px rgba(10, 10, 10, .18);
  --ease-spring: cubic-bezier(.22, 1.18, .36, 1);
  --ease-out: cubic-bezier(.22, .8, .24, 1);
  --ease-soft: cubic-bezier(.4, .14, .2, 1);
  --topbar-h: 66px;
  --sidebar-w: 246px;
  --sidebar-w-collapsed: 78px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--ink); color: #fff; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: #c9c8c2 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d3d2cc; border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #b9b8b1; background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-sm { width: 15px; height: 15px; }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
.eyebrow {
  font-family: var(--display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 20px;
  height: 1px;
  background: var(--ink);
  opacity: .55;
}
.eyebrow.no-rule::before { display: none; }
.muted { color: var(--ink-3); }
.tiny { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ------------------------------ buttons ------------------------------ */
.btn {
  --btn-h: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: var(--btn-h);
  padding: 0 20px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  transition: background .18s, color .18s, border-color .18s, transform .18s var(--ease-out), box-shadow .18s;
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn .icon { width: 17px; height: 17px; }
.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: #262624; box-shadow: var(--shadow-md); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #262624; }
.btn-ghost { border: 1px solid var(--line-2); background: var(--card); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); background: var(--card); }
.btn-soft { background: var(--paper-2); color: var(--ink-2); }
.btn-soft:hover { background: var(--paper-3); color: var(--ink); }
.btn-danger-soft { background: var(--red-soft); color: var(--ink); }
.btn-danger-soft:hover { background: var(--paper-3); }
.btn-sm { --btn-h: 36px; padding: 0 14px; font-size: 12.5px; border-radius: 9px; }
.btn-xs { --btn-h: 30px; padding: 0 10px; font-size: 11.5px; border-radius: 8px; }
.btn-lg { --btn-h: 52px; padding: 0 26px; font-size: 14px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading .btn-label { opacity: .75; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner.dark { border-color: rgba(10, 10, 10, .18); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2);
  transition: background .18s, color .18s;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn.active { background: var(--paper-2); color: var(--ink); }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  transition: opacity .18s;
}
.link-btn:hover { opacity: .6; }

/* ------------------------------ badges & chips ------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 11px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .02em;
  background: var(--paper-2); color: var(--ink-2);
  white-space: nowrap;
}
.badge-red { background: var(--ink); color: #fff; }
.badge-ink { background: var(--ink); color: #fff; }
.badge-line { background: transparent; border: 1px solid var(--line-2); color: var(--ink-3); }
.badge-dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--paper-2); color: var(--ink); }
.badge-warn { background: #f6efe2; color: var(--warn); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 15px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--card);
  font-size: 13px; color: var(--ink-2);
  transition: all .18s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .icon { width: 14px; height: 14px; }

/* ------------------------------ forms ------------------------------ */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; justify-content: space-between; }
.field-hint { font-size: 12px; color: var(--ink-3); }
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line-2);
  background: var(--card);
  border-radius: var(--r-sm);
  padding: 0 14px;
  height: 46px;
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.65; }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(10, 10, 10, .08);
  background: #fff;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%230a0a0a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .icon { position: absolute; left: 14px; width: 17px; height: 17px; color: var(--ink-3); pointer-events: none; }
.input-affix .input { padding-left: 41px; }
.input-affix .affix-btn { position: absolute; right: 5px; }

.switch {
  position: relative; width: 42px; height: 24px; border-radius: var(--r-pill);
  background: var(--paper-3); transition: background .2s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .22);
  transition: transform .24s var(--ease-spring);
}
.switch.on { background: var(--ink); }
.switch.on::after { transform: translateX(18px); }

/* ------------------------------ segmented tabs ------------------------------ */
.seg {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px; border-radius: var(--r-pill);
  background: var(--card);
  border: 1px solid var(--line-2);
}
.seg-btn {
  position: relative; height: 38px; padding: 0 18px;
  border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 600; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 7px;
  transition: color .18s, background .2s;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--ink); color: #fff; }
.seg-btn .count {
  font-size: 11px; font-weight: 600; color: inherit;
  background: rgba(10, 10, 10, .07); border-radius: var(--r-pill); padding: 0 7px; height: 19px; display: inline-flex; align-items: center;
}
.seg-btn.active .count { background: rgba(255, 255, 255, .18); color: #fff; }
.seg.lg { padding: 5px; }
.seg.lg .seg-btn { height: 44px; padding: 0 22px; font-size: 14px; }

/* underline tabs */
.tabs-line { display: flex; align-items: center; gap: 30px; border-bottom: 1px solid var(--line); }
.tab-line {
  position: relative; padding: 0 1px 16px;
  font-size: 14.5px; font-weight: 600; color: var(--ink-3);
  transition: color .2s;
  display: flex; align-items: center; gap: 8px;
}
.tab-line:hover { color: var(--ink); }
.tab-line.active { color: var(--ink); }
.tab-line.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--ink);
}
.tab-line .count { font-size: 11.5px; color: var(--ink-3); background: var(--paper-2); border-radius: var(--r-pill); padding: 2px 8px; }
.tab-line.active .count { background: var(--ink); color: #fff; }

/* ------------------------------ panels ------------------------------ */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 9px; }
.panel-body { padding: 22px 24px; }

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.v-divider { width: 1px; align-self: stretch; background: var(--line); }

/* ------------------------------ media ------------------------------ */
.ratio { position: relative; width: 100%; overflow: hidden; background: var(--paper-2); }
.ratio > img, .ratio > video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.ratio-1 { padding-top: 100%; }
.ratio-43 { padding-top: 133.333%; }
.ratio-45 { padding-top: 125%; }
.ratio-34 { padding-top: 75%; }
.ratio-169 { padding-top: 56.25%; }
.media-img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease-out); }

/* image hover overlay pattern */
.img-actions {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end; justify-content: center;
  gap: 8px; padding: 12px;
  background: linear-gradient(to top, rgba(10, 10, 10, .5), rgba(10, 10, 10, .06) 46%, transparent 70%);
  opacity: 0; transition: opacity .25s;
}
.hoverable:hover .img-actions { opacity: 1; }
.img-actions .btn { backdrop-filter: blur(8px); background: rgba(255, 255, 255, .94); color: var(--ink); box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.img-actions .btn:hover { background: #fff; }
.img-actions .btn-red { background: var(--ink); color: #fff; }
.img-actions .btn-red:hover { background: #000; }

/* ------------------------------ modal ------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(10, 10, 10, .52);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
  opacity: 0; transition: opacity .26s;
}
.modal-backdrop.open { opacity: 1; }
.modal {
  position: relative;
  width: min(1080px, 100%);
  max-height: calc(100vh - 64px);
  background: var(--card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(18px) scale(.982);
  opacity: 0;
  transition: transform .45s var(--ease-spring), opacity .3s;
  display: flex; flex-direction: column;
}
.modal-backdrop.open .modal { transform: none; opacity: 1; }
.modal-sm { width: min(560px, 100%); }
.modal-md { width: min(760px, 100%); }
.modal-lg { width: min(1180px, 100%); }
.modal-close {
  position: absolute; top: 18px; right: 18px; z-index: 5;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); backdrop-filter: blur(8px);
  transition: all .18s;
}
.modal-close:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.modal-body { overflow: auto; }
.modal-topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 30px 34px 22px; border-bottom: 1px solid var(--line);
}
.modal-title { font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: -.01em; }

/* ------------------------------ drawer ------------------------------ */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 10, 10, .38);
  opacity: 0; transition: opacity .28s;
}
.drawer-backdrop.open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 91;
  width: min(480px, 92vw);
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -40px 0 90px -50px rgba(0, 0, 0, .55);
  transform: translateX(102%);
  transition: transform .48s var(--ease-spring);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px; border-bottom: 1px solid var(--line);
}
.drawer-body {
  flex: 1; overflow: auto;
  background:
    linear-gradient(var(--card) 30%, rgba(255, 255, 255, 0)) center top / 100% 28px no-repeat local,
    linear-gradient(rgba(255, 255, 255, 0), var(--card) 70%) center bottom / 100% 28px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(10, 10, 10, .14), rgba(10, 10, 10, 0)) center top / 100% 10px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(10, 10, 10, .14), rgba(10, 10, 10, 0)) center bottom / 100% 10px no-repeat scroll;
}
.drawer-foot { padding: 20px 26px; border-top: 1px solid var(--line); background: var(--card); }

/* ------------------------------ toast ------------------------------ */
.toast-root {
  position: fixed; z-index: 120; left: 50%; bottom: 36px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 20px 13px 14px;
  background: var(--ink);
  color: #f4f4f2;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500;
  box-shadow: 0 20px 44px -18px rgba(0, 0, 0, .55);
  animation: toastIn .5s var(--ease-spring) both;
  max-width: 540px;
}
.toast.out { animation: toastOut .35s var(--ease-soft) both; }
.toast .toast-icon {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #fff;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.toast .toast-icon .icon { width: 14px; height: 14px; }
.toast b { font-weight: 650; color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ------------------------------ skeletons & empties ------------------------------ */
.shimmer {
  position: relative; overflow: hidden;
  background: linear-gradient(100deg, #ecebe6 20%, #f8f7f4 40%, #ecebe6 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.empty {
  padding: 64px 26px; text-align: center;
  border: 1px dashed var(--line-2); border-radius: var(--r-lg);
  color: var(--ink-3); background: rgba(255, 255, 255, .55);
}
.empty .icon { width: 28px; height: 28px; margin: 0 auto 12px; color: var(--ink-4); }

/* ------------------------------ misc helpers ------------------------------ */
.btn-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-4); display: inline-block; }
.dot-red { background: var(--ink); }
.dot-ok { background: var(--ok); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

@media (max-width: 760px) {
  .modal-backdrop { padding: 12px; }
  .modal { border-radius: var(--r-lg); max-height: calc(100vh - 24px); }
  .modal-topbar { padding: 22px 22px 18px; }
}
