:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --bot: #232c38;
  --accent: #4db6ac;
  --accent2: #3ba99c;
  --text: #e6edf3;
  --muted: #9aa7b4;
}
* { box-sizing: border-box; }
/* hidden 属性は display 指定より常に優先（ビュー切替を確実化） */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}
.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.hdr { padding: 20px 20px 8px; }
.logo { font-size: 20px; font-weight: 700; }
.tag { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  padding: 12px 14px;
  border-radius: 14px;
  max-width: 92%;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.bot { background: var(--bot); border-top-left-radius: 4px; align-self: flex-start; }
.msg.sys { background: transparent; color: var(--muted); font-size: 13px; align-self: center; text-align: center; }
.msg.handoff { background: #1d2b2a; border: 1px solid var(--accent2); }
.title { margin: 0 0 4px; font-weight: 700; }
.detail { margin: 0; }
.linkbtn {
  display: inline-block;
  margin-top: 10px;
  padding: 9px 16px;
  background: var(--accent2);
  color: #06201d;
  font-weight: 700;
  border-radius: 10px;
  text-decoration: none;
}
.linkbtn:hover { background: var(--accent); }
.ftr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #2a333f;
  color: var(--muted);
  font-size: 13px;
}
.osbtn {
  padding: 6px 14px;
  border: 1px solid #36414f;
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}
.osbtn.active { background: var(--accent2); color: #06201d; border-color: var(--accent2); font-weight: 700; }

/* 貼り付け用コマンド枠（ステップ内・コピーボタン付き） */
.cmd {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 2px;
  padding: 8px 10px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
}
.cmdText {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: #e6edf3;
  overflow-x: auto;
  white-space: nowrap;
}
.cmdCopy {
  flex: none;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--accent2);
  color: #06201d;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.cmdCopy:hover { background: var(--accent); }

/* ---- ログイン画面 ---- */
.loginView { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.loginCard {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid #2a333f; border-radius: 16px; padding: 28px 24px; text-align: center;
}
.loginCard h2 { margin: 10px 0 4px; font-size: 22px; }
.lsub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.tin {
  width: 100%; padding: 12px 14px; margin: 6px 0;
  background: #0d1117; border: 1px solid #30363d; border-radius: 10px;
  color: var(--text); font-size: 15px;
}
.tin:focus { outline: none; border-color: var(--accent2); }
.lerr { color: #ff8a8a; font-size: 13px; min-height: 18px; margin: 4px 0; }
.primaryBtn {
  width: 100%; padding: 12px 16px; margin-top: 8px; border: 0; border-radius: 10px;
  background: var(--accent2); color: #06201d; font-weight: 700; font-size: 15px; cursor: pointer;
}
.primaryBtn:hover { background: var(--accent); }

/* ---- アプリ ヘッダ右 ---- */
.appView .hdr { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid #2a333f; }
.hdrRight { display: flex; align-items: center; gap: 12px; }
.budget { color: var(--muted); font-size: 12px; }
.ghostBtn {
  padding: 7px 12px; border: 1px solid #36414f; background: transparent;
  color: var(--text); border-radius: 999px; cursor: pointer; font-size: 13px;
}
.ghostBtn:hover { border-color: var(--accent2); }

/* ---- 自分の吹き出し・送信画像 ---- */
.msg.me { background: var(--accent2); color: #06201d; align-self: flex-end; border-top-right-radius: 4px; }
.msg.me p { margin: 0; }
.sentImg, .msg.me img { max-width: 220px; border-radius: 8px; margin-top: 6px; display: block; }

/* ---- 入力欄（composer） ---- */
.composer { border-top: 1px solid #2a333f; padding: 10px 16px 14px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { position: relative; }
.thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid #30363d; }
.thumbX {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: 50%; background: #0d1117; color: #fff; cursor: pointer; font-size: 12px; line-height: 20px;
}
.composerRow { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
.msgInput { flex: 1; resize: none; max-height: 140px; margin: 0; line-height: 1.5; }
.composerRow .primaryBtn { width: auto; margin: 0; padding: 12px 18px; }
.osrow { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 13px; }

/* ---- BYOキー設定 ---- */
.byok { margin: 0 16px 8px; padding: 14px; background: #1d2b2a; border: 1px solid var(--accent2); border-radius: 12px; }
.byok p { margin: 0 0 8px; font-size: 14px; }
.byok code { background: #0d1117; padding: 1px 6px; border-radius: 5px; }
