:root {
  --ink: #111; --ink-2: #555; --ink-3: #8a8a8a; --line: rgba(0, 0, 0, 0.09); --panel: rgba(255, 255, 255, 0.84);
  --warn: #c8473f; --radius: 14px; --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 28px rgba(0, 0, 0, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #efe6e1; color: var(--ink); font-family: var(--font); font-weight: 500; -webkit-font-smoothing: antialiased; }
body.nocursor, body.nocursor * { cursor: none !important; }
body[data-tool="brush"] #stage, body[data-tool="mallet"] #stage, body[data-tool="feather"] #stage, body[data-tool="spray"] #stage, body[data-tool="wand"] #stage { cursor: grab; cursor: grabbing; } /* a closed hand, holding the 3D tool by its handle */
body.dragging, body.dragging * { cursor: grabbing !important; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: var(--ink); cursor: pointer; }
.ico { width: 20px; height: 20px; display: block; flex: none; }

/* icon buttons */
.ib { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 10px; background: transparent; transition: background .15s ease, color .15s ease, transform .1s ease; }
.ib:hover { background: rgba(0, 0, 0, 0.06); }
.ib:active { transform: scale(0.94); }
.ib.active { background: var(--ink); color: #fff; }
.ib.on { color: var(--ink); } .ib.off { color: var(--ink-3); }
.ib:disabled { opacity: .35; cursor: default; }
.ib:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.card { background: var(--panel); backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); pointer-events: auto; }

/* boot */
.boot { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 14px; background: #f4efec; transition: opacity .8s ease; color: var(--ink-2); font-size: 14px; letter-spacing: .02em; }
.boot.gone { opacity: 0; pointer-events: none; }
.boot-mochi { width: 96px; animation: squish 1.4s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes squish { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.07, 0.93); } }

/* top bar */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.topbar { position: absolute; top: 12px; left: calc(12px + var(--back-w, 186px) + (100% - 24px - var(--back-w, 186px)) / 2); transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px - var(--back-w, 186px)); min-height: 52px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; row-gap: 2px; padding: 8px 8px 8px 16px; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); pointer-events: auto; }
.topbar::-webkit-scrollbar { display: none; }
/* back to the portfolio: top-left corner, same card as the bar; the bar centres itself in the space to its right */
.back-link { position: absolute; top: 12px; left: 12px; height: 52px; box-sizing: border-box; display: inline-flex; align-items: center; gap: 8px; padding: 0 16px 0 13px; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); color: var(--ink); font-size: 13.5px; font-weight: 600; letter-spacing: -.005em; text-decoration: none; white-space: nowrap; pointer-events: auto; transition: background .15s ease, transform .1s ease; }
.back-link:hover { background: #fff; } .back-link:active { transform: scale(0.97); }
.back-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.back-link .ico { width: 18px; height: 18px; }
.topbar .group { display: flex; gap: 2px; align-items: center; }
.topbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; flex: none; }
.topbar .grow { flex: 1; min-width: 8px; }
.who { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; min-width: 128px; }
#pet-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; cursor: text; }
.mood { font-size: 12px; color: var(--ink-3); }
.mood.bad { color: var(--warn); }
.clock { font: inherit; font-size: 12px; color: var(--ink-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; height: 36px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.clock:hover { background: rgba(0, 0, 0, 0.06); }
.clock.manual { color: var(--ink); font-weight: 700; }
.clock .ico { width: 16px; height: 16px; }
.ai { width: 28px; display: grid; place-items: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.dot.on { background: var(--ink); } .dot.off { background: transparent; border: 1.5px solid var(--ink-3); }
.menu-wrap { position: relative; }
.menu { position: fixed; left: 0; top: 0; display: flex; gap: 2px; padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 30; pointer-events: auto; }
.time-panel { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; padding: 12px 14px 12px; }
.time-read { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0 6px; }
#time-big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
#time-mode { font-size: 11px; color: var(--ink-3); }
#time-slider { width: 100%; margin: 4px 0 10px; accent-color: var(--ink); }
.time-row { display: flex; align-items: center; gap: 2px; } .time-row .grow { flex: 1; }
.time-row .now { border: 1px solid var(--line); }

/* stats */
.stats { position: absolute; top: var(--below, 76px); left: var(--bar-l, 12px); width: 200px; padding: 12px 14px; }
.meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--ink-3); margin-bottom: 10px; }
.meta.small { margin: 10px 0 0; } .meta b { color: var(--ink-2); font-weight: 600; }
.hearts { display: inline-flex; gap: 2px; } .hearts svg { width: 11px; height: 11px; }
.bars { display: grid; gap: 7px; }
.bar { display: flex; align-items: center; gap: 9px; color: var(--ink-2); }
.bar .ico { width: 15px; height: 15px; }
.bar .track { flex: 1; height: 4px; border-radius: 4px; background: rgba(0, 0, 0, 0.08); overflow: hidden; }
.bar .fill { height: 100%; width: 50%; border-radius: 4px; background: var(--ink); transition: width .6s ease, background .3s ease; }
.bar.low { color: var(--warn); } .bar.low .fill { background: var(--warn); }
.needs { margin-top: 10px; font-size: 11.5px; color: var(--warn); line-height: 1.4; }

.reminders { position: absolute; top: var(--below, 76px); right: var(--bar-r, 12px); width: 230px; font-size: 12.5px; padding: 10px 12px; }
.rem-title { font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.rem { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); }
.rem span { flex: 1; } .rem em { color: var(--ink-3); font-style: normal; font-size: 11px; }
.rem.due span, .rem.due em { color: var(--warn); font-weight: 600; }
.rem .ib { width: 26px; height: 26px; } .rem .ico { width: 16px; height: 16px; }

/* chat */
.chat { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(560px, calc(100% - 24px)); display: flex; gap: 4px; align-items: center; padding: 5px; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); pointer-events: auto; }
.chat input { flex: 1; font: inherit; font-size: 14px; border: 0; background: transparent; padding: 8px 6px; color: var(--ink); outline: none; min-width: 0; }
.chat input::placeholder { color: var(--ink-3); }
.chat .send { background: var(--ink); color: #fff; }
.chat.thinking .send { opacity: .4; }
.chat.thinking input { background-image: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.05), transparent); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
#btn-mic.rec { background: var(--warn); color: #fff; }

/* speech bubble */
.bubble { position: fixed; left: 0; top: 0; z-index: 12; max-width: min(300px, 70vw); background: #fff; border: 1.5px solid var(--ink); border-radius: 16px; padding: 9px 13px; font-size: 14px; line-height: 1.4; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1); pointer-events: auto; cursor: pointer; --tail: 40px; animation: pop .22s cubic-bezier(.2, 1.4, .4, 1); }
.bubble::after { content: ''; position: absolute; left: var(--tail); bottom: -7px; width: 12px; height: 12px; background: #fff; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: translateX(-50%) rotate(45deg); }
.bubble.think { border-style: dashed; color: var(--ink-2); }
.bubble.alert { background: var(--ink); color: #fff; } .bubble.alert::after { background: var(--ink); }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }

/* close-tab pop-up */
#popups { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.popup { position: absolute; left: 0; top: 0; width: 290px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22); pointer-events: auto; transform-origin: center; }
.popup.stage2 { border-color: var(--warn); }
.popup-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.popup-body { font-size: 13px; color: var(--ink-2); margin-bottom: 14px; line-height: 1.45; }
.popup-btns { display: flex; gap: 8px; }
.popup-btns button { font-size: 13px; font-weight: 600; border-radius: 10px; padding: 9px 12px; border: 1px solid var(--ink); }
.popup-btns .keep { background: var(--ink); color: #fff; flex: 1; }
.popup-btns .close { background: #fff; color: var(--ink-2); border-color: var(--line); }
.popup.flying { pointer-events: none; }

#fake-cursor { position: fixed; left: 0; top: 0; z-index: 30; width: 22px; height: 30px; pointer-events: none; display: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 30'%3E%3Cpath d='M2 2 L2 24 L8 18 L12 28 L16 26 L12 17 L20 17 Z' fill='white' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat; }
#fake-cursor.show { display: block; animation: wobble .4s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(10deg); } }

/* game */
.game { position: fixed; z-index: 15; left: 50%; bottom: 84px; transform: translateX(-50%); width: 240px; padding: 14px 14px 12px; text-align: center; }
.game-title { font-weight: 700; font-size: 14px; }
.game-status { color: var(--ink-2); font-size: 12.5px; margin: 2px 0 12px; min-height: 1.3em; }
.game-row { display: flex; gap: 10px; justify-content: center; }
.game-row .pick { width: 64px; height: 44px; border: 1px solid var(--ink); border-radius: 12px; }
.game-row .pick .ico { width: 22px; height: 22px; }
.game-round { margin-top: 10px; display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 11px; color: var(--ink-3); }
.pips { display: inline-flex; gap: 4px; } .pip { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--ink); } .pip.win { background: var(--ink); } .pip.miss { border-color: var(--ink-3); }
.game .quit { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; } .game .quit .ico { width: 16px; height: 16px; }

/* wardrobe */
.wardrobe { position: fixed; z-index: 40; right: var(--bar-r, 12px); top: var(--below, 76px); width: 268px; padding: 12px 14px 12px; }
.wardrobe .slot { display: grid; gap: 6px; margin-top: 12px; }
.wardrobe .slot > span { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.wardrobe .items { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wardrobe .wear { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.wardrobe .wear .ico { width: 24px; height: 24px; }
.wardrobe .wear.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.text-btn.plain { color: var(--ink-2); margin-top: 12px; }

/* colours */
.colors { position: fixed; z-index: 40; right: var(--bar-r, 12px); top: var(--below, 76px); width: 268px; padding: 12px 14px 14px; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0; }
.swatch { height: 58px; border: 1px solid var(--line); border-radius: 12px; background: #fff; display: grid; place-items: center; padding: 0; }
.swatch svg { width: 40px; height: 40px; }
.swatch:hover { border-color: rgba(0, 0, 0, 0.3); }
.swatch.active { border: 1.5px solid var(--ink); }
.pickers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pickers label { display: grid; justify-items: center; gap: 4px; font-size: 11px; color: var(--ink-2); cursor: pointer; }
.pickers input { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; border: 1px solid var(--line); border-radius: 9px; padding: 0; background: none; cursor: pointer; }
.pickers input::-webkit-color-swatch-wrapper { padding: 3px; } .pickers input::-webkit-color-swatch { border: 0; border-radius: 6px; }
.pickers input::-moz-color-swatch { border: 0; border-radius: 6px; }

/* diary + help */
.diary { position: fixed; z-index: 40; right: var(--bar-r, 12px); top: var(--below, 76px); width: min(360px, calc(100% - 24px)); max-height: calc(100% - 170px); display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; }
.diary-head { display: flex; align-items: center; gap: 2px; } .diary-head h2 { margin: 0 auto 0 0; font-size: 15px; font-weight: 700; }
.diary-list { overflow-y: auto; display: grid; gap: 12px; }
.diary-list article { padding-top: 10px; border-top: 1px solid var(--line); }
.diary-list time { font-size: 11px; color: var(--ink-3); } .diary-list p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.55; }
.diary-list .empty { color: var(--ink-3); font-size: 13px; margin: 0; }
.help { position: fixed; z-index: 40; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto; padding: 14px 18px 16px; font-size: 13.5px; line-height: 1.5; }
.help dl { display: grid; grid-template-columns: 24px 1fr; gap: 10px 12px; margin: 14px 0; }
.help dt { padding-top: 1px; } .help dd { margin: 0; color: var(--ink-2); }
.help .small { color: var(--ink-3); font-size: 12px; margin: 0 0 10px; }
.text-btn { background: none; border: 0; padding: 0; font-size: 12px; color: var(--warn); text-decoration: underline; text-underline-offset: 3px; }

#flash { position: fixed; inset: 0; z-index: 35; background: #fff; opacity: 0; pointer-events: none; }
#flash.go { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }
#toast { position: fixed; left: 50%; top: var(--below, 76px); transform: translate(-50%, -10px); z-index: 45; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 12.5px; opacity: 0; transition: all .25s ease; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1340px) {
  .topbar .ib { width: 33px; height: 33px; } .topbar .sep { margin: 0 3px; } .who .mood { display: none; } .who { min-width: 0; }
}
@media (max-width: 1180px) {
  .back-link { padding: 0 16px; } .back-link .bl-text { display: none; }
}
@media (max-width: 760px) {
  .back-link { height: 48px; padding: 0 14px; }
  .topbar { padding: 6px 6px 6px 12px; min-height: 48px; } .who { min-width: 0; } .clock { padding: 0 6px; }
  .stats { width: 170px; padding: 10px 12px; }
  .popup { width: 250px; }
}
