:root {
  --bg: #F1ECE3; --card: #FFFDF9; --glass: rgba(255, 253, 249, .82); --ink: #242321; --muted: #77726A; --line: #E6E0D5;
  --orange: #FF5A24; --soft: #F6F2EB; --shadow: 0 10px 30px rgba(36, 35, 33, .10);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
body.night { --bg: #121418; --card: #1C1F25; --glass: rgba(28, 31, 37, .82); --ink: #EEF0F3; --muted: #9AA0AA; --line: #2C3038; --soft: #252932; --shadow: 0 10px 30px rgba(0, 0, 0, .35); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; transition: background .4s; }
a { color: var(--orange); text-decoration: none; font-weight: 600; }
button, select { font: inherit; color: inherit; }
.logo { width: 22px; height: 22px; border-radius: 7px; background: var(--ink); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--orange); }
.logo.big { width: 44px; height: 44px; border-radius: 14px; } .logo.big::after { inset: 12px; }

.app { display: flex; height: 100vh; height: 100dvh; }

/* 侧栏 */
.side { width: 304px; flex: none; margin: 12px 0 12px 12px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 3; overflow: hidden; }
.side-top { padding: 18px 18px 10px; display: flex; justify-content: space-between; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; }
.brand b { font-weight: 800; letter-spacing: -.02em; } .brand .sub { color: var(--muted); font-size: 13px; font-weight: 500; }
.links { display: flex; gap: 10px; font-size: 12.5px; }
.board { margin: 4px 14px 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.board div { background: var(--soft); border-radius: 14px; padding: 8px 4px 7px; text-align: center; font-size: 11.5px; color: var(--muted); }
.board b { display: block; font-size: 20px; color: var(--ink); line-height: 1.15; font-variant-numeric: tabular-nums; }
.board .o b { color: var(--orange); }
.side-head { display: flex; justify-content: space-between; padding: 0 18px 6px; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.staff { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; scrollbar-width: thin; }
.staff li { display: flex; gap: 11px; align-items: center; padding: 8px 10px; border-radius: 16px; cursor: pointer; transition: background .15s, transform .15s; outline: none; }
.staff li:hover, .staff li:focus-visible { background: var(--soft); }
.staff li.on { background: var(--soft); box-shadow: inset 3px 0 0 var(--orange); }
.staff .av { width: 44px; height: 44px; flex: none; border-radius: 50%; overflow: hidden; background: color-mix(in srgb, var(--c) 16%, var(--card)); display: grid; place-items: end center; }
.staff .av svg { width: 44px; height: 50px; margin-bottom: -6px; }
.staff .who { min-width: 0; flex: 1; }
.row1 { display: flex; gap: 6px; align-items: center; }
.staff .who b { font-size: 14.5px; }
.staff .who em { font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.staff .who p { margin: 1px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 舞台 */
.stage { position: relative; flex: 1; min-width: 0; }
.scene { position: absolute; inset: 0; }
.scene canvas { display: block; touch-action: none; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap; border: 0; font: inherit;
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--ink);
  border-radius: 999px; padding: 4px 11px 4px 6px; font-size: 12.5px; display: flex; gap: 6px; align-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .14); transition: opacity .2s; }
.lbl i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.lbl b { font-weight: 700; }
.lbl small { display: none; color: var(--muted); font-size: 11.5px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.labels.near .lbl small, .lbl:hover small { display: inline; }
.lbl:hover { z-index: 2; }
body.editing .lbl { opacity: .3; pointer-events: none; }

.toolbar { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; display: flex; gap: 8px; z-index: 2; }
.tb { height: 40px; padding: 0 14px; border-radius: 13px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  cursor: pointer; font-weight: 600; box-shadow: var(--shadow); transition: transform .12s; white-space: nowrap; }
.tb:active { transform: scale(.97); }
.tb.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.tb.danger { color: #D93A2B; } .tb.ghost { box-shadow: none; }
.tb.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 11px; }
body.editing #edit-btn { display: none; }
.tip { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; font-size: 12px; color: var(--muted); background: var(--glass); padding: 4px 12px; border-radius: 999px; pointer-events: none; }
body.editing .tip { display: none; }

/* 编辑器 */
.editor { position: absolute; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 2; max-width: 820px; margin: 0 auto;
  background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line); border-radius: 22px; padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.ed-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.ed-head b { font-size: 15px; } .ed-hint { color: var(--muted); font-size: 12.5px; flex: 1; }
.save-state { font-size: 12px; color: #1F7A4D; }
.palette { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.palette::-webkit-scrollbar { display: none; }
.palette button { flex: none; width: 76px; border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 9px 4px 7px; cursor: pointer; font-size: 12px; display: grid; justify-items: center; gap: 4px; transition: transform .12s, border-color .12s; }
.palette button:hover { border-color: var(--orange); transform: translateY(-2px); }
.palette button span { font-size: 24px; line-height: 1; }
.sel-bar { display: flex; gap: 8px; align-items: center; background: color-mix(in srgb, var(--orange) 10%, var(--card)); border-radius: 14px; padding: 6px 8px 6px 14px; }
.sel-bar span { flex: 1; font-weight: 600; }
.ed-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ed-foot label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.ed-foot select { height: 34px; border-radius: 11px; border: 1px solid var(--line); background: var(--card); padding: 0 8px; }
.grow { flex: 1; }

/* 加载 */
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 5; transition: opacity .5s; }
.loading.done { opacity: 0; pointer-events: none; }
.ld-card { display: grid; justify-items: center; gap: 12px; color: var(--muted); }
.ld-card p { margin: 0; }
.bar { width: 160px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { display: block; width: 40%; height: 100%; background: var(--orange); border-radius: 4px; animation: ld 1.1s ease-in-out infinite; }
@keyframes ld { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* 员工详情 */
.panel { position: fixed; inset: 0; z-index: 10; background: rgba(20, 20, 22, .35); display: flex; justify-content: flex-end; padding: 12px; }
.panel-card { width: min(400px, 100%); height: 100%; overflow-y: auto; background: var(--card); border-radius: 22px; padding: 24px 22px calc(24px + env(safe-area-inset-bottom)); position: relative; box-shadow: var(--shadow); animation: slide .25s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.close { position: absolute; right: 12px; top: 10px; width: 44px; height: 44px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--muted); }
.p-head { display: flex; gap: 14px; align-items: center; }
.p-avatar { width: 76px; height: 76px; flex: none; border-radius: 50%; overflow: hidden; background: color-mix(in srgb, var(--c) 16%, var(--card)); display: grid; place-items: end center; }
.p-avatar svg { width: 76px; height: 86px; margin-bottom: -10px; }
.p-head h2 { margin: 0; font-size: 24px; } .p-role { margin: 2px 0 0; color: var(--muted); }
.panel h3 { font-size: 12px; color: var(--muted); margin: 20px 0 6px; letter-spacing: .05em; }
.panel p { margin: 0; }
.p-notes { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.p-notes li { background: var(--soft); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; }
.p-files { padding: 0; list-style: none; margin: 0; font: 12.5px/1.9 ui-monospace, SFMono-Regular, Menlo, monospace; }
.p-files .no { color: var(--muted); }
.btn { display: block; text-align: center; margin-top: 24px; height: 50px; line-height: 50px; border-radius: 14px; background: var(--orange); color: #fff; font-weight: 700; font-size: 15px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px !important; text-align: center; }

@media (prefers-reduced-motion: reduce) { .panel-card, .bar i { animation: none; } }
@media (max-width: 760px) {
  .app { flex-direction: column-reverse; }
  .side { width: auto; margin: 0 8px calc(8px + env(safe-area-inset-bottom)); border-radius: 18px; flex: none; }
  .side-top, .board, .side-head { display: none; }
  .staff { display: flex; overflow-x: auto; overflow-y: hidden; padding: 8px; gap: 2px; flex: none; }
  .staff li { flex-direction: column; gap: 3px; padding: 6px 4px; min-width: 62px; }
  .staff .who p, .staff .who em { display: none; }
  .staff .who b { font-size: 12px; }
  .toolbar { left: 10px; right: 10px; top: calc(10px + env(safe-area-inset-top)); }
  .toolbar .tb { flex: 1; padding: 0 8px; font-size: 13px; }
  .tip { display: none; }
  .editor { left: 8px; right: 8px; bottom: 8px; padding: 12px; }
  .ed-hint { display: none; }
  .panel { align-items: flex-end; padding: 0; }
  .panel-card { height: auto; max-height: 88vh; border-radius: 22px 22px 0 0; animation: none; }
}
