:root {
  color: #2a241c;
  background: #c9d8e4;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  --ink: #2a241c;
  --muted: #6d6258;
  --paper: rgba(250, 246, 239, 0.94);
  --line: rgba(42, 36, 28, 0.12);
  --accent: #8e4d45;
  --moss: #3d5c45;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#app {
  position: fixed; inset: 0; z-index: 2;
  pointer-events: none;
}
header, #dock, #goalsPanel, #hint, #toast, #coach { pointer-events: auto; }

header {
  position: absolute; top: 12px; left: 326px; right: 300px;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.brand p { margin: 0; font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.brand h1 {
  margin: 0;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: 1.45rem; font-weight: 600; line-height: 1;
}
.actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.actions button, #coach button {
  border: 0; border-radius: 999px; padding: 8px 12px; background: rgba(42, 36, 28, 0.06);
}
#liveBtn.on { background: var(--moss); color: #f6f1e4; }
body.live-mode #dock #tools,
body.live-mode #dock h2,
body.live-mode #dock .swatches,
body.live-mode #dock .note,
body.live-mode #dock .grid,
body.live-mode #dock h3,
body.live-mode #goalsPanel { display: none; }
body.live-mode #lifePanel { display: flex; }
.actions button:hover, #coach button:hover { background: rgba(42, 36, 28, 0.1); }
#undoBtn:disabled { opacity: 0.4; cursor: default; }

#dock, #goalsPanel, #lifePanel {
  position: absolute; top: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: auto;
}
#dock { left: 12px; width: 302px; }
#goalsPanel { right: 12px; width: 276px; bottom: auto; max-height: calc(100% - 24px); }
#lifePanel {
  display: none;
  right: 12px;
  width: 286px;
  bottom: auto;
  max-height: calc(100% - 24px);
}
.emotion {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  font-family: Georgia, "Palatino Linotype", serif;
}
.emotion.warn { color: var(--accent); }
.emotion.good { color: var(--moss); }
.life-bars { display: grid; gap: 6px; }
.life-row { display: grid; grid-template-columns: 62px 1fr 28px; gap: 8px; align-items: center; font-size: 0.78rem; color: var(--muted); }
.life-track { height: 8px; border-radius: 999px; background: rgba(42, 36, 28, 0.08); overflow: hidden; }
.life-fill { height: 100%; border-radius: inherit; background: var(--moss); transition: width 0.25s ease; }
.life-fill.low { background: var(--accent); }
.life-fill.urgent { background: #c45a28; }
#lifeChoices {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(420px, calc(100% - 24px));
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(28, 24, 18, 0.12);
  z-index: 5;
}
#lifeChoices[hidden] { display: none; }
#lifeChoices p { margin: 0; font-size: 0.92rem; color: var(--ink); }
.life-choice-grid { display: grid; gap: 8px; }
.life-choice {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  font: inherit;
}
.life-choice strong { font-size: 0.92rem; color: var(--ink); }
.life-choice span { font-size: 0.78rem; color: var(--muted); }
.life-choice:disabled { opacity: 0.45; cursor: default; }
.life-choice:not(:disabled):hover { background: rgba(42, 36, 28, 0.06); }
#lifeChoicesCancel {
  align-self: flex-end;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 4px 0;
}
.wallet { margin: 0; font-size: 0.82rem; color: var(--ink); }
#lifeTasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#lifeTasks li { font-size: 0.84rem; padding-left: 14px; position: relative; color: var(--ink); }
#lifeTasks li::before { content: "○"; position: absolute; left: 0; color: var(--accent); }

h2, h3 {
  margin: 4px 0 0;
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 650;
}
h3 {
  margin-top: 10px;
  font-size: 0.66rem;
  color: var(--accent);
}
.tool-list { display: grid; gap: 4px; }
.tool-list .tool kbd:empty { display: none; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 8px; border: 0; border-radius: 12px; text-align: left;
  background: rgba(42, 36, 28, 0.04);
}
.tool b { font-size: 0.82rem; font-weight: 600; }
.tool kbd { font-family: inherit; font-size: 0.68rem; color: #8a7b6b; }
.tool.on { background: var(--moss); color: #f6f1e4; }
.tool.on kbd { color: rgba(246, 241, 228, 0.75); }
#toolHelp, .note { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
#toolHelp { color: var(--ink); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid white;
  box-shadow: 0 0 0 1px var(--line); padding: 0;
}
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }

#goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
#goals li { display: flex; gap: 8px; align-items: flex-start; font-size: 0.86rem; }
#goals i {
  width: 14px; height: 14px; margin-top: 2px; border-radius: 50%;
  border: 1.5px solid #b5a89a; flex: none;
}
#goals li.done { color: var(--moss); }
#goals li.done i { background: var(--moss); border-color: var(--moss); box-shadow: inset 0 0 0 2px #f6f1e4; }
#goalCount { margin: 0; color: var(--muted); font-size: 0.78rem; }

#hint, #toast {
  position: absolute; left: 50%; transform: translateX(-50%);
  margin: 0; border-radius: 999px; padding: 8px 14px; font-size: 0.82rem;
}
#hint {
  bottom: 16px; max-width: min(560px, calc(100% - 580px));
  background: var(--paper); border: 1px solid var(--line); color: var(--muted); text-align: center;
}
#toast { top: 74px; z-index: 4; background: var(--ink); color: #f6f1e4; }
#toast[hidden], #coach[hidden] { display: none; }
body:not(.coach-off) #hint { visibility: hidden; }

#coach {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(460px, calc(100% - 580px));
  display: flex; gap: 10px; align-items: center;
  padding: 12px 12px 12px 14px; border-radius: 16px;
  background: var(--moss); color: #f6f1e4;
}
#coach p { margin: 0; font-size: 0.9rem; line-height: 1.35; }
#coach button { background: #f6f1e4; color: var(--ink); white-space: nowrap; }

#reticle {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(42, 36, 28, 0.28);
  pointer-events: none;
  z-index: 3;
  display: none;
}
body.locked #reticle { display: block; }

@media (max-width: 980px) {
  header { left: 12px; right: 12px; top: auto; bottom: 12px; }
  #dock { top: 12px; bottom: 72px; width: 220px; }
  #goalsPanel { display: none; }
  #hint, #coach { left: 240px; transform: none; width: auto; max-width: calc(100% - 260px); bottom: 78px; }
}
