:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-alt: #fdf9f2;
  --border: #e6e0d4;
  --text: #2b2a27;
  --muted: #7a746a;
  --accent: #d97706;
  --accent-soft: #fde7c8;
  --user-bubble: #fff3df;
  --bot-bubble: #ffffff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 24px 20px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.tagline {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.context-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.context-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}

.context-label {
  font-weight: 600;
  color: var(--muted);
  min-width: 110px;
}

.context-value {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.chat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 320px;
  overflow-y: auto;
}

.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  word-break: break-word;
  border: 1px solid var(--border);
  animation: fadeInUp 160ms ease-out;
}

.bubble.bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  border-top-left-radius: 4px;
}

.bubble.user {
  align-self: flex-end;
  background: var(--user-bubble);
  border-top-right-radius: 4px;
}

.bubble.system {
  align-self: center;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  border-style: dashed;
}

.bubble.loading::after {
  content: " …";
  animation: blink 1.2s infinite;
}

.results {
  align-self: stretch;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.results h2 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--accent);
}

.result-category {
  margin-bottom: 14px;
}

.result-category:last-child {
  margin-bottom: 0;
}

.result-category h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text);
}

.result-category ul {
  margin: 0;
  padding-left: 20px;
}

.result-category li {
  font-size: 14px;
  margin-bottom: 2px;
}

.result-category a {
  color: var(--accent);
  text-decoration: none;
}

.result-category a:hover {
  text-decoration: underline;
}

.input-bar {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
}

.user-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-size: 15px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}

.user-input:disabled {
  color: var(--muted);
}

#send-button {
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: background 120ms ease;
}

#send-button:hover:not(:disabled) {
  background: #b86205;
}

#send-button:disabled {
  background: #d6d1c7;
  cursor: not-allowed;
}

.app-footer {
  text-align: center;
  padding: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .context-label {
    min-width: auto;
  }
  .app-header h1 {
    font-size: 19px;
  }
}
