/* NAI RELAY · 创作工作台（浅色三栏） */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

.wk {
  --bg: #f6f4f1;
  --panel: #fff;
  --line: #e9e5df;
  --line-2: #f1ede7;
  --ink: #1b1a18;
  --ink-2: #6c6862;
  --ink-3: #a09b93;
  --accent: #ff6a1a;
  --accent-2: #f26312;
  --accent-soft: #fff2e9;
  --accent-line: #ffd7bf;
  --ok: #2f9e63;
  --r: 12px;
  --shadow: 0 1px 2px rgba(28, 25, 22, .04), 0 8px 24px -18px rgba(28, 25, 22, .28);

  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.wk ::selection { background: #ffd9c4; }
.wk button, .wk input, .wk select, .wk textarea { font: inherit; color: inherit; }
.wk .hidden { display: none !important; }

/* ---------------- 顶栏 ---------------- */
.wk-top {
  flex: none;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; flex: none; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(145deg, #ff8a45, #f2540d);
  box-shadow: 0 4px 12px -5px rgba(242, 84, 13, .8);
  color: #fff; font-weight: 800; font-size: 13px;
}
.brand .mark img { width: 100%; height: 100%; object-fit: cover; }
.brand .txt { display: flex; flex-direction: column; line-height: 1.2; }
.brand .txt b { font-size: 13px; letter-spacing: .01em; }
.brand .txt span { font-size: 10px; color: var(--ink-3); letter-spacing: .04em; }

.wk-vline { width: 1px; height: 22px; background: var(--line); flex: none; }

.wk-model {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 5px 10px 5px 9px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; box-shadow: 0 1px 1px rgba(28, 25, 22, .03);
}
.wk-model .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none;
  box-shadow: 0 0 0 3px rgba(47, 158, 99, .14);
}
.wk-model select {
  appearance: none; -webkit-appearance: none;
  border: 0; background: transparent; outline: none; cursor: pointer;
  font-size: 12px; font-weight: 600; max-width: 230px;
  padding-right: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236c6862' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center; background-size: 11px;
}

.wk-spacer { flex: 1; }

.chip.credits {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--accent-line); background: var(--accent-soft);
  color: #b54a10; font-size: 11.5px; font-weight: 600;
}
.chip.credits svg { width: 13px; height: 13px; }
.chip.credits b { font-weight: 700; }

.sbtn.pill {
  display: inline-flex; align-items: center; justify-content: center;
  height: 30px; padding: 0 13px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 12px; font-weight: 600; transition: .16s;
}
.sbtn.pill:hover { background: #faf8f5; color: var(--ink); }
.sbtn.pill.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sbtn.pill.primary:hover { background: var(--accent-2); }

.avatar-l {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; text-decoration: none;
  background: #221f1c; color: #fff; font-size: 12px; font-weight: 700;
}
.icon-btn {
  display: none; width: 32px; height: 32px; border-radius: 9px; place-items: center;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; }

/* ---------------- 主体三栏 ---------------- */
.wk-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 348px minmax(0, 1fr) 206px;
}

/* 左侧参数栏 */
.wk-panel {
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.panel-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 11px 12px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: #ded9d2 transparent;
}
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: #ded9d2; border-radius: 8px; }

.pcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  flex: none;
}
.pcard-h {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 8px;
}
.pcard-h .t {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .01em;
}
.pcard-h .t svg { width: 14px; height: 14px; color: var(--ink-3); flex: none; }
.pcard-h .grow { flex: 1; }
.pcard-b { padding: 0 12px 10px; }

.mini {
  font-size: 11px; color: var(--ink-3); font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.mini.link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent-2); font-size: 11px; font-weight: 600;
}
.mini.link:hover { text-decoration: underline; }

/* 折叠箭头 */
.card-fold {
  width: 20px; height: 20px; border: 0; background: none; cursor: pointer; padding: 0;
  display: grid; place-items: center; color: var(--ink-3); border-radius: 6px;
  transition: transform .2s ease, background .16s;
}
.card-fold:hover { background: #f5f1ec; }
.pcard.collapsed .card-fold { transform: rotate(-90deg); }
.pcard.collapsed .pcard-b { display: none; }

/* 模型卡 */
.model-row { display: flex; align-items: center; gap: 8px; }
.select-wrap { position: relative; flex: 1; min-width: 0; }
.select-wrap select, .pselect {
  width: 100%; appearance: none; -webkit-appearance: none;
  height: 32px; padding: 0 30px 0 11px;
  border: 1px solid var(--line); border-radius: 9px; background: #fdfcfa;
  font-size: 12.5px; font-weight: 600; cursor: pointer; outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.select-wrap select:focus, .pselect:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(255, 106, 26, .1); }
.select-wrap::after {
  content: ""; position: absolute; right: 11px; top: 50%; width: 8px; height: 8px;
  margin-top: -6px; border-right: 1.6px solid #8d8780; border-bottom: 1.6px solid #8d8780;
  transform: rotate(45deg); pointer-events: none;
}
.tag-pill {
  flex: none; height: 24px; display: inline-flex; align-items: center; padding: 0 9px;
  border-radius: 999px; background: #f3f0ec; color: var(--ink-2);
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
}
.model-note {
  margin-top: 8px; font-size: 11px; line-height: 1.6; color: var(--ink-3);
}

/* 提示词 */
.ptabs {
  display: flex; gap: 4px; padding: 3px; margin-bottom: 9px;
  background: #f5f2ee; border-radius: 9px;
}
.ptab {
  flex: 1; height: 28px; border: 0; border-radius: 7px; background: transparent;
  color: var(--ink-2); font-size: 11.5px; font-weight: 600; cursor: pointer; transition: .16s;
}
.ptab:hover { color: var(--ink); }
.ptab.on { background: var(--accent-soft); color: #c2521a; box-shadow: inset 0 0 0 1px var(--accent-line); }

.ptextarea {
  width: 100%; min-height: 132px; max-height: 300px; resize: vertical;
  padding: 9px 10px; border: 1px solid var(--line-2); border-radius: 9px;
  background: #fdfcfa; font-size: 12.5px; line-height: 1.72; outline: none;
  transition: border-color .16s, background .16s;
}
.ptextarea::placeholder { color: #b6b1a9; }
.ptextarea:focus { border-color: var(--accent-line); background: #fff; }

.pmeta {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  font-size: 11px; color: var(--ink-3);
}
.pmeta .grow { flex: 1; }
.chiprow { display: flex; flex-wrap: wrap; gap: 5px; }
.pick {
  height: 24px; padding: 0 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 11px; font-weight: 500; transition: .15s;
}
.pick:hover { border-color: #ddd6cd; color: var(--ink); background: #faf8f5; }
.pick.on {
  border-color: var(--accent-line); background: var(--accent-soft); color: #c2521a; font-weight: 600;
}

/* 角色提示 */
.char-list { display: flex; flex-direction: column; gap: 7px; }
.char-row { display: flex; gap: 6px; align-items: center; }
.char-idx {
  flex: none; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  background: #f3f0ec; color: var(--ink-2); font-size: 10.5px; font-weight: 700;
}
.char-input {
  flex: 1; min-width: 0; height: 32px; padding: 0 9px;
  border: 1px solid var(--line-2); border-radius: 8px; background: #fdfcfa;
  font-size: 12px; outline: none;
}
.char-input:focus { border-color: var(--accent-line); background: #fff; }
.char-del {
  flex: none; width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-3); cursor: pointer; font-size: 13px; line-height: 1;
}
.char-del:hover { color: #c2370a; border-color: #f3c7b4; background: #fff7f3; }
.char-add {
  margin-top: 7px; width: 100%; height: 30px; border-radius: 8px; cursor: pointer;
  border: 1px dashed #ddd6cd; background: #fdfcfa; color: var(--ink-2);
  font-size: 11.5px; font-weight: 600;
}
.char-add:hover { border-color: var(--accent-line); color: var(--accent-2); background: var(--accent-soft); }
.char-empty { margin-top: 7px; font-size: 11px; line-height: 1.55; color: var(--ink-3); }

/* 参考图像 */
.ref-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 40px; padding: 7px 10px; cursor: pointer;
  border: 1px dashed #ddd6cd; border-radius: 9px; background: #fdfcfa;
  font-size: 11.5px; color: var(--ink-2); transition: .16s;
}
.ref-box:hover { border-color: var(--accent-line); background: var(--accent-soft); color: #b54a10; }
.ref-box.has { border-style: solid; border-color: var(--line); background: #fff; cursor: default; }
.ref-thumb { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; flex: none; }
.ref-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ref-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pfield { display: flex; flex-direction: column; gap: 5px; }
.pfield > label { font-size: 10.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.pinput {
  width: 100%; height: 32px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 8px; background: #fdfcfa;
  font-size: 12.5px; outline: none; transition: .16s;
}
.pinput:focus { border-color: var(--accent-line); background: #fff; }
.prow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.prow:last-child { margin-bottom: 0; }

/* 生成按钮 */
.gen-btn {
  flex: none;
  padding: 9px 12px 12px;
  background: var(--bg);
  border-top: 1px solid var(--line-2);
  z-index: 5;
}
.gen-btn button {
  width: 100%; height: 44px; border: 0; border-radius: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: linear-gradient(180deg, #ff7a2f, #f25e0b);
  color: #fff; font-size: 14px; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 10px 22px -12px rgba(242, 94, 11, .95), inset 0 1px 0 rgba(255, 255, 255, .28);
  transition: transform .14s, box-shadow .18s, filter .18s;
}
.gen-btn button:hover { transform: translateY(-1px); filter: brightness(1.03); }
.gen-btn button:active { transform: translateY(0) scale(.995); }
.gen-btn button:disabled { filter: grayscale(.4) brightness(.9); cursor: not-allowed; transform: none; box-shadow: none; }
.gen-btn .cost { font-size: 11px; font-weight: 500; opacity: .82; }

/* ---------------- 画布 ---------------- */
.wk-canvas {
  position: relative;
  min-width: 0;
  overflow: auto;
  background:
    radial-gradient(120% 90% at 50% 0%, #ffffff, #faf9f7 62%, #f4f2ee 100%);
}
.canvas-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center;
  pointer-events: none; padding: 24px;
}
.canvas-empty .ic {
  width: 34px; height: 34px; color: #d8d2c9; stroke-width: 1.4;
  margin-bottom: 2px;
}
.canvas-empty b { font-size: 13px; font-weight: 600; color: #8f8a82; }
.canvas-empty span { font-size: 11.5px; color: #b3ada4; }

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 22px;
  align-content: start;
  min-height: 100%;
}
.results:empty { padding: 0; }
.result {
  position: relative; border-radius: 12px; overflow: hidden;
  background: #fff; border: 1px solid var(--line);
  box-shadow: 0 12px 30px -22px rgba(28, 25, 22, .55);
}
.result img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.result .bar2 {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 22px 10px 9px;
  background: linear-gradient(to top, rgba(12, 10, 8, .78), rgba(12, 10, 8, 0));
  opacity: 0; transition: opacity .2s;
}
.result:hover .bar2 { opacity: 1; }
.result .bar2 button, .result .bar2 a {
  height: 26px; padding: 0 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .16);
  color: #fff; font-size: 11px; display: inline-flex; align-items: center;
  text-decoration: none; backdrop-filter: blur(6px);
}
.result .bar2 button:hover, .result .bar2 a:hover { background: rgba(255, 255, 255, .3); }

.loading {
  display: grid; place-items: center; min-height: 260px; border-radius: 12px;
  border: 1px dashed #e2dcd4; background: rgba(255, 255, 255, .6);
  color: #a8a29a; font-size: 12px;
  background-image: linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, .9) 50%, rgba(255, 255, 255, 0) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }

.canvas-tip {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  padding: 7px 13px; border-radius: 999px; background: rgba(27, 26, 24, .86);
  color: #fff; font-size: 11.5px; z-index: 8; backdrop-filter: blur(8px);
  transition: opacity .3s;
}

/* ---------------- 右栏 ---------------- */
.wk-rail {
  min-height: 0; overflow-y: auto; border-left: 1px solid var(--line);
  padding: 12px 10px; scrollbar-width: thin;
}
.wk-rail::-webkit-scrollbar { width: 7px; }
.wk-rail::-webkit-scrollbar-thumb { background: #e0dbd4; border-radius: 8px; }
.wk-rail > .t {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 700; color: var(--ink-2); margin: 2px 2px 10px;
}
.wk-rail > .t span:last-child {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #ece8e2; color: var(--ink-2);
  font-size: 10px; font-weight: 700; display: inline-grid; place-items: center;
}
#railList { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
#railList .item {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); background: #fff; transition: .18s;
}
#railList .item:hover { transform: translateY(-1px); box-shadow: 0 8px 18px -12px rgba(28, 25, 22, .6); border-color: var(--accent-line); }
#railList .item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------------- 提示条 ---------------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  padding: 9px 13px; border-radius: 10px; max-width: 320px;
  background: rgba(27, 26, 24, .92); color: #fff; font-size: 12px; line-height: 1.55;
  box-shadow: 0 14px 30px -16px rgba(0, 0, 0, .6);
  backdrop-filter: blur(8px);
}
.toast.bad { background: #b3300a; }

/* ---------------- 移动端 ---------------- */
@media (max-width: 1180px) {
  .wk-body { grid-template-columns: 320px minmax(0, 1fr) 0; }
  .wk-rail { display: none; }
}
/* ---------------- 标签补全 ---------------- */
.tag-pop {
  position: fixed; z-index: 70;
  display: flex; flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 48px -22px rgba(28, 25, 22, .38), 0 2px 8px rgba(28, 25, 22, .06);
  overflow: hidden;
}
.tag-pop[hidden] { display: none; }
.tag-pop-h {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-2);
  background: #fcfbf9;
  font-size: 11.5px; color: var(--ink-3);
  white-space: nowrap;
}
.tag-pop-h .tl { color: var(--ink-2); font-weight: 600; }
.tag-pop-h .tl b { color: var(--accent-2); font-weight: 700; margin: 0 1px; }
.tag-pop-h .tk { margin-left: auto; font-size: 10.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.tag-pop-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px; }
.tag-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 32px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent;
  text-align: left; cursor: pointer;
}
.tag-row .tg {
  flex: 1 1 auto; min-width: 0;
  font-size: 12.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tag-row .tg em { font-style: normal; color: var(--accent-2); font-weight: 600; }
.tag-row .zh {
  flex: 0 1 auto; max-width: 48%;
  font-size: 11.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tag-row:hover, .tag-row.on { background: var(--accent-soft); }
.tag-row.on .tg em { color: var(--accent-2); }
.tag-empty { padding: 14px 10px; font-size: 12px; color: var(--ink-3); text-align: center; }

@media (max-width: 900px) {
  .tag-pop-h .tk { display: none; }
  .tag-pop { max-height: 46vh !important; }
}

@media (max-width: 900px) {
  .wk-body { grid-template-columns: minmax(0, 1fr); }
  .wk-panel {
    position: fixed; left: 0; top: 56px; bottom: 0; width: min(92vw, 360px);
    border-right: 0;
    background: var(--bg); z-index: 40;
    transform: translateX(-102%); transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 24px 0 60px -30px rgba(0, 0, 0, .5);
  }
  .wk-panel.open { transform: none; }
  .icon-btn { display: grid; }
  .wk-top { gap: 8px; padding: 0 10px; }
  .brand .txt { display: none; }
  .wk-model { display: none; }
  .wk-vline { display: none; }
  .wk-top .sbtn.pill { display: none; }
  .chip.credits { height: 28px; padding: 0 9px; font-size: 11px; }
  .results { grid-template-columns: 1fr; padding: 14px; }
  .canvas-empty b { font-size: 12.5px; }
}
