:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3d9a6f;
  --accent-dim: #2d7a56;
  --danger: #c45c5c;
  --radius: 12px;
  --font: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

header {
  margin-bottom: 1.5rem;
}

header .eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: none;
}

header h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  letter-spacing: 0.02em;
}

header p.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.mode-tabs button {
  flex: 1;
  min-width: min(100%, 140px);
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.mode-tabs button:hover {
  border-color: var(--muted);
}

.mode-tabs button.active {
  border-color: var(--accent);
  background: rgba(61, 154, 111, 0.12);
  color: #b8e6cf;
}

.chat-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 360px;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  max-height: min(52vh, 520px);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.msg {
  max-width: 92%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: rgba(61, 154, 111, 0.2);
  border: 1px solid rgba(61, 154, 111, 0.35);
}

.msg.assistant {
  align-self: flex-start;
  background: #141c28;
  border: 1px solid var(--border);
}

.msg .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.empty-hint {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 1rem;
}

.composer {
  border-top: 1px solid var(--border);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.image-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.image-row input[type="file"] {
  font-size: 0.85rem;
  color: var(--muted);
}

.image-preview {
  max-width: 120px;
  max-height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  display: none;
}

.image-preview.visible {
  display: block;
}

.btn-clear-img {
  font-size: 0.8rem;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}

.text-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

textarea {
  flex: 1;
  min-height: 72px;
  max-height: 200px;
  resize: vertical;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #141c28;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea::placeholder {
  color: #5a6a7d;
}

button.send {
  padding: 0.65rem 1.1rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #0a120e;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  align-self: stretch;
}

button.send:hover:not(:disabled) {
  background: #4caf7d;
}

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

.banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.88rem;
  border: 1px solid #6b5a2d;
  background: rgba(200, 160, 60, 0.1);
  color: #e6d4a8;
}

.banner.error {
  border-color: #8b3d3d;
  background: rgba(180, 60, 60, 0.12);
  color: #f0b0b0;
}

.banner:not(.error) code {
  font-size: 0.85em;
  color: #c9dcb8;
}

.manual-link {
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
}

.manual-link a {
  color: #7ec8a8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.manual-link a:hover {
  color: #a8e0c4;
}

footer.disclaimer {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

footer.disclaimer strong {
  color: #a0aec0;
}

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.35rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 520px) {
  .text-row {
    flex-direction: column;
    align-items: stretch;
  }

  button.send {
    align-self: auto;
  }
}
