:root {
  color-scheme: light;
  --bg: #eef7ff;
  --bg-strong: #d9ecff;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --text: #10233f;
  --muted: #5a6b82;
  --line: rgba(74, 122, 174, 0.22);
  --blue-900: #0b2f6b;
  --blue-700: #145cbf;
  --blue-500: #1f8fff;
  --blue-300: #8dccff;
  --cyan: #00a8d8;
  --green: #169b75;
  --amber: #b7791f;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(28, 80, 140, 0.18);
  font-family: "LINE Seed JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(31, 143, 255, 0.18), rgba(0, 168, 216, 0.08) 38%, rgba(255, 255, 255, 0.86) 72%),
    radial-gradient(circle at 12% 0%, rgba(20, 92, 191, 0.20), transparent 32%),
    var(--bg);
  -webkit-tap-highlight-color: rgba(20, 92, 191, 0.18);
}

button,
input,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
audio:focus-visible,
pre:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(31, 143, 255, 0.65);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: 12px;
  z-index: 10;
  padding: 10px 12px;
  color: white;
  background: var(--blue-900);
  border-radius: 6px;
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px max(24px, env(safe-area-inset-left)) 18px max(24px, env(safe-area-inset-right));
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue-700);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  text-wrap: balance;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(20, 92, 191, 0.20);
  border-radius: 999px;
  color: var(--blue-900);
  background: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.live,
.badge.success {
  color: #07543f;
  border-color: rgba(22, 155, 117, 0.28);
  background: rgba(218, 250, 240, 0.9);
}

.status-pill.error {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.28);
  background: rgba(255, 235, 232, 0.9);
}

.badge.neutral {
  color: var(--muted);
}

.badge.accent {
  color: #07536a;
  border-color: rgba(0, 168, 216, 0.28);
  background: rgba(226, 248, 255, 0.9);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 16px;
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 0 32px;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.response-panel,
.pipeline-panel,
.log-panel {
  grid-column: span 1;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(74, 122, 174, 0.28);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 132px;
  padding: 12px;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: #8a9bb0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

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

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.primary-button {
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  box-shadow: 0 12px 26px rgba(20, 92, 191, 0.24);
}

.secondary-button {
  padding: 0 16px;
  color: var(--blue-900);
  border: 1px solid rgba(20, 92, 191, 0.22);
  background: #ffffff;
}

.ghost-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--blue-700);
  border: 1px solid rgba(20, 92, 191, 0.16);
  background: rgba(255, 255, 255, 0.6);
}

.wide {
  width: 100%;
  margin-top: 12px;
}

.tab-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid rgba(74, 122, 174, 0.20);
  border-radius: 8px;
  background: rgba(225, 240, 255, 0.65);
}

.tab-list button {
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}

.tab-list button[aria-selected="true"] {
  color: var(--blue-900);
  background: #fff;
  box-shadow: 0 8px 22px rgba(28, 80, 140, 0.12);
}

.tab-panel.hidden {
  display: none;
}

.recorder-surface {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(74, 122, 174, 0.20);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(224, 242, 255, 0.78));
}

.recorder-label,
.recorder-state {
  margin: 0;
}

.recorder-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.recorder-state {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 800;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(20, 92, 191, 0.14);
}

.meter span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--blue-500));
  transform-origin: left center;
}

.meter.active span {
  animation: meterPulse 900ms ease-in-out infinite alternate;
}

.action-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.action-strip > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(74, 122, 174, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.live-control {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid rgba(31, 143, 255, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(232, 246, 255, 0.96), rgba(255, 255, 255, 0.78));
}

.live-control strong {
  display: block;
  color: var(--blue-900);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.label-text {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.action-strip strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.audio-control {
  width: 100%;
  margin-top: 12px;
}

.prompt-player {
  min-width: 0;
}

.compact-row {
  align-items: center;
  margin-top: 10px;
}

.audio-status {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.audio-status.live {
  color: var(--green);
}

.audio-status.error {
  color: var(--danger);
}

.json-view {
  min-height: 210px;
  max-height: 360px;
  margin: 14px 0 0;
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(74, 122, 174, 0.18);
  border-radius: 8px;
  color: #143159;
  background: #f8fbff;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pipeline-list {
  display: grid;
  gap: 10px;
}

.pipeline-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(120px, 1.6fr) 64px;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.pipeline-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(20, 92, 191, 0.12);
}

.pipeline-bar span {
  display: block;
  width: var(--bar-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue-500), var(--cyan));
}

.pipeline-ms {
  text-align: right;
  color: var(--blue-900);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.api-log {
  display: grid;
  gap: 8px;
  max-height: 340px;
  margin: 0;
  overflow: auto;
  padding: 0;
  list-style: none;
}

.api-log li {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 64px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(74, 122, 174, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.api-log code {
  min-width: 0;
  overflow: hidden;
  color: var(--blue-900);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-log .ok {
  color: var(--green);
  font-weight: 800;
  text-align: right;
}

.api-log .ng {
  color: var(--danger);
  font-weight: 800;
  text-align: right;
}

@keyframes meterPulse {
  from { transform: scaleX(0.22); }
  to { transform: scaleX(1); }
}

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

@media (max-width: 920px) {
  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-header {
    padding-inline: 16px;
  }

  .app-shell {
    width: calc(100vw - 20px);
  }

  .form-grid,
  .action-strip,
  .recorder-surface,
  .pipeline-row,
  .api-log li {
    grid-template-columns: 1fr;
  }

  .pipeline-ms,
  .api-log .ok,
  .api-log .ng {
    text-align: left;
  }
}
