/* =========================================================================
   メールアプリ型の配置と大きさ
   - 上に細い帯（アプリ名・検索・アカウント）、左にアイコンの列、
     中は境界線で区切った欄（フォルダ｜一覧｜本文）。
   - 大きさの基準: 文字 14px（補助 12px）、ボタンと入力欄の高さ 32px、
     一覧の1行 約36px、角の丸み 4px。影は浮いた部品（メニュー・窓）だけ。
   style.css → workspace.css の後に読み込み、上書きする。
   ========================================================================= */
:root {
  --bg: #f5f5f5;
  --panel: #fff;
  --panel-alt: #fafafa;
  --chrome: #f0f0f0;
  --border: #e5e5e5;
  --border-strong: #c8c8c8;
  --text: #242424;
  --text-soft: #424242;
  --muted: #616161;
  --hover: #f0f0f0;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow-sm: none;
  --shadow: 0 2px 8px rgba(0, 0, 0, .14);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .2);
  --side-bg-soft: #e6e6e6;
  --topbar-h: 48px;
  --rail-w: 68px;
  --ctl-h: 32px;
}

html, body { height: 100%; }
body { font-size: 14px; line-height: 1.5; background: var(--panel); }
h1 { font-size: 18px; font-weight: 600; letter-spacing: 0; line-height: 1.4; margin: 0; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: 0; margin: 24px 0 8px; }
:focus-visible { border-radius: 4px; }

/* ---- 外枠 --------------------------------------------------------------- */
.app-shell {
  display: grid; min-height: 0; height: 100dvh;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
}

/* 上の帯 */
.topbar {
  grid-column: 1 / -1; display: grid; align-items: center; gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 480px) minmax(0, 1fr);
  padding: 0 12px 0 20px; background: var(--chrome); border-bottom: 1px solid var(--border);
}
.topbar-brand {
  justify-self: start; max-width: 100%; color: var(--text); font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-brand:hover { color: var(--text); text-decoration: none; }
.workspace-search {
  width: 100%; margin: 0; gap: 8px; height: var(--ctl-h); padding: 0 4px 0 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
}
.workspace-search svg { width: 16px; height: 16px; }
.workspace-search input { font-size: 14px; padding: 0; height: 100%; outline: none; }
.workspace-search input:focus-visible { box-shadow: none; }
.workspace-search button { padding: 2px 8px; font-size: 12px; background: transparent; color: var(--muted); border-radius: 4px; }
.workspace-search button:hover { background: var(--hover); color: var(--text); }
.workspace-search:focus-within { outline: 2px solid var(--primary); outline-offset: -1px; }

/* アカウントのメニュー（右上） */
.user-menu { justify-self: end; position: relative; }
.user-menu > summary {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 4px 0 10px;
  border-radius: 4px; cursor: pointer; list-style: none; font-size: 13px; color: var(--text-soft);
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--side-bg-soft); }
.user-menu-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-avatar { width: 28px; height: 28px; font-size: 12px; font-weight: 600; }
.user-menu-pop {
  position: absolute; right: 0; top: 40px; z-index: 60; width: 220px; padding: 4px;
  background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow-lg);
}
.user-menu-who { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-menu-pop a { display: block; padding: 6px 12px; border-radius: 4px; font-size: 13px; color: var(--text); }
.user-menu-pop a:hover { background: var(--hover); text-decoration: none; }
.user-menu-pop a[aria-current] { font-weight: 600; background: var(--primary-soft); color: var(--primary-dark); }
.user-menu-group { padding: 8px 12px 2px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 4px; }
.user-menu-out { border-top: 1px solid var(--border); margin-top: 4px; border-radius: 0 0 4px 4px !important; }

/* 左のアイコン列 */
.sidebar {
  width: auto; height: auto; position: static; background: var(--chrome);
  border-right: 1px solid var(--border); overflow-y: auto; overflow-x: hidden;
}
.sidebar-nav { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; overflow: visible; }
.nav-item {
  position: relative; flex-direction: column; justify-content: center; gap: 3px;
  width: 60px; min-height: 52px; padding: 6px 0 5px; border: 0; border-radius: 6px;
  font-size: 11px; font-weight: 400; line-height: 1.2; color: var(--muted); white-space: nowrap;
}
.nav-item:hover { background: var(--side-bg-soft); color: var(--text); }
.nav-item.active { background: transparent; color: var(--primary-dark); font-weight: 600; border: 0; }
.nav-item.active:hover { background: var(--side-bg-soft); }
.nav-item.active::before {
  content: ""; position: absolute; left: -4px; top: 14px; bottom: 14px; width: 3px;
  border-radius: 2px; background: var(--primary);
}
.nav-ico-wrap { position: relative; display: grid; }
.nav-ico { width: 22px; height: 22px; opacity: 1; }
.nav-badge {
  position: absolute; top: -6px; left: 13px; margin: 0; min-width: 16px; padding: 0 4px;
  font-size: 10px; font-weight: 600; line-height: 16px; background: var(--primary); color: #fff;
}

/* 中身 */
.app-main { min-width: 0; min-height: 0; overflow-y: auto; background: var(--panel); display: block; }
.container { max-width: none; margin: 0; padding: 0 24px 40px; }
.container > :first-child { margin-top: 16px; }
.container.wide { height: 100%; padding: 0; display: flex; flex-direction: column; }
.container.wide > * { margin-top: 0; }
.container.wide > .flash, .container.wide > .error { margin: 8px 12px; }

/* ---- ページの見出しの帯 -------------------------------------------------- */
.page-head, .container > .page-head:first-child {
  align-items: center; gap: 16px; margin: 0 -24px 16px; padding: 8px 24px; min-height: 52px;
  border-bottom: 1px solid var(--border); background: #fff;
}
.page-sub, .page-head .page-sub { font-size: 12px; line-height: 1.5; margin: 0; }
.crumb { margin: 0 0 12px; font-size: 12px; }
.eyebrow { font-size: 12px; margin: 0 0 4px; }
.section-heading { margin: 24px 0 8px; }
.section-heading > span, .section-heading > a { font-size: 12px; }
section[id] { scroll-margin-top: 56px; }
.section-nav { margin: 16px 0 0; padding: 8px 0; background: #fff; }
.section-nav a { padding: 3px 12px; font-size: 12.5px; font-weight: 400; box-shadow: none; }

/* ---- ボタン・入力欄 ------------------------------------------------------ */
.btn, button.primary {
  min-height: var(--ctl-h); padding: 0 12px; font-size: 13px; font-weight: 500;
  border-radius: 4px; box-shadow: none; border-color: #d1d1d1; white-space: nowrap;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn.primary, button.primary { border-color: var(--primary); box-shadow: none; }
.btn.small, .row-actions .btn, .rail-cutoff .btn, .list-pager .btn, .list-bulk-body .btn {
  min-height: 26px; padding: 0 8px; font-size: 12px;
}
button.linklike { font-size: 12.5px; font-weight: 400; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=tel],
input[type=url], input[type=number], input[type=date], input[type=time], input[type=datetime-local],
select, textarea { border-radius: 4px; }
.form input, .form select, .form textarea,
.inline-form input, .inline-form select, .inline-form textarea,
.inline-row select, .inline-row input[type="text"], .note-form textarea,
.filter input[type=text], .filter select {
  padding: 5px 8px; font-size: 14px; border-radius: 4px; border-color: var(--border-strong);
}
.form input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), .form select,
.inline-form input:not([type=checkbox]):not([type=radio]):not([type=file]), .inline-form select,
.inline-row select, .inline-row input[type="text"],
.filter input[type=text], .filter select { min-height: var(--ctl-h); }
.form label, .inline-form label, .inline-row label, .note-form label { font-size: 12px; gap: 4px; }
.form { padding: 16px 20px; gap: 12px; border-radius: 6px; }
.form .row, .inline-form .row, .form-row { gap: 12px; }
.form fieldset.form-group { padding: 12px 14px; gap: 10px; }
.form-actions { gap: 8px; margin-top: 4px; }
.inline-form { margin: 8px 0; padding: 0 14px; border-radius: 6px; }
.inline-form summary { padding: 8px 0; font-size: 13px; }
.inline-form form { gap: 10px; padding: 4px 0 12px; }
.manage-bar { padding: 10px 14px; margin-top: 16px; }
.inline-row { gap: 12px; }
.note-form { gap: 8px; margin: 8px 0; }

/* 絞り込みの行（枠で囲まない） */
.filter { background: none; border: 0; border-radius: 0; padding: 0; gap: 8px; margin: 0 0 12px; }
.filter label { font-size: 12px; gap: 4px; font-weight: 400; }
.filter button { min-height: var(--ctl-h); padding: 0 14px; font-size: 13px; border-radius: 4px; }
.filter .clear { font-size: 12.5px; }
.result-count { font-size: 12px; margin: 0 0 6px; }
.filter-chips { gap: 6px; margin: 0 0 10px; }
.filter-label { font-size: 12px; }
.chip { padding: 2px 10px; font-size: 12px; }
.tabs { margin: 0 0 12px; }
.tabs .tab { padding: 6px 12px; font-size: 13px; }
.bulk-bar { padding: 6px 10px; margin: 0 0 10px; font-size: 12.5px; border-radius: 4px; }
.bulk-bar select, .bulk-bar input[type=text], .row-actions select, .row-actions input[type=text],
.cutoff-form input[type=date], .list-bulk-body select, .list-bulk-body input[type=text] {
  min-height: 26px; padding: 2px 6px; font-size: 12px; border-radius: 4px;
}

/* ---- 表（一覧）：枠なし・行の区切り線だけ --------------------------------- */
.grid { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; }
.table-wrap { border-radius: 0; }
.grid th, .grid td { padding: 8px 12px; font-size: 13px; }
.grid th { background: #fff; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: none; padding-top: 7px; padding-bottom: 7px; }
.grid td { padding-top: 8px; padding-bottom: 8px; }
.grid tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.grid tbody tr:nth-child(even) { background: transparent; }
.grid tbody tr:hover, .grid tbody tr:focus-within { background: var(--hover); }
.grid td a { font-weight: 600; }
.grid td.empty, .empty { padding: 28px 16px; font-size: 13px; }
.rowactions, .tl-actions { gap: 10px; }
.pager, .pagination { margin: 12px 0 0; font-size: 12.5px; gap: 8px; }
.pagination a { padding: 4px 10px; border-radius: 4px; box-shadow: none; font-weight: 400; }

/* ---- 札・カード・詳細 ---------------------------------------------------- */
.badge { padding: 1px 8px; font-size: 11.5px; font-weight: 600; line-height: 1.5; }
.age { padding: 0 7px; font-size: 11px; line-height: 1.6; }
.flash { padding: 8px 12px; font-size: 13px; font-weight: 500; margin: 12px 0; box-shadow: none; }
.alert, .error, .notice, .hint { padding: 8px 12px; font-size: 13px; margin: 0 0 12px; }
.muted { font-size: 12.5px; }
.cards { gap: 8px; }
.card { padding: 12px 14px; border-radius: 6px; box-shadow: none; }
.task-cards .card { padding: 12px 14px; }
.card-label { font-size: 12px; font-weight: 400; }
.card-value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.card-hint, .card-note { font-size: 12px; margin-top: 4px; padding-top: 0; }
.card-link:hover { box-shadow: none; }
.overview-cards { border-radius: 6px; }
.overview-cards .card { padding: 10px 14px; }
.overview-cards .card-value, .company-summary .card-value { font-size: 18px; }
.priority-panel { padding: 16px 20px; gap: 20px; border-radius: 6px; }
.priority-copy h2 { font-size: 16px; margin: 0; }
.priority-copy p:not(.eyebrow) { font-size: 13px; margin: 4px 0 12px; }
.priority-copy .btn { gap: 12px; }
.priority-metric { min-width: 150px; padding-left: 20px; font-size: 12px; }
.priority-metric strong { font-size: 34px; font-weight: 600; line-height: 1.3; }
.priority-metric small { font-size: 13px; margin-left: 6px; }
.detail-grid { gap: 10px 24px; padding: 14px 16px; border-radius: 6px; }
.detail-grid .dt { font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 400; margin-bottom: 1px; }
.timeline { margin: 8px 0; }
.timeline li { padding: 10px 14px; margin-bottom: 6px; border-radius: 6px; }
.tl-head { font-size: 12px; gap: 8px; margin-bottom: 4px; }
.tl-body { font-size: 13px; }
.tag-chip { padding: 2px 10px; font-size: 12px; font-weight: 400; }
.tag-add select { padding: 3px 8px; font-size: 13px; min-height: var(--ctl-h); }
.file-chip { padding: 1px 9px; font-size: 12px; }
.decision-log > li { padding: 8px 0; gap: 12px; }
.bulk-confirm-dialog { padding: 20px; border-radius: 8px; }
.bulk-confirm-dialog h2 { font-size: 16px; }
.bulk-confirm-dialog p { margin: 8px 0 16px; font-size: 13px; }

/* 案件の中の左欄 */
.folder-shell { gap: 0; margin: 0 -24px; border-top: 1px solid var(--border); }
.folder-list { flex-basis: 220px; top: 0; border: 0; border-right: 1px solid var(--border); border-radius: 0; padding: 12px 8px; background: var(--panel-alt); align-self: stretch; }
.folder-list-head { padding: 0 8px 8px; }
.fl-title { font-size: 14px; }
.fl-owner { font-size: 12px; }
.folder-item { padding: 0 10px; min-height: var(--ctl-h); border-radius: 4px; }
.fl-ico { width: 16px; height: 16px; }
.fl-name { font-size: 13.5px; }
.folder-main { padding: 0 24px 24px; }

/* =========================================================================
   問い合わせ（フォルダ｜一覧｜本文）
   ========================================================================= */
.mail-ws {
  flex: 1 1 auto; min-height: 0; height: auto; gap: 0;
  grid-template-columns: 216px minmax(280px, 360px) minmax(0, 1fr);
}
.mail-pane { border: 0; border-right: 1px solid var(--border); border-radius: 0; background: #fff; }
.mail-view { border-right: 0; }

/* フォルダ欄 */
.mail-rail { padding: 12px 8px; background: var(--panel-alt); }
.rail-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); padding: 0; }
.rail-compose { width: 100%; min-height: 36px; margin: 0 0 12px; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; }
.rail-compose .rail-ico { color: inherit; }
.rail-views { gap: 1px; }
.rail-view, .rail-chk {
  min-height: var(--ctl-h); padding: 0 10px; gap: 10px; border-radius: 4px;
  font-size: 14px; font-weight: 400; color: var(--text);
}
.rail-view:hover, .rail-chk:hover { background: var(--side-bg-soft); }
.rail-view.on { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.rail-ico { width: 16px; height: 16px; flex: none; color: var(--muted); }
.rail-view.on .rail-ico { color: var(--primary); }
.rail-view-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-count, .rail-count.is-alert { min-width: 0; padding: 0; background: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.rail-count.is-alert, .rail-view.on .rail-count { color: var(--primary-dark); }
.rail-sep { height: 1px; margin: 6px 10px; background: var(--border); }
.rail-filters { margin-top: 12px; gap: 1px; }
.rail-group { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.rail-chk { font-size: 13px; }
.rail-chk .chk-box { width: 14px; height: 14px; border-radius: 3px; }
.rail-tool { margin-top: 12px; padding-top: 8px; }
.rail-tool > summary { font-size: 12px; }
.rail-cutoff { padding: 8px 10px; font-size: 12px; }
.rail-cutoff input[type=date] { min-height: 26px; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* 一覧 */
.list-meta { min-height: 40px; padding: 0 12px 0 16px; gap: 8px; border-bottom: 1px solid var(--border); font-size: 12px; flex-wrap: nowrap; }
.list-title { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-q { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--muted); }
.list-q a { margin-left: 4px; }
.list-total, .list-selall, .selection-count { flex: none; white-space: nowrap; font-size: 12px; }
.list-bulk > summary { padding: 5px 16px; font-size: 12px; }
.list-bulk-body { padding: 4px 16px 10px; }
.mrow { gap: 0; }
.mrow:hover { background: var(--hover); }
.mrow.on { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.mrow .rowchk { margin: 11px 0 0 12px; }
.mrow-body { padding: 8px 12px 8px 16px; }
.mrow .rowchk + .mrow-body { padding-left: 8px; }
.mrow-top, .mrow-mid { display: flex; align-items: center; gap: 8px; }
.mrow-from { font-size: 14px; font-weight: 600; }
.mrow-date { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mrow-subject { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 13px; color: var(--text); }
.mrow-preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow-sub { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 11.5px; }
.mrow-sub > span { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow-sub > .badge, .mrow-sub > .mrow-tag { flex: none; }
.mrow-sub .badge { font-size: 11px; padding: 0 7px; }
.mrow-tag.is-private { color: var(--text-soft); font-weight: 600; }
.list-pager { padding: 6px; font-size: 12px; }
.list-rows .empty { padding: 28px 16px; font-size: 13px; }

/* 本文 */
.mail-view { padding: 0; }
.mail-blank { font-size: 13px; }
.view-actions {
  position: sticky; top: 0; z-index: 5; flex: none; gap: 6px; min-height: 44px;
  padding: 6px 16px; background: #fff; border-bottom: 1px solid var(--border);
}
.view-actions .btn { min-height: 30px; padding: 0 10px; font-size: 13px; }
.view-actions select { min-height: 30px; padding: 0 6px; font-size: 13px; border-radius: 4px; border: 1px solid #d1d1d1; background: #fff; }
.view-actions .assign-form { margin: 0 0 0 auto; }
.view-actions .assign-form select { max-width: 13rem; font-size: 13px; padding: 0 6px; }
.act-done { position: relative; }
.act-done[open] > summary { margin-bottom: 0; }
.act-done .done-fields {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 10; width: 320px; gap: 6px;
  padding: 10px; border-radius: 6px; box-shadow: var(--shadow);
}
.done-fields select, .done-fields input[type=text] { flex: 1 1 100%; }
.field-help { font-size: 12px; }
.view-body { padding: 16px 24px 32px; }
.view-head { padding: 0; border: 0; }
.view-subject { font-size: 18px; font-weight: 600; line-height: 1.4; }
.view-sender { display: flex; align-items: flex-start; gap: 12px; margin-top: 12px; }
.view-sender .side-avatar { width: 36px; height: 36px; font-size: 14px; background: #e0e0e0; color: var(--text-soft); }
.view-sender-main { flex: 1 1 auto; min-width: 0; }
.view-sender-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.view-sender-addr { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.view-meta { margin-top: 2px; gap: 2px 14px; font-size: 12px; }
.view-date { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mail-visibility { gap: 10px; margin-top: 10px; padding: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 12.5px; }
.view-note { margin: 10px 0 0; padding: 6px 10px; font-size: 12.5px; border-radius: 4px; }
.mail-view .mailbody {
  max-height: none; overflow: visible; margin: 16px 0 0; padding: 0; background: none; border: 0;
  border-radius: 0; box-shadow: none; font-size: 14px; line-height: 1.7; color: var(--text);
}
.view-atts { margin-top: 16px; font-size: 13px; }
.view-fold { margin-top: 12px; padding-top: 8px; }
.view-fold > summary { font-size: 13px; }
.mail-attachments { padding: 12px 14px; }
.sharing-page { margin: 16px 0; }
.sharing-summary { margin: 16px 0; padding: 14px 16px; }

/* =========================================================================
   カレンダー（左欄＋本体）を外枠に合わせる
   ========================================================================= */
.container:has(.cal-shell) { padding: 0; }
.container:has(.cal-shell.is-fixed) { height: 100%; }
.container:has(.cal-shell) > .flash { margin: 8px 12px; }
.cal-shell { gap: 0; min-height: 100%; margin-top: 0 !important; }
.cal-shell.is-fixed { height: 100%; }
.cal-side { flex: 0 0 220px; width: 220px; gap: 14px; padding: 12px; background: var(--panel-alt); border-right: 1px solid var(--border); }
.cal-main { padding: 10px 16px 12px; }
.cal-bar { padding: 6px 0; margin-bottom: 8px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: #fff; }
.cal-bar-title { font-size: 16px; }
.cal-bar .cal-arrow { min-width: 30px; height: 30px; border-radius: 4px; }
.cal-tab { padding: 5px 14px; font-size: 13px; font-weight: 500; }
.cal-tabs, .scope-btn { border-radius: 4px; }
.day-cal, .week-cal { box-shadow: none; }

/* ---- ログイン ------------------------------------------------------------ */
.login-page { min-height: 100dvh; background: var(--bg); }
.login-card { width: min(360px, 100%); padding: 28px; border-radius: 8px; border-top-width: 3px; box-shadow: var(--shadow); gap: 12px; }
.login-card .login-sub { font-size: 12px; margin: 0 0 8px; }
.login-card label { font-size: 12px; gap: 4px; }
.login-card .alert { margin: 0; }
.login-card h1 { font-size: 18px; }
.login-card input { padding: 6px 10px; font-size: 14px; min-height: 36px; border-radius: 4px; }
.login-card button { padding: 0 12px; min-height: 36px; font-size: 14px; border-radius: 4px; }

/* =========================================================================
   画面の幅に合わせる
   ========================================================================= */
@media (max-width: 1240px) {
  .mail-ws { height: auto; grid-template-columns: 200px minmax(240px, 320px) minmax(0, 1fr); }
  .mail-rail { grid-column: auto; }
  .mail-rail .rail-views, .mail-rail .rail-filters { flex-direction: column; flex-wrap: nowrap; }
  .mail-list, .mail-view { max-height: none; }
  .container { padding: 0 20px 40px; }
  .page-head, .container > .page-head:first-child { margin: 0 -20px 16px; padding: 8px 20px; }
  .folder-shell { margin: 0 -20px; }
  .workspace-search { width: 100%; margin: 0; }
}
@media (max-width: 1000px) {
  /* フォルダ欄を上の横1列にして、一覧と本文に幅を回す */
  .mail-ws { grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .mail-rail { grid-column: 1 / -1; display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 6px 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .mail-rail .rail-views, .mail-rail .rail-filters { flex-direction: row; flex: none; margin: 0; }
  .rail-compose { width: auto; margin: 0; flex: none; }
  .rail-view, .rail-chk { flex: none; }
  .rail-view-label { overflow: visible; }
  .rail-sep, .rail-group { display: none; }
  .rail-tool { flex: none; margin: 0; padding: 0; border: 0; }
}
@media (max-width: 820px) {
  /* スマホ: 左の列を下の横並びにする（メールアプリの下のタブと同じ） */
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar-h) minmax(0, 1fr) 56px; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; padding: 0 8px 0 12px; gap: 8px; }
  .topbar-brand { display: none; }
  .user-menu-name { display: none; }
  .user-menu > summary { padding: 0 4px; }
  .sidebar, .js-enabled .sidebar {
    display: block; grid-row: 3; width: auto; height: auto; position: static;
    border-right: 0; border-top: 1px solid var(--border); overflow-x: auto; overflow-y: hidden;
  }
  .sidebar-nav { display: flex; flex-direction: row; align-items: stretch; justify-content: space-between; gap: 0; padding: 2px 4px; grid-template-columns: none; }
  .nav-item { flex: 1 0 56px; width: auto; min-height: 50px; }
  .nav-item.active::before { left: 14px; right: 14px; top: 0; bottom: auto; width: auto; height: 3px; }
  .container, .container.wide { padding: 0 12px 32px; }
  .container.wide { height: auto; padding: 0; display: block; }
  .page-head, .container > .page-head:first-child { margin: 0 -12px 12px; padding: 8px 12px; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
  .folder-shell { margin: 0 -12px; }
  .folder-list { border-right: 0; border-bottom: 1px solid var(--border); }
  .folder-main { padding: 0 12px 24px; }
  h1 { font-size: 17px; }
  .mail-ws { display: block; }
  .mail-pane { border-right: 0; }
  .mail-rail { border-bottom: 1px solid var(--border); }
  .mail-list { max-height: 60vh; border-bottom: 1px solid var(--border); }
  .mail-view { max-height: none; overflow: visible; }
  .mail-back-link { margin: 8px 12px 0; padding: 4px 0; font-size: 13px; }
  .view-actions { position: static; padding: 6px 12px; }
  .view-actions .assign-form { margin-left: 0; }
  .view-body { padding: 12px 12px 24px; }
  .view-sender { flex-wrap: wrap; }
  .view-date { flex-basis: 100%; padding-left: 48px; }
  .act-done .done-fields { width: min(320px, calc(100vw - 24px)); }
  .container:has(.cal-shell), .container:has(.cal-shell.is-fixed) { height: auto; padding: 0; }
  .cal-shell, .cal-shell.is-fixed { height: auto; min-height: 0; }
  .cal-side { flex-basis: auto; width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
  .cal-main { padding: 8px 12px 12px; }
  .priority-metric { min-width: 110px; padding-left: 14px; }
  .priority-metric strong { font-size: 28px; }
}
@media (max-width: 480px) {
  .priority-panel { padding: 14px; }
  .priority-metric { padding: 0 0 10px; }
  .priority-metric strong { font-size: 28px; }
  .card-value { font-size: 20px; }
  .card-label { font-size: 12px; }
}

/* 横に流れる列（狭い画面のフォルダ欄・下のタブ）のスクロールバーは細くする */
.mail-rail, .sidebar { scrollbar-width: thin; }
/* 検索の入力欄は広がりすぎないようにする */
.filter .search-field { flex: 0 1 420px; }
.mail-ws > section { margin-top: 0; }
.done-fields select, .done-fields input[type=text] { min-height: 30px; padding: 0 8px; border: 1px solid #d1d1d1; border-radius: 4px; font-size: 13px; background: #fff; }
