/* La Briller Case Portal
 * 色はすべて :root の変数で持つ(配色を変える時はここだけ直す)。
 */
:root:lang(zh-CN) {
  --mincho: 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
:root {
  --top-h: 60px;               /* 上部の高さ・下のタブの高さ(スマホの横は低くする) */
  --tab-h: 64px;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f4f7fc;        /* 入力欄(薄い青み) */
  --surface-ro: #edf2f9;       /* 閲覧のみの欄 */
  --line: #dde5f0;
  --glass-card: rgba(255, 255, 255, .95); /* カード */
  --line-soft: #eef1f4;
  --text: #000000;
  --text-2: #000000;
  --text-3: #000000;
  --brand: #0068b7;            /* 主ボタン = ロゴの青 */
  --brand-ink: #ffffff;
  --brand-soft: #e6f0fa;       /* 選択中の行 */
  --accent: #a77d2c;           /* 金(英字の見出し・細線) */
  --blue-grad: linear-gradient(100deg, #1d5a9e 0%, #3a78c0 40%, #6aa0d8 52%, #2a69ad 70%, #1d5a9e 100%);
  --gold-grad: linear-gradient(100deg, #84590f 0%, #b88a2a 35%, #d6b05a 50%, #a97a20 68%, #84590f 100%);
  --link: #0a6eb4;             /* リンクの青 */
  --logo-blue: #0068b7;        /* ロゴの実色(カードの細枠) */
  --focus: rgba(10, 110, 180, .28);
  --shadow: 0 1px 2px rgba(0, 40, 90, .06), 0 8px 28px rgba(0, 40, 90, .10);
  --radius: 10px;
  --radius-sm: 6px;
  --red: #c2414b;
  --red-bg: #fbeef0;
  --amber: #9a6a12;
  --amber-bg: #fbf3e2;
  --green: #2c7a55;
  --green-bg: #e8f4ee;
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --mincho: 'Noto Serif JP', 'Hiragino Mincho ProN', 'YuMincho', 'Yu Mincho', serif;   /* 日本語の明朝(英字の Cormorant と揃える) */
  --sans: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* 縦のスクロールバーの場所は常に空けておく = 出たり消えたりで中身の幅が変わらない
   (書いた分だけ高くなる欄を測り直す間に 幅が変わって高さを測り違えない) */
html { scrollbar-gutter: stable; }
/* 背景(body の写真)は html の大きさに合わせて置かれる = 中身が少ない画面でも 画面の下まで写真にする(スマホで下が灰色にならない) */
html { min-height: 100%; }
/* iPhone は横にすると 一部の文字を勝手に大きくする(並びが崩れる)= 書いた大きさのまま */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* 文字の大きさ(自分の設定)。文字は rem で書いてある = ここだけで全部の文字が大きくなる(並びはそのまま) */
html.font-large { font-size: 112.5%; }
/* 文字は黒体(Noto Sans JP / 中国語は Noto Sans SC)。明朝はログイン画面の見出し・ボタンだけ */
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8125rem;
  letter-spacing: .02em;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
.link { background: none; border: none; padding: 0; color: var(--link); }
.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* 英字の見出し(CASE PORTAL / ORDER / FILES / CHAT) */
.login-sub, .login-label, .top-sub, .ct { font-family: var(--serif); color: var(--accent); font-weight: 600; }
/* 英字は金属の金(グラデーションを文字に抜く)。中の日本語ラベルは普通の色に戻す */
.login-sub, .login-label, .top-sub, .ct {
  background: var(--gold-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-label span, .ct span, .ct .ct-link { -webkit-text-fill-color: currentColor; }
/* 行いっぱいの要素は、渐変を英字の長さ分だけにする(行全体に伸ばすと英字が暗い端しか拾わない) */
.login-label, .ct { background-size: 170px 100%; background-repeat: no-repeat; }
/* 内页の英字見出し = ロゴの青。上部の CASE PORTAL は青灰の無地 */
.ct { background-image: var(--blue-grad); }
.top-sub { background: none; color: #3f5b7e; -webkit-text-fill-color: currentColor; }

/* ---- ログイン ---- */
/* 背景 = 珠光のプリズム写真。カードは磨りガラスで光を透かす */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: #eef1f8 url('/assets/login-bg.jpg') center / cover no-repeat fixed;
}
/* 言語(ログイン画面の右上・地球の印 + 今の言語。押すと一覧)。画面と一緒に動く(スマホで引っ張っても 離れて見えない) */
.lang-pick { position: absolute; top: 14px; right: 16px; z-index: 5; }
.lang-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid rgba(30, 50, 90, .15); border-radius: 999px; background: rgba(255, 255, 255, .7); color: var(--text); font-size: 0.8125rem; }
.lang-btn:hover { background: #fff; }
.lang-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 140px; padding: 6px; display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 25, 40, .15); }
.lang-menu[hidden] { display: none; }
.lang-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border: none; border-radius: 6px; background: none; color: var(--text); font-size: 0.875rem; text-align: left; }
.lang-menu button:hover { background: var(--brand-soft); }
.lang-menu button[aria-selected="true"] { color: var(--logo-blue); font-weight: 600; }
.lang-menu button[aria-selected="true"]::after { content: '✓'; }
/* カードの幅は言語で変えない(日本語・中文とも 380px・狭い画面では全幅) */
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  width: 100%; max-width: 380px; border-radius: 16px;
  background: rgba(255, 255, 255, .62);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--logo-blue);
  box-shadow: 0 10px 40px rgba(60, 80, 140, .12), inset 0 1px 0 rgba(255, 255, 255, .9);
}
/* 中文字体の「•」は全角幅で間が空くので、パスワードの伏せ字だけ欧文字体で出す(Mac/Win 共通) */
.login-input[type=password] { font-family: Arial, Helvetica, sans-serif; letter-spacing: .12em; }
.login-page .login-input { background: rgba(255, 255, 255, .75); border-color: rgba(30, 50, 90, .12); }
.login-inner { padding: 44px 40px 32px; }
.login-logo { display: block; margin: 0 auto; height: 88px; }
.login-sub { font-size: 0.875rem; letter-spacing: .5em; text-align: center; margin: 14px 0 30px; }
.login-sub::after { content: ''; display: block; width: 36px; height: 1px; background: var(--gold-grad); margin: 14px auto 0; }
.login-label { display: block; font-size: 0.8125rem; letter-spacing: .25em; margin-bottom: 6px; }
.login-label span { font-family: var(--mincho); font-weight: 400; font-size: 0.75rem; letter-spacing: .15em; margin-left: 10px; color: var(--text-2); }
.login-input { width: 100%; height: 42px; margin-bottom: 18px; padding: 0 14px; font-size: 0.875rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.login-input:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px var(--focus); background: var(--surface); }
.login-error { min-height: 18px; color: var(--red); font-size: 0.75rem; margin: -8px 0 6px; }
.login-btn { width: 100%; height: 46px; margin-top: 4px; background: var(--brand); color: var(--brand-ink); border: none; border-radius: var(--radius-sm); font-family: var(--mincho); font-weight: 500; font-size: 0.875rem; letter-spacing: .6em; text-indent: .6em; }
.login-btn:hover { filter: brightness(1.08); }
.login-btn:disabled { opacity: .6; }
.login-note { font-family: var(--mincho); font-size: 0.6875rem; letter-spacing: 0; text-wrap: balance; text-align: center; margin: 20px 0 0; color: var(--text-3); }

/* ---- 枠 ---- */
/* 内页の地 = ログインと同じ珠光図(白の膜は 1 割だけ)。カード・入力・一覧の各項目は白地なので読みやすさは変わらない。
   図は 画面に固定した層(::before)に敷く = どの頁も 画面 1 枚分の同じ図(頁の長さで伸びない・iPhone/iPad は background-attachment: fixed が効かない)。
   層の高さ = 一番大きい画面の高さ(100lvh)= iPhone でキーボードを出して閉じても 層が縮んだまま残らない */
.app-page { background: var(--bg); }
.app-page::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: 100lvh; z-index: -1; pointer-events: none;
  background:
    linear-gradient(rgba(246, 248, 252, .1), rgba(246, 248, 252, .1)),
    url('/assets/app-bg.jpg') center / cover no-repeat;
}
.top { height: var(--top-h); background: rgba(255, 255, 255, .25); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid rgba(255, 255, 255, .7); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 5; }
.top-logo { height: 34px; }
.top-sub { letter-spacing: .45em; font-size: 0.75rem; padding-left: 16px; border-left: 1px solid var(--line); }
.top-me { margin-left: auto; color: var(--text-2); font-size: 0.75rem; display: flex; align-items: center; gap: 10px; }
.top-me b { color: var(--text); font-weight: 400; }
.top-me .sep { color: var(--line); }
.wrap { display: flex; min-height: calc(100vh - var(--top-h)); }

/* ---- 左の一覧 ---- */
.side { width: var(--side-w, 300px); flex: none; background: rgba(255, 255, 255, .2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-right: 1px solid var(--logo-blue); box-shadow: 4px 0 18px rgba(20, 50, 90, .06); padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); }
.new { height: 40px; background: var(--brand); color: var(--brand-ink); border: none; border-radius: var(--radius-sm); letter-spacing: .2em; }
.new:hover { filter: brightness(1.08); }
/* 左一覧は珠光を透かしたまま、中身(絞り込み・検索・各症例)に白い地と枠を付けて背景から浮かせる */
.filters { display: flex; gap: 0; padding: 3px; background: rgba(255, 255, 255, .92); border: 1px solid var(--logo-blue); border-radius: 8px; box-shadow: 0 1px 3px rgba(20, 50, 90, .06); }
.filters button { flex: 1 1 auto; height: 28px; padding: 0 2px; background: none; border: none; border-radius: var(--radius-sm); font-size: 0.75rem; color: var(--text-2); white-space: nowrap; }
/* 一覧を狭めた時は 絞り込みの字を一覧の幅に合わせて小さくする(5 つが枠に収まる) */
.side { container-type: inline-size; }
.side .filters button { font-size: clamp(10px, 4.5cqi, 0.75rem); }   /* 下限は px = 大きい字の設定でも 5 つが収まる */
.filters button.on { background: var(--logo-blue); color: #fff; }
.clinic-filter, .search { height: 34px; border: 1px solid var(--logo-blue); background: #fff; box-shadow: 0 1px 3px rgba(20, 50, 90, .06); border-radius: var(--radius-sm); padding: 0 12px; font-size: 0.75rem; width: 100%; }
.clinic-filter:focus, .search:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px var(--focus); }
/* 高さが足りない時に縮むのは一覧だけ(ボタン・検索欄は潰さない) */
.side > * { flex-shrink: 0; }
.side > .case-list { flex-shrink: 1; min-height: 0; }
/* 一覧の幅を変えるつまみ(一覧の右の縦線に重ねる) */
.side-resize { flex: none; width: 8px; margin: 0 -4px; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); cursor: col-resize; z-index: 3; }
.side-resize:hover, .side-resizing .side-resize { background: linear-gradient(90deg, transparent 3px, var(--logo-blue) 3px, var(--logo-blue) 5px, transparent 5px); }
.side-resizing { cursor: col-resize; user-select: none; }
.case-list { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 6px 6px 0; }
.grp-head { display: flex; align-items: center; width: 100%; padding: 12px 8px 6px; font-size: 0.6875rem; color: var(--text-3); background: none; border: none; text-align: left; letter-spacing: .08em; }
.grp-head.pinned { color: var(--red); }
.grp-head.month::before { content: ''; width: 5px; height: 5px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(-45deg); margin-right: 9px; transition: transform .15s; }
.grp-head.month.open::before { transform: rotate(45deg); }
/* 完結した症例 = 医院ごとのフォルダ(中の月は一段下げる) */
.grp-head.done { margin-top: 10px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.grp-head.clinic { color: var(--text); font-size: 0.75rem; letter-spacing: 0; }
.grp-head.clinic::before { content: ''; width: 5px; height: 5px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(-45deg); margin-right: 9px; transition: transform .15s; }
.grp-head.clinic.open::before { transform: rotate(45deg); }
.grp-head.month.sub { padding-left: 24px; }
.grp-head .cnt { margin-left: auto; }
.fd { display: flex; align-items: center; gap: 8px; padding: 10px 10px; margin-bottom: 6px; border-radius: 8px; cursor: pointer; background: rgba(255, 255, 255, .92); border: 1px solid var(--logo-blue); box-shadow: 0 1px 3px rgba(20, 50, 90, .06); }
.fd:hover { background: #fff; box-shadow: 0 2px 8px rgba(0, 104, 183, .12); }
.fd.on { background: #fff; border-color: var(--logo-blue); box-shadow: inset 3px 0 0 var(--logo-blue), 0 2px 8px rgba(0, 104, 183, .12); }
.fd-text { flex: 1; min-width: 0; }
.fd { position: relative; }
.fd .fd-badge { top: -6px; right: -6px; }
.fd-tags { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.fd .n, .fd .d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fd .d { font-size: 0.6875rem; color: var(--text-3); margin-top: 2px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); flex: none; }
.list-empty { color: var(--text-3); padding: 24px 6px; text-align: center; }

/* 状態の札 */
.b { font-size: 0.6875rem; padding: 2px 9px; border-radius: 999px; white-space: nowrap; letter-spacing: .05em; }
.b-draft { background: var(--surface-ro); color: var(--text-2); }
.b-pending { background: var(--amber-bg); color: var(--amber); }
.b-rejected { background: var(--red-bg); color: var(--red); }
.b-approved { background: var(--green-bg); color: var(--green); }
.b-shipped { background: #e6f0fb; color: var(--logo-blue); }
.b-cancelled { background: #eceff3; color: #5b6878; text-decoration: line-through; }
.b-cancelreq { background: #fff3c4; color: #7a5a00; box-shadow: inset 0 0 0 1px #e9cf6b; }
.b-remake { background: #f3e8ff; color: #6b21a8; }
.tag-remake { display: inline-block; margin-left: 6px; font-size: 0.6875rem; padding: 1px 8px; border-radius: 999px; background: #f3e8ff; color: #6b21a8; vertical-align: middle; }

/* ---- 右の症例 ---- */
.main { flex: 1; min-width: 0; padding: 22px 26px 40px; display: flex; flex-direction: column; gap: 16px; container-type: inline-size; }
.case-empty { color: var(--text-3); padding: 80px 0; text-align: center; }
/* 症例を選ぶ前の迎え画面 = 水晶の図 + ロゴ */
.welcome {
  flex: 1; min-height: calc(100vh - 110px); border-radius: var(--radius);
  background: url('/assets/crystal-bg.jpg') center / cover no-repeat;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px;
}
.welcome img { height: 110px; }
.welcome-sub { font-family: var(--serif); font-weight: 600; font-size: 0.9375rem; letter-spacing: .5em; background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.welcome-sub::after { content: ''; display: block; width: 36px; height: 1px; background: var(--gold-grad); margin: 14px auto 0; }
.welcome p { margin: 6px 0 0; color: var(--text-2); font-size: 0.8125rem; letter-spacing: .08em; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head h1 { font-size: 1.375rem; font-weight: 400; margin: 0; letter-spacing: .04em; color: var(--text); }
.head .meta { color: var(--text-3); font-size: 0.75rem; display: inline-flex; flex-wrap: wrap; column-gap: 1em; }
.head .meta > span { white-space: nowrap; }
.head .meta > .meta-clinic { white-space: normal; }
.head .actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { background: none; border: none; color: var(--text-3); font-size: 0.9375rem; padding: 0 2px; }
.icon-btn:hover { color: var(--link); }
.btn { height: 36px; padding: 0 20px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #a9bcd3; border-radius: var(--radius-sm); background: #fff; font-size: 0.8125rem; white-space: nowrap; color: var(--text); transition: border-color .15s, background .15s, color .15s; }
.btn:hover { border-color: var(--logo-blue); color: var(--logo-blue); }
.btn.sm { height: 28px; padding: 0 12px; }
.btn.on, .btn.on:hover { background: var(--logo-blue); color: #fff; border-color: var(--logo-blue); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); letter-spacing: .15em; }
.btn.primary:hover { filter: brightness(1.1); color: var(--brand-ink); }
.btn.ng { border-color: var(--red); color: var(--red); }
.btn.ng:hover { background: var(--red-bg); }
.btn:disabled { opacity: .45; cursor: default; pointer-events: none; }
.btn.ok { background: var(--green); border-color: var(--green); color: #fff; letter-spacing: .15em; }
.linkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 14px; font-size: 0.75rem; border-radius: var(--radius-sm); background: #eef3fa; box-shadow: inset 3px 0 0 var(--logo-blue); }
.linkbar a { color: var(--link); }
.ngbar { background: var(--red-bg); color: var(--red); padding: 10px 14px; font-size: 0.75rem; border-radius: var(--radius-sm); box-shadow: inset 3px 0 0 var(--red); white-space: pre-wrap; }
.warnbar { background: #fff8db; color: #7a5a00; padding: 10px 14px; font-size: 0.75rem; border-radius: var(--radius-sm); box-shadow: inset 3px 0 0 #e0b400; white-space: pre-wrap; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--glass-card); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--logo-blue); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; min-width: 0; }
.ct { letter-spacing: .3em; font-size: 1rem; margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: baseline; }
.ct span { font-family: var(--sans); font-weight: 400; font-size: 0.8125rem; letter-spacing: .08em; margin-left: 8px; color: var(--text-2); }
.ct-links { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; column-gap: 12px; }
.ct-link { font-family: var(--sans); font-size: 0.75rem; letter-spacing: 0; text-decoration: none; white-space: nowrap; }
.sec { font-size: 0.8125rem; color: var(--text); font-weight: 400; letter-spacing: .1em; border-bottom: 1px solid #cfdcec; padding: 0 0 6px 10px; margin: 18px 0 12px; box-shadow: inset 3px 0 0 var(--logo-blue); }

/* 発注表 */
/* 欄名は 1 行(長い欄名でも * が欄名のすぐ後ろ)= 欄名の列は いちばん長い欄名の幅 */
.g { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr); gap: 10px 12px; align-items: center; }
.g .lbl { font-size: 0.8125rem; color: var(--text); text-align: right; white-space: nowrap; }
.req { color: var(--red); margin-left: 2px; }
.in { height: 36px; width: 100%; border: 1px solid #a9bcd3; border-radius: var(--radius-sm); background: #fff; padding: 0 10px; font-size: 0.875rem; min-width: 0; color: var(--text); }
.in:focus { outline: none; border-color: var(--logo-blue); box-shadow: 0 0 0 3px rgba(0, 104, 183, .18); background: #fff; }
.in.ro { display: flex; align-items: center; height: auto; min-height: 36px; padding-top: 6px; padding-bottom: 6px; overflow-wrap: anywhere; background: #e9f0f9; border-color: #d3dfee; color: var(--text); font-weight: 400; }
.in.multi, textarea.in { height: auto; min-height: 60px; padding: 8px 10px; display: block; white-space: pre-wrap; line-height: 1.6; }
textarea.in { resize: none; overflow: hidden; }   /* 高さは case.js の fitHeight が内容に合わせる */
.seg { display: flex; gap: 4px; }
/* SET日: 日付欄の右に 最短/未定(同じ行・日付欄が縮む。入らない時 = スマホは 次の行へ) */
.setdate-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.setdate-row .in { flex: 0 1 220px; min-width: 9em; }
.g .val.wide { grid-column: 2 / -1; }
.setdate-row span { display: flex; gap: 4px; flex: none; }
.g4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; margin-top: 14px; }
.g4 label, .notes label { display: block; font-size: 0.75rem; color: var(--text); margin-bottom: 4px; }
.notes { margin-top: 12px; }
/* 再製: 「未装着」・「前回同様」(枠付きで目立たせる) */
.chk { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text); cursor: pointer; letter-spacing: 0; }
.chk input { flex: none; accent-color: var(--logo-blue); margin: 0; width: 17px; height: 17px; }
.chk.big { font-size: 0.875rem; }
.chk.same { display: inline-flex; margin: 0; height: 36px; font-size: 0.875rem; font-weight: 500; color: var(--logo-blue); background: #eef5fc; border: 1px solid var(--logo-blue); border-radius: var(--radius-sm); padding: 0 12px; }   /* 形と高さ = 入力欄(.in)と同じ */
.chk.same.ro { cursor: default; }
.g4.with-same { grid-template-columns: repeat(5, minmax(0, 1fr)); }   /* 色の右に「色：前回同様」を 5 つ目の欄として(同じ幅) */
.same-cell { align-self: end; }
.same-cell .chk.same { width: 100%; justify-content: center; }
.lb-tooth-chart { border-color: #cfdcec !important; border-radius: var(--radius) !important; --tooth-chart-width: 580px !important; padding: 14px 16px !important; }
.lb-tooth-chart .tooth-chart-head h3,
.lb-tooth-chart .out-head h4 { color: var(--text-2) !important; font-weight: 400 !important; font-size: 0.75rem; letter-spacing: .1em; }
.lb-tooth-chart .tooth-chart-body { font-family: var(--sans) !important; }
/* 歯式図の中の字(歯番号・右/左・本数・上顎/下顎・型ボタン)も黒に揃える */
.lb-tooth-chart .tooth-chart-body, .lb-tooth-chart .fdi-lbl, .lb-tooth-chart .arch-label, .lb-tooth-chart .seg-count,
.lb-tooth-chart .out .k, .lb-tooth-chart .types button:not(.on), .lb-tooth-chart .out .empty { color: var(--text) !important; }
::placeholder { color: #8a94a3; opacity: 1; }   /* 未入力の案内は灰のまま(記入済みと見分ける) */
/* 内页の和文は太字にしない。英字見出し(Cormorant)だけ 600 */
.ct .ct-link, .lb-tooth-chart .tooth-chart-head h3, .lb-tooth-chart .types button,
.lb-tooth-chart .seg-name,
.lb-tooth-chart .out .k,
.lb-tooth-chart .out .result-chip,
.lb-tooth-chart .out .missing-type { font-weight: 400 !important; }
/* 閲覧のみ(BMF・提出後)は押せる見た目にしない */
/* 部品側の is-readonly{opacity:.84} は後から読み込まれるので !important で打ち消す(閲覧のみでも色を薄めない) */
.lb-tooth-chart.is-readonly { opacity: 1 !important; }
.lb-tooth-chart.is-readonly .tooth,
.lb-tooth-chart.is-readonly .tooth .hit,
.lb-tooth-chart.is-readonly .types button { cursor: default; }
.lb-tooth-chart.is-readonly .tooth:not(.sel):hover .cap { fill: #fff; }
.lb-tooth-chart.is-readonly .types button:hover { background: #fff; }
.lb-tooth-chart.is-readonly .types button.on:hover { background: var(--logo-blue); }
/* 歯式図の色: I型 = ロゴの青 / おまかせ = 濃い灰 / J型 = 部品どおりの緑 */
.lb-tooth-chart .tooth.sel .cap { fill: var(--logo-blue) !important; stroke: #004f8c !important; }
.lb-tooth-chart .tooth.sel.t-j .cap { fill: #2f8f5b !important; stroke: #1f6b43 !important; }
.lb-tooth-chart .tooth.sel.t-o .cap { fill: #5f6f82 !important; stroke: #46546a !important; }
.lb-tooth-chart .types button.on { background: var(--logo-blue) !important; border-color: var(--logo-blue) !important; }
.lb-tooth-chart .types button .dot { background: var(--logo-blue) !important; }
.lb-tooth-chart .types button[data-t="J型"] .dot { background: #2f8f5b !important; }
.lb-tooth-chart .types button[data-t="おまかせ"] .dot { background: #5f6f82 !important; }
.lb-tooth-chart .out .result-chip, .lb-tooth-chart .out .result-type { background: var(--logo-blue) !important; border-color: var(--logo-blue) !important; }
.lb-tooth-chart .out .result-group.t-j .result-chip { background: #2f8f5b !important; border-color: #1f6b43 !important; }
.lb-tooth-chart .out .result-group.t-o .result-chip { background: #5f6f82 !important; border-color: #46546a !important; }
/* 型がまだ無い歯 = 部品どおり黄色の点線(「型を選んで」の合図)。上の青で消さない */
.lb-tooth-chart .tooth.sel.t-none .cap { fill: #fde68a !important; stroke: #d97706 !important; }
/* 再製: 元の受注の歯(淡い型の色)・破折・脱離の歯(赤・✕) */
.lb-tooth-chart .tooth.base .cap { fill: #a9c4df !important; stroke: #5a7ea3 !important; }
.lb-tooth-chart .tooth.base.t-j .cap { fill: #a7d3b9 !important; stroke: #3f8a5f !important; }
.lb-tooth-chart .tooth.base.t-o .cap { fill: #c6ced8 !important; stroke: #7b8a9c !important; }
.lb-tooth-chart .tooth.sel.mk .cap { fill: var(--red) !important; stroke: #991b1b !important; }
.lb-tooth-chart .out-head h4.mark { color: var(--red) !important; }
.lb-tooth-chart .out .result-group.t-none .result-chip { background: #d97706 !important; border-color: #b45309 !important; }

/* ファイル */
.drop { border: 1px dashed var(--logo-blue); border-radius: var(--radius); background: var(--surface-2); min-height: 72px; display: flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 0.75rem; text-align: center; padding: 10px; cursor: pointer; transition: background .15s, border-color .15s; }
.drop:hover, .drop.over { background: var(--brand-soft); border-color: var(--link); }
.drop-sub { text-align: right; font-size: 0.6875rem; margin: 6px 0 10px; }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 10px; }
.th { position: relative; height: 76px; background: var(--surface-ro); border-radius: var(--radius-sm); }   /* 角は中の写真・名前で丸める(「…」の一覧を枠の外へ出す) */
.th img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; border-radius: var(--radius-sm); }
.th-name { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(255, 255, 255, .88); font-size: 0.625rem; color: var(--text-2); padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
/* ファイル・フォルダの「…」(名前変更・削除) */
.fmenu summary.dots { width: 24px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--text-2); font-size: 0.9375rem; line-height: 1; }
.fmenu summary.dots:hover, .fmenu[open] summary.dots { background: var(--brand-soft); color: var(--link); }
.fmenu .more-body { min-width: 120px; }
.fmenu[open] { z-index: 21; }   /* 開いた一覧は 後に並ぶ写真・行より上 */
.card:has(.fmenu[open]) { position: relative; z-index: 21; }   /* カードごとに重なりが閉じている(背景のぼかし)= 開いた一覧のカードを次のカードより上へ */
.th .fmenu { position: absolute; top: 3px; right: 3px; }
.th .fmenu summary.dots { background: rgba(255, 255, 255, .92); }
.fl { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 0.75rem; }
.fl:last-of-type { border-bottom: none; }
.fl .ic { width: 40px; height: 22px; flex: none; background: var(--brand-soft); color: var(--link); border-radius: 4px; font-size: 0.625rem; letter-spacing: .05em; display: flex; align-items: center; justify-content: center; }
.fl .fn { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl a.fn { color: var(--text); text-decoration: none; }
.fl a.fn:hover { color: var(--link); text-decoration: underline; }
.fl .sz { color: var(--text-3); font-size: 0.6875rem; white-space: nowrap; }
.fl .tg, .fo .tg { max-width: 30%; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.6875rem; color: var(--text-3); }   /* 共有ファイルの公開先(管理員) */
.fl .tg.some, .fo .tg.some { color: var(--logo-blue); }

/* 共有ファイルの公開先: 今の選び(置く前)と 選ぶ窓 */
.tg-now { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.8125rem; margin-bottom: 10px; }
.tg-now b { font-weight: 500; color: var(--logo-blue); min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-pick { display: flex; flex-direction: column; gap: 10px; }
.tg-some { display: flex; flex-direction: column; gap: 8px; padding-left: 24px; }
.tg-some[hidden] { display: none; }
.tg-tools { display: flex; align-items: center; gap: 10px; }
.tg-tools .in { flex: 1; min-width: 0; }
.tg-count { font-size: 0.75rem; color: var(--text-2); white-space: nowrap; }
.tg-list { display: flex; flex-direction: column; gap: 6px; max-height: min(56vh, 560px); overflow-y: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.tg-list .chk { white-space: normal; font-size: 0.8125rem; }
.tg-list .chk[hidden] { display: none; }
.x { border: none; background: none; color: var(--text-3); padding: 0 4px; }
.x:hover { color: var(--red); }
.files-none { color: var(--text-3); font-size: 0.75rem; padding: 10px 0; }
/* ファイルの欄のフォルダ(1 版)= 閉じて並べ、押すと下に開く */
.fo { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 0.75rem; }
.fo-head { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: none; border: none; padding: 0; text-align: left; color: var(--text); font-size: inherit; cursor: pointer; }
.fo-head::before { content: ''; flex: none; width: 5px; height: 5px; margin: 0 3px; border-right: 1px solid var(--text-3); border-bottom: 1px solid var(--text-3); transform: rotate(-45deg); transition: transform .15s; }
.fo-head.open::before { transform: rotate(45deg); }
.fo-head:hover .fo-name { color: var(--link); }
.fo-ic { width: 18px; height: 18px; flex: none; fill: var(--brand-soft); stroke: var(--link); stroke-width: 1.5; stroke-linejoin: round; }
.fo-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fo-n { margin-left: auto; color: var(--text-3); font-size: 0.6875rem; white-space: nowrap; }
.fo-body { padding: 8px 0 4px 20px; border-bottom: 1px solid var(--line-soft); }
.notice-none { color: var(--text-3); font-size: 0.8125rem; }
.up { display: flex; align-items: center; gap: 8px; font-size: 0.6875rem; padding: 4px 0; }
.up-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-bar { width: 120px; height: 4px; background: var(--line-soft); border-radius: 2px; overflow: hidden; flex: none; }
.up-bar i { display: block; height: 100%; background: var(--link); }
.up.err { color: var(--red); }
.up-err { flex: none; max-width: 60%; }

/* チャット */
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 200px; max-height: 420px; overflow-y: auto; padding: 2px; }
/* 1 件 = 名前(相手の側・自分以外)+ 吹き出しと時刻の行。自分の側は右寄せで、吹き出しの左に 既読・時刻(LINE と同じ) */
.m-row { max-width: 85%; display: flex; flex-direction: column; align-items: flex-start; align-self: flex-start; }
.m-row.me { align-self: flex-end; align-items: flex-end; }
/* 相手の側 = 左に頭像・右に 名前と吹き出し(LINE と同じ) */
.m-row.them { flex-direction: row; gap: 8px; }
.m-col { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.m-name { font-size: 0.625rem; color: var(--text-3); margin: 0 4px 2px; }
.m-line { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.m-row.me .m-line { flex-direction: row-reverse; }
.m-meta { display: flex; flex-direction: column; flex: none; font-size: 0.625rem; line-height: 1.4; color: var(--text-3); white-space: nowrap; }
.m-row.me .m-meta { align-items: flex-end; }
.m-meta .rd:empty { display: none; }
.m { min-width: 0; padding: 8px 12px; font-size: 0.75rem; line-height: 1.6; border-radius: 12px; background: var(--surface-ro); border-bottom-left-radius: 4px; }
.m-row.me .m { background: var(--brand-soft); border-radius: 12px; border-bottom-right-radius: 4px; }
.m .m-head { font-weight: 500; margin-bottom: 2px; }
.m .mb { white-space: pre-wrap; word-break: break-word; }
.m-row .m.sys { background: var(--red-bg); color: var(--red); }
.m-row .m.okm { background: var(--green-bg); color: var(--green); }
.send { display: flex; gap: 8px; margin-top: 12px; }
.send .in { flex: 1; height: 36px; }

/* 弾窗 */
.modal-back { position: fixed; inset: 0; background: rgba(15, 25, 40, .32); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
/* 弾窗・チャットの拡大を開いている間は 後ろの画面を動かさない(スマホで指で送っても 後ろが動かない)。中で送り切っても 後ろへ伝えない */
html:has(#modal-root .modal-back), html:has(.chat-back:not([hidden])), .main:has(> .chat-back:not([hidden])) .case-view { overflow: hidden; }
#chat-card.zoomed .chat { overscroll-behavior: contain; }
.modal-back, .modal-body { overscroll-behavior: contain; }
.modal { background: linear-gradient(rgba(255, 255, 255, .55), rgba(255, 255, 255, .55)), url('/assets/crystal-bg.jpg') center / cover no-repeat var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(15, 25, 40, .18); padding: 24px 26px 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; max-height: 92dvh; }
.modal.large { max-width: min(760px, 96vw); }
.modal.full { max-width: min(1100px, 96vw); height: 92dvh; }
.modal-title { font-weight: 600; font-size: 1rem; word-break: break-all; display: flex; align-items: center; gap: 8px; }
.done-icon { width: 24px; height: 24px; flex: none; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.modal-msg { line-height: 1.8; white-space: pre-wrap; display: flex; flex-direction: column; gap: 8px; }
.modal-msg p { margin: 0; }
/* 同じ名前で差し替えた知らせ(case.js replacedBox): 差し替えた名前(ファイルの印・太字)→ 戻せる案内 */
.replaced ul { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.replaced li { display: flex; align-items: center; gap: 8px; font-weight: 700; overflow-wrap: anywhere; }
.replaced .file-icon { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--text-2); stroke-width: 1.7; stroke-linejoin: round; }
.replaced p { margin: 0; line-height: 1.8; }
.modal-label { font-size: 0.8125rem; margin-bottom: -8px; }
.modal-body { min-height: 0; overflow-y: auto; }
.share-status { white-space: pre-line; line-height: 1.8; overflow-wrap: anywhere; }   /* 保存・共有(ui.js shareFile): 名前と案内を 2 行で */
.modal-body:empty { display: none; }
.modal.full .modal-body { flex: 1; overflow: hidden; }
.modal-input { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); padding: 10px; }
.modal-input:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px var(--focus); }
textarea.modal-input { resize: vertical; min-height: 8em; max-height: 50vh; }   /* 理由の欄: 高さだけ変えられる(弾窗の外へ出さない・つぶさない) */
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal-err { color: var(--red); font-size: 0.8125rem; line-height: 1.6; }
.modal-err[hidden], .modal-actions .btn[hidden] { display: none; }
.viewer { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--surface-ro); border-radius: var(--radius-sm); }
.vw-stage { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; object-fit: contain; }
/* 前後へ(ui.js viewMedia): 左右の端の丸いボタン・下の真ん中に 何枚目か */
.vw-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: none; border-radius: 50%;
  background: rgba(20, 30, 45, .55); color: #fff; font-size: 1.75rem; line-height: 1; display: flex; align-items: center; justify-content: center; }
.vw-nav:hover { background: rgba(20, 30, 45, .75); }
.vw-nav.prev { left: 10px; }
.vw-nav.next { right: 10px; }
.vw-count { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); padding: 2px 10px; border-radius: 10px;
  background: rgba(20, 30, 45, .55); color: #fff; font-size: 0.75rem; }

/* 削除したファイル(case.js openTrash) */
.trash { display: flex; flex-direction: column; gap: 6px; }
/*   1 行目 = 名前(長くても折り返す)/ 2 行目 = 消した日時と人・「元に戻す」 */
.tr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 0.8125rem; }
.tr-name { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
.tr-when { flex: 1; min-width: 0; color: var(--text-3); font-size: 0.75rem; overflow-wrap: anywhere; }

/* 設計効果図・形態確認画像の確認(case.js reviewHtml)・一覧の札 */
.rv { padding: 8px 12px; margin-bottom: 10px; font-size: 0.75rem; border-radius: var(--radius-sm); line-height: 1.7; }
.rv p { margin: 0 0 8px; }
.rv-acts { display: flex; justify-content: flex-end; gap: 8px; }
.rv-ask, .rv-pending { background: var(--amber-bg); color: var(--amber); box-shadow: inset 3px 0 0 var(--amber); }
.rv-ok { background: var(--green-bg); color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.rv-fix { background: var(--red-bg); color: var(--red); box-shadow: inset 3px 0 0 var(--red); }
.b-rv-pending { background: var(--amber-bg); color: var(--amber); }
.b-rv-fix { background: var(--red-bg); color: var(--red); }

/* 発注表カードが狭い時(3 列並びの中幅画面など)は 欄を 1 列にする(日付・選択が潰れないように) */
#order-card { container-type: inline-size; }
@container (max-width: 600px) {
  .g { grid-template-columns: max-content minmax(0, 1fr); }
  .g .late { order: 1; }   /* 再製: 未装着 を 装着日の真下へ(case.js gridHtml) */
  .g4, .g4.with-same { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g4 .same-cell { grid-column: 2; }   /* 2 つずつの時も「色：前回同様」は 色の真下 */
}
/* ==== P2 ==================================================================== */
/* 上部メニュー(症例 / 共有ファイル / お知らせ / 管理) */
.top-nav { display: flex; gap: 4px; margin-left: 12px; }
.top-nav a { position: relative; padding: 6px 14px; border-radius: 999px; color: var(--text); text-decoration: none; font-size: 0.8125rem; }
.top-nav a:hover { background: rgba(255, 255, 255, .7); }
.top-nav a.on { background: var(--logo-blue); color: #fff; }
.nav-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 0.6875rem; line-height: 18px; text-align: center; }


/* 症例以外の画面は左の一覧を出さず、中央に置く */
.page-mode .side, .page-mode .side-resize { display: none; }
.side-hidden .side, .side-hidden .side-resize { display: none; }   /* 左の症例一覧を隠した(side-toggle.js) */
.side-toggle { width: 34px; height: 34px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(255, 255, 255, .7); color: var(--text-2); }
.side-toggle:hover, .side-toggle[aria-pressed="true"] { background: var(--brand-soft); color: var(--link); border-color: var(--logo-blue); }
.page-mode .side-toggle { visibility: hidden; }   /* 一覧の無い画面(共有ファイル・管理など)では出さない */
.route-view { display: contents; }   /* 画面ごとの入れ物(並びには関わらない) */
.page { width: 100%; max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: center; gap: 12px; }
.page-head h1 { font-size: 1.375rem; font-weight: 400; margin: 0; }
.page-head .btn { margin-left: auto; }

/* 管理のタブ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--logo-blue); }
.tabs a { padding: 8px 18px; border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0; color: var(--text); text-decoration: none; background: rgba(255, 255, 255, .6); }
.tabs a.on { background: #fff; border-color: var(--logo-blue); margin-bottom: -1px; }
.tab-tools { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-bottom: 12px; }

/* 表 */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
table.grid th { text-align: left; font-weight: 400; color: var(--text); background: #eef3fa; padding: 8px 10px; border-bottom: 1px solid #cfdcec; white-space: nowrap; }
table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tr.off td { color: #8a94a3; }
table.grid .sub { font-size: 0.6875rem; color: var(--text-3); }
table.grid .nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
/* アカウントの表の操作は 1 つの「操作」にまとめる(幅を 表示名・医院・メール に譲る) */
.user-actions { text-align: right; white-space: nowrap; }
.user-actions .more { display: inline-block; text-align: left; }
.user-actions summary::after { content: ' ▾'; }
/* アカウントの表は横に送らない(送る枠に入れると 下の行の「操作」の一覧が枠で切れる)= 長い名前・メールは折り返して表を画面に収める */
table.grid.users td { overflow-wrap: anywhere; }
.st { font-size: 0.6875rem; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.st-active { background: var(--green-bg); color: var(--green); }
.st-inactive { background: #eceff3; color: #5b6878; }
.st-locked { background: var(--red-bg); color: var(--red); }

/* 設定の開関 */
.settings { display: flex; flex-direction: column; gap: 14px; }
.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 0.875rem; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { width: 42px; height: 24px; border-radius: 12px; background: #c9d3df; position: relative; transition: background .15s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch-row input:checked + .switch { background: var(--logo-blue); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--focus); outline-offset: 2px; }
.mail-min { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.875rem; margin-bottom: 4px; }
.mail-min .in { width: 80px; text-align: right; }

/* 操作ログ */
.log-filter { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.log-filter label { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; }
.log-filter .in { width: 160px; }
.log-filter .log-q { flex: 1; min-width: 200px; width: auto; }
.log-more { text-align: center; margin-top: 12px; }
/* エクスポート */
/* エクスポート: 他の管理の頁と同じ幅。左 = 条件・右 = 出力内容とダウンロード(狭い時は縦に) */
.export-title { font-size: 1.125rem; font-weight: 500; margin: 0 0 6px; }
.export-lead { font-size: 0.8125rem; line-height: 1.7; margin: 0 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
#export-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px 28px; align-items: start; }
.export-cond, .export-side { display: flex; flex-direction: column; gap: 14px; }
.export-field { display: flex; flex-direction: column; gap: 6px; font-size: 0.8125rem; }
.export-dates { display: flex; gap: 14px; flex-wrap: wrap; }
.export-dates .export-field { flex: 1; min-width: 180px; }
.export-note { font-size: 0.75rem; line-height: 1.8; color: var(--text-2); margin: -4px 0 0; }
.export-contents { display: flex; flex-direction: column; gap: 8px; font-size: 0.8125rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; }
.export-contents-head { font-weight: 500; }
.export-item { display: flex; align-items: center; gap: 8px; }
.export-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.export-actions { display: flex; justify-content: flex-end; }
.export-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.export-actions svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* 弾窗の中の入力欄(発送・お知らせ・アカウント) */
.ship-form { display: flex; flex-direction: column; gap: 10px; }
.ship-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; }
.ship-form label[hidden] { display: none; }

/* 発送カード。見出し(便・本数・印)は 1 行、ボタンはその下の行(狭い欄でも見出しが縦に潰れない) */
.ship-block + .ship-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.ship-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 6px; font-size: 0.8125rem; }
.ship-head > span { white-space: nowrap; }
.ship-actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.ship-lock { font-size: 0.6875rem; padding: 1px 8px; border-radius: 999px; background: var(--green-bg); color: var(--green); }
.ship-tag { font-size: 0.6875rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-ro); color: var(--text); }
.ship-tag.full { background: var(--green-bg); color: var(--green); }
.ship-unlocked { font-size: 0.6875rem; padding: 1px 8px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); }
.ship-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 0.8125rem; }
.ship-dl dt { color: var(--text); }
.ship-dl dd { margin: 0; word-break: break-all; }
.ship-none { color: #8a94a3; font-size: 0.8125rem; }
.ship-wait { color: var(--amber); font-size: 0.8125rem; }
.ship-sum { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 0.8125rem; margin-bottom: 12px; }
.ship-qty { font-size: 0.75rem; color: var(--text); }
.ship-adds { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.legs { display: flex; flex-direction: column; gap: 10px; }
.leg + .leg { padding-top: 10px; border-top: 1px dashed var(--line-soft); }
.leg-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 0.75rem; color: var(--brand); margin-bottom: 4px; }
.leg-head > span { white-space: nowrap; }
.leg .ship-actions { margin: 6px 0 0; }

/* 患者氏名の後ろの敬称(日本語の「様」・表示だけ・保存しない) */
.with-suffix { display: flex; align-items: center; gap: 6px; }
.with-suffix span { flex: none; white-space: nowrap; }
.with-suffix .modal-input { flex: 1; width: auto; min-width: 0; }   /* 弾窗の名前の欄: 拡張子の分を空ける */
/* 発注表の患者氏名: 「様」は欄の中の右端(欄の幅は他の欄と揃える・長い名前でも「様」に重ならない) */
.g .with-suffix { position: relative; }
.g .with-suffix .in { padding-right: 2.4em; }
.g .with-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 0.875rem; color: var(--text-2); pointer-events: none; }   /* 字の大きさ = 欄(.in)と同じ */

/* 見出しの「その他の操作」(削除・キャンセル・再製の依頼) */
.more { position: relative; }
.more summary { list-style: none; cursor: pointer; }
.more summary::-webkit-details-marker { display: none; }
.more-body { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: flex; flex-direction: column; gap: 6px; padding: 10px; min-width: 180px; background: #fff; border: 1px solid var(--logo-blue); border-radius: 8px; box-shadow: var(--shadow); }
.more-body.up { top: auto; bottom: calc(100% + 4px); }   /* 下に収まらない時は上に開く(ui.js) */
.more-body.right { right: auto; left: 0; }   /* 左に収まらない時は右へ開く(ui.js) */
.more-body a.btn { text-decoration: none; }

/* お知らせ */
.notice { padding: 14px 22px; }
.notice.unread { box-shadow: inset 4px 0 0 var(--red), var(--shadow); }
.notice-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; }
.notice-arrow { color: var(--brand); transition: transform .15s; }
.notice.open .notice-arrow { transform: rotate(90deg); }
.notice-text { min-height: 220px; }
.notice-head h2 { font-size: 1rem; font-weight: 400; margin: 0; }
.notice-date { font-size: 0.75rem; color: var(--text-3); }
.notice-actions { margin-left: auto; display: flex; gap: 4px; }
.notice-body { margin-top: 10px; white-space: pre-wrap; line-height: 1.8; font-size: 0.875rem; }
.nb { font-size: 0.6875rem; padding: 1px 8px; border-radius: 999px; background: var(--red); color: #fff; }
/* お知らせのタグ(重要 赤・注目 橙・チェック 青・おすすめ 緑)と 管理員だけに出す 掲載予定/掲載終了 */
.ntag { display: inline-flex; align-items: center; gap: 4px; font-size: 0.6875rem; padding: 1px 9px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.ntag svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ntag-important { background: #fdecec; color: #b42318; border-color: #f3b4b4; }
.ntag-attention { background: #fff1e3; color: #a14e00; border-color: #f6c38f; }
.ntag-check { background: #e8f0fb; color: #1f4f8f; border-color: #a9c4ec; }
.ntag-recommend { background: #e9f6ee; color: #1b7f3b; border-color: #a7dcb9; }
.ntag-pick { cursor: pointer; font-size: 0.75rem; padding: 3px 11px; opacity: .45; }
.ntag-pick.on { opacity: 1; outline: 2px solid var(--link); outline-offset: 1px; }
.notice-tags-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.75rem; }
.notice-dates { display: flex; gap: 12px; flex-wrap: wrap; }
.notice-dates label { flex: 1; min-width: 160px; }
/* 日付の欄: iPhone は 日付を真ん中に寄せ・欄を中身より狭くできない(枠を押し広げる)= 標準の見た目を外して 他の欄と同じ幅に(押すと日付を選ぶ画面は出る) */
input.in[type="date"] { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; }
input.in[type="date"]::-webkit-date-and-time-value { text-align: left; }
.nstate { font-size: 0.6875rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-ro); color: var(--text-2); }
.welcome-notices { margin-top: 18px; width: min(560px, 100%); display: flex; flex-direction: column; gap: 6px; }
.welcome-notices:empty { display: none; }
.wn-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.75rem; color: var(--text); text-align: left; }
.wn-head a { color: var(--link); text-decoration: none; }
.wn-head a::after { content: ' ›'; }
.wn-head a:hover { text-decoration: underline; }
.wn-item { display: flex; flex-direction: column; gap: 5px; padding: 10px 14px; background: rgba(255, 255, 255, .92); border: 1px solid var(--logo-blue); border-radius: 8px; color: var(--text); text-decoration: none; text-align: left; }
.wn-item:hover { box-shadow: 0 2px 8px rgba(0, 104, 183, .15); }
.wn-date { font-size: 0.75rem; color: var(--text-3); white-space: nowrap; }
.wn-meta { display: flex; align-items: center; gap: 10px; }
/* 件名は 2 行まで(それより長ければ「…」・全文はお知らせの画面で) */
.wn-title { line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }

/* ログイン 2 段目(確認コード) */
.login-input.code { font-family: Arial, Helvetica, sans-serif; font-size: 1.375rem; letter-spacing: .5em; text-align: center; }
.login-note.left { text-align: left; margin: -6px 0 12px; }

/* ==== P3 ==================================================================== */

/* 管理: 医院・認定医(見るだけ) */
.master-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; font-size: 0.8125rem; }
.master-q { margin-left: auto; width: min(380px, 100%); }
.doc { display: inline-block; margin: 2px 6px 2px 0; padding: 2px 10px; border: 1px solid #cfdcec; border-radius: 999px; background: #fff; font-size: 0.75rem; white-space: nowrap; }
.doc small { margin-left: 2px; font-size: 0.6875rem; }
.doc-rt { border-color: var(--red); color: var(--red); }

/* ==== 頭像・自分の設定 ============================================================ */
/* 画像が無い時 = 名前の最初の 1 文字(色は持ち主ごと --av-hue) */
.av { width: 30px; height: 30px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; color: #fff; font-size: 0.8125rem; background: hsl(var(--av-hue, 210) 45% 52%); }
.av img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.av.sm { width: 22px; height: 22px; font-size: 0.6875rem; }
.av.lg { width: 76px; height: 76px; font-size: 1.75rem; }
.top-me .me { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
/* 歯車 = 丸いボタン(押せる範囲をはっきりさせ、ログアウトとは区切り線で離す) */
.top-me .gear { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
  color: var(--text-2); background: var(--brand-soft); }
.top-me .gear:hover { color: var(--link); background: #d6e6f6; }
.top-me .gear + .sep { margin: 0 6px; }
.top-home { display: inline-flex; }
.settings .card { display: flex; flex-direction: column; gap: 12px; }
.set-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 0.8125rem; }
.set-row > .lbl { width: 120px; flex: none; color: var(--text-2); }
.set-note { font-size: 0.6875rem; color: var(--text-3); }
.set-pw { display: grid; grid-template-columns: max-content minmax(0, 320px); gap: 10px 16px; align-items: center; font-size: 0.8125rem; }
.set-pw > form { display: contents; }   /* メールアドレス: 送る・確かめる の 2 つの form を 1 つの並び(欄の頭を揃える) */

/* ==== メッセージ(医院 ↔ La Briller)・既読 ===================================== */
/* メッセージの窓(/messages)いっぱい。管理員 = 左に医院の一覧・右に会話 / 医院 = 会話だけ。窓を狭くすると一覧は上へ */
.msg-wrap { display: flex; gap: 12px; height: 100vh; padding: 12px; }
.msg-threads { width: 300px; flex: none; display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.msg-thread-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.mt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: none; border-radius: var(--radius-sm); background: none; text-align: left; color: var(--text); }
.mt:hover { background: rgba(255, 255, 255, .7); }
.mt.on { background: var(--brand-soft); }
.mt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mt-top, .mt-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mt-name { flex: 1; min-width: 0; font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-time { font-size: 0.625rem; color: var(--text-3); white-space: nowrap; }
.mt-last { flex: 1; min-width: 0; font-size: 0.6875rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-last:empty { display: none; }
.mt-unread { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 0.6875rem; line-height: 18px; text-align: center; }
.msg-card { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.msg-card.over { border-style: dashed; background: var(--brand-soft); }
.msg-chat { flex: 1; max-height: none; min-height: 0; }
.msg-empty { margin: auto; color: var(--text-3); font-size: 0.75rem; }
.msg-send { align-items: flex-end; }
.msg-send textarea.in { min-height: 36px; max-height: 160px; overflow-y: auto; padding: 6px 10px; resize: none; }
.msg-attach { padding: 0 12px; font-size: 1rem; color: #4b5563; display: inline-flex; align-items: center; }
.msg-pending { display: flex; flex-wrap: wrap; gap: 6px; }
.msg-pending:empty { display: none; }
.msg-pend { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font-size: 0.75rem; padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
.msg-pend .up-name { max-width: 220px; }
.msg-pend-size { color: var(--text-3); white-space: nowrap; }
.msg-hint { margin-top: 6px; font-size: 0.6875rem; color: var(--text-3); display: flex; flex-direction: column; gap: 4px; }
.msg-hint p { margin: 0; }
.clip { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; flex: none; }
.mt-last .clip { margin-right: 3px; }
.mimg { display: block; padding: 0; border: none; background: none; cursor: zoom-in; }
.mimg img { display: block; height: 160px; max-width: 100%; object-fit: contain; border-radius: var(--radius-sm); background: #fff; }

/* チャットの拡大(case.js zoomChat): 画面の真ん中に大きく(上のメニューの下)。後ろは暗くして押せなくする */
.ct-btn { margin-left: auto; align-self: center; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(255, 255, 255, .7); color: var(--text-2); }
.ct-btn:hover, .ct-btn[aria-pressed="true"] { background: var(--brand-soft); color: var(--link); border-color: var(--logo-blue); }
.chat-back { position: fixed; inset: 0; z-index: 30; background: rgba(15, 25, 40, .32); }
#chat-card.zoomed { position: fixed; z-index: 31; top: 76px; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: min(max(62%, 640px), calc(100% - 32px)); display: flex; flex-direction: column; background: #fff; box-shadow: 0 18px 48px rgba(15, 25, 40, .28); }
#chat-card.zoomed .chat { flex: 1; min-height: 0; max-height: none; }
/* 拡大している間は 中身の枠(.main = 拡大したチャットの親)を「幅で並びを変える枠(container)」にしない
   (container は 中身を閉じ込める扱い = 画面に固定した物の基準になることがある・Safari) */
.main:has(> #chat-card.zoomed) { container-type: normal; }
#chat-card.zoomed .mimg img { height: 320px; }
.mvid { display: block; height: 200px; max-width: 100%; border-radius: var(--radius-sm); background: #000; }
#chat-card.zoomed .mvid { height: 360px; }
.mfile, .mfile-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.75rem; }
.mfile-meta { margin-top: 4px; }
.mfile .ic { width: 40px; height: 22px; flex: none; background: #fff; color: var(--link); border-radius: 4px; font-size: 0.625rem; display: flex; align-items: center; justify-content: center; }
.mfile .fn, .mfile-meta .fn { min-width: 0; word-break: break-all; }
.mfile .sz, .mfile-meta .sz { color: var(--text-3); font-size: 0.6875rem; white-space: nowrap; }
.mfile .dl, .mfile-meta .dl { font-size: 0.6875rem; white-space: nowrap; }
/* 送る前の写真: 小さな見本と「✎ 編集」 */
.cp-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; flex: none; }
.cp-edit { font-size: 0.75rem; white-space: nowrap; }

/* ==== 写真の書き込み(image-edit.js) ============================================== */
.ie { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }
/* 写真の書き込み: 道具は 図だけの釦(名前は title)・色・戻す/やり直す/すべて消す を 区切り線で分ける */
.ie-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; align-self: flex-start; }
.ie-tool { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: none; background: none; border-radius: 8px; color: var(--text); }
.ie-tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ie-tool:hover { background: var(--brand-soft); }
.ie-tool.on { background: var(--brand-soft); color: var(--logo-blue); }
.ie-tool:disabled { color: #c3cbd5; background: none; cursor: default; }
.ie-sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.ie-color { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #94a3b8; padding: 0; }
.ie-color.on { box-shadow: 0 0 0 2px #111827; }
.ie-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--surface-ro); border-radius: var(--radius-sm); overflow: hidden; }
.ie-canvas { max-width: 100%; max-height: 100%; cursor: crosshair; touch-action: none; transform-origin: 0 0; }   /* 2 本の指で拡大(image-edit.js)*/
.ie-text { position: absolute; z-index: 2; min-width: 180px; padding: 2px 6px; border: 1px dashed currentColor; border-radius: 4px; background: rgba(255, 255, 255, .85); font-weight: 700; }

/* 症例の画面 = 画面の高さの枠(.case-view)の中を 上の段(名前・状態・操作・帯)ごと上下に動かす。
   上の段が見えている間は 発注表・右の欄を動かしても 枠ごと動く(上の段が上へ出ていく)。
   上の段が出切ったら(stuck・case.js)発注表 と 右の欄(ファイル・発送・チャット)は 枠の上で止まり、それぞれ 中で上下に動く
   (片方が長くても もう片方は動かない)。一番上で上へ動かすと 枠ごと戻って 上の段が出てくる。
   62px = .main の上下の余白。右の欄の左に 左の一覧と同じ青い線(右の欄の中身の幅 = 400px・線をつかんで左へ広げられる) */
.case-view { height: calc(100vh - 60px - 62px); overflow: hidden auto; }   /* 上下だけ動かす(左右には動かさない) */
.case-top { display: flex; flex-direction: column; gap: 16px; padding-bottom: 16px; }
#ng-bar:empty { display: none; }
/* 右の欄の幅(--stack-col)= つかんで変えた幅(--stack-w・stack-resize.js)。狭くても今までの幅・広くても発注表が 520px 残るまで */
.case-view .cols { --stack-col: max(419px, min(var(--stack-w, 419px), calc(100% - 520px)));
  position: sticky; top: 0; height: 100%; grid-template-columns: minmax(0, 1fr) var(--stack-col); grid-template-rows: minmax(0, 1fr); column-gap: 12px; }
/* 左の一覧を隠した = 空いた幅を 中 2・右 1 で分ける(つかんで広げていれば その幅)。狭い画面では 中(発注表)だけ広げる(右が発注表より広くならない) */
@container (min-width: 1150px) {
  .side-hidden .case-view .cols { --stack-col: max(calc(419px + var(--side-w, 300px) / 3), min(var(--stack-w, 0px), calc(100% - 520px))); }
}
/* 発注表 と 右の欄 の間の青い線(右の欄の左の線)をつかむ所 */
.stack-resize { position: absolute; top: 0; bottom: 0; right: calc(var(--stack-col) - 4px); width: 8px; cursor: col-resize; z-index: 3; }
.stack-resize:hover, .stack-resizing .stack-resize { background: linear-gradient(90deg, transparent 3px, var(--logo-blue) 3px, var(--logo-blue) 5px, transparent 5px); }
.stack-resizing { cursor: col-resize; user-select: none; }
.case-view #order-card { max-height: 100%; overflow-y: auto; }
.case-view .stack { height: 100%; overflow-y: auto; padding: 0 6px 6px 12px; border-left: 1px solid var(--logo-blue); }   /* 右・下の余白 = カードの影を切らない(枠の外へは出さない) */
.case-view:not(.stuck) #order-card, .case-view:not(.stuck) .stack { overflow-y: hidden; }   /* 上の段が出切るまでは 枠ごと動かす */
/* 上下に動かす枠(左の一覧・症例の枠・発注表・右の欄)は つまみ(スクロールバー)を出さない = ホイール・指で動かす */
.case-list, .case-view, .case-view #order-card, .case-view .stack { scrollbar-width: none; }
.case-list::-webkit-scrollbar, .case-view::-webkit-scrollbar, .case-view #order-card::-webkit-scrollbar, .case-view .stack::-webkit-scrollbar { display: none; }
/* 症例の 2 段(発注表 | ファイル・発送・チャット)は 中身の幅で 1 段にする(窓の幅だけでなく 左の一覧を広げた時も)。
   1 段の時は 画面ごと上下に動かす(青い線も無し)。761〜900px(タブレットの横で一覧を出した時など)は 右の欄を細くして 2 段のまま */
@container (min-width: 761px) and (max-width: 900px) {
  .case-view .cols { --stack-col: 360px; }
  .stack-resize { display: none; }
}
@container (max-width: 760px) {
  .cols, .case-view .cols { grid-template-columns: minmax(0, 1fr); }
  .stack-resize { display: none; }
  .case-view { height: auto; overflow: visible; }
  .case-view .cols { position: static; height: auto; grid-template-rows: none; }
  .case-view #order-card, .case-view .stack,
  .case-view:not(.stuck) #order-card, .case-view:not(.stuck) .stack { height: auto; max-height: none; overflow: visible; }
  .case-view .stack { margin-right: 0; padding: 0; border-left: none; }
}
@media (max-width: 760px) {
  .login-page { background-attachment: scroll; }   /* iOS Safari は fixed を拡大表示してしまう */
  .g { grid-template-columns: max-content minmax(0, 1fr); }
  .g .late { order: 1; }   /* 再製: 未装着 を 装着日の真下へ(case.js gridHtml) */
  .g4, .g4.with-same { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g4 .same-cell { grid-column: 2; }   /* 2 つずつの時も「色：前回同様」は 色の真下 */
}

/* パスワード欄の目のボタン(ログイン・自分の設定) */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-right: 40px; }
.login-page .pw-wrap { margin-bottom: 18px; }
.pw-wrap > .login-input { margin-bottom: 0; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: none; border: none; color: #4b5563; cursor: pointer; padding: 0; }
.pw-eye:hover { color: var(--link); }
.pw-eye svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* スマホ・タブレットの縦・狭い窓(幅 900px 以下)とスマホの横(タッチで 高さ 500px 以下)= アプリのように 下にタブ・右上は頭像だけ(押すと 名前・個人設定・ログアウト)。
   それより広い = 上部メニュー(今まで通り)。下のタブは メニューが 2 つ以上の人だけ(body.has-tabs・app.js) */
.tab-bar { display: none; }
.me-slot { display: contents; }   /* 右上の自分(top-me.js)の入れ物 = 中身が header の並びに入る */
.me-toggle { display: none; }
.gear-text { display: none; }
@media (max-width: 900px), (pointer: coarse) and (max-height: 500px) {
  .top { padding: 0 16px; gap: 10px; }
  .top-sub, .top-nav { display: none; }
  .me-toggle { display: inline-flex; margin-left: auto; padding: 0; border: none; background: none; border-radius: 50%; }
  .me-toggle .av { width: 36px; height: 36px; font-size: 0.9375rem; }
  .top-me { display: none; position: absolute; top: calc(var(--top-h) - 4px); right: 12px; z-index: 20; flex-direction: column; align-items: stretch; gap: 2px;
    min-width: 220px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 25, 40, .15); font-size: 0.875rem; }
  .top-me.open { display: flex; }
  .top-me .sep { display: none; }
  .top-me .me { padding: 8px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .top-me .gear, .top-me > .link { width: auto; height: auto; min-height: 44px; border-radius: 8px; justify-content: flex-start; gap: 10px; padding: 0 10px;
    background: none; color: var(--text); text-align: left; display: flex; align-items: center; font-size: inherit; text-decoration: none; }
  .top-me .gear:hover, .top-me > .link:hover { background: var(--brand-soft); }
  .top-me > .link { color: var(--link); }
  .gear-text { display: inline; }
  /* アプリの枠: 画面の高さ = 上部 + 中身(ここだけ動く)+ 下のタブ。下のタブは 画面に固定せず 並びの最後に置く
     = iPhone(ホーム画面から開いた時)で 画面を回した後も 古い画面の高さの所にタブが残らない */
  html, .app-page { height: 100%; }
  .app-page { display: flex; flex-direction: column; overflow: hidden; }
  .app-page > .top { flex: none; }
  .app-page > .wrap, .chat-window > main { flex: 1; min-height: 0; }
  .app-page > .wrap { overflow-y: auto; overscroll-behavior-y: contain; container-type: size; }   /* size = チャットのタブの高さを 中身の高さ(cqh)から決める */
  .has-tabs .tab-bar { display: flex; flex: none; z-index: 30; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(15, 25, 40, .06); }
  .tab-bar a { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-2); text-decoration: none; font-size: 0.6875rem; }
  .tab-bar a span:not(.nav-badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-bar a.on { color: var(--logo-blue); font-weight: 600; }
  .tab-bar .nav-badge { top: 6px; right: calc(50% - 24px); }
}

/* 症例: スマホ・タブレットの縦・狭い窓(幅 900px 以下)= 一覧 と 症例 を 1 画面ずつ(body.case-open = 症例を開いている)。
   症例の中は 4 つのタブ(発注・ファイル・発送・チャット)で 1 つずつ(.case-view の data-pane・case.js)。
   チャットのタブは 画面の残りいっぱい(上の段は出さない・入力欄は下) */
.back-link, .pane-tabs { display: none; }
@media (max-width: 900px), (pointer: coarse) and (max-height: 500px) {
  .wrap { flex-direction: column; min-height: 0; }
  .side, .side-hidden:not(.page-mode) .side { display: flex; width: auto; position: static; height: auto; max-height: none; border-right: none; box-shadow: none; padding: 16px; }
  .side-resize, .side-toggle { display: none; }
  .case-open .side, .case-open.side-hidden .side { display: none; }
  .app-page:not(.page-mode):not(.case-open) .main { display: none; }
  .main { padding: 8px 16px 24px; }
  .case-view { height: auto; overflow: visible; }
  .case-view .cols { display: block; position: static; height: auto; }
  .case-view #order-card, .case-view .stack,
  .case-view:not(.stuck) #order-card, .case-view:not(.stuck) .stack { height: auto; max-height: none; overflow: visible; }
  .case-view .stack { padding: 0; border-left: none; gap: 12px; }
  .back-link { display: inline-flex; align-items: center; min-height: 40px; color: var(--link); text-decoration: none; font-size: 0.9375rem; }
  .pane-tabs { display: flex; margin: 0 0 12px; border: 1px solid var(--logo-blue); border-radius: 10px; overflow: hidden; background: rgba(255, 255, 255, .85); }
  .pane-tabs button { flex: 1; min-width: 0; min-height: 42px; border: none; background: none; color: var(--logo-blue); font-size: 0.9375rem; padding: 0 2px; white-space: nowrap; }   /* 未読の印は 字の横(折り返さない) */
  .pane-tabs button[aria-selected="true"] { background: var(--logo-blue); color: #fff; }
  .pane-tabs button[hidden] { display: none; }
  .pane-tabs .nav-badge:not([hidden]) { position: static; display: inline-block; margin-left: 2px; vertical-align: 1px; min-width: 16px; height: 16px; padding: 0 3px; line-height: 16px; }
  .case-view:not([data-pane="order"]) [data-pane="order"],
  .case-view:not([data-pane="files"]) [data-pane="files"],
  .case-view:not([data-pane="ship"]) [data-pane="ship"],
  .case-view:not([data-pane="chat"]) [data-pane="chat"] { display: none; }
  .case-view[data-pane="chat"] .case-top { display: none; }
  /* 100cqh = 中身(.wrap)の高さ・40px = 「‹ 一覧」・54px = タブ・34px = 上下の余白と枠の線 */
  .case-view[data-pane="chat"] #chat-card { display: flex; flex-direction: column; height: calc(100cqh - 40px - 54px - 34px); min-height: 320px; }
  .case-view[data-pane="chat"] .chat { flex: 1; min-height: 0; max-height: none; }
  #chat-card [data-act="chat-zoom"] { display: none; }   /* 画面いっぱいなので 拡大は要らない */
}

/* マウスの画面とタッチの画面で言い方を変える説明(ui.js deviceHtml)。タッチではフォルダを選べない */
.for-touch { display: none; }
@media (pointer: coarse) {
  .for-touch { display: inline; }
  .for-mouse { display: none; }
  .drop-sub { display: none; }
  .drop ~ .set-note { margin-top: 10px; }
}

/* 管理の表(table.grid.cards): スマホの縦(幅 600px 以下)は 1 行 = 1 枚のカード。値の左に列の名前(td の data-label)・
   空の値は出さない・頭像(.card-mark)はカードの右上・「操作」は右下。上のタブは 1 行のまま左右に送る */
@media (max-width: 600px) {
  /* 横にだけ送る(選んだタブを下へ 1px はみ出させる作りだと 縦にも動いてしまう = 下の線は影で引き、はみ出させない) */
  .tabs { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none; border-bottom: none; box-shadow: inset 0 -1px 0 var(--logo-blue); }
  .tabs a:not(.on) { box-shadow: inset 0 -1px 0 var(--logo-blue); }   /* タブの背景が下の線を隠すので 選んでいないタブは自分で線を引く */
  .tabs a.on { margin-bottom: 0; }
  .tabs a { flex: none; white-space: nowrap; padding: 10px 16px; }
  table.grid.cards, table.grid.cards tbody { display: block; }
  table.grid.cards thead { display: none; }
  table.grid.cards tr { display: block; position: relative; padding: 10px 12px; margin-bottom: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
  table.grid.cards td { display: block; position: relative; padding: 3px 0; border: none; white-space: normal; overflow-wrap: anywhere; }
  table.grid.cards td[data-label] { padding-left: 86px; }
  table.grid.cards td[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 4px; width: 76px; color: var(--text-3); font-size: 0.75rem; }
  table.grid.cards td[data-label]:empty { display: none; }
  table.grid.cards td.card-mark { position: absolute; top: 10px; right: 12px; padding: 0; }
  table.grid.cards td.user-actions { text-align: right; padding-top: 6px; }
  table.grid.cards td.files-none { text-align: center; }
  /* お知らせ: 1 行目 = 日付・タグ / 2 行目 = 件名 / 3 行目 = 編集・削除(右)= タグの長さで並びが変わらない */
  .notice-head h2 { flex-basis: 100%; }
  .notice-actions { flex-basis: 100%; justify-content: flex-end; }
  .notice-dates label { flex-basis: 100%; }   /* 掲載日・掲載終了日 は上下に */
  .table-wrap:has(table.grid.cards) { overflow-x: visible; }
}

/* メッセージの画面: スマホ・タブレットの縦・狭い窓(幅 900px 以下)= 医院の一覧 と 会話 を 1 画面ずつ
   (body.thread-open = 会話を開いている・医院は会話 1 つなので いつも会話)。高さ = アプリの枠の中身(上部・下のタブの残り)。
   同じ画面で開いた時(body.in-app)= 門戸の画面と同じ上部。パソコンの別の窓(in-app 無し)は上部を出さない */
.msg-top { display: none; }
.chat-window.in-app .msg-top { display: flex; }   /* 同じ画面で開いた(スマホ・タブレット)= 門戸の画面と同じ上部 */
.chat-window.in-app .msg-wrap { height: calc(100dvh - var(--top-h)); }
@media (max-width: 900px), (pointer: coarse) and (max-height: 500px) {
  .msg-wrap, .chat-window.in-app .msg-wrap { flex-direction: column; height: 100%; padding: 8px; }
  .msg-threads { width: auto; flex: 1; min-height: 0; }
  .thread-open .msg-threads { display: none; }
  .chat-window:not(.thread-open) .msg-card { display: none; }
}

/* スマホ・タブレットで 文字を打っている間(どの入力欄でも カーソルがある間)= 下のタブ・その下の余白を出さない。
   送る欄は 欄の下の説明も出さない(送る欄が キーボードのすぐ上に来る・会話が多く見える)。キーボードを閉じると元に戻る */
@media (max-width: 900px) and (pointer: coarse), (pointer: coarse) and (max-height: 500px) {
  .has-tabs:has(:is(input:not([type="checkbox"], [type="radio"], [type="file"]), textarea, select):focus) .tab-bar { display: none; }
}
@media (pointer: coarse) {
  .cp-form:has(.cp-input:focus) ~ .msg-hint { display: none; }
}
@media (pointer: coarse) and (max-height: 500px) {
  :root { --top-h: 44px; --tab-h: 44px; }
  .top-logo { height: 26px; }
  .me-toggle .av { width: 32px; height: 32px; }
  .tab-bar a { flex-direction: row; gap: 6px; }
  .tab-bar .nav-badge { position: static; }
  .case-view[data-pane="chat"] #chat-card { min-height: 200px; }
  /* 会話を少しでも多く見せる: 送る欄の下の説明・チャットの見出し(上のタブに「チャット」とある)は出さない */
  .msg-hint, .case-view[data-pane="chat"] #chat-card > .ct { display: none; }
  .modal-back { padding: 8px; }
  .modal { padding: 14px 18px 12px; gap: 10px; }
}

/* タッチの画面(スマホ・タブレット): 押せる物の高さを 40px 以上にする(指で押し間違えない)。パソコン(マウス)は今まで通り */
@media (pointer: coarse) {
  .btn, .btn.sm, summary.btn, .in, input.search, .filters button, .grp-head, .lang-btn, .lang-menu button,
  .lb-tooth-chart .types button, .lb-tooth-chart .btn-clear { min-height: 40px; }
  .btn.sm, summary.btn.sm { padding-top: 0; padding-bottom: 0; display: inline-flex; align-items: center; }
  .filters button { height: auto; }
  .me-toggle, .top-home, .pw-eye, .icon-btn { min-width: 40px; min-height: 40px; justify-content: center; align-items: center; }
  .icon-btn { display: inline-flex; }
  .pw-eye { width: 40px; height: 40px; }
  .mfile .dl, .mfile-meta .dl, table.grid.cards td a { display: inline-flex; align-items: center; min-height: 40px; }
  .msg-send textarea.in { min-height: 40px; }
  /* iPhone は 16px 未満の入力欄を押すと 画面を拡大してしまう(戻らない)= タッチの画面の入力欄は 16px 以上 */
  .in, .login-input, .search, .clinic-filter, .modal-input { font-size: 1rem; }
  .mfile a.fn { display: inline-block; min-height: 40px; padding-top: 10px; }   /* 押せる名前だけ(写真・動画の下の名前は押せない = 高さを足さない) */
  /* ファイルの欄・お知らせ・管理のタブ(スマホの並びでも タブレットの横のパソコンの並びでも使う物) */
  .clinic-filter, .fo-head, .notice-head, .tabs a { min-height: 40px; }
  .ct-link, .fl a.fn, .wn-head a { display: inline-flex; align-items: center; min-height: 40px; }
  .fmenu summary.dots, .ct-btn { width: 40px; height: 40px; }
  .up-x { min-width: 40px; min-height: 40px; }
}
/* タッチの画面で パソコンの並び(タブレットの横・大きいタブレット)= 上部メニュー・右上の自分・左の一覧を隠すボタン も 40px 以上 */
@media (pointer: coarse) and (min-width: 901px) and (min-height: 501px) {
  .top-nav a, .top-me > .link { display: inline-flex; align-items: center; min-height: 40px; }
  .top-me .gear, .side-toggle { width: 40px; height: 40px; }
}
