/* === Base === */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --bg-secondary: #252540;
  --bg-bubble-user: #2a4a7f;
  --bg-bubble-horikun: #2d2d4a;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #6c63ff;
  --accent-hover: #5a52d5;
  --border: #3d3d5c;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
}

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

/* === Landing page === */
.landing {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  padding: 2rem;
}

.landing-inner {
  width: 100%;
  max-width: 600px;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.logo-icon { font-size: 2rem; }

.logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.input-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.input-area textarea {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  resize: vertical;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.input-area textarea:focus {
  border-color: var(--accent);
}

.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s;
}

.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: #4a4a6a; cursor: not-allowed; opacity: 0.7; }

/* === Chat page === */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
}

.chat-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-logo {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

/* Message bubbles */
.message-row {
  display: flex;
  gap: 0.5rem;
  max-width: 85%;
}

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.horikun {
  align-self: flex-start;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.message-row.user .avatar { background: var(--bg-bubble-user); }

.bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.message-row.user .bubble {
  background: var(--bg-bubble-user);
  border-bottom-right-radius: 4px;
}

.message-row.horikun .bubble {
  background: var(--bg-bubble-horikun);
  border-bottom-left-radius: 4px;
}

/* Streaming cursor */
.bubble.streaming::after {
  content: '▊';
  animation: blink 0.8s infinite;
  color: var(--accent);
  margin-left: 1px;
}

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

/* Thinking animation */
.thinking-row {
  align-self: flex-start;
  display: flex;
  gap: 0.5rem;
  max-width: 85%;
}

.thinking-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  background: var(--bg-bubble-horikun);
  position: relative;
  min-width: 200px;
  min-height: 42px;
}

.thinking-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.thinking-text::after {
  content: '';
  animation: thinkingDots 1.5s infinite;
}

@keyframes thinkingDots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* Shimmer effect on thinking bubble */
.thinking-bubble::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(108, 99, 255, 0.06) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Footer input */
.chat-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.follow-up-area {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.follow-up-area textarea {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 120px;
  transition: border-color 0.2s;
}

.follow-up-area textarea:focus { border-color: var(--accent); }
.follow-up-area textarea:disabled { opacity: 0.5; }

.follow-up-area .send-btn {
  padding: 0.6rem;
  border-radius: 10px;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Responsive */
@media (max-width: 640px) {
  .message-row { max-width: 92%; }
  .chat-messages { padding: 0.75rem; }
}
