:root {
  --paper: #f4eadb;
  --paper-deep: #e7d8c0;
  --card: #fffaf3;
  --ink: #2a2118;
  --muted: #7a6a58;
  --line: #e3d3ba;
  --seal: #8f2d24;
  --wood: #4a3023;
  --wood-hi: #6b4632;
  --gold: #9a6b28;
  --shadow: 0 18px 40px rgba(70, 42, 24, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fff8ec 0%, transparent 55%),
    linear-gradient(180deg, #f7f0e4 0%, var(--paper) 40%, #e9dcc6 100%);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }

.top {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 22px 10px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 220px; }

.seal {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 2px solid var(--seal);
  color: var(--seal);
  font-family: "Iowan Old Style", Palatino, "Songti SC", "STSong", serif;
  font-size: 26px;
  font-weight: 700;
  background: rgba(143, 45, 36, 0.04);
}

.brand h1 {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, "Songti SC", "STSong", serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.clockblock { min-width: 180px; }

.clock {
  font-family: "Iowan Old Style", Palatino, "Songti SC", serif;
  font-size: 40px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.when { margin-top: 4px; color: var(--muted); font-size: 13px; }

.stamp {
  margin-left: auto;
  min-width: 64px;
  padding: 8px 10px;
  text-align: center;
  border: 1.5px solid var(--seal);
  color: var(--seal);
  letter-spacing: 0.2em;
  font-family: "Songti SC", "STSong", serif;
}

.controls { display: flex; gap: 6px; }

.controls button, .tabs button {
  border: 1px solid #d9c7ad;
  background: var(--card);
  padding: 7px 12px;
  cursor: pointer;
}

.controls button.on, .tabs button.on {
  background: var(--ink);
  color: #f6efe4;
  border-color: var(--ink);
}

.controls button:hover, .tabs button:hover { border-color: var(--gold); }

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
}

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  padding: 12px 12px 8px 16px;
  gap: 8px;
}

.frame {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, var(--wood-hi), var(--wood));
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 236, 210, 0.25);
}

canvas {
  display: block;
  background: #d5e2bc;
  border-radius: 4px;
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
}

.tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  padding: 6px 8px;
  background: rgba(42, 33, 24, 0.92);
  color: #f6efe4;
  font-size: 12px;
  border-radius: 4px;
  max-width: 220px;
}

.legend, .mix {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.legend i, .mix i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: -1px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.mix {
  height: 22px;
  background: rgba(255, 250, 243, 0.7);
  border: 1px solid var(--line);
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.mix span {
  height: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2a2118;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
}

aside {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: rgba(255, 250, 243, 0.55);
}

.card {
  margin: 12px 12px 0;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
}

.card h2 {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, "Songti SC", serif;
  font-size: 24px;
  font-weight: 650;
}

.meta, .muted { color: var(--muted); font-size: 13px; }
.card .bio { margin: 8px 0; line-height: 1.55; font-size: 14px; }
.doing { margin: 6px 0 10px; font-size: 14px; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--seal);
  color: var(--seal);
  font-size: 12px;
  vertical-align: 2px;
}

.jobbar { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; align-items: center; margin: 8px 0; font-size: 12px; color: var(--muted); }
.jobbar em { font-style: normal; }
.bars { display: grid; gap: 5px; margin: 8px 0; }
.bar { display: grid; grid-template-columns: 32px 1fr 28px; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.track { height: 6px; background: #efe4d2; }
.track div { height: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button, .row {
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.chips button { padding: 3px 8px; font-size: 12px; }
.chips button em {
  margin-left: 6px;
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--seal);
}
.chips button:hover, .row:hover { border-color: var(--gold); background: #fff; }

.desk {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.desk .kicker { margin-bottom: 6px; }

.desk .chips button.on {
  background: var(--ink);
  color: #f6efe4;
  border-color: var(--ink);
}

.desk button:disabled { opacity: 0.35; cursor: default; }
.kicker { margin: 10px 0 0; font-size: 12px; letter-spacing: 0.12em; color: var(--gold); }

.tabs { display: flex; gap: 6px; padding: 10px 12px 0; }
.tools { display: flex; gap: 6px; padding: 8px 12px; }
.tools input, .tools select {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 7px 8px;
}
.tools input { flex: 1; min-width: 0; }
.tools[hidden] { display: none; }

.scroll { min-height: 0; overflow: auto; padding: 0 8px 12px; }

.row {
  width: 100%;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-width: 0 0 1px;
  background: transparent;
}
.row .dot { width: 8px; height: 8px; border-radius: 50%; }
.row b { font-weight: 600; }
.row small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.row.on { background: #fff; border-color: transparent; box-shadow: inset 2px 0 0 var(--seal); }
.row em { font-style: normal; color: var(--muted); font-size: 12px; }

.log { list-style: none; margin: 0; padding: 0 12px 16px; }
.log li {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.45;
}
.log time { color: var(--gold); font-variant-numeric: tabular-nums; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px 10px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

@media (max-width: 980px) {
  body { overflow: auto; }
  main { grid-template-columns: 1fr; grid-template-rows: minmax(320px, 52vh) auto; }
  aside { border-left: 0; border-top: 1px solid var(--line); min-height: 520px; }
  .stamp { margin-left: 0; }
  .top { flex-wrap: wrap; }
}
