
:root {
  --bg: #f6f8fc; --panel: #ffffff; --text: #1f1f1f; --sub: #444746; --muted: #5f6368; --line: #e3e3e3; --line2: #f1f3f4;
  --row-read: #f2f6fc; --hover: #e8eaed; --nav-sel: #d3e3fd; --compose: #c2e7ff; --compose-hover: #b3dcf9; --search: #e9eef6;
  --accent: #0b57d0; --accent-text: #ffffff; --danger: #b3261e; --ok: #146c2e; --chip: #e8f0fe; --row-sel: #c2dbff; --star: #f4b400;
  --shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --pop: 0 4px 8px 3px rgba(60,64,67,.15), 0 1px 3px rgba(60,64,67,.3);
  --snack: #323232; --snack-text: #f2f2f2; --snack-act: #a8c7fa;
  --row-h: 40px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1b1f; --panel: #232327; --text: #e3e3e3; --sub: #c4c7c5; --muted: #9aa0a6; --line: #3c4043; --line2: #2f3033;
    --row-read: #1f1f23; --hover: #333438; --nav-sel: #004a77; --compose: #004a77; --compose-hover: #005a8f; --search: #2d2f33;
    --accent: #a8c7fa; --accent-text: #062e6f; --chip: #2d3a4f; --row-sel: #2a3f5f; --snack: #e3e3e3; --snack-text: #1f1f1f; --snack-act: #0b57d0; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif; font-size: 14px; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--sub); flex: none; }
.iconbtn:hover { background: var(--hover); }
.iconbtn:disabled { opacity: .38; cursor: default; background: transparent; }
.iconbtn.sm { width: 32px; height: 32px; }

/* ── 標章(名は enMail・書体 Universe。無い端末は似た字形の書体へ) ── */
.mark { display: flex; align-items: center; gap: 10px; color: var(--sub); text-decoration: none; border: 0; background: transparent; padding: 0; }
.mark-logo { height: 34px; width: auto; display: block; border-radius: 3px; }
.gate-card .mark-logo { height: 48px; }
.wordmark { font-family: "Universe", "Univers", "Univers LT Std", "Univers Next Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 22px; letter-spacing: -.01em; color: var(--sub); }

/* ── ログイン・登録 ── */
.gate { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gate-card { background: var(--panel); border-radius: 28px; padding: 36px 40px; width: 100%; max-width: 448px; box-shadow: var(--shadow); }
.gate-card h1 { font-size: 24px; font-weight: 400; margin: 16px 0 8px; }
.gate-card p { color: var(--sub); line-height: 1.6; margin: 8px 0; }
.pill { border: 0; border-radius: 20px; padding: 10px 24px; background: var(--accent); color: var(--accent-text); font-weight: 500; }
.pill:hover { filter: brightness(1.08); box-shadow: var(--shadow); }
.pill:disabled { opacity: .5; cursor: default; box-shadow: none; filter: none; }
.pill.quiet { background: transparent; color: var(--accent); }
.pill.quiet:hover { background: var(--chip); box-shadow: none; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.err { color: var(--danger); min-height: 1.4em; margin-top: 12px; }
.note { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ── 全体 ── */
.app { display: grid; grid-template-rows: 64px 1fr; height: 100%; }
.top { display: flex; align-items: center; gap: 4px; padding: 0 8px 0 8px; min-width: 0; }
.top .mark { width: 200px; padding-left: 4px; flex: none; }
.search { flex: 1; max-width: 720px; min-width: 0; position: relative; display: flex; align-items: center; gap: 4px; height: 48px; padding: 0 4px; background: var(--search); border-radius: 24px; }
.search:focus-within, .search.open { background: var(--panel); box-shadow: var(--shadow); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; }
.search input::-webkit-search-cancel-button { display: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; padding-left: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #0b57d0; color: #fff; border: 0; font-weight: 600; margin: 0 4px; }
.body { position: relative; display: grid; grid-template-columns: 256px 1fr; min-height: 0; }
.nav { padding: 8px 8px 8px 0; overflow-y: auto; overflow-x: hidden; min-width: 0; }
.compose-btn { display: inline-flex; align-items: center; gap: 12px; margin: 0 0 16px 8px; height: 56px; padding: 0 24px 0 16px; border: 0; border-radius: 16px; background: var(--compose); font-weight: 500; font-size: 14px; white-space: nowrap; }
.compose-btn:hover { background: var(--compose-hover); box-shadow: var(--shadow); }
.nav-head { color: var(--sub); font-size: 13px; font-weight: 500; padding: 16px 0 6px 26px; white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: 18px; width: 100%; height: 32px; padding: 0 12px 0 26px; border: 0; border-radius: 0 16px 16px 0; background: transparent; color: var(--text); text-align: left; white-space: nowrap; }
.nav-item:hover { background: var(--hover); }
.nav-item.sel { background: var(--nav-sel); font-weight: 700; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-count { font-size: 12px; font-weight: 700; }
.nav .note { padding: 4px 16px 4px 26px; }
/* 畳んだ左の並び(広い画面): アイコンだけの細い帯。上に乗せると一時的に開く(Gmail と同じ) */
.body.rail { grid-template-columns: 72px 1fr; }
.rail .nav { width: 72px; padding-right: 0; }
.rail .nav .compose-btn { padding: 0 16px; margin-left: 8px; }
.rail .nav .compose-btn span, .rail .nav .nav-label, .rail .nav .nav-count, .rail .nav .nav-head, .rail .nav .note { display: none; }
.rail .nav .nav-item { width: 56px; margin-left: 8px; padding: 0 0 0 18px; border-radius: 16px; }
.rail .nav.peek { position: absolute; top: 0; bottom: 0; left: 0; width: 256px; z-index: 12; background: var(--bg); box-shadow: 0 0 16px rgba(0,0,0,.2); padding-right: 8px; }
.rail .nav.peek .compose-btn span, .rail .nav.peek .nav-label, .rail .nav.peek .nav-count, .rail .nav.peek .nav-head, .rail .nav.peek .note { display: initial; }
.rail .nav.peek .nav-head, .rail .nav.peek .note { display: block; }
.rail .nav.peek .nav-item { width: 100%; margin-left: 0; padding: 0 12px 0 26px; border-radius: 0 16px 16px 0; }
.rail .nav.peek .compose-btn { padding: 0 24px 0 16px; }
.main { background: var(--panel); border-radius: 16px; margin: 0 16px 16px 0; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 2px; height: 48px; padding: 0 8px 0 8px; border-bottom: 1px solid var(--line2); flex: none; }
.toolbar .spacer { flex: 1; }
.toolbar .range { color: var(--sub); font-size: 12px; padding: 0 8px; white-space: nowrap; }
.selbox { display: inline-flex; align-items: center; border-radius: 4px; }
.selbox:hover { background: var(--hover); }
.selbox input { width: 18px; height: 18px; margin: 0 2px 0 11px; }
.selbox .iconbtn { width: 20px; height: 32px; border-radius: 4px; }
.selbox .iconbtn .icon { width: 16px; height: 16px; }
.list { overflow: auto; flex: 1; }
.row { display: grid; grid-template-columns: 34px 34px minmax(120px, 200px) 1fr auto; align-items: center; height: var(--row-h); padding: 0 16px 0 4px; border-bottom: 1px solid var(--line2); background: var(--row-read); cursor: pointer; position: relative; }
.row.unread { background: var(--panel); font-weight: 700; }
.row.sel { background: var(--row-sel); }
.row.cur::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.row:hover { box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15); z-index: 1; }
.row .cb { width: 18px; height: 18px; margin: 0 auto; }
.row .who, .row .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 16px; }
.row .what .sub { color: var(--muted); font-weight: 400; }
.row .what .icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; color: var(--muted); }
.row .end { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 72px; }
.row .when { font-size: 12px; white-space: nowrap; }
.row .hover { display: none; }
.row:hover .hover { display: flex; } .row:hover .when, .row:hover .clip { display: none; }
.row .clip { width: 16px; height: 16px; color: var(--muted); }
/* 差出人の証明(mailer-v3-sender-proof)。色だけでなく形で見分ける */
.proof { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
.proof.l1 { color: var(--accent); } .proof.l2 { color: #8a5300; } .proof.l3 { color: var(--ok); } .proof.l4 { color: var(--muted); opacity: .7; } .proof.l5 { color: var(--danger); }
.proofbtn { display: inline-flex; align-items: center; gap: 2px; border: 0; background: transparent; padding: 2px 6px 2px 2px; border-radius: 12px; font-size: 12px; color: var(--sub); }
.proofbtn:hover { background: var(--hover); }
.brandlogo { vertical-align: middle; object-fit: contain; background: #fff; border-radius: 4px; margin: 0 4px 0 2px; box-shadow: 0 0 0 1px var(--line); }
.proofbox { margin-top: 10px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; line-height: 1.6; }
.proofbox dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 0; }
.row .who.alike { text-decoration: underline wavy var(--danger); text-underline-offset: 3px; }
.proofbox dt { color: var(--muted); } .proofbox dd { margin: 0; overflow-wrap: anywhere; }
.dangerbar { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; margin: 0 0 8px; border-radius: 8px; background: #fce8e6; color: #8c1d18; line-height: 1.6; }
.star { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; color: #c4c7c5; border: 0; background: transparent; padding: 0; }
.star:hover { background: var(--hover); }
.star.on { color: var(--star); } .star.on .icon { fill: currentColor; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); line-height: 1.6; }
.d-compact { --row-h: 32px; } .d-comfortable { --row-h: 40px; } .d-default { --row-h: 44px; }

/* ── メールを開いたとき ── */
.thread { overflow: auto; flex: 1; padding: 8px 24px 32px 72px; }
.thread h2 { font-size: 22px; font-weight: 400; margin: 12px 0 16px -56px; padding-left: 56px; display: flex; align-items: center; gap: 12px; }
.thread h2 .flag { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 4px; background: var(--chip); color: var(--sub); }
.msg { display: grid; grid-template-columns: 40px 1fr auto; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.msg .face { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; background: #8e9aaf; }
.msg .meta { color: var(--sub); font-size: 12px; margin-top: 4px; }
.msg .locked { margin-top: 16px; padding: 16px; border-radius: 8px; background: var(--row-read); color: var(--sub); display: flex; gap: 10px; align-items: flex-start; line-height: 1.6; }
.msg .side { display: flex; align-items: flex-start; gap: 4px; color: var(--sub); font-size: 12px; white-space: nowrap; }
.msg .side span { padding-top: 8px; }
.replies { display: flex; gap: 8px; margin: 20px 0 0 56px; }
.ghost { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 18px; background: transparent; padding: 8px 18px; color: var(--sub); }
.ghost:hover { background: var(--hover); }

/* ── 作成の窓 ── */
.compose { position: fixed; right: 24px; bottom: 0; width: 560px; max-width: calc(100vw - 32px); height: 520px; max-height: calc(100vh - 80px); background: var(--panel); border-radius: 8px 8px 0 0; box-shadow: 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12), 0 5px 5px -3px rgba(0,0,0,.2); display: flex; flex-direction: column; z-index: 20; }
.compose.min { height: 40px; width: 280px; }
.compose.min > :not(.compose-head) { display: none; }
.compose.max { right: 50%; transform: translateX(50%); bottom: 5vh; width: min(1000px, calc(100vw - 32px)); height: 90vh; border-radius: 8px; }
.compose-back { position: fixed; inset: 0; background: rgba(32,33,36,.5); z-index: 19; }
.compose-head { display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 8px 0 16px; background: var(--row-read); border-radius: 8px 8px 0 0; font-weight: 500; cursor: pointer; flex: none; }
.compose-head .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-head .iconbtn { width: 28px; height: 28px; }
.compose-head .iconbtn .icon { width: 16px; height: 16px; }
.compose-field { display: flex; align-items: center; gap: 8px; margin: 0 16px; border-bottom: 1px solid var(--line2); min-height: 38px; flex-wrap: wrap; flex: none; }
.compose-field > label { color: var(--sub); min-width: 40px; }
.compose-field input, .compose-field select { flex: 1; min-width: 120px; border: 0; outline: none; background: transparent; height: 36px; }
.compose-field .links { display: flex; gap: 8px; }
.compose-field .links button { border: 0; background: transparent; color: var(--sub); padding: 4px; }
.compose-field .links button:hover { text-decoration: underline; }
.chip { display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 2px 0 10px; border-radius: 12px; background: var(--chip); font-size: 13px; }
.chip.bad { background: #fce8e6; color: #a50e0e; }
.chip button { border: 0; background: transparent; width: 20px; height: 20px; border-radius: 50%; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: inherit; }
.chip button .icon { width: 12px; height: 12px; }
.compose textarea { flex: 1; border: 0; outline: none; resize: none; margin: 8px 16px; background: transparent; line-height: 1.5; }
.compose-foot { display: flex; align-items: center; gap: 8px; padding: 8px 16px 12px; flex: none; }
.compose-foot .err { margin: 0; flex: 1; font-size: 12px; }
.send { border: 0; border-radius: 18px; padding: 9px 24px; background: var(--accent); color: var(--accent-text); font-weight: 500; }

/* ── 浮く窓(選ぶ・その他・設定・検索の条件) ── */
.pop { position: fixed; background: var(--panel); border-radius: 8px; box-shadow: var(--pop); padding: 8px 0; min-width: 200px; z-index: 40; }
.pop button.mi { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 20px; }
.pop button.mi:hover { background: var(--hover); }
.pop .ph { color: var(--sub); font-size: 12px; font-weight: 500; padding: 8px 20px 4px; }
.pop label.radio { display: flex; align-items: center; gap: 12px; padding: 8px 20px; cursor: pointer; }
.pop label.radio:hover { background: var(--hover); }
.adv { position: absolute; left: 0; right: 0; top: 52px; background: var(--panel); border-radius: 8px; box-shadow: var(--pop); padding: 16px 24px; z-index: 40; }
.adv .f { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 8px; margin: 6px 0; }
.adv .f label { color: var(--sub); font-size: 13px; }
.adv .f input[type=text], .adv .f input[type=date], .adv .f select { border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 6px 2px; outline: none; }
.adv .checks { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0; }
.adv .checks label { display: flex; align-items: center; gap: 6px; }
.pop .note { padding: 4px 20px 8px; }
.menu { position: fixed; right: 12px; top: 60px; background: var(--panel); border-radius: 16px; box-shadow: var(--pop); padding: 16px; min-width: 240px; z-index: 40; }
.menu .who { font-weight: 500; margin-bottom: 4px; }
.menu .role { color: var(--muted); font-size: 12px; margin-bottom: 12px; }

/* ── 知らせ ── */
.snack { position: fixed; left: 24px; bottom: 24px; display: flex; align-items: center; gap: 16px; min-height: 48px; padding: 6px 8px 6px 24px; border-radius: 4px; background: var(--snack); color: var(--snack-text); box-shadow: var(--pop); z-index: 50; max-width: calc(100vw - 48px); }
.snack button { border: 0; background: transparent; color: var(--snack-act); font-weight: 500; padding: 8px; }
.snack .iconbtn { color: var(--snack-text); width: 32px; height: 32px; }

/* ── 利用者の管理・窓 ── */
.admin { overflow: auto; flex: 1; padding: 16px 24px; }
.admin h2 { font-size: 20px; font-weight: 400; margin: 4px 0 16px; }
.utable { width: 100%; border-collapse: collapse; }
.utable th { text-align: left; color: var(--sub); font-weight: 500; font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); }
.utable td { padding: 10px 8px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.utable .ops { display: flex; flex-wrap: wrap; gap: 4px; }
.small { border: 1px solid #c4c7c5; border-radius: 16px; background: transparent; padding: 4px 12px; font-size: 12px; }
.small:hover { background: var(--hover); }
.small.danger { color: var(--danger); border-color: #f2b8b5; }
.dialog-back { position: fixed; inset: 0; background: rgba(32,33,36,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.dialog { background: var(--panel); border-radius: 28px; padding: 24px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.dialog h3 { font-size: 22px; font-weight: 400; margin: 0 0 16px; }
.dialog label { display: block; color: var(--sub); font-size: 12px; margin: 12px 0 4px; }
.dialog input[type=text], .dialog select { width: 100%; border: 1px solid #747775; border-radius: 4px; padding: 10px 12px; background: transparent; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center; }
.keys kbd { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--row-read); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; justify-self: start; }
.linkbox { display: flex; gap: 8px; margin-top: 8px; }
.linkbox input { flex: 1; border: 1px solid #747775; border-radius: 4px; padding: 8px; font-size: 12px; background: transparent; }
.nav-domain { padding: 10px 16px 2px 26px; font-size: 12px; color: var(--muted); }
.role-row { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.role-row .role-domain { flex: 1; font-size: 14px; }
.dialog .role-row select { width: 140px; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid #c4c7c5; border-radius: 22px; margin-bottom: 12px; flex-wrap: wrap; }
.seg-item { border: 0; background: transparent; border-radius: 18px; padding: 6px 14px; font-size: 13px; color: var(--muted); }
.seg-item.on { background: var(--compose); color: var(--text); font-weight: 600; }
.checks { display: grid; gap: 6px; max-height: 280px; overflow: auto; margin-top: 8px; }
.checks label { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; margin: 0; }
.drawer-back { display: none; }
.fab { display: none; }

/* ── 狭い画面: 左は引き出し・作成は右下の丸・行は 2 段 ── */
@media (max-width: 760px) {
  .top .mark .wordmark { display: none; } .top .mark { width: auto; }
  .body, .body.rail { grid-template-columns: 1fr; }
  .nav, .rail .nav { position: fixed; top: 0; bottom: 0; left: 0; width: 280px; z-index: 31; background: var(--bg); transform: translateX(-100%); transition: transform .2s; padding-top: 16px; }
  .body.drawer .nav { transform: none; box-shadow: 0 0 16px rgba(0,0,0,.3); }
  .body.drawer .drawer-back { display: block; position: fixed; inset: 0; background: rgba(32,33,36,.5); z-index: 30; }
  .rail .nav .compose-btn span, .rail .nav .nav-label, .rail .nav .nav-count { display: initial; }
  .rail .nav .nav-head, .rail .nav .note { display: block; }
  .rail .nav .nav-item { width: 100%; margin-left: 0; padding: 0 12px 0 26px; border-radius: 0 16px 16px 0; }
  .fab { display: inline-flex; position: fixed; right: 16px; bottom: 16px; margin: 0; z-index: 18; box-shadow: var(--pop); }
  .main { margin: 0 8px 8px; border-radius: 12px; }
  .row { grid-template-columns: 34px 1fr auto; grid-template-areas: "s who end" "s what end"; height: auto; padding: 8px 12px 8px 4px; row-gap: 2px; }
  .row .cb { display: none; } .row .star { grid-area: s; } .row .who { grid-area: who; } .row .what { grid-area: what; } .row .end { grid-area: end; align-self: start; min-width: 0; }
  .row:hover .hover { display: none; } .row:hover .when, .row:hover .clip { display: initial; }
  .thread { padding: 8px 12px 24px; } .thread h2 { margin-left: 0; padding-left: 0; } .replies { margin-left: 0; }
  .compose, .compose.max { right: 0; left: 0; bottom: 0; top: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; transform: none; }
  .compose.min { top: auto; height: 40px; width: 100%; }
  .adv .f { grid-template-columns: 1fr; }
  .snack { left: 8px; right: 8px; bottom: 88px; }
}
