/* ===== 色の設定（ここを変えると全体の色が変わります） ===== */
:root {
  --bg: #030b17;          /* 背景 */
  --panel: #07182c;       /* パネルの背景 */
  --line: #12406b;        /* 枠線 */
  --accent: #34c3ff;      /* メインの青 */
  --accent-soft: rgba(52, 195, 255, 0.15);
  --text: #d8f1ff;        /* 文字 */
  --muted: #6f93b3;       /* 薄い文字 */
  --danger: #ff5c7a;      /* 停止・エラー */
  --ok: #3dffb5;          /* 正常 */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -10%, #0b3a66 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;   /* スマホでも左右に16pxの余白 */
}

/* ===== ヘッダー ===== */
.header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px 20px;
}
.title {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(52, 195, 255, 0.6);
}
.subtitle { margin: 0; font-size: 12px; color: var(--muted); letter-spacing: 0.15em; }

/* 光るコア（JARVISの“目”）。読み上げ中は脈打つ */
.core {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: radial-gradient(circle, #bfefff 0%, var(--accent) 30%, transparent 70%);
  box-shadow: 0 0 18px var(--accent);
}
.core.speaking { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse {
  50% { transform: scale(1.15); box-shadow: 0 0 32px var(--accent); }
}

.status {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.status-dot.speaking { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status-dot.error { background: var(--danger); }

/* ===== パネルの並び：PCは2列、スマホは1列 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .title { font-size: 22px; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: inset 0 0 24px rgba(52, 195, 255, 0.05);
}
.panel-title {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.15em;
}

/* ===== ボタン ===== */
.btn {
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;   /* 指で押しやすい大きさ */
  font-size: 15px;
  cursor: pointer;
  transition: 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); box-shadow: 0 0 10px rgba(52, 195, 255, 0.4); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #00182b; font-weight: bold; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.phrases {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

/* ===== 入力欄 ===== */
textarea, select, input[type="text"], input[type="password"] {
  width: 100%;
  background: #020a14;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 16px;   /* 16px未満だとiPhoneで勝手にズームされる */
  font-family: inherit;
}
textarea:focus, select:focus, input[type="text"]:focus, input[type="password"]:focus { outline: none; border-color: var(--accent); }

.row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.row .btn { flex: 1; }
.space-between { justify-content: space-between; }
.space-between .btn { flex: none; }

.field { display: block; margin-bottom: 12px; font-size: 14px; }
.field > span { display: block; margin-bottom: 6px; color: var(--muted); }
.field b { color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.hint { font-size: 12px; color: var(--muted); margin: 0; }
.hint.error { color: var(--danger); }

/* ===== 履歴 ===== */
.history {
  list-style: none; margin: 0; padding: 0;
  max-height: 240px; overflow-y: auto;
  font-size: 14px;
}
.history li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.history time { color: var(--muted); font-size: 12px; margin-right: 8px; }
.history .empty { color: var(--muted); border: none; }

/* ===== AI会話 ===== */
.panel.wide { grid-column: 1 / -1; }   /* PCでも横いっぱいに広げる */
.chat {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 160px; max-height: 50vh; overflow-y: auto;
  padding: 4px 2px 12px;
}
.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.6;
  white-space: pre-wrap;   /* 改行をそのまま表示 */
  word-break: break-word;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: #00182b; }
.bubble.assistant { align-self: flex-start; background: var(--accent-soft); border: 1px solid var(--line); }
.bubble.notice { align-self: center; font-size: 13px; color: var(--danger); background: none; }
.bubble.thinking { color: var(--muted); }
.bubble.info { align-self: center; font-size: 12px; color: var(--muted); padding: 2px 8px; }
.check { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.status-dot.thinking { background: #ffd166; animation: blink 1s infinite; }
.status-dot.listening { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: blink 1s infinite; }
.core.listening { border-color: var(--ok); box-shadow: 0 0 24px var(--ok); animation: pulse 1.4s ease-in-out infinite; }

/* マイクボタン：聞き取り中は緑に光る */
.btn.mic.active { border-color: var(--ok); color: var(--ok); box-shadow: 0 0 12px rgba(61, 255, 181, 0.5); }
@keyframes blink { 50% { opacity: 0.3; } }

/* ===== タスク ===== */
.tasks { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.tasks li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 15px;
}
.tasks input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.tasks .title { flex: 1; word-break: break-word; }
.tasks li.done .title { color: var(--muted); text-decoration: line-through; }
.tasks .delete { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; }
.tasks .delete:hover { color: var(--danger); }
.tasks .empty { color: var(--muted); border: none; }
.row input[type="text"] { flex: 3; }

/* ===== システム状態 ===== */
.modules { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.modules li { padding: 6px 0; }
.tag {
  display: inline-block; min-width: 56px; text-align: center;
  font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-right: 6px;
}
.tag.ok { color: var(--ok); border: 1px solid var(--ok); }
.tag.off { color: var(--muted); border: 1px solid var(--muted); }
.tag.ng { color: var(--danger); border: 1px solid var(--danger); }
