* {
  box-sizing: border-box;
}

:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --text: #111111;
  --muted: #777777;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.12);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.app {
  width: min(920px, 100%);
  height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  min-height: 76px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(247, 247, 245, 0.96);
}

.brand {
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

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

.status,
.top-link,
.clear-btn {
  height: 36px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  padding: 0 11px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

.top-link {
  color: #111111;
  font-weight: 700;
}

.clear-btn {
  color: #111111;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.clear-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 120px;
}

.message {
  display: flex;
  margin: 12px 0;
}

.message.user {
  justify-content: flex-end;
}

.message.ai {
  justify-content: flex-start;
}

.bubble {
  max-width: min(720px, 86%);
  padding: 13px 15px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow);
}

.message.ai .bubble {
  background: var(--card);
  border: 1px solid var(--line);
}

.message.user .bubble {
  background: #111111;
  color: #ffffff;
  border: 1px solid #111111;
}

.composer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(920px, 100%);
  padding: 14px 14px 18px;
  background: linear-gradient(to top, var(--bg) 78%, rgba(247, 247, 245, 0));
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  padding: 14px 15px;
  font-size: 16px;
  line-height: 1.5;
  min-height: 52px;
  max-height: 140px;
  outline: none;
  box-shadow: var(--shadow);
  font-family: inherit;
}

textarea:focus {
  border-color: rgba(0, 0, 0, 0.28);
}

.composer button {
  height: 52px;
  border: none;
  border-radius: 16px;
  padding: 0 18px;
  background: #111111;
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

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

@media (max-width: 640px) {
  .topbar {
    min-height: 72px;
    padding: 14px 12px 12px;
    align-items: flex-start;
  }

  .brand {
    font-size: 24px;
  }

  .sub {
    font-size: 11px;
  }

  .top-actions {
    gap: 6px;
  }

  .status,
  .top-link,
  .clear-btn {
    height: 32px;
    padding: 0 9px;
    font-size: 11px;
  }

  .chat {
    padding: 18px 12px 112px;
  }

  .bubble {
    max-width: 90%;
    font-size: 14px;
  }

  .composer {
    padding: 12px 10px 14px;
  }

  .composer button {
    padding: 0 15px;
  }
}
