:root {
  --ink: #2a241f;
  --soft: #6a5f55;
  --cream: #f7f1e6;
  --wood: #c4a07a;
  --denim: #7ea0c0;
  --gold: #d4b056;
  --tomato: #e4572e;
  --ok: #3d8f6e;
  --shadow: rgba(42, 36, 31, 0.2);
  --display: "Fraunces", Georgia, serif;
  --body: "Figtree", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: var(--body); color: var(--ink); }
body { min-height: 100vh; }

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 20% 0%, #fff8ee, transparent 55%),
    radial-gradient(800px 480px at 90% 10%, #e7f0f6, transparent 50%),
    linear-gradient(160deg, #e8dcc8 0%, #d5c4ae 40%, #c7b8a4 100%);
}

.top, .layout { position: relative; z-index: 1; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  padding: 20px 24px 8px;
  flex-wrap: wrap;
}

.top h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 700;
}
.top h1 span { color: var(--soft); font-weight: 500; font-size: 0.7em; }
.top p { margin: 4px 0 0; color: var(--soft); font-size: 13px; }

.col__desc {
  margin: 0;
  font-size: 12px;
  color: var(--soft);
  line-height: 1.45;
  max-width: 360px;
  text-align: right;
}

.layout {
  display: grid;
  gap: 16px;
  padding: 12px 20px 28px;
}

.layout--2 {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 380px);
  align-items: start;
}

.col--scene {
  min-height: 0;
}

.col--panel {
  background: transparent;
  border: 0;
  padding: 0;
  box-shadow: none;
}

/* 右侧模块：时钟与专注同款卡片对齐 */
.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding-right: 2px;
}

.panel .mod,
.panel .wardrobe {
  padding: 14px;
  border-radius: 16px;
  background: rgba(247, 241, 230, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 10px 22px rgba(42, 36, 31, 0.08);
}

.panel h3 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 17px;
}

.mod__foot {
  margin-top: 10px;
  display: flex;
  align-items: center;
}

.mod__head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mod__head-row h3 { margin: 0; }

.btn--block {
  width: 100%;
  margin-top: 4px;
}

.btn--sm {
  padding: 6px 10px;
  font-size: 12px;
}

.period-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(126, 160, 192, 0.22);
  color: #35586d;
  font-size: 12px;
  font-weight: 700;
}

/* 穿搭 Look（参考 UI） */
.look-mod__title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--body);
}

.look-mod__title em {
  font-family: var(--display);
  font-style: normal;
  font-weight: 700;
  margin-left: 4px;
}

.look-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

@media (min-width: 340px) {
  .look-grid { grid-template-columns: repeat(3, 1fr); }
}

.look-btn {
  border: 1px solid rgba(42, 36, 31, 0.1);
  background: rgba(255, 255, 255, 0.65);
  border-radius: 14px;
  padding: 12px 12px 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  box-shadow: 0 0 0 0 transparent;
  border-bottom-width: 3px;
}

.look-btn:hover { background: #fff; }
.look-btn.is-active {
  background: rgba(61, 111, 90, 0.14);
  border-color: rgba(61, 111, 90, 0.35);
  box-shadow: 0 4px 14px rgba(61, 111, 90, 0.12);
}

.look-btn__name {
  display: block;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}

.look-btn__meta {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--soft);
}

.with-chip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  font-family: var(--body);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(228, 87, 46, 0.14);
  color: var(--tomato);
}

/* 交互状态机：树状串联 */
.state-tree {
  margin: 0;
  padding: 14px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(42, 36, 31, 0.06);
  font-family: "SF Mono", "Menlo", "Consolas", ui-monospace, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-soft, #6a5f55);
  white-space: pre;
  overflow: auto;
  max-height: 420px;
}

.state-tree--lg {
  max-height: none;
  font-size: 13.5px;
  line-height: 1.6;
  padding: 24px;
  width: min(920px, 100%);
}

.state-tree .st-on {
  color: #2f6b52;
  font-weight: 700;
  background: rgba(61, 111, 90, 0.12);
  border-radius: 4px;
}

/* 全屏状态机 */
.fs-machine {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(232, 220, 200, 0.96);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
}

.fs-machine[hidden] { display: none !important; }

.fs-machine__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(42, 36, 31, 0.08);
}

.fs-machine__bar strong {
  font-family: var(--display);
  font-size: 18px;
}

.fs-machine__bar span {
  flex: 1;
  font-size: 12px;
  color: var(--soft);
}

.fs-machine__body {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: grid;
  place-items: start center;
}

.scene-wrap { position: relative; min-height: 560px; }

.pet-win {
  position: absolute;
  left: 6%;
  top: 4%;
  width: min(400px, 92%);
  border-radius: 22px;
  background: rgba(247, 241, 230, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.65);
  box-shadow: 0 22px 50px var(--shadow);
  overflow: hidden;
  animation: in .45s cubic-bezier(.2,.9,.2,1) both;
}

@keyframes in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.pet-win__bar, .pet-win__foot {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--soft);
}

.pet-win__bar span:first-child {
  font-family: var(--display);
  color: var(--ink);
  font-size: 14px;
}

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(61,143,110,.12);
  color: var(--ok);
  font-weight: 700;
}
.badge[data-k="focus"] { background: rgba(228,87,46,.12); color: var(--tomato); }
.badge[data-k="sleep"] { background: rgba(126,160,192,.25); color: #35586d; }
.badge[data-k="rest"] { background: rgba(212,176,86,.2); color: #8a6a1c; }

.scene {
  position: relative;
  height: 400px;
  margin: 0 12px;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.6), transparent 52%),
    linear-gradient(180deg, #eef4f7 0%, #e8dcc8 100%);
  cursor: grab;
  outline: none;
}
.scene:active { cursor: grabbing; }

/* 整帧状态图：角色+书桌同框锁定；禁止大小节律缩放 */
.scene__alice {
  width: min(92%, 340px);
  height: auto;
  max-height: 92%;
  object-fit: contain;
  pointer-events: none;
  transition: opacity .22s ease;
  filter: drop-shadow(0 10px 14px rgba(42,36,31,.16));
}

.scene__alice.is-lifted {
  filter: drop-shadow(0 16px 14px rgba(42,36,31,.22));
}

.scene__alice.is-portrait {
  width: min(70%, 240px);
  max-height: 85%;
}

.scene__caption {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(42,36,31,.78);
  color: #fff8ee;
  font-size: 11px;
  white-space: nowrap;
}

/* 素材未入库时顶掉浏览器碎图，并显示缺失的具体路径（见 app.js 的 bindAssetFallback） */
.scene__alice.is-missing { opacity: 0; }

/* display:flex 会盖掉 hidden 属性自带的 display:none，必须显式复位 */
.scene__missing[hidden] { display: none; }

.scene__missing {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(84%, 300px);
  padding: 18px 16px;
  border-radius: 16px;
  border: 1px dashed rgba(42, 36, 31, 0.28);
  background: rgba(255, 253, 249, 0.86);
  text-align: center;
}

.scene__missing strong {
  font-size: 13px;
  color: var(--tomato);
}

.scene__missing code {
  font-size: 11px;
  line-height: 1.5;
  color: var(--soft);
  word-break: break-all;
}

.toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(42,36,31,.9);
  color: #fff;
  font-size: 12px;
  z-index: 3;
  animation: toast .25s ease both;
}
@keyframes toast {
  from { opacity: 0; transform: translate(-50%, -6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.card {
  position: absolute;
  right: 16px;
  top: 16px;
  width: min(300px, calc(100% - 32px));
  padding: 16px;
  border-radius: 18px;
  background: rgba(247,241,230,.95);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 18px 40px var(--shadow);
  z-index: 5;
  animation: in .3s ease both;
}
.card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card h2 { margin: 0; font-family: var(--display); font-size: 20px; }
.icon {
  width: 30px; height: 30px; border: 0; border-radius: 10px;
  background: rgba(42,36,31,.06); font-size: 18px; cursor: pointer;
}
.card__meta { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.card__meta img { width: 52px; height: 52px; object-fit: cover; border-radius: 12px; background: #fff; }
.card__meta p { margin: 2px 0 0; font-size: 12px; color: var(--soft); }
.card dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 10px;
}
.card dl > div {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(126,160,192,.14);
}
.card dt { font-size: 11px; color: var(--soft); }
.card dd { margin: 2px 0 0; font-family: var(--display); font-size: 20px; font-weight: 700; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; margin-bottom: 10px; }
.badges span {
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: rgba(228,87,46,.12); color: var(--tomato);
}

.field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--soft);
  margin-bottom: 8px;
}
.field input {
  border: 1px solid rgba(42,36,31,.12);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.toggle {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--soft);
  margin: 6px 0;
  cursor: pointer;
}

.timer { text-align: center; padding: 6px 0 10px; }
.timer div:first-child {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--soft); font-weight: 700;
}
.timer__clock {
  font-family: var(--display);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -.03em;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid rgba(42,36,31,.12);
  background: rgba(255,255,255,.6);
  border-radius: 11px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}
.btn:hover { background: #fff; }
.btn--primary { background: #3d6f5a; border-color: #3d6f5a; color: #f4faf6; }
.btn--primary:hover { background: #325c4a; }
.btn--ghost { background: transparent; width: 100%; margin-top: 8px; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.grid button {
  border: 1px solid rgba(42,36,31,.1);
  background: rgba(255,255,255,.5);
  border-radius: 10px;
  padding: 8px 4px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.grid button.is-on {
  border-color: #3d6f5a;
  background: rgba(61,111,90,.12);
}

.note { margin: 8px 0 0; font-size: 12px; color: var(--soft); line-height: 1.45; }

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 160px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}
.log li {
  padding: 6px 8px;
  border-radius: 9px;
  background: rgba(42,36,31,.05);
  color: var(--soft);
}
.log strong { color: var(--ink); }

/* —— v4 tabs / compact / prompt library —— */
.top {
  align-items: center;
}
.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(247, 241, 230, 0.9);
  border: 1px solid rgba(42, 36, 31, 0.08);
}
.tabs__btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--soft);
  cursor: pointer;
}
.tabs__btn.is-on {
  background: #2a241f;
  color: #f7f1e6;
}
.col--scene .col__desc {
  margin-top: 10px;
  text-align: left;
  max-width: none;
}
.mod--compact .compact-row {
  display: flex;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
.mod--compact .field--grow { flex: 1; min-width: 0; margin: 0; }
.mod--compact .toggles {
  align-items: center;
  margin-bottom: 10px;
}
.timer--mini {
  min-width: 88px;
  text-align: right;
  padding: 4px 0;
}
.timer--mini .timer__clock {
  font-size: 22px;
  line-height: 1.1;
}
.mod--log .log { max-height: 120px; }
.mod--log .btn--ghost { width: auto; margin: 0; }

.prompt-view {
  position: relative;
  z-index: 1;
  padding: 8px 20px 40px;
  max-width: 1100px;
  margin: 0 auto;
}
.prompt-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 14px;
}
.prompt-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
}
.prompt-head p {
  margin: 6px 0 0;
  color: var(--soft);
  font-size: 13px;
  max-width: 520px;
  line-height: 1.45;
}
.prompt-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.prompt-search,
.prompt-tools select {
  border: 1px solid rgba(42, 36, 31, 0.12);
  background: rgba(247, 241, 230, 0.95);
  border-radius: 11px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}
.prompt-search { min-width: 220px; }
.prompt-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--soft);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(42, 36, 31, 0.06);
}
.prompt-compose {
  margin-bottom: 16px;
}
.prompt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(247, 241, 230, 0.9);
  border: 1px solid rgba(42, 36, 31, 0.08);
  font-size: 12px;
  color: var(--soft);
}
.prompt-meta strong { color: var(--ink); }
.prompt-cat {
  margin-bottom: 22px;
}
.prompt-cat h3 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 18px;
}
.prompt-cat h3 em {
  font-style: normal;
  font-family: var(--body);
  font-size: 12px;
  color: var(--soft);
  margin-left: 6px;
}
.prompt-cat__blurb {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--soft);
}
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}
.prompt-card {
  padding: 12px;
  border-radius: 14px;
  background: rgba(247, 241, 230, 0.92);
  border: 1px solid rgba(42, 36, 31, 0.08);
  box-shadow: 0 8px 18px rgba(42, 36, 31, 0.06);
}
.prompt-card__head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
  margin-bottom: 6px;
}
.prompt-card__head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.prompt-card__head code {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--soft);
}
.prompt-card__pads {
  font-size: 11px;
  color: #5a6f63;
  margin-bottom: 6px;
}
.prompt-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.prompt-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(61, 111, 90, 0.12);
  color: #2f5a48;
}
.prompt-card__text {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.prompt-empty {
  color: var(--soft);
  font-size: 14px;
  padding: 24px 0;
}

@media (max-width: 960px) {
  .layout--2 { grid-template-columns: 1fr; }
  .pet-win { left: 4%; top: 4%; position: relative; }
  .scene-wrap { min-height: 480px; }
  .panel { max-height: none; }
  .col__desc { text-align: left; max-width: none; }
  .prompt-grid { grid-template-columns: 1fr; }
}
