:root {
  --hue: 220;
  --bg: hsl(var(--hue) 40% 97%);
  --bg-2: hsl(var(--hue) 45% 93%);
  --ink: hsl(var(--hue) 30% 14%);
  --muted: hsl(var(--hue) 15% 45%);
  --line: hsl(var(--hue) 25% 84%);
  --card: #fff;
  --accent: hsl(var(--hue) 70% 48%);
  --accent-ink: #fff;
  --danger: hsl(4 75% 50%);
  --ok: hsl(150 55% 40%);
  --radius: 18px;
  --pulse: 2.4s;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--ink);
  min-height: 100vh;
  padding-inline: clamp(16px, 4vw, 48px);
  padding-block: 20px 32px;
  transition: background 600ms ease, color 600ms ease;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 48px);
  letter-spacing: -0.03em;
  line-height: 1;
}

.tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
  transition: background 200ms;
}

.dot.busy { background: var(--accent); animation: blink 0.6s infinite alternate; }
.dot.ready { background: var(--ok); }
.dot.error { background: var(--danger); }

@keyframes blink { from { opacity: 0.4; } to { opacity: 1; } }

.latency { font-variant-numeric: tabular-nums; }

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 5fr) minmax(320px, 7fr);
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.input, .stage, .signals {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 10px 30px hsl(var(--hue) 40% 40% / 0.06);
  transition: border-color 400ms, box-shadow 400ms;
}

.label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  font: inherit;
  font-size: clamp(20px, 2.6vw, 28px);
  line-height: 1.4;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  min-height: 150px;
}

textarea::placeholder { color: hsl(var(--hue) 15% 70%); }

.samples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.samples button {
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  transition: background 150ms, transform 150ms;
}

.samples button:hover { background: var(--bg-2); transform: translateY(-1px); }
.samples button.reset { color: var(--muted); }

.note {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 360px;
}

.stage.ready {
  border-color: var(--ok);
  box-shadow: 0 0 0 4px hsl(150 55% 40% / 0.15), 0 10px 30px hsl(var(--hue) 40% 40% / 0.08);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.badge {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: opacity 300ms, transform 300ms;
}

.badge:empty { display: none; }
.badge.hot { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.badge.warn { background: var(--danger); color: #fff; border-color: transparent; animation: pulse var(--pulse) infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 350ms ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.panel .sub { color: var(--muted); font-size: 14px; margin: 0; }

.placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--hue) 15% 70%);
  font-size: 18px;
  text-align: center;
  padding: 24px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar .dow {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.calendar .day {
  aspect-ratio: 1.15;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background 300ms, transform 300ms, color 300ms;
}

.calendar .day small { font-size: 10px; color: var(--muted); }
.calendar .day.today { border-color: var(--accent); }
.calendar .day.hit { background: var(--accent); color: var(--accent-ink); transform: scale(1.06); }
.calendar .day.hit small { color: var(--accent-ink); }
.calendar .day.soft { background: hsl(var(--hue) 70% 48% / 0.18); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.chip.on { background: var(--ink); color: #fff; border-color: transparent; }

.results { display: flex; flex-direction: column; gap: 10px; }

.result {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}

.result .bar {
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-2), var(--line));
}

.result .bar.short { width: 55%; }
.result .bar.mid { width: 80%; }
.result .tag { font-size: 12px; color: var(--accent); }

.sheet {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: repeating-linear-gradient(transparent 0 27px, var(--line) 27px 28px);
  line-height: 28px;
  font-size: 15px;
  min-height: 140px;
  white-space: pre-wrap;
}

.calc {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.calc .expr { color: var(--muted); font-size: 18px; }
.calc .value { font-size: clamp(36px, 6vw, 56px); letter-spacing: -0.02em; }

.compose { display: flex; flex-direction: column; gap: 10px; }

.compose .row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  font-size: 15px;
}

.compose .row b { color: var(--muted); font-weight: 500; font-size: 13px; width: 48px; }
.compose .body { white-space: pre-wrap; line-height: 1.6; font-size: 15px; }

.route { display: flex; flex-direction: column; gap: 0; }

.route .stop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 16px;
}

.route .stop i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.route .leg {
  margin-left: 5px;
  border-left: 2px dashed var(--line);
  height: 28px;
}

.bubble {
  align-self: flex-start;
  max-width: 85%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 4px;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.5;
}

.bubble.me {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  border-color: transparent;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}

.confirm {
  font: inherit;
  font-size: 16px;
  padding: 11px 22px;
  border-radius: 12px;
  border: none;
  background: var(--danger);
  color: #fff;
  cursor: pointer;
  animation: rise 300ms ease;
}

.ready {
  margin-left: auto;
  font-size: 14px;
  color: var(--ok);
  animation: rise 300ms ease;
}

.signals-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.meta { font-variant-numeric: tabular-nums; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.signal {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  display: grid;
  gap: 6px;
}

.signal .k { color: var(--muted); }
.signal .v { font-size: 14px; color: var(--ink); display: flex; justify-content: space-between; gap: 8px; }
.signal .v span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); }

.signal .track {
  height: 6px;
  border-radius: 4px;
  background: var(--bg-2);
  overflow: hidden;
}

.signal .fill {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 350ms ease;
}

.foot {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.foot a { color: inherit; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  max-width: calc(100vw - 32px);
  animation: rise 250ms ease;
}
