/* info@ メール — 色は HP（みずいろノート）の青→ティールに合わせる */
:root {
  --bg: #f4f8fb;
  --panel: #ffffff;
  --ink: #1d2b36;
  --muted: #5f7180;
  --line: #dbe5ec;
  --accent: #2f7fbf;
  --accent-ink: #ffffff;
  --accent-soft: #e6f1fa;
  --teal: #1b9a94;
  --unread: #0f5f9a;
  --error: #b42318;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4b00;
  --out-bg: #f1f8f7;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f171d; --panel: #16212a; --ink: #e3ecf2; --muted: #9bb0bf; --line: #27343f;
    --accent: #5aa6e0; --accent-ink: #0b1620; --accent-soft: #1b2e3d; --teal: #4cc3bb; --unread: #8cc8f5;
    --error: #ff8a80; --warn-bg: #3a3014; --warn-ink: #f4d58a; --out-bg: #152724;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 15px; line-height: 1.6;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--error); margin: 8px 0; white-space: pre-wrap; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 6px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-decoration: none; color: var(--ink);
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.icon { width: 38px; padding: 0; font-size: 18px; }
.btn.wide { width: 100%; }
.btn.small { min-height: 30px; padding: 2px 10px; font-size: 13px; }

/* ログイン */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 20px; text-align: center; display: grid; gap: 10px; }
.login-card h1 { font-size: 20px; margin: 4px 0 0; overflow-wrap: anywhere; }
.login-card p { margin: 0 0 8px; }

/* 骨組み */
.main { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 6px; flex-shrink: 0; }
.banner { margin: 0; padding: 6px 16px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }
.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 380px) 1fr; }
.list-pane { border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel); }
.thread-pane { overflow-y: auto; min-width: 0; }

/* 一覧 */
.list-tools { position: sticky; top: 0; z-index: 1; background: var(--panel); padding: 10px 12px 8px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.tabs { display: flex; gap: 4px; }
.tab { flex: 1; border: 0; background: none; padding: 6px 4px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; line-height: 20px; }
.search input { width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.thread-list { list-style: none; margin: 0; padding: 0; }
.thread-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 14px; cursor: pointer; }
.thread-item:hover { background: var(--accent-soft); }
.thread-item[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.ti-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ti-peer { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ti-date { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.ti-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ti-snippet { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-item.unread .ti-peer, .thread-item.unread .ti-subject { font-weight: 700; color: var(--unread); }
.ti-badge { font-size: 11px; color: var(--teal); border: 1px solid currentColor; border-radius: 6px; padding: 0 4px; margin-right: 4px; }
.empty { color: var(--muted); padding: 24px 16px; text-align: center; margin: 0; }
.empty.big { padding-top: 80px; }
#more-btn { margin: 8px 12px 16px; width: calc(100% - 24px); }

/* スレッド */
#thread-view { padding: 12px 16px 40px; max-width: 900px; }
.thread-head { display: flex; align-items: center; gap: 8px; }
.thread-head h2 { font-size: 19px; margin: 4px 0; overflow-wrap: anywhere; }
.back { display: none; flex-shrink: 0; }
.thread-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.messages { display: grid; gap: 12px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.msg.out { background: var(--out-bg); }
.msg-head { padding: 10px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 2px; }
.msg-from { font-weight: 600; overflow-wrap: anywhere; }
.msg-from .addr { font-weight: 400; color: var(--muted); font-size: 13px; }
.msg-meta { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.msg-tag { font-size: 11px; border-radius: 6px; padding: 0 6px; margin-left: 6px; background: var(--accent-soft); color: var(--ink); font-weight: 400; }
.msg-tag.dry { background: var(--warn-bg); color: var(--warn-ink); }
.msg-body { padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-html { width: 100%; border: 0; display: block; min-height: 120px; background: #fff; }
.msg-tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--line); align-items: center; }
.att { display: inline-flex; gap: 4px; align-items: center; max-width: 100%; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.collapsed .msg-body, .msg.collapsed .msg-html, .msg.collapsed .msg-tools { display: none; }
.msg.collapsed .msg-head { cursor: pointer; border-bottom: 0; }
.msg-snip { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 作成・設定 */
/* 画面の高さに収める：本文欄だけが伸び縮みし、送信ボタンは常に見える */
.composer { width: min(760px, calc(100% - 16px)); height: min(720px, calc(100dvh - 16px)); max-height: none; padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--ink); overflow: hidden; }
.composer::backdrop { background: rgba(10, 20, 30, .45); }
.composer form { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; height: 100%; }
.composer .grow { flex: 1; min-height: 0; grid-template-rows: auto 1fr; }
.composer .grow textarea { height: 100%; min-height: 100px; resize: none; }
.composer-head { display: flex; justify-content: space-between; align-items: center; }
.composer-head h2 { font-size: 17px; margin: 0; }
.composer label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.composer input, .composer textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); font-size: 15px; }
.composer textarea { line-height: 1.6; }
.composer-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); z-index: 10; }

/* スマホ：一覧と本文を切り替えて1枚ずつ */
@media (max-width: 760px) {
  .top { padding: 8px 12px; }
  .brand span { font-size: 14px; }
  #compose-btn { padding: 6px 10px; }
  .panes { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; }
  .main.reading .list-pane { display: none; }
  .main:not(.reading) .thread-pane { display: none; }
  .back { display: inline-flex; }
  #thread-view { padding: 10px 12px 40px; }
  .composer { width: 100%; max-width: 100%; height: 100dvh; border-radius: 0; margin: 0; border: 0; }
}
