/* ゆらさん専用の相談の画面。色はアプリと同じ（深緑・テラコッタ・ゴールド・クリーム。2026-06-14 確定） */
:root {
  --bg: #F8F4EC;
  --panel: #FFFFFF;
  --line: #E4DDCF;
  --text: #2B2A27;
  --muted: #6E685E;
  --green: #234D32;
  --green-soft: #E6EFE8;
  --terra: #C15539;
  --terra-soft: #F7E4DE;
  --gold: #D6A526;
  --gold-soft: #FBF1D6;
  --gold-text: #7A5B0B;
  --select: #EFE7D6;
  --mine: #E9F1EA;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1D1B;
    --panel: #262825;
    --line: #3A3D38;
    --text: #ECE8DF;
    --muted: #A9A398;
    --green: #6FA383;
    --green-soft: #2C3B31;
    --terra: #E07A5F;
    --terra-soft: #4A2C24;
    --gold: #E2B84A;
    --gold-soft: #463A1C;
    --gold-text: #F0CF79;
    --select: #34362F;
    --mine: #2D3A30;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--green); }

/* ---- ボタン ---- */
button { cursor: pointer; border-radius: 8px; }
.primary {
  background: var(--green); color: #fff; border: 0;
  padding: 10px 20px; font-weight: 600; min-height: 44px;
}
.primary:disabled { opacity: .5; cursor: default; }
.plain {
  background: transparent; border: 1px solid var(--line);
  padding: 8px 14px; min-height: 40px; color: var(--text);
}
.small { min-height: 34px; padding: 4px 12px; font-size: 14px; }

/* ---- ログイン ---- */
.gate { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px 28px 20px; width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 14px;
}
.card.wide { max-width: 560px; }
.card h1 { margin: 0 0 4px; font-size: 22px; color: var(--green); }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.card input {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  background: var(--bg); font-size: 18px; color: var(--text);
}
.card .plain { align-self: flex-start; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.error { color: var(--terra); margin: 0; min-height: 1.6em; font-size: 14px; }
.steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 10px; }
.enroll-qr { display: flex; justify-content: center; }
.enroll-qr img { width: 180px; height: 180px; background: #fff; border-radius: 8px; padding: 6px; }
.secret { margin: 0; font-size: 14px; color: var(--muted); word-break: break-all; }
.secret code { color: var(--text); font-size: 15px; }

/* ---- 上の帯 ---- */
#app { height: 100%; display: flex; flex-direction: column; }
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--green); }
.tally { display: flex; gap: 6px; flex-wrap: wrap; }
.bar-space { flex: 1; }
.notice {
  margin: 0; padding: 8px 16px; background: var(--terra-soft); color: var(--text);
  border-bottom: 1px solid var(--line); font-size: 14px;
}

/* ---- 2つの枠（一覧・相談） ---- */
.panes { flex: 1; display: grid; grid-template-columns: 360px 1fr; min-height: 0; }
.list { overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); }
.detail { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.empty { margin: auto; color: var(--muted); padding: 24px; }
#detail-body { display: flex; flex-direction: column; height: 100%; min-height: 0; }

/* 一覧 */
.group {
  position: sticky; top: 0; z-index: 1;
  margin: 0; padding: 6px 16px; font-size: 13px; font-weight: 700; color: var(--muted);
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.item {
  display: block; width: 100%; text-align: left; border: 0; border-radius: 0;
  border-bottom: 1px solid var(--line); background: transparent;
  padding: 12px 16px 12px 14px; border-left: 4px solid transparent;
}
.item:hover { background: var(--select); }
.item.selected { background: var(--select); }
.item.unread { border-left-color: var(--terra); }
.item.unreplied { border-left-color: var(--gold); }
.item-top { display: flex; align-items: center; gap: 8px; }
.item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.unread .item-title { font-weight: 700; }
.item-time { white-space: nowrap; }
.item.unread .item-time { color: var(--terra); font-weight: 700; }
.item-preview {
  color: var(--muted); font-size: 14px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.item-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.item-meta .draft { color: var(--green); font-weight: 600; }
.list-empty { padding: 24px 16px; color: var(--muted); }

/* 状態の印 */
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; line-height: 1;
  padding: 5px 8px; border-radius: 999px; white-space: nowrap;
}
.badge.unread { background: var(--terra); color: #fff; }
.badge.unreplied { background: var(--gold-soft); color: var(--gold-text); border: 1px solid var(--gold); }
.badge.replied { background: transparent; color: var(--muted); border: 1px solid var(--line); }

/* 相談の上の段 */
.detail-head { padding: 14px 20px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.back { display: none; margin-bottom: 8px; }
.title-row { display: flex; align-items: center; gap: 10px; }
.title-row h2 { margin: 0; font-size: 20px; line-height: 1.4; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.title-form { display: flex; gap: 8px; margin-top: 6px; }
.title-form input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--bg);
}
.d-meta { margin: 4px 0 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.d-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.d-more { margin-top: 8px; font-size: 14px; }
.d-more summary { cursor: pointer; color: var(--green); }
.d-more ul { margin: 6px 0 0; padding-left: 1.2em; }
.d-more a { cursor: pointer; }
.note { margin: 6px 0 0; padding: 8px 10px; background: var(--bg); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note small { color: var(--muted); display: block; }

/* やり取り */
.messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 82%; display: flex; flex-direction: column; gap: 4px; }
.msg.user { align-self: flex-start; }
.msg.mikokai { align-self: flex-end; align-items: flex-end; }
.msg-who { font-size: 12px; color: var(--muted); }
.msg-body {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.mikokai .msg-body { background: var(--mine); border-color: transparent; }
.msg-new .msg-body { border-color: var(--terra); }
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-images a { display: block; }
.msg-images img {
  width: 160px; height: 160px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
.msg-images .missing { font-size: 13px; color: var(--muted); }

/* 返信を書く所 */
.composer {
  border-top: 1px solid var(--line); background: var(--panel);
  padding: 10px 20px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
.composer-label { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.draft-by { color: var(--green); font-weight: 700; }
.composer textarea {
  width: 100%; resize: vertical; min-height: 96px; max-height: 45vh;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg);
  font-size: 16px; line-height: 1.6;
}
.composer-row { display: flex; align-items: center; gap: 12px; }
.attach-button { display: inline-flex; align-items: center; cursor: pointer; border-radius: 8px; font-size: 14px; }
.attach-button.disabled { opacity: .5; cursor: default; }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; }
.attachment { position: relative; }
.attachment img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.attachment button {
  position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; min-height: 0; padding: 0;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 16px; line-height: 1;
}
.attach-hint { margin: 0; font-size: 13px; }
.draft-status { flex: 1; font-size: 13px; color: var(--muted); }

/* 幅が狭いとき（iPad の画面分割など）は、一覧と相談を切り替えて出す */
@media (max-width: 759px) {
  .panes { grid-template-columns: 1fr; }
  .panes.showing-detail .list { display: none; }
  .panes:not(.showing-detail) .detail { display: none; }
  .back { display: inline-block; }
  .msg { max-width: 92%; }
  .bar { flex-wrap: wrap; }
}
@media (min-width: 760px) and (max-width: 1023px) {
  .panes { grid-template-columns: 300px 1fr; }
}
