:root {
  color-scheme: light;
  --ink: #241f1a;
  --muted: #5e584f;
  --paper: rgba(247, 244, 238, 0.92);
  --line: rgba(36, 31, 26, 0.1);
  --accent: #1e3d36;
  --amber: #a15c28;
  --danger: #a33b32;
  --shadow: 0 14px 40px rgba(48, 38, 28, 0.14);
  font-family: Outfit, "PingFang TC", "Noto Sans CJK TC", "Microsoft JhengHei", "WenQuanYi Micro Hei", sans-serif;
}

* { box-sizing: border-box; }

html, body, #app {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #d5e0db;
}

body.simulating::before,
body.day::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #c56a2d;
  z-index: 6;
  pointer-events: none;
}

body.day::before { background: #1e3d36; }
body.ops::before { background: #243044; }

.day-clock {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 92px;
  padding: 4px 10px 5px;
  border-radius: 14px;
  background: #24312e;
  color: #f7f3ea;
}

.day-clock[hidden] { display: none; }

#day-time {
  font-family: Fraunces, Georgia, serif;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.day-beat {
  color: #e7c56a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.assign-cloud { pointer-events: auto; }

.assign-pop {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 220px;
  padding: 8px 10px;
  background: #fffef8;
  border: 2.5px solid #241f1a;
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(48, 38, 28, 0.16);
}

.assign-pop input {
  width: 100%;
  border: 0;
  background: transparent;
  font: 600 13px Outfit, sans-serif;
  color: #241f1a;
}

.assign-pop input:focus { outline: none; }

.assign-hint {
  margin: 0;
  color: #5e584f;
  font-size: 11px;
}

.badge.is-day { background: #1e3d36; color: #f7f3ea; border-color: transparent; }
.badge.is-ops { background: #243044; color: #f7f3ea; border-color: transparent; }

#viewport {
  position: fixed;
  inset: 0;
  touch-action: none;
}

#viewport canvas,
#viewport .label-layer {
  position: absolute;
  inset: 0;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

button, .chip {
  font: inherit;
  color: var(--ink);
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.left-col {
  position: absolute;
  top: 12px;
  left: 12px;
  bottom: 16px;
  width: min(292px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.left-col > * { pointer-events: auto; }

.mast {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand, .detail, .roster { padding: 12px 14px; }

.brand h1,
.detail h2,
.dept h2 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand h1 { font-size: 22px; line-height: 1.1; }

.sub, .count, .hint, .role, .sim-note, .detail p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.zones {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.zones::-webkit-scrollbar { display: none; }

.chip, .cams button, .primary, .bot {
  border: 1px solid var(--line);
  background: rgba(247, 244, 238, 0.94);
}

.chip {
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chip[aria-pressed="true"],
.primary {
  background: var(--accent);
  color: #f6f3ee;
  border-color: transparent;
}

.primary {
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
}

.primary[aria-pressed="true"] {
  background: #f6f3ee;
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: #efeae2;
  color: #3f3933;
  border: 1px solid var(--line);
}

.badge.is-sim { background: var(--amber); color: #fffaf6; border-color: transparent; }
.badge.is-live { background: var(--accent); color: #f4faf7; border-color: transparent; }

.roster {
  flex: 1;
  min-height: 0;
  padding: 8px;
  display: none;
}

.roster.is-open { display: flex; }

.roster-list {
  overflow: auto;
  width: 100%;
  padding-right: 2px;
}

.dept { margin-bottom: 8px; }
.dept h2 {
  font-family: Outfit, sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 6px 4px;
}

.bot {
  width: 100%;
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  border-radius: 12px;
  padding: 7px 8px;
  margin-bottom: 4px;
}

.bot.is-selected {
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent);
  background: #fff;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
}

.bot-copy { display: flex; flex-direction: column; min-width: 0; }
.bot-name { font-weight: 600; font-size: 14px; }
.bot-role {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.state {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.state.is-working { color: var(--accent); }
.state.is-waiting { color: var(--amber); }
.state.is-error { color: var(--danger); }
.state.is-done { color: #2a6a62; }

.detail {
  position: absolute;
  right: 12px;
  bottom: 68px;
  width: min(320px, calc(100vw - 24px));
  max-height: min(380px, calc(100vh - 180px));
  overflow: auto;
  pointer-events: auto;
}

.detail.is-empty { display: none; }

.detail h2 { font-size: 28px; line-height: 1; margin-top: 2px; }
.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail dl { margin: 12px 0 0; }
.detail dl div { margin-top: 8px; }
.detail dt {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail dd { margin: 2px 0 0; font-size: 14px; }
.detail a { color: var(--accent); }

.sim-note { color: var(--amber); }

.hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(247, 244, 238, 0.88);
  white-space: nowrap;
}

.cams {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.cams button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
}

.tag {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 8px 8px;
  border-radius: 999px;
  background: rgba(247, 244, 238, 0.96);
  border: 1px solid rgba(36, 31, 26, 0.12);
  box-shadow: 0 8px 20px rgba(48, 38, 28, 0.16);
  white-space: nowrap;
}

.tag-name { font-size: 13px; font-weight: 650; color: var(--ink); }
.tag-state { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.tag-state[hidden] { display: none; }

.cloud {
  pointer-events: none;
  user-select: none;
}

.cloud-pop {
  opacity: 0;
  transform: scale(0.86) translateY(6px);
}

.cloud-pop.is-in {
  animation: cloud-in 0.28s ease forwards;
}

.cloud-pop.is-hold {
  opacity: 1;
  transform: none;
}

.cloud-pop.is-out {
  animation: cloud-out 0.36s ease forwards;
}

.cloud-pop.is-still {
  opacity: 1;
  transform: none;
  animation: none;
}

.cloud-bob.is-live {
  animation: cloud-bob 2.8s ease-in-out infinite;
}

.cloud-body {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 210px;
  padding: 7px 11px 8px;
  background: #fffef8;
  border: 2.5px solid #241f1a;
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(48, 38, 28, 0.14);
}

.cloud.is-speech .cloud-body {
  box-shadow: inset 3px 0 0 var(--who, #241f1a), 0 8px 18px rgba(48, 38, 28, 0.14);
}

.cloud.is-alarm .cloud-body {
  background: #fff6ee;
  border-color: #c4512c;
}

.cloud.is-alarm .cloud-line {
  color: #6a2c1c;
}

.cloud.is-think .cloud-body {
  border-radius: 18px;
}

.spark { display: none; }

.cloud.is-think .spark {
  display: block;
  position: absolute;
  right: 7px;
  top: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e2b340;
  animation: spark 1.6s ease-in-out infinite;
}

.cloud.is-think[data-think="1"] .lobe-a { width: 26px; height: 16px; left: -8px; top: 6px; }
.cloud.is-think[data-think="2"] .lobe-b { width: 24px; height: 24px; right: -12px; top: -10px; }

@keyframes spark {
  0%, 100% { transform: scale(0.7); opacity: 0.45; }
  50% { transform: scale(1.15); opacity: 1; }
}

.cloud-line {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: #241f1a;
}

.cloud.is-think .cloud-line {
  font-weight: 500;
  color: #3e3933;
}

.cloud-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.cloud-dot.is-quiet {
  opacity: 0.45;
  transform: scale(0.8);
}

.cloud.is-think .cloud-dot { display: none; }

.lobe { display: none; }

.cloud.is-think .lobe {
  display: block;
  position: absolute;
  background: #fffef8;
  border: 2.5px solid #241f1a;
  border-radius: 50%;
  z-index: -1;
}

.lobe-a { width: 22px; height: 22px; left: -10px; top: -8px; }
.lobe-b { width: 18px; height: 18px; right: -8px; top: -6px; }
.lobe-c { width: 16px; height: 16px; right: -6px; bottom: -6px; }
.lobe-d { width: 14px; height: 14px; left: -6px; bottom: -5px; }

.cloud-tail {
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 16px;
  height: 12px;
  margin-left: -8px;
  transform-origin: 50% 0;
}

.cloud.is-think .cloud-tail { display: none; }

.cloud-tail b {
  display: block;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid #241f1a;
  position: relative;
}

.cloud-tail b::after {
  content: "";
  position: absolute;
  left: -6px;
  top: -11px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #fffef8;
}

.cloud-puffs { display: none; }

.cloud.is-think .cloud-bob {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.cloud.is-think .cloud-puffs {
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 2px 0 0 12px;
}

.cloud-puffs i {
  display: block;
  background: #fffef8;
  border: 2px solid #241f1a;
  border-radius: 50%;
}

.cloud-puffs i:nth-child(1) { width: 10px; height: 10px; }
.cloud-puffs i:nth-child(2) { width: 7px; height: 7px; }
.cloud-puffs i:nth-child(3) { width: 4px; height: 4px; }

@keyframes cloud-in {
  from { opacity: 0; transform: scale(0.84) translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes cloud-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(0.92) translateY(-4px); }
}

@keyframes cloud-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .cloud-pop,
  .cloud-bob { animation: none !important; }
}

#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #e7efe9;
  z-index: 5;
  color: var(--ink);
  font-family: Fraunces, Georgia, serif;
  font-size: 28px;
}

#boot.is-hidden { display: none; }

@media (max-width: 900px) {
  .left-col {
    bottom: auto;
    width: auto;
    right: 12px;
  }
  .roster {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: min(420px, calc(100vw - 24px));
    max-height: 46vh;
    z-index: 3;
  }
  .detail { left: 12px; width: auto; bottom: 68px; }
  .hint { display: none; }
  .brand h1 { font-size: 18px; }
}
