:root {
  --bg: #f7fbff;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-soft: #f4f8fd;
  --text: #0b2146;
  --muted: #7086ad;
  --line: #dfe9f7;
  --primary: #1677ff;
  --primary-soft: #eaf4ff;
  --orange: #ff8a00;
  --green: #16c784;
  --purple: #873cff;
  --cyan: #2ab5ff;
  --shadow: 0 12px 32px rgba(42, 87, 143, 0.11);
  --shadow-soft: 0 6px 18px rgba(42, 87, 143, 0.08);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  font-family: Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(42, 181, 255, 0.10), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, #f5f9ff 100%);
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 12px 88px;
  background: rgba(255, 255, 255, 0.72);
  border-left: 1px solid rgba(223, 233, 247, 0.6);
  border-right: 1px solid rgba(223, 233, 247, 0.6);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 8px 4px 14px;
}

.icon-button,
.avatar-button,
.attachment-button,
.help-dot,
.nav-item {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 24px;
  color: #164a92;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: white;
  font-weight: 800;
  background: linear-gradient(145deg, #0d4fb7, #1887ff);
  box-shadow: var(--shadow-soft);
}

.brand-copy h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.brand-copy p {
  margin: 2px 0 0;
  font-size: 11px;
  color: #8ca1c3;
}

.header-spacer {
  flex: 1;
}

.level-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  font-size: 13px;
  font-weight: 700;
}

.avatar-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(#e9f1fc, #dce8f9);
  color: #5278ad;
  font-size: 20px;
}

.opponent-card,
.metric-card,
.conversation-card {
  background: var(--surface);
  border: 1px solid rgba(223, 233, 247, 0.88);
  box-shadow: var(--shadow);
}

.opponent-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: var(--radius-lg);
}

.opponent-summary {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  overflow: hidden;
}

.opponent-summary > div:last-child {
  min-width: 0;
}

.emotion-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
}

.emotion-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  color: #637ba4;
}

.opponent-summary h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.compact-status-block {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.status-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.help-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #dbe6f5;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.signal-lights {
  display: flex;
  gap: 6px;
}

.signal-light {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d9e3f0;
  box-shadow: inset 0 1px 2px rgba(7, 38, 77, 0.08);
}

.signal-light.go {
  background: linear-gradient(145deg, #34d998, #11b873);
  box-shadow: 0 0 9px rgba(22, 199, 132, 0.28);
}

.signal-light.check {
  background: linear-gradient(145deg, #ffd54a, #ff9f0a);
  box-shadow: 0 0 9px rgba(255, 159, 10, 0.24);
}

.temperature-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.temperature-display strong {
  color: var(--orange);
  font-size: 16px;
}

.thermometer {
  position: relative;
  width: 15px;
  height: 34px;
  border: 3px solid #8aa7cf;
  border-radius: 9px 9px 7px 7px;
  background: #fff;
  overflow: visible;
}

.thermometer::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 13px;
  height: 13px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--orange);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #8aa7cf;
}

.thermometer-fill {
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 5px;
  height: 60%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(#ffc44d, var(--orange));
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin: 12px 0;
}

.metric-card {
  min-width: 0;
  padding: 10px 5px 9px;
  border-radius: var(--radius-md);
  text-align: center;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: 0 auto 4px;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 800;
  background: #eef5ff;
}

.metric-card strong {
  display: block;
  font-size: 11px;
  line-height: 1.2;
}

.metric-dots {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 7px;
}

.metric-dot {
  width: 8px;
  height: 5px;
  border-radius: 999px;
  background: #dbe5f2;
}

.metric-dot.on {
  background: var(--metric-color, var(--primary));
}

.conversation-card {
  display: flex;
  flex-direction: column;
  height: min(64vh, 680px);
  min-height: 480px;
  padding: 14px 12px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.conversation-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px 12px;
  border-bottom: 1px solid #edf2f8;
}

.conversation-head strong {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.turn-status {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #175aa9;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.message-list {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 14px 3px 18px;
  scroll-behavior: smooth;
}

.message-list:focus-visible {
  outline: 2px solid rgba(22, 119, 255, 0.28);
  outline-offset: -2px;
  border-radius: 12px;
}

.turn-separator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8196b7;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.turn-separator::before,
.turn-separator::after {
  content: "";
  height: 1px;
  flex: 1;
  background: #e3ebf6;
}

.message-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.message-row.user {
  justify-content: flex-end;
}

.message-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border: 2px solid #dde8f6;
  border-radius: 50%;
  background: #fff;
  color: var(--primary);
  font-size: 18px;
}

.message-content {
  max-width: 78%;
}

.message-bubble {
  padding: 13px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.65;
  background: #f7f9fc;
  border: 1px solid #edf1f6;
}

.message-row.user .message-bubble {
  background: linear-gradient(145deg, #eef7ff, #e4f1ff);
  border-color: #d7eaff;
}

.message-time {
  margin-top: 5px;
  color: #7890b5;
  font-size: 10px;
}

.message-row.user .message-time {
  text-align: right;
}

.composer {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 48px;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-soft);
}

.attachment-button,
.send-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.attachment-button {
  color: #6885b4;
  font-size: 22px;
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 8px;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--text);
  background: transparent;
}

.composer textarea::placeholder {
  color: #a6b7d0;
}

.send-button {
  border: 0;
  color: white;
  font-size: 21px;
  cursor: pointer;
  background: linear-gradient(145deg, #2d8dff, #0666ee);
  box-shadow: 0 8px 18px rgba(22, 119, 255, 0.27);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  width: min(100%, 460px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.nav-item {
  display: grid;
  justify-items: center;
  gap: 3px;
  color: #7890b7;
}

.nav-item span {
  min-height: 21px;
  font-size: 17px;
  font-weight: 800;
}

.nav-item small {
  font-size: 11px;
}

.nav-item.active {
  color: var(--primary);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 390px) {
  .app-shell {
    padding-inline: 8px;
  }

  .opponent-card {
    grid-template-columns: 1fr 1fr;
  }

  .opponent-summary {
    grid-column: 1 / -1;
  }

  .compact-status-block.push-pull-block {
    border-left: 0;
    padding-left: 0;
  }

  .metric-card {
    padding-inline: 2px;
  }

  .metric-card strong {
    font-size: 10px;
  }

  .conversation-head {
    align-items: flex-start;
  }

  .turn-status {
    font-size: 10px;
  }
}

@media (min-width: 760px) {
  body {
    padding: 28px 0;
  }

  .app-shell {
    min-height: calc(100vh - 56px);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: 0 22px 70px rgba(42, 87, 143, 0.15);
  }

  .bottom-nav {
    bottom: 28px;
    border: 1px solid var(--line);
    border-radius: 0 0 28px 28px;
  }
}
