/* 作戦室 */
:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1c1d20;
  --ink-2: #55575e;
  --ink-3: #8a8c93;
  --line: #e6e4df;
  --line-2: #efeee9;
  --side: #16171a;
  --side-ink: #d8d8dc;
  --side-ink-2: #8d8e95;
  --accent: #b8892c;      /* 金 */
  --accent-soft: #f6ecd6;
  --fumi: #2f6fd6;
  --ishii: #1f9a6b;
  --claude: #c2622d;
  --image: #7b4fd6;
  --danger: #c2392d;
  --me-bg: #fff8e8;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.65; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--fumi); }
[hidden] { display: none !important; }

/* ===== レイアウト ===== */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr) 360px; height: 100dvh; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; background: var(--bg); }

/* ===== サイドバー ===== */
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; font-size: 17px; letter-spacing: .04em; color: #fff; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #16171a; display: grid; place-items: center; font-size: 16px; }
.rooms { flex: 1; overflow-y: auto; padding: 4px 10px; }
.room-link { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; background: none; border: 0; color: var(--side-ink); font-size: 14.5px; }
.room-link:hover { background: #24252a; }
.room-link.on { background: #2c2d33; color: #fff; }
.room-link .rname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-link .hash { color: var(--side-ink-2); }
.room-link.unread .rname { font-weight: 700; color: #fff; }
.room-link .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.room-link .cnt { font-size: 11.5px; font-weight: 700; background: var(--accent); color: #16171a; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.side-foot { border-top: 1px solid #2a2b30; padding: 12px 14px calc(12px + var(--safe-b)); font-size: 13px; }
.usage { color: var(--side-ink-2); margin-bottom: 8px; }
.usage .bar { height: 4px; background: #2a2b30; border-radius: 4px; margin-top: 4px; overflow: hidden; }
.usage .bar i { display: block; height: 100%; background: var(--accent); }
.me-row { display: flex; align-items: center; gap: 10px; }
.me-name { flex: 1; display: flex; align-items: center; gap: 8px; color: #fff; }
.link-btn { background: none; border: 0; color: var(--side-ink-2); padding: 0; font-size: 13px; text-decoration: none; }
.link-btn:hover { color: #fff; }

/* ===== アバター ===== */
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; flex: none; background: #888; }
.avatar[data-u="fumi"] { background: var(--fumi); }
.avatar[data-u="ishii"] { background: var(--ishii); }
.avatar[data-u="claude"] { background: var(--claude); }
.avatar[data-u="image"] { background: var(--image); }
.me-name .avatar { width: 22px; height: 22px; font-size: 11px; }

/* ===== トップバー ===== */
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 58px; }
.room-title { flex: 1; min-width: 0; }
.room-title h1 { margin: 0; font-size: 17px; line-height: 1.3; }
.room-sub { font-size: 12.5px; color: var(--ink-3); }
.icon-btn { background: none; border: 0; font-size: 18px; width: 38px; height: 38px; border-radius: 8px; display: inline-grid; place-items: center; position: relative; flex: none; }
.icon-btn:hover { background: var(--line-2); }
.badge { position: absolute; top: 2px; right: 0; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 9px; padding: 0 5px; line-height: 16px; }
.only-mobile, .only-overlay, .notes-toggle { display: none; }

/* ===== ピン帯（決定・宿題の要約） ===== */
.pinbar { display: flex; gap: 8px; padding: 8px 20px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; font-size: 13px; scrollbar-width: none; }
.pinbar:empty { display: none; }
.pin { white-space: nowrap; background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 3px 11px; color: var(--ink-2); }
.pin b { color: var(--ink); }
.pin.warn { background: var(--accent-soft); border-color: #ead7ad; color: #7a5a14; }

/* ===== メッセージ ===== */
.messages { flex: 1; overflow-y: auto; padding: 12px 0 18px; overscroll-behavior: contain; }
.load-more { display: block; margin: 6px auto 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 4px 14px; font-size: 13px; color: var(--ink-2); }
.day { text-align: center; margin: 16px 0 6px; font-size: 12px; color: var(--ink-3); }
.day span { background: var(--bg); padding: 0 10px; }
.msg { display: flex; gap: 12px; padding: 8px 20px; position: relative; }
.msg:hover { background: #efede8; }
.msg.to-me { background: var(--me-bg); box-shadow: inset 3px 0 0 var(--accent); }
.msg.cont { padding-top: 2px; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg.cont .mhead { display: none; }
.mbody-wrap { min-width: 0; flex: 1; }
.mhead { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 13.5px; }
.mhead .who { font-weight: 700; }
.mhead .arrow { color: var(--ink-3); }
.to-pill { font-size: 12px; border-radius: 10px; padding: 0 8px; background: var(--line-2); color: var(--ink-2); font-weight: 600; }
.to-pill.t-claude { background: #fbe7da; color: var(--claude); }
.to-pill.t-image { background: #ece4fb; color: var(--image); }
.to-pill.t-me { background: var(--accent); color: #fff; }
.mhead time { color: var(--ink-3); font-size: 12px; }
.mtext { word-break: break-word; }
.mtext p { margin: 2px 0 8px; }
.mtext p:last-child { margin-bottom: 2px; }
.mtext h3, .mtext h4, .mtext h5, .mtext h6 { margin: 12px 0 4px; font-size: 15px; }
.mtext ul, .mtext ol { margin: 4px 0 8px; padding-left: 1.4em; }
.mtext li { margin: 2px 0; }
.mtext code { font-family: var(--mono); font-size: .9em; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.mtext pre { background: #1e1f23; color: #e6e6e6; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.mtext pre code { background: none; padding: 0; }
.mtext blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--ink-2); }
.mtext hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.mtext .tbl { overflow-x: auto; margin: 6px 0 10px; }
.mtext table { border-collapse: collapse; font-size: 14px; }
.mtext th, .mtext td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; vertical-align: top; }
.mtext th { background: var(--line-2); }
.mref { text-decoration: none; }
.mimg { margin-top: 6px; }
.mimg img { max-width: min(360px, 100%); max-height: 360px; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; display: block; background: #fff; }
.mmeta { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.await { font-size: 12.5px; color: #7a5a14; background: var(--accent-soft); border-radius: 10px; padding: 0 9px; }
.await.mine { background: var(--accent); color: #fff; font-weight: 700; }
.src-tag { font-size: 11.5px; color: var(--ink-3); }
.msg.summary .mtext { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.msg.error .mtext { color: var(--danger); }
.thinking { color: var(--ink-3); font-size: 14px; }
.thinking i { display: inline-block; width: 6px; height: 6px; background: var(--claude); border-radius: 50%; margin-left: 3px; animation: blink 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .2s; } .thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.macts { position: absolute; right: 16px; top: -10px; display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.msg:hover .macts { display: flex; }
.macts button { background: none; border: 0; font-size: 12.5px; padding: 4px 9px; color: var(--ink-2); }
.macts button:hover { background: var(--line-2); color: var(--ink); }
.msg.flash { animation: flash 1.6s; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.empty { text-align: center; color: var(--ink-3); padding: 60px 20px; }

/* ===== 入力欄 ===== */
.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 10px 20px calc(12px + var(--safe-b)); }
.to-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.to-row .lbl { font-size: 12.5px; color: var(--ink-3); margin-right: 2px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 18px; padding: 3px 12px; font-size: 13.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.chip .avatar { width: 18px; height: 18px; font-size: 10px; }
.chip.on { color: #fff; border-color: transparent; background: var(--ink); }
.chip.on[data-r="claude"] { background: var(--claude); }
.chip.on[data-r="image"] { background: var(--image); }
.chip.on[data-r="fumi"] { background: var(--fumi); }
.chip.on[data-r="ishii"] { background: var(--ishii); }
.to-hint { font-size: 12px; color: var(--ink-3); min-height: 18px; margin: 3px 0 6px; }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.input-row textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; max-height: 40vh; background: var(--bg); line-height: 1.55; outline: none; }
.input-row textarea:focus { border-color: #c9c6be; background: #fff; }
.attach { cursor: pointer; }
.send { border: 0; background: var(--ink); color: #fff; border-radius: 10px; padding: 0 18px; height: 42px; font-weight: 700; }
.send:disabled { opacity: .4; cursor: default; }
.attach-preview { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.attach-preview img { height: 56px; border-radius: 6px; border: 1px solid var(--line); }
.attach-preview button { background: none; border: 0; color: var(--danger); }

/* ===== 記録パネル ===== */
.notes { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 0 18px 24px; }
.notes-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 8px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.notes-head h2 { font-size: 15px; margin: 0; }
.summarize { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px; font-size: 14px; margin-bottom: 12px; }
.summarize:hover { border-color: var(--claude); color: var(--claude); }
.note-add { display: grid; gap: 6px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: 16px; }
.note-add input, .note-add select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: #fff; width: 100%; min-width: 0; }
.note-add-row { display: flex; gap: 6px; }
.note-add button[type=submit] { border: 0; background: var(--ink); color: #fff; border-radius: 8px; padding: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 4px 12px; font-size: 13px; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: #fff; }
.nsec { margin-bottom: 18px; }
.nsec h3 { font-size: 13px; color: var(--ink-3); margin: 0 0 6px; font-weight: 700; letter-spacing: .03em; display: flex; justify-content: space-between; }
.nitem { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.nitem input[type=checkbox] { margin-top: 5px; accent-color: var(--ink); width: 16px; height: 16px; flex: none; }
.nitem .nb { flex: 1; min-width: 0; word-break: break-word; }
.nitem .nm { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.nitem .as { border-radius: 8px; padding: 0 7px; color: #fff; background: #888; }
.nitem .as[data-u="fumi"] { background: var(--fumi); }
.nitem .as[data-u="ishii"] { background: var(--ishii); }
.nitem .as[data-u="both"] { background: var(--ink-2); }
.nitem.done .nb { color: var(--ink-3); text-decoration: line-through; }
.nitem .ndel { background: none; border: 0; color: var(--ink-3); font-size: 13px; padding: 0 2px; visibility: hidden; }
.nitem:hover .ndel { visibility: visible; }
.nitem.decision::before { content: "✔"; color: var(--accent); font-weight: 700; margin-top: 1px; }
.nitem.memo::before { content: "・"; color: var(--ink-3); }
.ntoggle { background: none; border: 0; color: var(--ink-3); font-size: 12.5px; padding: 4px 0; }
.nempty { color: var(--ink-3); font-size: 13px; padding: 4px 0; }

/* ===== モーダル類 ===== */
.modal { position: fixed; inset: 0; background: rgba(20,20,22,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--panel); border-radius: 14px; width: min(460px, 100%); max-height: 90dvh; overflow-y: auto; padding: 6px 22px 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-card h3 { font-size: 14px; margin: 14px 0 8px; }
.line-box { margin-top: 10px; font-size: 14px; background: var(--bg); border-radius: 10px; padding: 12px; }
.line-box .code { font-family: var(--mono); font-size: 22px; font-weight: 700; letter-spacing: .1em; }
.pw-form { display: grid; gap: 8px; }
.pw-form input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.pw-form button, .line-box button { border: 0; background: var(--ink); color: #fff; border-radius: 8px; padding: 8px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 60; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 86dvh; border-radius: 6px; }
.lb-dl { position: fixed; bottom: calc(20px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: #fff; color: #111; border-radius: 20px; padding: 6px 18px; text-decoration: none; font-weight: 700; }
.toast { position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 10px; padding: 9px 16px; z-index: 70; font-size: 14px; max-width: 90vw; }
.scrim { display: none; }

/* ===== ログイン ===== */
.login-body { display: grid; place-items: center; min-height: 100dvh; background: var(--side); padding: 16px; }
.login-card { background: var(--panel); border-radius: 16px; padding: 28px; width: min(360px, 100%); display: grid; gap: 14px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-sub { margin: -8px 0 4px; color: var(--ink-3); font-size: 13px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.login-card input { border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 16px; }
.login-card button { border: 0; background: var(--ink); color: #fff; border-radius: 8px; padding: 11px; font-weight: 700; font-size: 15px; }
.login-err { color: var(--danger); font-size: 13px; margin: 0; }

/* ===== 中くらいの画面：記録パネルは右から出す ===== */
@media (max-width: 1180px) {
  .app { grid-template-columns: 232px minmax(0, 1fr); }
  .notes { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); z-index: 40; transform: translateX(100%); transition: transform .22s ease; box-shadow: -8px 0 24px rgba(0,0,0,.08); }
  .app.notes-open .notes { transform: none; }
  .notes-toggle, .only-overlay { display: inline-grid; }
  .app.notes-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 35; }
}

/* ===== スマホ ===== */
@media (max-width: 760px) {
  body { font-size: 15.5px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: min(290px, 86vw); z-index: 40; transform: translateX(-100%); transition: transform .22s ease; }
  .app.rooms-open .sidebar { transform: none; }
  .app.rooms-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .only-mobile { display: inline-grid; }
  .topbar { padding: 8px 10px; min-height: 52px; }
  .pinbar { padding: 7px 12px; }
  .msg { padding: 8px 12px; gap: 10px; }
  .msg .avatar { width: 26px; height: 26px; }
  .macts { display: none !important; }
  .composer { padding: 8px 10px calc(10px + var(--safe-b)); }
  .to-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chip { flex: none; }
  .input-row textarea { font-size: 16px; }
  .mimg img { max-width: 100%; }
}
