:root {
  --ink: #171614;
  --ink-2: #23211d;
  --paper: #e8dfcf;
  --paper-2: #f2eadc;
  --oxide: #9c4f2f;
  --iron: #6b6f68;
  --brass: #b48a52;
  --jade: #6b7f72;
  --line: rgba(34,31,26,.22);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--paper-2);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}
button, input { font: inherit; }

#app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 100vh;
}

#studio {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  padding: 14px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(212,199,170,.05), transparent 45%),
    #11110f;
}
/* 画布 contain：任何屏幕都完整可见（不再被容器裁剪） */
#canvasWrap {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}
#canvasWrap canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  aspect-ratio: 1600 / 1500;
  display: block;
  box-shadow: 0 24px 70px rgba(0,0,0,.42);
}

/* 全屏按钮（悬浮右上，桌面/移动通用） */
#fsBtn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 30;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(232,223,207,.22);
  background: rgba(17,17,15,.55);
  backdrop-filter: blur(6px);
  color: var(--paper-2);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .18s, color .18s;
}
#fsBtn:hover { background: var(--oxide); border-color: var(--oxide); }
#studio:fullscreen { padding: 0; }
#studio:fullscreen #fsBtn { top: 12px; right: 12px; }
body.is-fs #consoleTab { display: none; }

/* 控制台抽屉手柄（窄屏显示，桌面隐藏） */
#consoleTab {
  display: none;
}

#epochOverlay {
  position: absolute;
  left: 26px;
  bottom: 22px;
  pointer-events: none;
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-size: 13px;
  letter-spacing: .08em;
  color: rgba(232,223,207,.78);
  text-transform: uppercase;
}
#epochOverlay span:first-child {
  font-weight: 700;
  color: var(--paper);
  font-size: 15px;
}

#console {
  background: linear-gradient(180deg, var(--ink-2), #1d1b18 100%);
  border-left: 1px solid rgba(232,223,207,.12);
  padding: 18px 16px 24px;
  overflow-y: auto;
  max-height: 100vh;
}

header .eyebrow {
  color: var(--brass);
  font-size: 11px;
  letter-spacing: .2em;
}
header h1 {
  margin: 8px 0 6px;
  font-size: 25px;
  letter-spacing: 0;
  line-height: 1.18;
}
header p {
  margin: 0 0 16px;
  color: rgba(232,223,207,.66);
  font-size: 12px;
  line-height: 1.7;
}

.timeBlock {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.metric {
  padding: 10px 12px;
  background: rgba(232,223,207,.06);
  border: 1px solid rgba(232,223,207,.11);
  border-radius: 6px;
}
.metric span {
  display: block;
  color: rgba(232,223,207,.5);
  font-size: 11px;
}
.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--paper);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

#historyCanvas {
  width: 100%;
  height: 128px;
  background: #121210;
  border: 1px solid rgba(232,223,207,.12);
  border-radius: 6px;
  margin-bottom: 14px;
}

.panel {
  padding: 12px;
  margin-bottom: 14px;
  background: rgba(232,223,207,.055);
  border: 1px solid rgba(232,223,207,.12);
  border-radius: 6px;
}
.panelTitle {
  font-size: 12px;
  letter-spacing: .12em;
  color: var(--brass);
  margin-bottom: 10px;
}
.sliderRow {
  margin: 8px 0;
}
.sliderRow label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(232,223,207,.8);
  font-size: 12px;
}
.sliderRow output {
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}
.sliderRow input[type=range] {
  width: 100%;
  margin-top: 5px;
  accent-color: var(--oxide);
}

#dnaBars {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.dnaRow {
  display: grid;
  grid-template-columns: 66px 1fr 28px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: rgba(232,223,207,.62);
}
.dnaTrack {
  height: 5px;
  background: rgba(232,223,207,.1);
  border-radius: 99px;
}
.dnaFill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--jade), var(--brass) 55%, var(--oxide));
}
.dnaValue { text-align: right; color: var(--paper-2); }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.actions button {
  padding: 10px 8px;
  border-radius: 6px;
  border: 1px solid rgba(232,223,207,.18);
  background: transparent;
  color: var(--paper-2);
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s;
}
.actions button:hover {
  background: var(--oxide);
  border-color: var(--oxide);
}
.actions button.snd-on {
  background: rgba(107,127,114,.4);
  border-color: var(--jade);
}

@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; }
  /* 画布占满视口（完整 contain），底部预留抽屉手柄 */
  #studio {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 10px 10px calc(52px + env(safe-area-inset-bottom));
  }
  /* 控制台 → 底部抽屉：默认只露手柄，点击展开 */
  #console {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    max-height: 44dvh;
    border-left: none;
    border-top: 1px solid rgba(232,223,207,.16);
    border-radius: 16px 16px 0 0;
    padding: 0 14px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;
    transform: translateY(calc(100% - 48px));
    transition: transform .3s ease;
    box-shadow: 0 -16px 46px rgba(0,0,0,.5);
    background: linear-gradient(180deg, rgba(35,33,29,.97), rgba(29,27,24,.98) 100%);
    backdrop-filter: blur(10px);
  }
  body.console-open #console { transform: translateY(0); }
  #consoleTab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 14px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    color: var(--paper-2);
    font-size: 13px;
    letter-spacing: .12em;
    border-bottom: 1px solid rgba(232,223,207,.1);
    margin: 0 -14px 10px;
    position: sticky;
    top: -1px;
    z-index: 2;
    background: rgba(35,33,29,.95);
    backdrop-filter: blur(8px);
    border-radius: 16px 16px 0 0;
  }
  #consoleTab i { font-style: normal; transition: transform .3s ease; }
  body.console-open #consoleTab i { transform: rotate(180deg); }
  header h1 { font-size: 21px; }
  #epochOverlay {
    left: 14px;
    bottom: 62px;
    gap: 8px;
    font-size: 11.5px;
    max-width: calc(100% - 60px);
  }
  #epochOverlay span:first-child { font-size: 13px; }
}
@media (max-width: 640px) {
  #epochOverlay {
    left: 12px;
    top: 12px;
    bottom: auto;
    gap: 8px;
    flex-wrap: wrap;
    max-width: calc(100% - 64px);
  }
  #fsBtn { top: 10px; right: 10px; width: 38px; height: 38px; }
  .actions { grid-template-columns: 1fr; }
  .timeBlock { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .dnaRow { grid-template-columns: 52px 1fr 24px; gap: 5px; }
  #console { max-height: 48dvh; }
}
