:root {
  --bg0: #07080d;
  --bg1: #12182a;
  --card: rgba(8, 12, 22, 0.72);
  --ink: #eef4ff;
  --muted: rgba(190, 210, 240, 0.68);
  --line: rgba(80, 210, 255, 0.18);
  --orange: #ff8a2a;
  --orange-2: #ffb060;
  --cyan: #3ee0e8;
  --good: #3ee0a0;
  --bad: #ff6b7a;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #05060a;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body { overflow: hidden; }
button { font: inherit; color: inherit; }

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(10px + var(--safe-t)) 12px calc(8px + var(--safe-b));
  background:
    radial-gradient(1000px 520px at 88% -8%, rgba(255, 138, 42, 0.22), transparent 52%),
    radial-gradient(900px 480px at 8% 0%, rgba(62, 224, 232, 0.16), transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 58%, #05060a);
  transition: background 0.8s ease;
}
.app.day {
  --bg0: #101826;
  --bg1: #1a2740;
  --ink: #eef6ff;
  --muted: rgba(210, 226, 245, 0.7);
  --card: rgba(12, 20, 34, 0.62);
  --line: rgba(140, 200, 230, 0.22);
  background:
    radial-gradient(900px 480px at 80% -10%, rgba(180, 220, 255, 0.28), transparent 52%),
    linear-gradient(180deg, #24344c, #151c2a 60%, #0c121c);
}
.app.evening {
  --bg0: #14080e;
  --bg1: #3a1820;
  --ink: #fff4ea;
  --muted: rgba(255, 230, 214, 0.72);
  --card: rgba(28, 10, 16, 0.62);
  --line: rgba(255, 160, 90, 0.22);
  background:
    radial-gradient(900px 480px at 90% 0%, rgba(255, 130, 60, 0.38), transparent 55%),
    linear-gradient(180deg, #5a2430, #241018 58%, #10080c);
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.mark, .welcome-mark {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #ffb060, #ff8a2a);
  color: #3a1600; font-weight: 800; flex: none;
  box-shadow: 0 0 18px rgba(255, 138, 42, 0.45), var(--shadow);
}
.brand-text h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.meta-line {
  margin: 2px 0 0;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.top-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.btc-pill, .icon-btn, .chip, .tab, .enter-btn {
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.btc-pill {
  display: flex; align-items: center; gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  min-height: 44px;
  box-shadow: 0 0 16px rgba(255, 138, 42, 0.08);
}
.btc-icon { color: var(--orange); font-weight: 800; }
.btc-change.up { color: var(--good); }
.btc-change.down { color: var(--bad); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; cursor: pointer;
}
.icon-btn[aria-pressed="true"] {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 12px rgba(62, 224, 232, 0.28);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 8px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
  backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.stat strong {
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-shadow: 0 0 12px rgba(62, 224, 232, 0.2);
}
.stat span { font-size: 11px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}
.chip.on, .chip[aria-pressed="true"] {
  background: rgba(62, 224, 232, 0.16);
  border-color: rgba(62, 224, 232, 0.55);
  box-shadow: 0 0 14px rgba(62, 224, 232, 0.18);
  color: #d9fbff;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  margin: 8px 0 0;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow), 0 0 0 1px rgba(62, 224, 232, 0.06), inset 0 0 40px rgba(62, 224, 232, 0.04);
  touch-action: none;
  background: #07080d;
}
#office { width: 100%; height: 100%; display: block; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.label-pair { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.bubble, .tag {
  position: absolute;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  pointer-events: none;
}
.bubble {
  background: rgba(10, 14, 24, 0.92);
  color: #eef6ff;
  border: 1px solid rgba(80, 210, 255, 0.35);
  border-radius: 14px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4), 0 0 16px rgba(62, 224, 232, 0.12);
}
.bubble.need {
  background: var(--orange);
  color: #3a1600;
  border-color: transparent;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px; height: 10px;
  background: inherit;
  border-right: 1px solid rgba(80, 210, 255, 0.35);
  border-bottom: 1px solid rgba(80, 210, 255, 0.35);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}
.bubble.need::after,
.bubble.error::after { border-color: transparent; }
.tag {
  margin-top: 8px;
  font-size: 10px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.85), 0 0 8px rgba(62, 224, 232, 0.35);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sheet-handle {
  width: 48px; height: 5px; border-radius: 99px;
  background: rgba(62, 224, 232, 0.35);
  margin: 4px auto 6px;
}
.sheet {
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px 22px 16px 16px;
  padding: 8px 8px 4px;
  backdrop-filter: blur(18px);
  max-height: 34dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 0 -8px 28px rgba(0,0,0,0.25);
}
.tabs { display: flex; gap: 6px; padding: 2px 4px 8px; }
.tab {
  flex: 1;
  min-height: 40px;
  border-radius: 999px;
  cursor: pointer;
}
.tab.on {
  background: var(--orange);
  color: #3a1600;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 0 16px rgba(255, 138, 42, 0.28);
}
.panel { overflow: auto; min-height: 0; padding: 0 4px 6px; }
.row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; color: #1b1020;
}
.row h3 { margin: 0; font-size: 14px; }
.row p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.state-chip {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,0.1);
}
.state-chip.coding, .state-chip.thinking { background: rgba(76, 141, 255, 0.28); }
.state-chip.need_me { background: var(--orange); color: #3a1600; }
.state-chip.done { background: rgba(62, 224, 160, 0.25); }
.feed-item { padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed-item time { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

.hidden { display: none !important; }

.welcome {
  position: fixed; inset: 0;
  background: rgba(3, 4, 8, 0.78);
  display: grid; place-items: center;
  padding: 24px;
  z-index: 20;
}
.welcome-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #1a2238, #0b0e16);
  color: #eef4ff;
  border-radius: 28px;
  padding: 28px 22px 22px;
  text-align: center;
  box-shadow: var(--shadow), 0 0 40px rgba(62, 224, 232, 0.12);
  border: 1px solid rgba(62, 224, 232, 0.22);
}
.welcome-mark { margin: 0 auto 12px; width: 52px; height: 52px; font-size: 22px; }
.welcome-card h2 { margin: 0 0 10px; font-size: 22px; letter-spacing: 0.04em; }
.welcome-card p { margin: 0 0 8px; color: rgba(220, 230, 255, 0.82); line-height: 1.55; font-size: 14px; }
.welcome-note { font-size: 12px !important; }
.enter-btn {
  margin-top: 14px;
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  background: var(--orange);
  color: #3a1600;
  border: 0;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255, 138, 42, 0.35);
}

@media (min-width: 900px) {
  .app { max-width: 520px; margin: 0 auto; }
}

.state-chip.terminal { background: rgba(46, 230, 214, 0.22); }
.state-chip.browsing { background: rgba(76, 141, 255, 0.22); }
.state-chip.error { background: rgba(255, 80, 80, 0.28); }
.state-chip.off { background: rgba(255,255,255,0.08); color: var(--muted); }
.bubble.need, .state-chip.need_me { animation: pulse-need 0.9s ease-in-out infinite; }
@keyframes pulse-need {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 60, 60, 0.7); }
  50% { box-shadow: 0 0 0 8px rgba(255, 60, 60, 0); background: #ff3b3b; color: #fff; }
}
.bubble.error { background: #ff5a4a; color: #fff; border-color: transparent; }
