:root {
  --paper: #faf9f6;
  --paper-2: #f3efe8;
  --panel: #ffffff;
  --ink: #23211f;
  --ink-2: #4a453f;
  --muted: #857b70;
  --line: #e5ddd2;
  --line-2: #d6cbbb;
  --accent: #b73d4b;
  --accent-ink: #8d2c38;
  --blue: #263a56;
  --gold: #b58c60;
  --green: #247b65;
  --orange: #c47a2c;
  --danger: #a83a3a;
  --shadow: 0 18px 50px rgba(58, 44, 30, .08);
  --radius: 14px;
  --serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.serif { font-family: var(--serif); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(24px, 4vw, 38px); font-family: var(--serif); font-weight: 500; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
small { color: var(--muted); }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
pre { background: #f5f0e8; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; font-size: 12px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 26px;
  background: rgba(250, 249, 246, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-size: 22px; letter-spacing: .04em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand i { color: var(--accent); font-style: normal; }
.brand-sub { font-size: 9px; letter-spacing: .22em; color: var(--muted); margin-left: -12px; }
.topbar-app { font-size: 12px; color: var(--ink-2); letter-spacing: .08em; border-left: 1px solid var(--line); padding-left: 18px; }
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 12px; }
.topbar-links { display: flex; gap: 8px; align-items: center; }

.container { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 26px 0 60px; }
.container-narrow { width: min(860px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 13px; }
.eyebrow { display: block; font-size: 10px; letter-spacing: .22em; color: var(--accent); text-transform: uppercase; margin-bottom: 6px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 0 rgba(60,45,30,.02); }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel-title .serif { color: var(--muted); font-size: 10px; letter-spacing: .18em; }
.panel-sub { color: var(--muted); font-size: 12px; }
.notice { background: #f4eee5; border: 1px solid #e8ddcd; border-radius: 10px; padding: 10px 14px; font-size: 12px; color: #6f6253; }
.notice.accent { background: #fbf0f1; border-color: #efd5d8; color: #8d3a44; }
.notice.green { background: #eef5f1; border-color: #d2e5db; color: #3c6b58; }
.help { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 12px; min-height: 16px; margin: 4px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  border-radius: 999px; padding: 9px 20px; font: inherit; font-size: 13px;
  cursor: pointer; transition: transform .12s ease, background .12s ease, opacity .12s;
  text-decoration: none; line-height: 1.3;
}
.btn:hover { background: #3a352f; transform: translateY(-1px); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-ink); }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.secondary:hover { border-color: var(--ink); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); padding: 7px 10px; }
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.full { width: 100%; }
.btn.sm { padding: 6px 13px; font-size: 12px; }
.text-btn { border: 0; background: none; color: var(--accent-ink); font: inherit; font-size: 12px; cursor: pointer; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; }
.text-btn:hover { color: var(--accent); }

label { display: block; font-size: 12px; color: var(--ink-2); margin: 14px 0 5px; letter-spacing: .02em; }
label small { color: var(--muted); font-weight: 400; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  border-radius: 9px; padding: 9px 11px; font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(183, 61, 75, .18); border-color: var(--accent); }
textarea { min-height: 88px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input[type="color"] { padding: 3px; height: 36px; cursor: pointer; }
input[type="range"] { accent-color: var(--accent); }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); margin: 10px 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.field-row label { margin-top: 0; }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.segmented button {
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 12px; cursor: pointer;
}
.segmented button.selected { background: var(--ink); border-color: var(--ink); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 16px; font: inherit; font-size: 13px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); white-space: nowrap; }
.tag.green { background: #e8f3ed; color: var(--green); }
.tag.red { background: #faeaea; color: var(--danger); }
.tag.orange { background: #f9efe1; color: var(--orange); }
.tag.blue { background: #e9eef5; color: var(--blue); }
.tag.demo { background: #f0e9f5; color: #6c4a83; }

.works { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.work { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.work-image { position: relative; background: linear-gradient(180deg, #f6f1e8, #efe7dc); aspect-ratio: 4 / 5; display: grid; place-items: center; overflow: hidden; }
.work-image img { width: 100%; height: 100%; object-fit: contain; }
.work-info { padding: 12px 14px; display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.work-info h3 { font-size: 15px; font-weight: 600; }
.work-info p { font-size: 11px; color: var(--muted); }
.work-open { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.86); border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; letter-spacing: .06em; border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap; }
td { border-bottom: 1px solid #f0eae1; padding: 9px 10px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.changed td { background: #fdf6ef; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.empty { text-align: center; color: var(--muted); padding: 36px 20px; font-size: 13px; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(32, 27, 22, .45); }
.modal-card { width: min(720px, 100%); max-height: 88vh; overflow: auto; background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); padding: 24px; border: 1px solid var(--line); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.modal-close { border: 0; background: var(--paper-2); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 16px; color: var(--ink); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 12.5px; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 200;
  max-width: min(680px, calc(100% - 40px));
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; font-family: var(--serif); font-weight: 500; line-height: 1.15; }
.stat span { font-size: 11px; color: var(--muted); letter-spacing: .05em; }

.progress { height: 6px; background: var(--paper-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .35s ease; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(0,0,0,.12); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.split { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 22px; align-items: start; }
.split.wide-left { grid-template-columns: minmax(0, 1fr) minmax(0, 420px); }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.scroll-x { overflow-x: auto; }

.image-frame { background: linear-gradient(180deg, #f6f1e8, #eee6da); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: grid; place-items: center; position: relative; min-height: 220px; }
.image-frame img { display: block; width: 100%; height: auto; max-height: 560px; object-fit: contain; }
.image-frame .frame-label { position: absolute; left: 12px; top: 12px; }
.image-frame .frame-actions { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; }

.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.preview-card { background: #f6f1e8; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.preview-card img { width: 100%; aspect-ratio: 4/5; object-fit: contain; display: block; }
.preview-card p { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* Palette */
.palette-families { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.palette-families button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 11px; color: var(--muted); cursor: pointer; }
.palette-families button.selected { background: var(--blue); color: #fff; border-color: var(--blue); }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 7px; overflow: hidden; transition: max-height .25s ease; }
.palette-grid.folded { max-height: 78px; }
.color-chip { width: 100%; aspect-ratio: 1; border-radius: 8px; border: 1px solid rgba(0,0,0,.12); cursor: pointer; position: relative; padding: 0; }
.color-chip[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.color-chip span { position: absolute; inset: auto 0 2px 0; text-align: center; font-size: 7px; color: rgba(0,0,0,.55); line-height: 1; }
.schemes { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 8px 0 4px; }
.scheme { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 7px 9px; cursor: pointer; font: inherit; font-size: 11px; text-align: left; }
.scheme:hover { border-color: var(--ink-2); }
.scheme b { display: block; font-weight: 500; margin-bottom: 4px; }
.scheme i { display: inline-block; width: 16px; height: 16px; border-radius: 50%; margin-right: 3px; border: 1px solid rgba(0,0,0,.12); }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.slot { border: 1px solid var(--line-2); background: #fff; border-radius: 10px; padding: 8px; cursor: pointer; text-align: left; font: inherit; font-size: 11px; }
.slot.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(183,61,75,.12); }
.slot .swatch { display: block; height: 22px; border-radius: 6px; margin-bottom: 5px; border: 1px solid rgba(0,0,0,.1); }

/* Viewer */
.viewer { position: relative; background: radial-gradient(120% 100% at 50% 0%, #fff 0%, #f4eee4 55%, #eae0d3 100%); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.viewer canvas { display: block; width: 100%; aspect-ratio: 4 / 3; touch-action: none; cursor: grab; }
.viewer canvas:active { cursor: grabbing; }
.viewer .tag { position: absolute; top: 12px; left: 12px; }
.viewer-hint { position: absolute; bottom: 10px; left: 12px; font-size: 10.5px; color: var(--muted); background: rgba(255,255,255,.7); padding: 3px 8px; border-radius: 999px; }
.viewer-controls { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.viewer-controls button { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 11px; cursor: pointer; }
.viewer-controls button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Region overlay */
.region-stage { position: relative; display: block; width: 100%; max-width: 360px; }
.region-stage img { display: block; width: 100%; height: auto; }
.region-box { position: absolute; border: 2px solid var(--accent); background: rgba(183,61,75,.12); border-radius: 3px; cursor: pointer; }
.region-box.dismiss { border-color: var(--muted); background: rgba(120,110,100,.12); }
.region-box.focused { box-shadow: 0 0 0 3px rgba(183,61,75,.25); }

/* Admin */
.admin-body { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.admin-side { background: #1f2a3a; color: #d8dee8; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; }
.admin-brand { color: #fff; font-family: var(--serif); font-size: 20px; letter-spacing: .04em; padding: 4px 10px 16px; }
.admin-brand small { display: block; color: #8fa0b8; font-family: var(--sans); font-size: 9px; letter-spacing: .18em; margin-top: 4px; }
.admin-side button { border: 0; background: transparent; color: #c8d1de; text-align: left; padding: 9px 12px; border-radius: 7px; font: inherit; font-size: 12.5px; cursor: pointer; }
.admin-side button:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-side button.active { background: #b73d4b; color: #fff; }
.admin-side .side-foot { margin-top: auto; font-size: 10px; color: #8fa0b8; padding: 12px 10px; }
.admin-main { background: #f5f6f8; min-width: 0; }
.admin-top { display: flex; align-items: center; gap: 14px; background: #fff; border-bottom: 1px solid #e3e6ec; padding: 12px 24px; position: sticky; top: 0; z-index: 10; }
.admin-top .crumb { font-size: 12px; color: #7d8798; }
.admin-content { padding: 22px 24px 50px; }
.admin-content .panel { box-shadow: 0 1px 2px rgba(20,30,50,.04); }
.admin-content h1 { font-family: var(--sans); font-size: 20px; font-weight: 600; }
.admin-content .page-head p { font-size: 12px; }
.admin-content .stat { background: #fff; border-color: #e3e6ec; }
.admin-content .stat b { font-family: var(--sans); font-size: 24px; }
.admin-content th { background: #fafbfc; color: #6d7787; }
.admin-content td { border-color: #eef0f4; }
.admin-content .tag { background: #f1f3f7; }
.admin-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.admin-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; background: #eef1f6; color: #556176; }
.admin-pill.green { background: #e7f3ec; color: #2a7158; }
.admin-pill.red { background: #fbeaea; color: #a83a3a; }
.admin-pill.orange { background: #fbf0e2; color: #a76a22; }

/* Landing / portal */
.landing-hero {
  position: relative; border-radius: 24px; overflow: hidden; min-height: 340px;
  background: #1c2430 url('/assets/fashion-editorial.png') center 30% / cover no-repeat;
  display: flex; align-items: flex-end; color: #fff;
}
.landing-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20,22,28,.72), rgba(20,22,28,.12) 70%); }
.landing-copy { position: relative; z-index: 1; padding: 34px; max-width: 560px; }
.landing-copy h1 { color: #fff; font-size: clamp(30px, 5vw, 52px); line-height: 1.05; }
.landing-copy h1 em { color: #f3c9a8; font-style: italic; }
.landing-copy p { color: #e6e2da; margin-top: 12px; font-size: 13.5px; }
.landing-copy .row { margin-top: 20px; }
.app-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.app-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; color: var(--ink); text-decoration: none; transition: .15s ease; }
.app-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; border-color: var(--line-2); }
.app-card .no { font-family: var(--serif); color: var(--muted); font-size: 12px; letter-spacing: .16em; }
.app-card h3 { margin: 10px 0 4px; font-size: 16px; }
.app-card p { color: var(--muted); font-size: 12px; min-height: 36px; }
.app-card .go { display: inline-block; margin-top: 12px; font-size: 12px; color: var(--accent-ink); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.login-art { background: #1c2430 url('/assets/fashion-editorial.png') center/cover no-repeat; position: relative; }
.login-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(20,22,28,.6), rgba(20,22,28,.1)); }
.login-art-copy { position: absolute; left: 34px; bottom: 34px; z-index: 1; color: #fff; }
.login-art-copy h2 { font-family: var(--serif); font-size: 30px; font-weight: 500; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 30px; background: var(--paper); }
.login-card { width: min(420px, 100%); }

@media (max-width: 1000px) {
  .split, .split.wide-left { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { min-height: 220px; }
  .admin-body { grid-template-columns: 1fr; }
  .admin-side { flex-direction: row; overflow-x: auto; align-items: center; padding: 10px; }
  .admin-brand { padding: 0 12px 0 4px; white-space: nowrap; }
  .admin-side button { white-space: nowrap; }
  .admin-side .side-foot { display: none; }
}
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar-app { display: none; }
  .container, .container-narrow { width: calc(100% - 24px); }
  .panel { padding: 16px; }
  .landing-copy { padding: 22px; }
  .page-head { align-items: flex-start; }
  th, td { padding: 8px 7px; }
  .admin-content { padding: 14px 12px 40px; }
  .admin-top { padding: 10px 14px; }
  .modal-card { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
