:root {
  color: #172033;
  background: #f6f7f8;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --navy: #0c1830;
  --ink: #172033;
  --muted: #697386;
  --line: #dfe3ea;
  --surface: #ffffff;
  --soft: #f1f3f6;
  --accent: #b99a5b;
  --danger: #a43d3d;
  --shadow: 0 18px 55px rgba(12, 24, 48, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  min-height: 100%;
  margin: 0;
}

body {
  overflow: auto;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.app-shell {
  width: min(100%, 1120px);
  min-height: 720px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background:
    radial-gradient(circle at top right, rgba(185, 154, 91, 0.12), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, #f7f8fa 100%);
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  color: #fff;
  background: linear-gradient(135deg, #081225 0%, #13223c 72%, #1b2c4a 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: #d5c39c;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  font-weight: 650;
  letter-spacing: -0.04em;
}

.subtitle {
  max-width: 680px;
  margin: 12px 0 0;
  color: #d9e0ec;
  line-height: 1.8;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 360px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #d9e0ec;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-panel,
.chat-panel,
.composer,
.cta-panel,
.error-banner {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 32px rgba(12, 24, 48, 0.07);
}

.sample-panel {
  padding: 16px 18px;
}

.sample-panel p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.sample-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sample-list button {
  border: 1px solid #ccd3df;
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--ink);
  background: #fff;
  transition:
    border-color 0.18s ease,
    transform 0.18s ease,
    background 0.18s ease;
}

.sample-list button:hover:not(:disabled) {
  border-color: var(--accent);
  background: #fbfaf7;
  transform: translateY(-1px);
}

.chat-panel {
  flex: 1;
  min-height: 320px;
  max-height: 430px;
  overflow: auto;
  padding: 20px;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: grid;
  gap: 6px;
  max-width: 86%;
}

.message--user {
  align-self: flex-end;
  justify-items: end;
}

.message--assistant {
  align-self: flex-start;
  justify-items: start;
}

.message-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.message-card {
  padding: 16px 18px;
  border-radius: 18px;
  line-height: 1.78;
}

.message--user .message-card {
  color: #fff;
  background: var(--navy);
  border-top-right-radius: 6px;
}

.message--assistant .message-card {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-top-left-radius: 6px;
}

.message-card p {
  margin: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 0.2em 0 0.55em;
  color: #0b172d;
  line-height: 1.35;
}

.markdown-body h1 {
  font-size: 1.35rem;
}

.markdown-body h2 {
  font-size: 1.16rem;
}

.markdown-body h3 {
  font-size: 1.02rem;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  margin: 0 0 0.85em;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.35em;
}

.markdown-body :last-child {
  margin-bottom: 0;
}

.metadata-panel {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.metadata-panel summary {
  color: #25324b;
  font-size: 0.88rem;
  font-weight: 700;
}

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

.metadata-grid section,
.debug-details {
  padding: 12px;
  border: 1px solid #e6e9ef;
  border-radius: 14px;
  background: var(--soft);
}

.metadata-grid h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.metadata-grid ul {
  display: grid;
  gap: 6px;
  padding-left: 1.1em;
  margin: 0;
}

.metadata-grid li strong {
  margin-left: 8px;
  color: var(--navy);
}

.source-list a {
  color: #1e3a68;
  word-break: break-word;
}

.debug-details {
  margin-top: 12px;
}

.debug-details pre {
  max-height: 260px;
  overflow: auto;
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #27334b;
  font-size: 0.78rem;
}

.loading-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.loader {
  width: 14px;
  height: 14px;
  border: 2px solid #ccd3df;
  border-top-color: var(--navy);
  border-radius: 999px;
  animation: spin 0.85s linear infinite;
}

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

.error-banner {
  padding: 12px 16px;
  color: var(--danger);
  background: #fff7f6;
  border-color: #efc5c2;
  font-weight: 700;
}

.error-region:empty {
  display: none;
}

.composer {
  padding: 16px;
}

.composer label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.composer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
}

textarea {
  width: 100%;
  min-height: 56px;
  max-height: 150px;
  resize: vertical;
  border: 1px solid #cfd6e2;
  border-radius: 15px;
  padding: 13px 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(185, 154, 91, 0.16);
}

.composer button {
  min-width: 104px;
  border: 0;
  border-radius: 15px;
  padding: 0 20px;
  color: #fff;
  background: var(--navy);
  font-weight: 800;
  transition:
    transform 0.18s ease,
    background 0.18s ease;
}

.composer button:hover:not(:disabled) {
  background: #15294d;
  transform: translateY(-1px);
}

.cta-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
}

.cta-panel p {
  margin: 0;
  color: #25324b;
  line-height: 1.7;
}

.cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.cta-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #c9b27a;
  border-radius: 8px;
  color: #172033;
  background: #fffbf0;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.cta-actions a:first-child {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.answer-note {
  max-width: 920px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

@media (max-width: 720px) {
  .app-shell {
    min-height: 100vh;
    padding: 14px;
  }

  .hero {
    flex-direction: column;
    padding: 22px;
    border-radius: 18px;
  }

  .status-pill {
    max-width: 100%;
  }

  .chat-panel {
    max-height: none;
    padding: 14px;
  }

  .message {
    max-width: 96%;
  }

  .metadata-grid {
    grid-template-columns: 1fr;
  }

  .composer-row {
    grid-template-columns: 1fr;
  }

  .cta-panel {
    grid-template-columns: 1fr;
  }

  .cta-actions {
    justify-content: stretch;
  }

  .cta-actions a {
    justify-content: center;
    width: 100%;
  }

  .composer button {
    min-height: 48px;
  }
}
