/* Repo Explainer — Apple "Liquid Glass" 風 UI
 * 半透明のフロストガラス（backdrop-filter）、淡いグラデーション背景、
 * 浮遊するぼかしブロブ、柔らかな影と丸み、ヴィブランシーを基調とする。
 */

:root {
  --text: #14181f;
  --muted: #5b6675;
  --accent: #0a84ff;          /* Apple blue */
  --accent-2: #5e5ce6;        /* indigo */
  --danger: #ff3b30;
  --warn: #ff9f0a;
  --ok: #30d158;

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 10px 40px rgba(31, 38, 71, 0.18);
  --blur: 22px;
  --radius: 22px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #eaf1ff 0%, #f6f0ff 40%, #fef0f6 100%);
  overflow-x: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ===== 背景ブロブ ===== */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: float 18s ease-in-out infinite;
}
.blob-1 { width: 420px; height: 420px; background: #7ab8ff; top: -80px; left: -60px; }
.blob-2 { width: 380px; height: 380px; background: #c79bff; top: 20%; right: -80px; animation-delay: -4s; }
.blob-3 { width: 460px; height: 460px; background: #ff9ec7; bottom: -120px; left: 15%; animation-delay: -8s; }
.blob-4 { width: 300px; height: 300px; background: #8affd1; bottom: 10%; right: 20%; animation-delay: -12s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 25px) scale(0.96); }
}

/* ===== ガラス共通 ===== */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ===== ヘッダー ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  margin: 12px 12px 0;
  border-radius: var(--radius);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: 0.2px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px rgba(10, 132, 255, 0.6);
}
.brand-dot.big { width: 40px; height: 40px; margin: 0 auto 6px; }

.nav { display: flex; gap: 6px; }
.nav-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: all 0.2s;
}
.nav-btn:hover { color: var(--text); background: rgba(255,255,255,0.4); }
.nav-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.35);
}

.user-area { display: flex; align-items: center; gap: 12px; }
.user-email { font-size: 13px; color: var(--muted); }

/* ===== ボタン ===== */
.primary-btn {
  border: none; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 11px 20px; border-radius: 999px; font-size: 15px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(10, 132, 255, 0.35);
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(10,132,255,0.45); }
.primary-btn:active { transform: translateY(0); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.ghost-btn {
  border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.35);
  color: var(--text); padding: 8px 14px; border-radius: 999px;
  cursor: pointer; font-size: 13px; transition: background 0.2s;
}
.ghost-btn:hover { background: rgba(255,255,255,0.6); }

/* ===== ログイン ===== */
.centered { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card {
  border-radius: 28px; padding: 40px 36px; text-align: center;
  max-width: 380px; width: 100%;
}
.card h2 { margin: 4px 0 6px; }
.card .primary-btn { margin-top: 18px; width: 100%; }

.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ===== チャット ===== */
.chat-view {
  flex: 1; display: flex; flex-direction: column;
  width: 100%; max-width: 880px; margin: 0 auto; padding: 16px 16px 22px;
  min-height: 0;
}
.controls {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
  padding: 14px 18px; border-radius: var(--radius); margin-bottom: 14px;
}
.control { display: flex; flex-direction: column; gap: 4px; }
.control-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.controls select {
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 14px;
  border: 1px solid rgba(255,255,255,0.6); background: rgba(255,255,255,0.65);
  max-width: 460px; color: var(--text);
}

.mode-toggle {
  display: inline-flex; align-items: center; background: rgba(255,255,255,0.5);
  border-radius: 999px; padding: 4px; border: 1px solid rgba(255,255,255,0.6);
}
.mode-toggle input { display: none; }
.mode-toggle label {
  padding: 7px 16px; border-radius: 999px; font-size: 13px; cursor: pointer;
  color: var(--muted); font-weight: 600; transition: all 0.2s;
}
.mode-toggle input:checked + label {
  background: #fff; color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.messages {
  flex: 1; overflow-y: auto; padding: 6px 2px 12px;
  display: flex; flex-direction: column; gap: 14px; min-height: 0;
}
.message { display: flex; flex-direction: column; max-width: 82%; }
.message.user { align-self: flex-end; align-items: flex-end; }
.message.assistant, .message.system { align-self: flex-start; }

.bubble {
  padding: 12px 16px; border-radius: 20px; white-space: pre-wrap;
  line-height: 1.7; font-size: 15px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.message.user .bubble {
  color: #fff; border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(10,132,255,0.3);
}
.message.assistant .bubble {
  background: var(--glass-bg-strong); border: 1px solid var(--glass-border);
  border-bottom-left-radius: 6px; box-shadow: var(--glass-shadow);
}
.message.system .bubble {
  background: rgba(255,255,255,0.4); color: var(--muted);
  font-size: 13px; font-style: italic; border-radius: 14px;
}

.files { margin-top: 6px; font-size: 12px; color: var(--muted); }
.msg-actions { margin-top: 6px; }
.msg-actions .ghost-btn { font-size: 12px; padding: 5px 12px; }

/* ぐるぐる（処理中） */
.typing { display: inline-flex; gap: 5px; align-items: center; }
.typing span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  opacity: 0.6; animation: blink 1.2s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* AIが検知した懸念 */
.issues {
  margin-top: 10px; border-radius: 16px; padding: 12px 14px;
  background: rgba(255, 159, 10, 0.12); border: 1px solid rgba(255,159,10,0.35);
}
.issues h4 { margin: 0 0 8px; font-size: 13px; color: #b25e00; }
.issue { font-size: 13px; margin: 6px 0; line-height: 1.5; }
.issue .sev {
  display: inline-block; font-size: 11px; font-weight: 700; color: #fff;
  border-radius: 6px; padding: 1px 7px; margin-right: 6px; vertical-align: middle;
}
.sev-high { background: var(--danger); }
.sev-medium { background: var(--warn); }
.sev-low { background: var(--ok); }

/* 入力フォーム */
.chat-form {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 12px; border-radius: var(--radius);
}
.chat-form textarea {
  flex: 1; resize: none; max-height: 160px;
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 15px;
  font-family: inherit; border: 1px solid rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.7); color: var(--text);
}
.chat-form textarea:focus { outline: 2px solid rgba(10,132,255,0.4); }

/* ===== 報告FAB ===== */
.report-fab {
  position: fixed; right: 22px; bottom: 24px; z-index: 30;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 12px 18px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--accent);
  border: 1px solid var(--glass-border);
}
.report-fab span { font-size: 16px; }
.report-fab:hover { background: var(--glass-bg-strong); }

/* ===== 報告一覧 ===== */
.reports-view { flex: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: 16px; }
.reports-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-radius: var(--radius); margin-bottom: 14px;
}
.reports-head h2 { margin: 0; font-size: 17px; }
.reports-list { display: flex; flex-direction: column; gap: 10px; }
.report-card {
  border-radius: 18px; padding: 14px 16px;
  background: var(--glass-bg-strong); border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
.report-card .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.report-card .msg { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.report-card .meta { font-size: 12px; color: var(--muted); margin-top: 8px; }
.tag {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: rgba(10,132,255,0.12); color: var(--accent);
}
.tag.ai { background: rgba(94,92,230,0.14); color: var(--accent-2); }
.tag.user { background: rgba(48,209,88,0.16); color: #1a8f3c; }

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(20, 24, 31, 0.35);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal {
  width: 100%; max-width: 480px; border-radius: 26px; padding: 0; overflow: hidden;
  background: var(--glass-bg-strong);
}
.modal-head, .modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 4px 20px 12px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field select, .field textarea {
  border: 1px solid rgba(255,255,255,0.6); background: rgba(255,255,255,0.8);
  border-radius: 12px; padding: 9px 12px; font-size: 14px; font-family: inherit;
  color: var(--text);
}
.modal-foot { gap: 10px; justify-content: flex-end; }

/* ===== トースト ===== */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  z-index: 50; padding: 12px 22px; border-radius: 999px; font-size: 14px;
  font-weight: 600; color: var(--text);
  background: var(--glass-bg-strong); border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

@media (max-width: 560px) {
  .nav { order: 3; width: 100%; justify-content: center; }
  .message { max-width: 92%; }
  .user-email { display: none; }
}
