/* 外部フォント・外部画像なし。古い端末向けに flex と CSS 変数のみ。 */
:root {
  --bg: #1a1a1a; --surface: #232220; --surface2: #2d2b28; --line: #3a3733;
  --fg: #efebe4; --muted: #8a8477; --seal: #c41e1a; --seal-fg: #fff;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 16px; line-height: 1.7; -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 11px; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.grow { flex: 1; min-width: 0; } .wide { width: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; }
p { margin: 0 0 .6em; }
h1 { font-family: "Hiragino Mincho ProN", "Noto Serif JP", "Yu Mincho", serif; font-weight: 600; font-size: 28px; line-height: 1.4; margin: 0 0 .6em; }

button, .icon, .filebtn { font: inherit; color: inherit; cursor: pointer; }
button { border: 0; background: none; }
.primary { background: var(--seal); color: var(--seal-fg); border-radius: 10px; padding: 12px 18px; min-height: 44px; }
.primary[disabled] { opacity: .35; }
.ghost { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-height: 44px; background: transparent; display: inline-block; text-align: center; }
.ghost[disabled] { opacity: .35; }
.ghost.small { min-height: 38px; padding: 6px 12px; }
.linkish { color: var(--muted); text-decoration: underline; padding: 6px 0; }
.icon { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; font-size: 20px; color: var(--muted); }
input[type=text], textarea {
  width: 100%; background: var(--surface); color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; font: inherit; outline: none;
}
textarea { resize: none; background: transparent; border: 0; padding: 4px 2px; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.setup { max-width: 520px; margin: 0 auto; min-height: 100%; padding: 56px 24px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.eyebrow { color: var(--muted); font-size: 13px; letter-spacing: .2em; }
.field { display: block; margin: 20px 0 16px; }
.field span { display: block; margin-bottom: 6px; }

.app { display: flex; height: 100%; overflow: hidden; }
.side { width: 288px; flex: none; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; }
.side-head p { margin: 0; }
.pad { padding: 0 12px; }
.matters { flex: 1; overflow-y: auto; padding: 12px; }
.m-row { display: flex; align-items: stretch; margin-bottom: 4px; }
.m-open { flex: 1; min-width: 0; text-align: left; padding: 8px 12px; border-radius: 10px; min-height: 44px; }
.m-open.on { background: var(--surface2); }
.m-open span { display: block; }
.m-del { min-width: 44px; color: var(--muted); }
.side-foot { border-top: 1px solid var(--line); padding: 12px 16px; }
.side-foot p { margin: 0 0 4px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.top p { margin: 0; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--muted); }
.meter { border-bottom: 1px solid var(--line); padding: 8px 16px; }
.meter-in { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.bar { flex: 1; height: 4px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--seal); transition: width .3s; }
.meter-in p { margin: 0; white-space: nowrap; }

.scroller { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.thread { max-width: 720px; margin: 0 auto; padding: 28px 16px; display: flex; flex-direction: column; gap: 24px; }
.empty h2 { font-family: "Hiragino Mincho ProN", "Noto Serif JP", serif; font-size: 26px; line-height: 1.45; margin: 24px 0 8px; font-weight: 600; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 40px; color: var(--muted); background: transparent; text-align: left; }

.msg-user { align-self: flex-end; max-width: 88%; background: var(--surface2); border-radius: 14px; padding: 10px 14px; }
.msg-user p { white-space: pre-wrap; margin: 0; word-break: break-word; }
.tags { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.state { align-self: flex-end; font-size: 12px; color: var(--muted); margin-top: -16px; }

details.panel { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
details.panel summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details.panel ol, details.panel ul { margin: 10px 0 2px; padding-left: 20px; font-size: 14px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.think { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.dots span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

.msg-human .who { color: var(--seal); font-size: 12px; letter-spacing: .2em; margin: 0 0 4px; }
.msg-human .body { white-space: pre-wrap; word-break: break-word; margin: 0 0 6px; }
.caret { display: inline-block; width: 8px; height: 1em; background: var(--fg); vertical-align: text-bottom; animation: blink 1s infinite; }
.meta { font-size: 12px; color: var(--muted); }
.acts { display: flex; gap: 4px; margin-top: 6px; }
.acts button { color: var(--muted); font-size: 13px; padding: 6px 10px; min-height: 36px; border-radius: 8px; }

.dock { border-top: 1px solid var(--line); padding: 8px 12px 10px; }
.handoff { max-width: 720px; margin: 0 auto 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.notice { max-width: 720px; margin: 0 auto 6px; color: var(--muted); min-height: 1.2em; }
.notice.err { color: #e8a09d; }
.composer { max-width: 720px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.kind { border-radius: 10px; padding: 6px 12px; min-height: 40px; background: var(--surface2); color: var(--muted); font-size: 14px; }
.kind.on { background: var(--seal); color: var(--seal-fg); }
.kind b { font-weight: 400; margin-left: 6px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.files { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.files li { background: var(--surface2); border-radius: 10px; padding: 4px 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.files label { color: var(--muted); font-size: 12px; }
.files button { color: var(--muted); min-width: 28px; min-height: 28px; }
.comp-row { display: flex; align-items: center; justify-content: space-between; }
.attach { display: flex; }
.send { min-width: 96px; }
.foot { max-width: 720px; margin: 6px auto 0; text-align: center; }

.only-narrow { display: none; }
@media (max-width: 760px) {
  .only-narrow { display: inline-flex; }
  .side { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .scrim { position: fixed; z-index: 20; inset: 0; background: rgba(0,0,0,.6); }
  h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .dots span, .caret { animation: none; opacity: 1; }
  .bar i, .side { transition: none; }
}

.icon.txt { font-size: 13px; padding: 0 8px; }
.m-del { font-size: 12px; }

/* v2 additions */
.comp-actions { display: flex; gap: 8px; align-items: center; }
.ghost.soft { color: var(--fg); }
.tagrow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }
.tag.shared { color: var(--fg); }
.search { margin: 0 12px 8px; }
.search input { padding: 8px 12px; }
.tagsin { width: 100%; background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 8px 2px; font-size: 14px; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.72); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92%; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 0 0; padding: 18px 16px 20px; }
@media (min-width: 761px) { .modal { align-items: center; } .sheet { border-radius: 16px; } }
.sheet h2 { margin: 0 0 10px; font-size: 20px; }
.sheet .item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.sheet .item label { display: flex; gap: 10px; align-items: flex-start; }
.sheet .sub { margin: 8px 0 0 28px; font-size: 14px; }
.sheet select, .sheet input[type=text] { width: 100%; min-height: 40px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font: inherit; margin-top: 6px; }
.sheet ul { padding-left: 20px; }
.sheet .btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.sheet .grp { margin: 16px 0; padding-top: 12px; border-top: 1px solid var(--line); }
.sheet .field { margin: 10px 0; }

/* narrow screens: keep Share/Record fully visible */
.comp-row { flex-wrap: wrap; gap: 6px; }
.comp-row .attach { flex-wrap: wrap; }
.comp-row .send, .comp-row .primary, .comp-row .ghost { flex: none; }
@media (max-width: 480px) {
  .comp-row { justify-content: flex-end; }
  .comp-row .attach { flex: 1 1 100%; }
  .send { min-width: 88px; }
}
