:root {
  --ink: #17222b;
  --muted: #62717c;
  --paper: #f5f6f3;
  --surface: #ffffff;
  --line: #d6ddd9;
  --left: #0a9a84;
  --left-soft: #dff5ef;
  --right: #f05d3f;
  --right-soft: #ffebe6;
  --signal: #2763e7;
  --dark: #101a22;
  --radius: 18px;
  --shadow: 0 18px 55px rgba(23, 34, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(10, 154, 132, 0.08), transparent 26rem),
    radial-gradient(circle at 92% 12%, rgba(240, 93, 63, 0.07), transparent 27rem),
    var(--paper);
  font-family: Inter, "Helvetica Neue", "Noto Sans JP", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  border-bottom: 1px solid rgba(23, 34, 43, 0.1);
  background: rgba(245, 246, 243, 0.92);
  backdrop-filter: blur(18px);
}

.header-inner,
.page-shell {
  width: min(1260px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner {
  padding: 28px 0 24px;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-decoration: none;
}

.back-link:hover {
  color: var(--ink);
}

.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
}

.language-switch button {
  min-width: 40px;
  min-height: 28px;
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 850;
  cursor: pointer;
}

.language-switch button.active {
  color: white;
  background: var(--signal);
}

.language-switch button:focus-visible {
  outline: 2px solid var(--right);
  outline-offset: 2px;
}

.title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--signal);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  line-height: 1.3;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.25rem, 5.4vw, 4.8rem);
  font-weight: 780;
  letter-spacing: -0.065em;
  line-height: 0.96;
}

h1 span {
  color: var(--signal);
}

.lead-copy {
  max-width: 660px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.toolkit-cluster {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.toolkit-slot {
  min-width: 190px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 24px rgba(23, 34, 43, 0.05);
}

.toolkit-slot .form-check {
  min-height: 24px;
  margin: 0;
  padding-left: 2.7em;
  align-items: center;
}

.toolkit-slot .form-check-input {
  width: 2.1em;
  height: 1.08em;
  margin-top: 0;
  margin-left: -2.7em;
  cursor: pointer;
}

.toolkit-slot .form-check-input:checked {
  border-color: var(--signal);
  background-color: var(--signal);
}

.toolkit-slot .form-check-label {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.toolkit-slot [id^="icon_settings"],
.toolkit-slot [id^="icon_battery"] {
  cursor: pointer;
}

.page-shell {
  padding: 22px 0 56px;
}

.control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
}

.source-state {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.source-state > div {
  display: grid;
  min-width: 0;
}

.source-state strong {
  font-size: 0.92rem;
}

.source-state span:last-child {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-badge {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 7px 10px;
  border-radius: 99px;
  color: white;
  background: var(--muted);
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
}

.source-badge.live {
  background: var(--left);
  box-shadow: 0 0 0 5px rgba(10, 154, 132, 0.1);
}

.source-badge.demo {
  background: var(--signal);
  box-shadow: 0 0 0 5px rgba(39, 99, 231, 0.1);
}

.source-badge.warning {
  color: #3d2b00;
  background: #f2bd3c;
  box-shadow: 0 0 0 5px rgba(242, 189, 60, 0.14);
}

.source-badge.error {
  background: var(--right);
}

.actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.button.secondary {
  color: white;
  background: var(--signal);
}

.button.secondary.active {
  background: var(--right);
}

.button.ghost {
  border-color: var(--line);
  color: var(--ink);
  background: var(--surface);
}

.graphs-section,
.result-section,
.how-section {
  margin-top: 22px;
}

.graphs-section {
  display: grid;
  gap: 8px;
}

.result-section {
  margin-top: 16px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.7vw, 2.2rem);
  font-weight: 760;
  letter-spacing: -0.035em;
}

.section-heading > p {
  max-width: 530px;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.step-trend-card {
  padding: 9px 12px 8px;
  border-radius: 14px;
  color: white;
  background: var(--dark);
  box-shadow: var(--shadow);
}

.step-trend-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 27px;
  padding: 0 6px 6px;
}

.step-trend-toolbar > div:first-child {
  display: grid;
  gap: 2px;
}

.step-trend-toolbar strong {
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}

.trend-kicker {
  color: #7fa4ff;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.step-trend-legend {
  display: flex;
  gap: 16px;
  color: #9fb0bc;
  font-size: 0.68rem;
  font-weight: 800;
}

.step-trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#step-trend-chart {
  display: block;
  width: 100%;
  height: 128px;
  border-radius: 8px;
  background: #0b141b;
}

.step-trend-latest {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px 2px 0;
}

.step-trend-latest > span {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  color: #9fb0bc;
  font-size: 0.57rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.step-trend-latest > span.left {
  box-shadow: inset 3px 0 0 var(--left);
}

.step-trend-latest > span.right {
  box-shadow: inset 3px 0 0 var(--right);
}

.step-trend-latest strong {
  margin-left: auto;
  color: white;
  font-size: 0.68rem;
  letter-spacing: 0;
}

.step-trend-latest strong + strong {
  margin-left: 0;
  color: #9fb0bc;
}

.table-frame {
  overflow: auto;
  border: 1px solid #c8d1cc;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.gait-table {
  width: 100%;
  min-width: 830px;
  border-collapse: separate;
  border-spacing: 0;
}

.gait-table th,
.gait-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.gait-table th:last-child,
.gait-table td:last-child {
  border-right: 0;
}

.gait-table tbody tr:last-child th,
.gait-table tbody tr:last-child td {
  border-bottom: 0;
}

.gait-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 18px;
  color: white;
  background: var(--dark);
  font-size: 0.8rem;
  text-align: left;
}

.gait-table thead .left-column {
  background: #087e6e;
}

.gait-table thead .right-column {
  background: #cc4e35;
}

.gait-table thead small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.64rem;
  font-weight: 600;
}

.parameter-column {
  width: 28%;
}

.side-column {
  width: 27%;
}

.source-column {
  width: 18%;
}

.side-heading {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.92rem;
  font-weight: 820;
}

.gait-table tbody th {
  padding: 13px 18px;
  background: #f8f9f7;
  font-size: 0.84rem;
  text-align: left;
}

.metric-label {
  display: block;
}

.metric-unit {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
}

.metric-cell {
  position: relative;
  overflow: hidden;
  padding: 9px 18px;
  background: var(--surface);
  transition: background-color 220ms ease, box-shadow 220ms ease;
}

.metric-cell::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(
    105deg,
    transparent 5%,
    rgba(255, 255, 255, 0.92) 45%,
    transparent 85%
  );
  content: "";
  pointer-events: none;
  opacity: 0;
  transform: translateX(-120%);
}

.metric-cell.left {
  box-shadow: inset 3px 0 0 rgba(10, 154, 132, 0.17);
}

.metric-cell.right {
  box-shadow: inset 3px 0 0 rgba(240, 93, 63, 0.17);
}

.metric-cell.left.is-updating {
  animation: step-cell-pulse-left 920ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.metric-cell.right.is-updating {
  animation: step-cell-pulse-right 920ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.metric-cell.is-updating::after {
  animation: step-cell-sweep 720ms ease-out;
}

.metric-cell.is-updating .metric-current {
  animation: metric-value-pop 720ms cubic-bezier(0.18, 0.82, 0.2, 1);
}

.metric-cell.is-updating .metric-summary {
  animation: metric-summary-rise 720ms ease-out;
}

.left-column.is-updating {
  animation: step-header-pulse-left 920ms ease-out;
}

.right-column.is-updating {
  animation: step-header-pulse-right 920ms ease-out;
}

.table-frame.is-stepping-left {
  animation: step-frame-pulse-left 920ms ease-out;
}

.table-frame.is-stepping-right {
  animation: step-frame-pulse-right 920ms ease-out;
}

.metric-current {
  position: relative;
  z-index: 1;
  display: block;
  min-height: 1.4em;
  font-size: 1rem;
  font-weight: 820;
  letter-spacing: -0.02em;
}

.metric-summary {
  position: relative;
  z-index: 1;
  display: block;
  min-height: 1.25em;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.65rem;
}

@keyframes step-cell-pulse-left {
  0% {
    background: #ffffff;
    box-shadow: inset 3px 0 0 rgba(10, 154, 132, 0.17);
  }
  16% {
    background: #75e3cb;
    box-shadow: inset 7px 0 0 #087e6e, inset 0 0 0 2px rgba(8, 126, 110, 0.65);
  }
  52% {
    background: #c7f7eb;
    box-shadow: inset 5px 0 0 rgba(10, 154, 132, 0.58);
  }
  100% {
    background: #ffffff;
    box-shadow: inset 3px 0 0 rgba(10, 154, 132, 0.17);
  }
}

@keyframes step-cell-pulse-right {
  0% {
    background: #ffffff;
    box-shadow: inset 3px 0 0 rgba(240, 93, 63, 0.17);
  }
  16% {
    background: #ff9b82;
    box-shadow: inset 7px 0 0 #cc4e35, inset 0 0 0 2px rgba(204, 78, 53, 0.65);
  }
  52% {
    background: #ffe0d8;
    box-shadow: inset 5px 0 0 rgba(240, 93, 63, 0.58);
  }
  100% {
    background: #ffffff;
    box-shadow: inset 3px 0 0 rgba(240, 93, 63, 0.17);
  }
}

@keyframes step-cell-sweep {
  0% {
    opacity: 0;
    transform: translateX(-120%);
  }
  18% {
    opacity: 0.85;
  }
  78% {
    opacity: 0.35;
  }
  100% {
    opacity: 0;
    transform: translateX(120%);
  }
}

@keyframes metric-value-pop {
  0% {
    transform: translateY(0) scale(1);
  }
  22% {
    transform: translateY(-2px) scale(1.16);
  }
  58% {
    transform: translateY(0) scale(1.04);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes metric-summary-rise {
  0% {
    opacity: 0.45;
    transform: translateY(5px);
  }
  45%,
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes step-header-pulse-left {
  0%,
  100% {
    background: #087e6e;
  }
  18% {
    background: #13b99f;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6);
  }
}

@keyframes step-header-pulse-right {
  0%,
  100% {
    background: #cc4e35;
  }
  18% {
    background: #ff7559;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6);
  }
}

@keyframes step-frame-pulse-left {
  18% {
    box-shadow: 0 0 0 4px rgba(10, 154, 132, 0.35), 0 18px 55px rgba(23, 34, 43, 0.08);
  }
}

@keyframes step-frame-pulse-right {
  18% {
    box-shadow: 0 0 0 4px rgba(240, 93, 63, 0.35), 0 18px 55px rgba(23, 34, 43, 0.08);
  }
}

.metric-source {
  padding: 12px 14px;
  background: #fbfcfa;
}

.source-tag {
  display: inline-flex;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.64rem;
  font-weight: 850;
}

.metric-source small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.4;
}

.notify-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.72rem;
}

.notify-strip span:first-child {
  color: var(--signal);
  font-weight: 850;
}

.notify-strip span:last-child {
  margin-left: auto;
  color: var(--ink);
  font-weight: 800;
}

.scope-note {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding: 12px 14px;
  border-left: 3px solid #d3a117;
  border-radius: 4px 10px 10px 4px;
  color: #63511d;
  background: #fff8df;
  font-size: 0.72rem;
  line-height: 1.6;
}

.scope-note p {
  margin: 0;
}

.chart-card {
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--dark);
  box-shadow: var(--shadow);
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
  padding: 0 6px 6px;
  color: #9fb0bc;
  font-size: 0.62rem;
  font-weight: 700;
}

.chart-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: white;
  font-size: 0.78rem;
}

.chart-title span {
  color: #7fa4ff;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.chart-meta {
  display: flex;
  align-items: center;
  gap: 15px;
}

.chart-legend {
  display: flex;
  gap: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-line {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 99px;
}

.legend-line.left {
  background: #35d1b6;
}

.legend-line.right {
  background: #ff7559;
}

#raw-chart {
  display: block;
  width: 100%;
  height: 146px;
  border-radius: 8px;
  background: #0b141b;
}

.chart-footnote {
  margin: 8px 4px 0;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.45;
}

.how-section {
  padding-top: 28px;
}

.settings-guide {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  padding: 15px 17px;
  border: 1px solid #c9d7ff;
  border-radius: 14px;
  color: var(--ink);
  background: #f2f6ff;
  font-size: 0.76rem;
  line-height: 1.55;
}

.settings-guide > i {
  flex: 0 0 auto;
  color: var(--signal);
  font-size: 1.25rem;
}

.settings-guide strong {
  font-size: 0.82rem;
}

.settings-guide p {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  margin: 7px 0 0;
  color: var(--muted);
}

.settings-guide p span {
  white-space: nowrap;
}

.settings-guide p .settings-guide-default {
  flex-basis: 100%;
  color: var(--ink);
  font-weight: 750;
}

code {
  padding: 0.1em 0.3em;
  border-radius: 4px;
  color: #244da6;
  background: #e9efff;
}

.code-card {
  overflow: auto;
  margin: 12px 0 0;
  padding: 20px;
  border-radius: 15px;
  color: #dce8ee;
  background: var(--dark);
  font: 0.78rem/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.code-card code {
  padding: 0;
  color: inherit;
  background: transparent;
}

footer {
  padding: 26px 0 8px;
  color: var(--muted);
  font-size: 0.65rem;
  text-align: center;
}

@media (max-width: 900px) {
  .title-line,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolkit-cluster {
    width: 100%;
  }

  .toolkit-slot {
    flex: 1;
  }

  .section-heading {
    gap: 8px;
  }

}

@media (max-width: 720px) {
  .header-inner,
  .page-shell {
    width: min(100% - 24px, 1260px);
  }

  .header-inner {
    padding-top: 20px;
  }

  .toolkit-cluster,
  .control-strip,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .control-strip {
    gap: 14px;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .button {
    padding-inline: 8px;
  }

  .notify-strip {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .notify-strip span:last-child {
    margin-left: 0;
  }

  .settings-guide p {
    align-items: flex-start;
    flex-direction: column;
  }

  .settings-guide p span {
    white-space: normal;
  }

  .step-trend-latest {
    gap: 4px;
  }

  #step-trend-chart {
    height: 128px;
  }

  #raw-chart {
    height: 150px;
  }

  .chart-toolbar,
  .chart-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
