/* === aic.asobi.info チャットUI === */
:root {
  --bg: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text: #e0e0e0;
  --text-secondary: #a0a0b0;
  --accent: #e94560;
  --accent-light: #ff6b81;
  --border: #2a2a4a;
  --msg-user: #0f3460;
  --msg-ai: #1a1a2e;
  --sidebar-w: 280px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app { display: flex; height: 100vh; }

/* === サイドバー === */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.logo { font-size: 1.2rem; margin-bottom: 12px; }
.sidebar-user { padding: 8px 16px; font-size: 0.85rem; color: var(--text-secondary); }
.sidebar-balance { padding: 4px 16px 8px; font-size: 0.8rem; color: var(--accent-light); border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section-title { padding: 8px 16px; font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.footer-link { color: var(--text-secondary); text-decoration: none; font-size: 0.85rem; }
.footer-link:hover { color: var(--accent); }

.conversation-list { display: flex; flex-direction: column; }
.conv-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}
.conv-item:hover { background: rgba(255,255,255,0.05); }
.conv-item.active { background: var(--bg-card); border-left: 3px solid var(--accent); }
.conv-item-name { font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; }
.conv-item-preview { font-size: 0.75rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === メインエリア === */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-header {
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.menu-btn { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; }
.header-title { flex: 1; font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-balance { font-size: 0.8rem; color: var(--accent-light); }

/* === 画面切り替え === */
.screen { display: none; flex: 1; overflow-y: auto; }
.screen.active { display: flex; flex-direction: column; }

/* === ホーム画面 === */
.home-content { padding: 24px; max-width: 800px; margin: 0 auto; width: 100%; }
.home-content h2 { font-size: 1.5rem; margin-bottom: 8px; }
.home-content > p { color: var(--text-secondary); margin-bottom: 24px; }
.char-section { margin-bottom: 32px; }
.char-section h3 { font-size: 1rem; margin-bottom: 12px; color: var(--text-secondary); }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.char-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid var(--border);
}
.char-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.char-card-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; margin-bottom: 8px;
}
.char-card-name { font-weight: 700; margin-bottom: 4px; }
.char-card-desc { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.char-card-meta { display: flex; gap: 8px; margin-top: 8px; font-size: 0.7rem; color: var(--text-secondary); }
.char-card-tag { background: rgba(233,69,96,0.2); color: var(--accent-light); padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; }

/* === チャット画面 === */
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg-user {
  background: var(--msg-user);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.msg-ai {
  background: var(--msg-ai);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.msg-ai-name { font-size: 0.75rem; color: var(--accent-light); margin-bottom: 4px; font-weight: 600; }
.msg-typing { color: var(--text-secondary); font-style: italic; }

.chat-input-area {
  display: flex;
  align-items: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  gap: 8px;
}
#chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 0.9rem;
  resize: none;
  max-height: 120px;
  outline: none;
  font-family: inherit;
}
#chat-input:focus { border-color: var(--accent); }
.send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.send-btn:hover { background: var(--accent-light); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }

/* === キャラ作成画面 === */
.create-form { padding: 24px; max-width: 600px; margin: 0 auto; width: 100%; }
.create-form h2 { margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
.form-group input[type="text"],
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--accent); }
.required { color: var(--accent); }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }

/* === タグ選択 === */
.tag-select { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-btn {
  padding: 4px 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.tag-btn:hover { border-color: var(--accent); }
.tag-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* === ボタン === */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-light); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* === モバイル対応 === */
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 99; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open + #main + .sidebar-overlay { display: block; }
  .menu-btn { display: block; }
  .char-grid { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
}

/* === スクロールバー === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
