/* デザイン: 色はすべてトークン(下の変数)で持ち、ライト(最初)とダーク・プロ(濃い紺)の 2 つを用意する。差し色はどちらもすみれ色。
   ・:root = ライト、[data-theme="dark"] = ダーク、[data-theme="auto"] = 端末の設定(prefers-color-scheme)に合わせる
     (data-theme は js/theme.js と index.html の head のスクリプトが <html> に付ける)
   ・ダークの値は [data-theme="dark"] と、@media の [data-theme="auto"] の 2 か所にある。変える時は両方を同じにする
   ・ノート・PDF・Word のページ、表のセル、スライドは、どちらの明るさでも紙と同じく作ったままの色(手書きや Excel の色をそのまま見せるため) */
:root {
  /* ライト: 少し青みのある白の机に、白い面と細い線。文字は濃い紺(本文 4.5:1 以上) */
  --bg: #f3f4f8;
  --panel: #ffffff;
  --raised: #ffffff;
  --raised-2: #eef0f5;
  --line: #e3e6ee;
  --line-strong: #cdd2de;
  --fg: #1b1e2b;
  --muted: #5c6378;
  --accent: #6151e6;
  --accent-hover: #5242d6;
  --accent-fg: #ffffff;
  --accent-soft: rgba(97, 81, 230, .10);
  --accent-text: #4c3cc9;
  --hover: rgba(24, 28, 48, .05);
  --danger: #c93131;
  --danger-fg: #ffffff;
  --desk: #e7e9ef;
  --paper: #ffffff;
  --k-note: #6d5ce8;
  --k-pdf: #cc3b3b;
  --k-sheet: #1b7d47;
  --k-doc: #2b6fd0;
  --k-slides: #a9560c;
  --badge-fg: #ffffff;
  --folder: #a3abc0;
  --folder-open: #8790a8;
  /* 角の丸み・影の決まり(ボタン・入力欄 = sm/md、メニュー・枠 = lg、ダイアログ = xl) */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 14px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .08);
  --shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 4px 16px rgba(17, 24, 39, .08);
  --shadow-lg: 0 2px 6px rgba(17, 24, 39, .06), 0 24px 56px rgba(17, 24, 39, .16);
  --scrim: rgba(15, 18, 30, .32);
  --toast-bg: #1f2232;
  --toast-fg: #f4f5f9;
  --toast-line: transparent;
  --selection: rgba(97, 81, 230, .22);
  --scroll: #c6cbd8;
  --scroll-hover: #a5adc0;
  --auth-glow: rgba(97, 81, 230, .12);
  --warn-fg: #7a4d00;
  --warn-bg: #fff6db;
  --warn-line: #efd48c;
  --cell-head: #f5f6f9;
  --tab-on: #ffffff; /* 2 つから選ぶ切り替え(ログインのタブ)の選んだ側 */
  --f-ui: "Inter", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --f-logo: "Inter", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
  color-scheme: light;
}
/* ダーク・プロ(濃い紺 + すみれ色)。下の @media の中と同じ値にする */
:root[data-theme="dark"] {
  --bg: #0f1117;
  --panel: #151821;
  --raised: #1c2030;
  --raised-2: #232838;
  --line: #262b3b;
  --line-strong: #353c52;
  --fg: #e6e9f2;
  --muted: #8b93a7;
  --accent: #7c6cff;
  --accent-hover: #8f82ff;
  --accent-fg: #ffffff;
  --accent-soft: rgba(124, 108, 255, .16);
  --accent-text: #b4abff;
  --hover: rgba(255, 255, 255, .05);
  --danger: #ff6b6b;
  --danger-fg: #1a0c0c;
  --desk: #0b0d12;
  --k-note: #9d8cff;
  --k-pdf: #ff7a7a;
  --k-sheet: #4fd18b;
  --k-doc: #5aa9ff;
  --k-slides: #ffad5a;
  --badge-fg: #0f1117;
  --folder: #6b7391;
  --folder-open: #8a92b2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .45);
  --scrim: rgba(5, 7, 12, .55);
  --toast-bg: #232838;
  --toast-fg: #e6e9f2;
  --toast-line: #353c52;
  --selection: rgba(124, 108, 255, .45);
  --scroll: #343a4f;
  --scroll-hover: #454d68;
  --auth-glow: rgba(124, 108, 255, .18);
  --warn-fg: #ffcf70;
  --warn-bg: rgba(255, 196, 0, .08);
  --warn-line: rgba(255, 196, 0, .25);
  --cell-head: #171a24;
  --tab-on: #232838;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  /* 端末に合わせる: 端末がダークの時は、上の [data-theme="dark"] と同じ値 */
  :root[data-theme="auto"] {
    --bg: #0f1117;
    --panel: #151821;
    --raised: #1c2030;
    --raised-2: #232838;
    --line: #262b3b;
    --line-strong: #353c52;
    --fg: #e6e9f2;
    --muted: #8b93a7;
    --accent: #7c6cff;
    --accent-hover: #8f82ff;
    --accent-fg: #ffffff;
    --accent-soft: rgba(124, 108, 255, .16);
    --accent-text: #b4abff;
    --hover: rgba(255, 255, 255, .05);
    --danger: #ff6b6b;
    --danger-fg: #1a0c0c;
    --desk: #0b0d12;
    --k-note: #9d8cff;
    --k-pdf: #ff7a7a;
    --k-sheet: #4fd18b;
    --k-doc: #5aa9ff;
    --k-slides: #ffad5a;
    --badge-fg: #0f1117;
    --folder: #6b7391;
    --folder-open: #8a92b2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .45);
    --scrim: rgba(5, 7, 12, .55);
    --toast-bg: #232838;
    --toast-fg: #e6e9f2;
    --toast-line: #353c52;
    --selection: rgba(124, 108, 255, .45);
    --scroll: #343a4f;
    --scroll-hover: #454d68;
    --auth-glow: rgba(124, 108, 255, .18);
    --warn-fg: #ffcf70;
    --warn-bg: rgba(255, 196, 0, .08);
    --warn-line: rgba(255, 196, 0, .25);
    --cell-head: #171a24;
    --tab-on: #232838;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--f-ui); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { display: grid; grid-template-columns: 276px minmax(0, 1fr); height: 100%; }

/* ---------- sidebar ---------- */
#side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding-block: 16px; }
/* 切り欠き・ホームのバー(safe area)の分をあける(ふつうの画面は 0) */
#side { padding-left: env(safe-area-inset-left, 0px); padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 16px 14px; }
.logo { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--fg); color: var(--panel); display: grid; place-items: center; font: 700 19px/1 var(--f-logo); }
.brand-name { font: 700 18px/1 var(--f-logo); letter-spacing: .02em; }
.side-actions { display: grid; gap: 8px; padding: 0 16px 16px; }
.side-label { padding: 0 16px 6px; font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.side-actions { grid-template-columns: minmax(0, 1fr); }
/* アカウント(ログイン・同期の状態) */
.account { padding: 0 16px 12px; }
.account[hidden] { display: none; }
.acct-login { width: 100%; font-size: 13px; }
.acct-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.acct-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--k-sheet); flex: none; }
.acct-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.acct-status { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.acct-status.bad { color: var(--danger); }
.login-err { color: var(--danger); min-height: 1.2em; }
.side-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.side-pair .btn { padding-inline: 6px; overflow: hidden; text-overflow: ellipsis; }
.side-search { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--raised); }
.side-search:focus { outline: 2px solid var(--accent); outline-offset: 0; }
#tree { overflow-y: auto; flex: 1; min-height: 0; padding: 0 8px 24px; border-radius: var(--r-md); }
/* 一覧の何も無い所にドロップすると最上位へ移動する(js/library.js の wireTree) */
#tree.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.lib-row { display: flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 8px; border-radius: var(--r-md); cursor: pointer; user-select: none; -webkit-user-select: none; }
.lib-row:hover { background: var(--accent-soft); }
.lib-row.current { box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-soft); }
.lib-row.drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.lib-row.folder { font-weight: 500; }
.lib-name { flex: 1; min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; line-height: 1.35; }
.lib-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.caret { border: 0; background: none; width: 18px; padding: 0; color: var(--muted); font-size: 11px; flex: none; }
/* フォルダの形(絵文字を使わず CSS で描く) */
.fold-icon { flex: none; width: 16px; height: 12px; border-radius: 2px 3px 3px 3px; background: #e0b85a; position: relative; margin-top: 2px; }
.fold-icon::before { content: ''; position: absolute; left: 0; top: -3px; width: 7px; height: 4px; border-radius: 2px 2px 0 0; background: #e0b85a; }
.fold-icon.open { background: #f0c96a; }
.hit { align-items: flex-start; }
.hit-snip { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 2px; word-break: break-all; }
.hit mark, .hit-snip mark { background: #ffe14d; color: #1b1b1f; border-radius: 2px; padding: 0 1px; }
.side-empty { margin: 8px; font-size: 12px; color: var(--muted); }
/* クラウドのファイルを受け取っている間(js/sync.js の loading) */
.side-loading { display: flex; align-items: center; gap: 8px; }
.spin { display: inline-block; flex: none; width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
.welcome h2 .spin { width: 22px; height: 22px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }
.side-foot { padding: 8px 16px 0; border-top: 1px solid var(--line); }
.side-settings { width: 100%; }
.side-settings { margin-top: 8px; }
.btn.ghost { border-color: transparent; background: none; padding-inline: 4px; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-fg); font-weight: 700; }
.danger-text { color: var(--danger); }
.doc-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--r-md); cursor: pointer; }
.doc-item:hover { background: var(--accent-soft); }
.doc-item.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
/* 印の幅はどの種類でも同じにそろえる(ノート・PDF・XLSX・DOCX・PPTX) */
.badge { flex: none; box-sizing: border-box; width: 46px; text-align: center; white-space: nowrap; font-size: 10px; font-weight: 700; padding: 2px 0; border-radius: 4px; color: var(--panel); background: var(--k-note); letter-spacing: .04em; }
.badge.pdf { background: var(--k-pdf); }
.badge.sheet { background: var(--k-sheet); }
.badge.doc { background: var(--k-doc); }
.badge.slides { background: var(--k-slides); }
.doc-meta { min-width: 0; flex: 1; }
/* 長い名前は 2 行まで折り返し、3 行目からは …(全部は「⋯」のメニューのいちばん上と、マウスを重ねた時に出る) */
.doc-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; font-weight: 500; line-height: 1.35; }
.doc-date { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.doc-del { flex: none; border: 0; background: none; color: var(--muted); border-radius: var(--r-sm); padding: 2px 6px; font-size: 12px; opacity: 0; }
.doc-item:hover .doc-del, .lib-row:hover .doc-del, .doc-del.confirm, .doc-del:focus-visible { opacity: 1; }
@media (hover: none) { .doc-del { opacity: .7; } }
/* はじめての使い方(js/tutorial.js)。電話の幅でもパソコンでも、真ん中に 1 枚のカード */
.tut { position: fixed; inset: 0; z-index: 115; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 17, 23, .45); }
.tut-card { width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow: auto; box-sizing: border-box; background: var(--panel); color: var(--fg); border-radius: var(--r-lg); box-shadow: 0 18px 48px rgba(0, 0, 0, .25); padding: 24px 22px 18px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.tut-art { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 4px; }
.tut-art .tut-ico { width: 48px; height: 48px; }
.tut-step { margin: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tut-title { margin: 0; font-size: 19px; }
.tut-text { margin: 0; font-size: 14px; line-height: 1.7; color: var(--fg); min-height: 4.8em; overflow-wrap: anywhere; }
.tut-dots { display: flex; gap: 6px; margin: 6px 0 4px; }
.tut-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.tut-dot.on { background: var(--accent); width: 18px; border-radius: 4px; }
.tut-actions { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.tut-go { display: flex; gap: 8px; }
.tut-actions .btn { min-height: 40px; }
/* ダイアログ(フォルダ選択・名前変更・確認) */
.modal-box.wide { width: min(640px, 100%); }
.modal-msg { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.modal-input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); font-size: 15px; }
.pick-body { display: flex; flex-direction: column; gap: 10px; }
.pick-files { margin: 0; padding: 8px 12px 8px 28px; background: var(--bg); border-radius: var(--r-md); font-size: 13px; max-height: 120px; overflow: auto; }
.pick-tree { border: 1px solid var(--line); border-radius: var(--r-lg); max-height: 280px; overflow-y: auto; padding: 4px; background: var(--bg); }
.pick-row { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: var(--r-sm); }
.pick-row:hover { background: var(--accent-soft); }
.pick-row.on { background: var(--accent); color: var(--accent-fg); font-weight: 700; }
.trash-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.trash-item { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-lg); }
.doc-del.confirm { background: var(--danger); color: var(--danger-fg); }
.side-hint { margin: 8px 16px 0; font-size: 11px; color: var(--muted); }
#scrim { display: none; }

/* ---------- top & toolbars ---------- */
/* 並べ方は grid-template-areas で決める。#main は 上の段・知らせ・タブ・#work(タブの位置 上・下・左・右 は下の「タブ」で変える)。
   #work は ツールバー・検索の欄・編集する場所(ツールバーの位置 上・下・左・右 は下の「ツールバーの位置」で変える) */
/* net: つながっていない時の知らせ(#net-banner)。いつも上の段のすぐ下に置き、出た時は下を押し下げる(ツールバーを覆わない) */
#main { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "net" "tabs" "work"; min-width: 0; min-height: 0; }
#split { grid-area: work; display: flex; min-width: 0; min-height: 0; }
#work { flex: 1 1 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); grid-template-areas: "tb" "find" "view"; min-width: 0; min-height: 0; }
#top { grid-area: top; } #net-banner { grid-area: net; } #tabs { grid-area: tabs; } #toolbar { grid-area: tb; } #findbar { grid-area: find; } #view { grid-area: view; }
#net-banner { display: flex; align-items: center; gap: 8px; padding: 7px 16px; font-size: 13px; line-height: 1.5; font-weight: 500;
  color: var(--warn-fg); background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); overflow-wrap: anywhere; }
#net-banner::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  border: 1.6px solid currentColor; font-size: 12px; font-weight: 700; line-height: 1; }
#net-banner[hidden] { display: none; }
#top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
#title { border: 1px solid transparent; background: none; border-radius: var(--r-sm); padding: 4px 8px; font-size: 16px; font-weight: 700; min-width: 72px; flex: 0 6 360px; /* 縮める時は、名前の欄から先に縮める(拡大縮小・ページの道具を隠さないように) */ text-overflow: ellipsis; }
#title:hover, #title:focus { border-color: var(--line); background: var(--raised); outline: none; }
#status { display: inline-flex; align-items: center; flex: none; min-width: 18px; font-size: 12px; color: var(--muted); white-space: nowrap; }
/* 保存の印(js/core.js の updateOnline): 保存済みは ✓、保存中は点。文字は保存できない時など */
#status .ico { width: 16px; height: 16px; }
#status.st-ok { color: var(--k-sheet); opacity: .75; }
#status.st-busy .st-dot { width: 7px; height: 7px; margin: 0 5px; border-radius: 50%; background: var(--muted); animation: st-pulse 1s ease-in-out infinite; }
@keyframes st-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { #status.st-busy .st-dot { animation: none; } }
#status.st-bad { color: var(--danger); font-weight: 600; white-space: normal; max-width: 220px; line-height: 1.3; }
#status.st-text { white-space: normal; max-width: 220px; line-height: 1.3; font-size: 11px; }
.vh { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* 上の段の絵だけのボタン(js/core.js の decorateChrome) */
#top .btn.icon-only { display: inline-flex; align-items: center; justify-content: center; gap: 2px; min-width: 38px; min-height: 36px; padding: 4px 8px; flex: none; }
#top .btn.icon-only .ico { width: 20px; height: 20px; }
#top .btn .ico-caret { width: 14px; height: 14px; margin-left: -2px; }
#top #btn-more { display: inline-flex; } /* 「⋯」はいつも出す(全画面。狭い時は検索・ストップウォッチ・並べるも) */
.side-actions .btn.ico-btn, .side-foot .btn.ico-both { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.side-actions .btn .ico, .side-foot .btn .ico { width: 18px; height: 18px; flex: none; }
.spacer { flex: 1; }
/* サイドバーを隠す・出すボタン(いつも出す) */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; border: 0; background: none; font-size: 20px; line-height: 1; padding: 4px; border-radius: var(--r-sm); color: var(--fg); }
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn .ico { width: 22px; height: 22px; }
/* ツールバーを隠した時(html の tb-hidden。js/core.js の toggleToolbar): ボタンは薄く、ツールバーは出さない */
.tb-hidden #toolbar { display: none !important; }
#btn-toolbar.off { color: var(--muted); }
#btn-toolbar.off .ico { opacity: .55; }
/* 広い画面でサイドバーを隠した時(index.html の先頭と js/core.js が html に side-hidden を付ける): 編集する場所を画面の幅いっぱいにする
   (電話を横にした時など、高さの低い画面(html の short)で幅 1100px 以下は、下の「phone / narrow」と同じく重ねて出すので除く。js/core.js の narrow) */
@media (min-width: 1101px) {
  .side-hidden #app { grid-template-columns: minmax(0, 1fr); }
  .side-hidden #side, .side-hidden #scrim { display: none; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  html.side-hidden:not(.short) #app { grid-template-columns: minmax(0, 1fr); }
  html.side-hidden:not(.short) #side, html.side-hidden:not(.short) #scrim { display: none; }
}
.btn { border: 1px solid var(--line); background: var(--raised); border-radius: var(--r-md); padding: 6px 12px; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 700; }
.btn:disabled { opacity: .45; cursor: default; }

#toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 6px 16px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 48px; }
#toolbar:empty { display: none; }
.tgroup { display: flex; align-items: center; gap: 4px; }
.seg { display: flex; background: var(--bg); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: var(--r-sm); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--raised); box-shadow: var(--shadow); font-weight: 700; color: var(--accent-text); }
.tbtn { border: 1px solid transparent; background: none; padding: 5px 9px; border-radius: var(--r-sm); white-space: nowrap; }
.tbtn:hover { border-color: var(--line); background: var(--raised); }
.tbtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
input[type="color"].swatch { -webkit-appearance: none; appearance: none; overflow: hidden; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
input[type="color"].swatch::-webkit-color-swatch-wrapper { padding: 0; opacity: 0; }
.tlabel { font-size: 12px; color: var(--muted); }
input[type="range"] { width: 90px; accent-color: var(--accent); }
.num { font-variant-numeric: tabular-nums; min-width: 44px; text-align: center; font-size: 12px; }

/* ---------- workspace ---------- */
#view { position: relative; overflow: auto; background: var(--desk); min-height: 0; }
.welcome { max-width: 560px; margin: 12vh auto; padding: 0 16px; text-align: center; color: var(--muted); }
.welcome h2 { font: 700 26px/1.3 var(--f-logo); color: var(--fg); text-wrap: balance; }
.dropping #view { outline: 3px dashed var(--accent); outline-offset: -12px; }

/* ---------- note pages ---------- */
.pages { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 24px 16px 40px; width: max-content; min-width: 100%; }
.page { position: relative; background: var(--paper); box-shadow: var(--shadow); touch-action: none; flex: none; user-select: none; -webkit-user-select: none; }
/* 指のスクロール・拡大縮小は、ペンの種類にかかわらず ink.js の TouchGesture が行う(ペンのみの時もページは touch-action: none) */
/* ノートは紙の外(ページの間・まわり)の指も TouchGesture が動かす(ブラウザの 2 本指の拡大で画面全体が大きくならないように) */
#view.v-note { touch-action: none; }
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* 2 つを並べて表示(js/ref-pane.js)。#split の中で、#ref(並べた側)と #work(いつもの画面)を横に並べる。--ref-frac は並べた側の割合 */
#ref { position: relative; flex: 0 0 calc(var(--ref-frac, .45) * 100%); min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--desk); border-right: 1px solid var(--line-strong, var(--line)); }
#split.ref-right #ref { order: 2; border-right: 0; border-left: 1px solid var(--line-strong, var(--line)); }
.ref-head { display: flex; align-items: center; gap: 4px; padding: 4px 8px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ref-head .tbtn { min-height: 32px; flex: none; }
.ref-head .spacer { flex: 1; }
.ref-title { min-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.ref-body { flex: 1; min-height: 0; overflow: auto; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 14px; touch-action: pan-x pan-y; overscroll-behavior: contain; }
.ref-page { position: relative; flex: none; background: #fff; box-shadow: var(--shadow); }
.ref-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ref-no { position: absolute; right: 0; bottom: -16px; font-size: 11px; color: var(--muted); }
.ref-msg { padding: 16px; color: var(--muted); font-size: 13px; }
.ref-grip { position: absolute; top: 0; bottom: 0; right: -5px; width: 10px; cursor: col-resize; z-index: 6; touch-action: none; }
.ref-grip::after { content: ''; position: absolute; top: 50%; left: 3px; width: 4px; height: 40px; margin-top: -20px; border-radius: 2px; background: var(--line-strong, var(--line)); }
.ref-grip:hover::after, .ref-grip:focus-visible::after { background: var(--accent); }
#split.ref-right .ref-grip { right: auto; left: -5px; }
.ref-pick { max-height: min(50dvh, 420px); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.ref-pick-item { display: flex; align-items: center; gap: 8px; padding: 8px; border: 0; border-radius: var(--r-md); background: none; text-align: left; cursor: pointer; }
.ref-pick-item:hover, .ref-pick-item:focus-visible { background: var(--accent-soft); }
.ref-pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-pick-sub { font-size: 11px; color: var(--muted); }
/* 狭い画面: 上下に並べる(上が並べた側) */
@container (max-width: 760px) {
  #split.on { flex-direction: column; }
  #split.on #ref { border-right: 0; border-left: 0; border-bottom: 1px solid var(--line-strong, var(--line)); }
  #split.on.ref-right #ref { border-bottom: 0; border-top: 1px solid var(--line-strong, var(--line)); }
  #split.on .ref-grip { top: auto; bottom: -5px; left: 0; right: 0; width: auto; height: 10px; cursor: row-resize; }
  #split.on.ref-right .ref-grip { bottom: auto; top: -5px; }
  #split.on .ref-grip::after { top: 3px; left: 50%; width: 40px; height: 4px; margin: 0 0 0 -20px; }
}
/* 版の履歴(js/versions.js) */
.ver-body { display: flex; flex-direction: column; gap: 10px; }
.ver-list { max-height: min(60dvh, 520px); overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.ver-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-lg); }
.ver-meta { flex: 1; min-width: 0; }
.ver-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.ver-sub, .ver-empty { font-size: 12px; color: var(--muted); }
@media (max-width: 520px) { .ver-row { flex-wrap: wrap; } .ver-meta { flex-basis: 100%; } }
/* テンプレートを選ぶ画面(js/template-picker.js) */
.tpl-body { max-height: min(70dvh, 640px); overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.tpl-group { margin: 6px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.tpl-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.tpl-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 1px solid transparent; border-radius: var(--r-lg); background: none; cursor: pointer; }
.tpl-item:hover, .tpl-item:focus-visible { background: var(--accent-soft); }
.tpl-item.cur { border-color: var(--accent); }
.tpl-thumb { border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--shadow); background: #fff; }
.tpl-name { font-size: 12px; max-width: 96px; text-align: center; }
/* しおりのあるページ(js/bookmarks.js): 右上のリボン */
.page.marked::after { content: ''; position: absolute; top: -3px; right: 18px; width: 14px; height: 24px; background: #e5484d; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%); pointer-events: none; z-index: 4; }
.menu { max-height: calc(100vh - 16px); overflow-y: auto; }
.page canvas.ink, .page canvas.live { mix-blend-mode: multiply; }
.page-no { position: absolute; bottom: -20px; right: 0; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.textlayer { position: absolute; inset: 0; pointer-events: none; }
.mode-text .page { cursor: text; }
.mode-eraser .page { cursor: cell; }
.tbox { position: absolute; pointer-events: none; color: #1b1b1f; }
.mode-text .tbox { pointer-events: auto; }
.tedit { padding: 2px 4px; outline: none; white-space: pre-wrap; word-break: break-word; line-height: 1.4; font-family: var(--f-ui); min-height: 1.4em; user-select: text; -webkit-user-select: text; }
.mode-text .tbox .tedit { outline: 1px dashed rgba(106, 90, 249, .35); }
.mode-text .tbox .tedit:focus { outline: 1.5px solid #6a5af9; }
.tgrip { position: absolute; left: -22px; top: 0; width: 20px; height: 20px; border-radius: var(--r-sm); display: none; place-items: center; background: #6a5af9; color: #fff; font-size: 11px; cursor: move; touch-action: none; }
.mode-text .tbox:hover .tgrip, .mode-text .tbox:focus-within .tgrip { display: grid; }
/* 文字ボックスの縦書き・横書きの切り替え(移動の持ち手の下)。縦書きは列が右から左へ増える */
.tdir { position: absolute; left: -22px; top: 24px; width: 20px; height: 20px; border: 0; border-radius: var(--r-sm); padding: 0; display: none; place-items: center; background: #fff; color: #6a5af9; box-shadow: inset 0 0 0 1.5px #6a5af9; font-size: 11px; font-weight: 700; cursor: pointer; }
.mode-text .tbox:hover .tdir, .mode-text .tbox:focus-within .tdir { display: grid; }
/* 書いていない箱は、ドラッグで動かせる(押して離すと書ける) */
.mode-text .tbox .tedit:not(:focus) { cursor: move; }
/* 文字ボックスを回す持ち手(上の○。画像の .nimg-rot と同じ形) */
.trot { display: none; position: absolute; left: 50%; top: -30px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: #fff; border: 2px solid #6a5af9; cursor: grab; touch-action: none; }
.trot::after { content: ''; position: absolute; left: 50%; top: 16px; width: 2px; height: 12px; margin-left: -1px; background: #6a5af9; }
.mode-text .tbox:hover .trot, .mode-text .tbox:focus-within .trot { display: block; }
.tedit.vert { writing-mode: vertical-rl; min-height: 0; min-width: 1.4em; }
/* 紙の大きさの画面 */
.mm-in { width: 6em; }
.note-warn { color: var(--danger); }
/* 「設定」の画面(長いので画面の高さに収めてスクロール。375px の幅でも 1 列に並ぶ) */
.modal-box.set-box { max-height: calc(100dvh - 32px); overflow: auto; }
.set-sec { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.set-sec legend { padding: 0 6px; font-size: 13px; font-weight: 600; }
/* 設定のメニュー(2026-10-24): 項目の一覧(1 行ずつ・右に ＞)と、項目の画面(「＜ 戻る」と見出し) */
.set-menu { display: flex; flex-direction: column; gap: 10px; }
.set-menu-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.set-menu-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 10px 14px; border: 0; border-top: 1px solid var(--line); background: var(--raised); color: inherit; font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.set-menu-row:first-child { border-top: 0; }
.set-menu-row:hover { background: var(--accent-soft); }
.set-menu-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.set-menu-title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.set-menu-arrow { flex: none; color: var(--muted); }
.set-page { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.set-page-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-page-head .set-back { flex: none; }
.set-page-title { margin: 0; font-size: 15px; font-weight: 600; flex: 1 1 auto; min-width: 0; }
.set-page-body { border: 0; padding: 0; }
.set-drive-low { color: var(--danger); font-weight: 600; }
.set-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.set-label { flex: 1 1 10em; min-width: 0; color: var(--muted); }
.set-row select { max-width: 100%; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--raised); }
.set-row input[type="range"] { width: 140px; }
/* ペン・マーカーの色: 道具バーと同じ見本と「ほかの色」 */
.set-swatches { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.set-other { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.set-chip { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong); flex: none; }
.set-chip.any { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.set-mm { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.set-check { cursor: pointer; flex-wrap: nowrap; align-items: flex-start; }
.set-check > span { flex: 1 1 auto; min-width: 0; }
.set-check input { width: 18px; height: 18px; accent-color: var(--accent); }
/* 「ツールバーに出す道具」: チェックを幅に合わせて並べる(狭い画面では 1 列) */
.set-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5em), 1fr)); gap: 4px 12px; }
.set-tools-title { grid-column: 1 / -1; font-size: 12px; font-weight: 600; color: var(--muted); }
.set-tools .set-check { align-items: center; min-height: 32px; }
.set-tools .set-check:has(input:disabled) { cursor: not-allowed; opacity: .7; }
/* 設定の「アカウントと同期」(ログイン中だけ) */
.set-email { flex: 1 1 12em; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.set-sync-status { flex: 1 1 12em; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.set-sync-status.bad { color: var(--danger); font-weight: 600; }
.set-move-msg.bad { color: var(--danger); font-weight: 600; }
.set-usage-val { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.set-acct-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.set-acct-btns .btn { flex: 1 1 8em; }
.btn.set-logout { color: var(--danger); border-color: var(--danger); }
/* ログアウトは同期のボタンから離し、線で区切って右寄せで置く */
.set-logout-row { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); justify-content: flex-end; }
.set-logout-row .btn { flex: 0 0 auto; }
/* 1ページずつの表示: 今のページだけ見せる */
.one-page .pages > .page:not(.cur) { display: none; }
.one-page .page-actions { display: none; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
/* ページの下の「＋ ページを追加」の並びで、ページの並び(.pages)を広げない(紙より広い時は折り返す。iPad の並べて表示・電話を横にした時に横へはみ出さない) */
#view:not(.flow-h) .page-actions { contain: inline-size; width: 100%; }

/* ---------- popups ---------- */
.menu { position: fixed; z-index: 50; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 6px; min-width: 200px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: var(--r-sm); }
.menu button:hover:not(:disabled) { background: var(--accent-soft); }
.menu button:disabled { color: var(--muted); cursor: default; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .sub { display: block; font-size: 11px; color: var(--muted); }
/* メニューの見出し(ファイル・フォルダの名前を全部出す) */
.menu .menu-head { max-width: min(320px, calc(100vw - 32px)); padding: 6px 10px 8px; font-size: 13px; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; white-space: normal; user-select: text; -webkit-user-select: text; }
#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 120; background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: var(--r-lg); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
/* 音声入力(js/voice.js): 聞いている間のボタンと、下の帯(知らせ #toast より上に出す) */
#btn-voice.voice-on { color: #fff; background: #d93a3a; border-color: #d93a3a; }
#voice-bar { position: fixed; left: 50%; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 119; display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px); padding: 8px 8px 8px 14px; border-radius: var(--r-lg); background: var(--raised); color: var(--fg); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); font-size: 13px; }
#voice-bar[hidden] { display: none; }
#voice-bar .vb-level { flex: none; display: flex; align-items: center; gap: 3px; height: 18px; }
#voice-bar .vb-level i { display: block; width: 3px; height: 18px; border-radius: 2px; background: #d93a3a; transform: scaleY(.18); transition: transform .1s linear; }
#voice-bar.vb-wait .vb-level i { background: var(--muted); }
#voice-bar .vb-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#voice-bar .vb-stop { flex: none; border: 0; border-radius: var(--r-sm); padding: 5px 10px; background: var(--accent-soft); color: var(--accent-text); font: inherit; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { #voice-bar .vb-level i { transition: none; } }
#toast.err { background: var(--danger); color: var(--danger-fg); border-color: var(--danger); }

/* ---------- phone / narrow ---------- */
/* 幅の狭い画面(760px 以下)と、電話を横にした時(html の short・幅 1100px 以下)は、サイドバーを上に重ねて出す(js/core.js の narrow と同じ条件) */
@media (max-width: 760px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #side { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 264px; transform: translateX(-100%); transition: transform .2s; padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
  .side-open #side { transform: none; }
  .side-open #scrim { display: block; position: fixed; inset: 0; z-index: 39; background: var(--scrim); }
  #top { padding-inline: 12px; }
  #toolbar { padding-inline: 12px; }
}
@media (max-width: 1100px) {
  html.short #app { grid-template-columns: minmax(0, 1fr); }
  html.short #side { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 264px; transform: translateX(-100%); transition: transform .2s; padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
  html.short .side-open #side { transform: none; }
  html.short .side-open #scrim { display: block; position: fixed; inset: 0; z-index: 39; background: var(--scrim); }
  html.short #top { padding-inline: 12px; }
  html.short #toolbar { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.resizing #side { transition: none !important; } /* 画面を回した・大きさが変わった直後(js/core.js の bindSidebar) */

/* ---------- 検索 ---------- */
.hit-loc { display: flex; gap: 8px; align-items: baseline; width: 100%; text-align: left; border: 0; background: none; color: inherit; font: inherit; padding: 4px 8px 4px 44px; border-radius: var(--r-sm); cursor: pointer; }
.hit-loc:hover { background: var(--accent-soft); }
.hit-loc .hit-snip { margin: 0; min-width: 0; }
.hit-loc-label { flex: none; font-size: 11px; font-weight: 700; color: var(--accent-text); white-space: nowrap; }
.hit-loc.more { font-size: 11px; color: var(--muted); }
.findbar { flex: none; border-bottom: 1px solid var(--line); background: var(--panel); position: relative; z-index: 5; }
.find-row { display: flex; align-items: center; gap: 4px; padding: 6px 12px; }
.find-input { flex: 0 1 280px; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--raised, #fff); color: inherit; font: inherit; }
.find-input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.find-count { min-width: 64px; font-size: 12px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.find-list { display: none; max-height: 40vh; overflow: auto; border-top: 1px solid var(--line); padding: 4px 8px 8px; }
.find-list.open { display: block; }
.find-item { display: flex; gap: 10px; align-items: baseline; width: 100%; border: 0; background: none; color: inherit; font: inherit; text-align: left; padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer; }
.find-item:hover { background: var(--accent-soft); }
.find-item.cur { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.find-loc { flex: none; font-size: 12px; font-weight: 700; color: var(--accent-text); min-width: 90px; }
.find-snip { font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.find-box { position: absolute; background: rgba(255, 213, 0, .38); border-radius: 2px; pointer-events: none; z-index: 2; mix-blend-mode: multiply; }
.find-box.cur { background: rgba(255, 140, 0, .55); box-shadow: 0 0 0 2px rgba(255, 140, 0, .9); }
::highlight(find-all) { background-color: rgba(255, 213, 0, .45); color: inherit; }
::highlight(find-cur) { background-color: rgba(255, 140, 0, .75); color: #000; }
.find-flash { animation: findFlash 1.4s ease-out 2; }
@keyframes findFlash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 4px rgba(255, 140, 0, .8); } }
@media (max-width: 640px) { .find-row { flex-wrap: wrap; } .find-input { flex: 1 1 100%; } }

/* ---------- 部品の見た目(ライト・ダーク共通。色はトークン) ---------- */
.logo { background: none; border-radius: var(--r-md); }
.logo svg { width: 100%; height: 100%; display: block; }
.brand-name { font: 600 17px/1 var(--f-logo); letter-spacing: -.01em; }
#side { background: var(--panel); }
.side-search { background: var(--bg); border-color: var(--line); }
.side-search:focus, .find-input:focus, .modal-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lib-row:hover, .doc-item:hover, .menu button:hover:not(:disabled), .pick-row:hover, .hit-loc:hover, .find-item:hover { background: var(--hover); }
.lib-row.current { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.doc-item.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.doc-item.active .doc-name { color: var(--fg); }
.fold-icon, .fold-icon::before { background: var(--folder); }
.fold-icon.open { background: var(--folder-open); }
.badge { color: var(--badge-fg); font-weight: 600; border-radius: var(--r-sm); }
.btn { background: var(--raised); border-color: var(--line); border-radius: var(--r-md); font-weight: 500; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, box-shadow .12s; }
.btn.ghost, .btn:disabled, #top .btn.icon-only { box-shadow: none; }
#top .btn.icon-only { border-color: transparent; background: none; color: var(--fg); }
#top .btn.icon-only:hover:not(:disabled) { background: var(--hover); border-color: transparent; }
#top .btn.icon-only[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
#btn-stopwatch.sw-running { color: var(--accent-text); background: var(--accent-soft); }
.menu { border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.btn:hover:not(:disabled) { background: var(--raised-2); border-color: var(--line-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
#top, #toolbar, .findbar { background: var(--panel); border-color: var(--line); }
#title { font-weight: 600; letter-spacing: -.01em; }
.tbtn { border-radius: var(--r-sm); transition: background .12s; }
.tbtn:hover { background: var(--hover); border-color: transparent; }
.tbtn[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; }
.seg { background: var(--bg); border: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); box-shadow: none; font-weight: 600; }
.swatch { border-color: var(--panel); box-shadow: 0 0 0 1px var(--line-strong); }
.welcome h2 { font: 600 28px/1.3 var(--f-logo); letter-spacing: -.02em; }
.menu { background: var(--raised); border-color: var(--line-strong); }
#toast { background: var(--toast-bg); color: var(--toast-fg); border: 1px solid var(--toast-line); box-shadow: var(--shadow); }
.pick-row.on { background: var(--accent); color: var(--accent-fg); }
.hit mark, .hit-snip mark, .find-snip mark { background: rgba(255, 213, 0, .85); color: #111; }
::selection { background: var(--selection); }
.page-no { color: var(--muted); }
/* スクロールバー(細く目立たないもの) */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: var(--r-lg); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

/* ---------- ログイン画面 ---------- */
.auth { position: fixed; inset: 0; z-index: 80; overflow-y: auto; background: radial-gradient(1200px 600px at 50% -10%, var(--auth-glow), transparent 60%), var(--bg); }
.auth-open #app { visibility: hidden; }
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 16px 32px; }
.auth-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 28px 28px 20px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; }
.auth-head { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 4px; }
.auth-head .logo { width: 36px; height: 36px; font-size: 18px; }
.auth-head .brand-name { font-size: 22px; }
.auth-err { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--danger); }
.auth-err:empty { min-height: 0; }
.auth-note { margin: 0; font-size: 13px; line-height: 1.7; color: var(--muted); }
.auth-note.warn { color: var(--warn-fg); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--r-md); padding: 8px 10px; }
.auth-link { border: 0; background: none; color: var(--accent-text); padding: 2px 0; font-size: 13px; }
.auth-link:hover { text-decoration: underline; }
.auth-link.guest { color: var(--muted); margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.auth-social { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
/* 「Google でログイン」: Google の Sign in with Google のきまり(明るい形)に合わせる。
   白の地・#747775 の 1px の枠・#1F1F1F の文字・Roboto Medium(無ければ端末の字)14px・G のロゴ 20px は変えない・左右 12px・ロゴと文字の間 10px。
   高さは指で押しやすい 44px(きまりは大きさを変えてよい)。画面の明るさがダークの時も、この明るい形のまま */
.gbtn-own { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 12px; border-radius: 4px; border: 1px solid #747775; background: #fff; color: #1f1f1f; font-family: Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 500; font-size: 14px; line-height: 20px; letter-spacing: .25px; cursor: pointer; }
.gbtn-own:hover { background: #f1f3f4; }
.gbtn-own:disabled { opacity: .6; cursor: default; }
.gbtn-own .gmark { display: flex; }
@media (max-width: 440px) { .auth-card { padding: 22px 18px 16px; border-radius: var(--r-xl); } }

/* ---------- ノートの画像 ---------- */
.imglayer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.nimg { position: absolute; }
.nimg img { display: block; width: 100%; height: 100%; object-fit: fill; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; pointer-events: none; }
.mode-image .imglayer { pointer-events: auto; }
.mode-image .page canvas.ink, .mode-image .page canvas.live { pointer-events: none; } /* 手書きの下の画像をつかめるように */
.mode-image .nimg { cursor: move; touch-action: none; }
.mode-image .nimg:hover { outline: 1px dashed rgba(106, 90, 249, .7); }
.nimg.sel { outline: 2px solid #6a5af9; }
.nimg-rs { display: none; position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border-radius: 4px; background: #fff; border: 2px solid #6a5af9; cursor: nwse-resize; touch-action: none; }
.mode-image .nimg.sel .nimg-rs { display: block; }
.mode-image .imglayer { overflow: visible; }
/* 画像の回転の持ち手(上の○) */
.nimg-rot { display: none; position: absolute; left: 50%; top: -30px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: #fff; border: 2px solid #6a5af9; cursor: grab; touch-action: none; }
.nimg-rot::after { content: ''; position: absolute; left: 50%; top: 16px; width: 2px; height: 12px; margin-left: -1px; background: #6a5af9; }
.mode-image .nimg.sel .nimg-rot { display: block; }

/* ---------- 手書きの選択(投げなわ・選択・ペンのみの時の指) ---------- */
.mode-select .page { cursor: default; }
/* 手のひら(動かす)・Space を押している間: ページを動かすだけ。文字ボックス・画像・選んだ範囲の層にも触れない */
.hand-tool .page, .hand-tool .ink { cursor: grab; }
.hand-tool .page:active, .hand-tool .ink:active { cursor: grabbing; }
.hand-tool .tbox, .hand-tool .nimg, .hand-tool .ink-grab, .hand-tool .tgrip, .hand-tool .trot { pointer-events: none !important; }
/* 選んだ範囲に重ねる見えない層。ペンのみの時もここだけは指でスクロールせず、選んだ物を動かせる */
.ink-grab { position: absolute; touch-action: none; cursor: move; background: transparent; }
.ink-grab[hidden] { display: none; }
.ink-grab-rotate { border-radius: 50%; cursor: grab; }
.ink-grab-scale { cursor: nwse-resize; }
.ink-grab-side-l, .ink-grab-side-r { cursor: ew-resize; }
.ink-grab-side-t, .ink-grab-side-b { cursor: ns-resize; }
/* 色の見本: 長押しで色を選び直す(iPad の長押しメニュー・文字選択・拡大鏡を出さない) */
.ink-style .swatch { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.swatch.pressing { transform: scale(1.18); transition: transform .5s; }

/* ---------- 色選び(NotePlay の色選び。js/color-picker.js) ---------- */
.cp-pop { position: fixed; z-index: 110; width: 272px; max-width: calc(100vw - 32px); box-sizing: border-box; padding: 12px; display: flex; flex-direction: column; gap: 10px;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow); color: var(--fg);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.cp-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.cp-preset { aspect-ratio: 1; min-height: 28px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); padding: 0; cursor: pointer; }
.cp-preset[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--accent); }
.cp-preset:focus-visible, .cp-sv:focus-visible, .cp-hue:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cp-sv { position: relative; height: 132px; border-radius: var(--r-md); touch-action: none; cursor: crosshair; }
.cp-sv-thumb { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5), 0 1px 4px rgba(0, 0, 0, .5); pointer-events: none; }
input[type="range"].cp-hue { width: 100%; height: 22px; margin: 0; -webkit-appearance: none; appearance: none; border-radius: var(--r-lg); touch-action: none;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.cp-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: transparent; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); }
.cp-hue::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: transparent; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); }
.cp-row { display: flex; align-items: center; gap: 8px; }
.cp-chip { flex: none; width: 32px; height: 32px; border-radius: var(--r-md); border: 1px solid var(--line-strong); }
.cp-hex { flex: 1; min-width: 0; font: 14px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 7px 9px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--fg); -webkit-user-select: text; user-select: text; }
.cp-hex.bad { border-color: var(--danger); }
.cp-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- ツールバーのアイコン(js/icons.js が #toolbar のボタンを絵にする) ----------
   絵は currentColor(文字の色)で描くので、ライト・ダーク・押している状態の色はボタンの文字の色に従う */
.ico { width: 20px; height: 20px; flex: none; display: block; }
.ico-caret { width: 12px; height: 12px; margin-left: -3px; opacity: .7; }
.ico-text { font-size: 13px; white-space: nowrap; }
#toolbar .ico-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1; }
#toolbar .ico-btn:not(.ico-both) { padding-inline: 7px; }
/* iPad でも指で押しやすい大きさ(36px 以上) */
#toolbar .tbtn, #toolbar .seg button, #toolbar .btn { min-width: 36px; min-height: 36px; }
#toolbar select { min-height: 36px; }
#toolbar .seg button { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- ツールバーの位置(「設定」の「ツールバーの位置」。#main の data-toolbar。js/icons.js の ToolbarPos) ---------- */
/* 下: 編集する場所の下に置く */
#main[data-toolbar="bottom"] #work { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "find" "view" "tb"; }
#main[data-toolbar="bottom"] #toolbar { border-bottom: 0; border-top: 1px solid var(--line); padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
/* 左・右: 編集する場所の横に、縦の列として置く(長い時は列の中でスクロール) */
@media (min-width: 431px) {
  #main[data-toolbar="left"] #work { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "tb find" "tb view"; }
  #main[data-toolbar="right"] #work { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "find tb" "view tb"; }
  #main[data-toolbar="left"] #toolbar, #main[data-toolbar="right"] #toolbar {
    width: 160px; min-height: 0; overflow-y: auto; overflow-x: hidden; align-content: flex-start; align-items: center;
    gap: 4px; padding: 4px 8px 12px; border-bottom: 0;
  }
  #main[data-toolbar="left"] #toolbar { border-right: 1px solid var(--line); }
  #main[data-toolbar="right"] #toolbar { border-left: 1px solid var(--line); }
  #main[data-toolbar="left"] #toolbar > *, #main[data-toolbar="right"] #toolbar > * { flex: 1 1 100%; min-width: 0; }
  #main[data-toolbar="left"] .tgroup, #main[data-toolbar="right"] .tgroup { flex-wrap: wrap; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--line); }
  #main[data-toolbar="left"] #toolbar > :last-child, #main[data-toolbar="right"] #toolbar > :last-child { border-bottom: 0; }
  #main[data-toolbar="left"] .seg, #main[data-toolbar="right"] .seg { flex-wrap: wrap; margin-top: 4px; }
  #main[data-toolbar="left"] #toolbar select, #main[data-toolbar="right"] #toolbar select,
  #main[data-toolbar="left"] #toolbar input[type="range"], #main[data-toolbar="right"] #toolbar input[type="range"],
  #main[data-toolbar="left"] #toolbar .fx, #main[data-toolbar="right"] #toolbar .fx,
  #main[data-toolbar="left"] #toolbar .namebox, #main[data-toolbar="right"] #toolbar .namebox { flex: 1 1 100%; width: 100%; max-width: 100%; }
  #main[data-toolbar="left"] #toolbar .ico-both, #main[data-toolbar="right"] #toolbar .ico-both { flex: 1 1 100%; justify-content: flex-start; }
  #main[data-toolbar="left"] #toolbar .tlabel, #main[data-toolbar="right"] #toolbar .tlabel { font-size: 11px; line-height: 1.45; }
}

/* ---------- 幅の狭い画面(430px 以下)。ツールバーの折り返しは下の「電話の幅(600px 以下)」 ---------- */
@media (max-width: 430px) {
  /* 左・右を選んでいても、下に置く */
  #main[data-toolbar="left"] #work, #main[data-toolbar="right"] #work { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "find" "view" "tb"; }
  #main[data-toolbar="left"] #toolbar, #main[data-toolbar="right"] #toolbar { border-bottom: 0; border-top: 1px solid var(--line); padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  /* 上の帯: タイトルを縮めて、ボタンが画面からはみ出さないようにする */
  #top { gap: 6px; padding-inline: 8px; }
  #top .btn { padding-inline: 8px; }
  #status { flex: none; font-size: 11px; }
  #net-banner { padding-inline: 10px; font-size: 12.5px; }
}
/* ---------- ストップウォッチ(js/stopwatch.js) ---------- */
.tbtn[hidden] { display: none; }
#btn-stopwatch.sw-running { border-color: var(--accent); color: var(--accent-text); }
.sw { position: fixed; z-index: 35; left: 0; top: 0; width: 232px; max-width: calc(100vw - 8px); box-sizing: border-box; display: flex; flex-direction: column; gap: 6px; padding: 8px;
  background: var(--raised); color: var(--fg); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); font-family: var(--f-ui); touch-action: none; user-select: none; -webkit-user-select: none; }
.sw.dragging { opacity: .92; }
.sw-head { display: flex; align-items: center; gap: 2px; }
.sw-main { flex: 1; min-width: 0; cursor: move; border-radius: var(--r-md); padding: 2px 6px; }
.sw-main:focus-visible, .sw-pill:focus-visible, .sw-laps:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sw-time { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: .02em; }
.sw-main .sw-time { font-size: 26px; line-height: 1.2; }
.sw.on .sw-main .sw-time { color: var(--accent-text); }
.sw-fold, .sw-close { padding: 2px 8px; font-size: 15px; color: var(--muted); }
.sw-btns { display: flex; gap: 4px; }
.sw-btns .tbtn { flex: 1; border: 1px solid var(--line); background: var(--panel); font-weight: 600; padding: 6px 4px; }
.sw-btns .tbtn:disabled { opacity: .45; }
.sw-btns .sw-go { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.sw-btns .sw-go.stop { background: var(--danger); border-color: var(--danger); color: var(--danger-fg); }
.sw-laps-wrap { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 6px; }
.sw-laps { list-style: none; margin: 0; padding: 0; max-height: 132px; overflow-y: auto; touch-action: pan-y; user-select: text; -webkit-user-select: text; font-size: 12px; }
.sw-laps li { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 2px 4px; border-radius: var(--r-sm); font-variant-numeric: tabular-nums; }
.sw-laps li:nth-child(odd) { background: var(--hover); }
.sw-no { color: var(--muted); }
.sw-total { color: var(--muted); }
.sw-copy { align-self: flex-end; font-size: 12px; padding: 2px 8px; }
.sw-collapsed { width: auto; padding: 0; border-radius: 999px; }
.sw-pill { display: flex; align-items: center; gap: 6px; border: 0; background: none; color: inherit; padding: 6px 12px; border-radius: 999px; cursor: move; touch-action: none; }
.sw-pill .sw-time { font-size: 14px; }
.sw-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sw.on .sw-dot { background: var(--danger); }
/* ノートのページを横に並べる(「設定」のページの並べ方): ページを左から右へ並べ、横にスクロールする */
.flow-h .pages { flex-direction: row; align-items: flex-start; padding: 24px 24px 40px; }
.flow-h .page-actions { flex-direction: column; align-self: center; flex: none; }

/* ページ一覧(js/page-overview.js): 画面いっぱいに小さな絵を並べる。375px で 2 列、広い画面でも 6 列まで */
.pov { position: fixed; inset: 0; z-index: 45; overflow-y: auto; overscroll-behavior: contain; background: var(--desk);
  padding: 0 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
.pov-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; margin: 0 -16px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.pov-title { margin: 0; font-size: 16px; font-weight: 600; }
.pov-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pov-sp { flex: 1; }
.pov-close { border-color: var(--line); }
.pov-hint { margin: 12px 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.pov-grid { --gap: 14px; display: grid; gap: var(--gap); align-items: end;
  grid-template-columns: repeat(auto-fill, minmax(max(132px, calc((100% - 5 * var(--gap)) / 6)), 1fr)); }
.pov-cell { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pov-thumb { display: block; width: 100%; padding: 0; border: 2px solid transparent; border-radius: var(--r-sm); background: none; cursor: pointer;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pov-thumb.cur { border-color: var(--accent); }
.pov-thumb:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pov-img { position: relative; width: 100%; overflow: hidden; background: var(--paper); box-shadow: var(--shadow); border-radius: 2px; pointer-events: none; }
.pov-img > canvas { display: block; width: 100%; height: 100%; }
.pov-foot { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 28px; }
.pov-no { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pov-more { padding: 2px 10px; }
.pov-cell.dragging { opacity: .35; }
.pov-cell.drop-before::before, .pov-cell.drop-after::after { content: ''; position: absolute; top: 0; bottom: 28px; width: 4px; border-radius: 2px; background: var(--accent); }
.pov-cell.drop-before::before { left: calc(var(--gap) / -2 - 2px); }
.pov-cell.drop-after::after { right: calc(var(--gap) / -2 - 2px); }
.pov-ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; padding: 0; border: 2px solid var(--accent); border-radius: var(--r-sm); background: none;
  box-shadow: var(--shadow-lg); opacity: .9; }
/* ドキュメントの小さな絵(紙の大きさで作って縮める) */
.pov-docpaper { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; overflow: hidden; text-align: start; font-weight: normal; white-space: normal; }
.pov-docpaper .page-bg { box-shadow: none; }
.pov-docbody { overflow: hidden; caret-color: transparent; }

/* ---------- 拡大縮小・ページの道具(上の段の右、検索・ストップウォッチの隣。#view-tools。ノート・ドキュメントが入れる) ----------
   書く道具と押し間違えないように、ツールバーから離して置く。入りきらない時は、上の段の 2 行目に回して、その中だけ横にスクロール */
#main { container-type: inline-size; }
.view-tools { display: flex; align-items: center; gap: 2px 8px; flex: 0 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; }
.view-tools::-webkit-scrollbar { display: none; }
.view-tools:empty { display: none; }
.view-tools .tgroup { flex: none; gap: 2px; }
.view-tools .tgroup + .tgroup { padding-left: 8px; border-left: 1px solid var(--line); }
.view-tools .ico-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1; }
.view-tools .tbtn { min-width: 36px; min-height: 36px; padding-inline: 7px; }
.view-tools .num { min-width: 40px; }
/* 上の段は 1 行に収める: タイトルを縮め、拡大縮小・ページの道具は入りきらない分をその中で横にスクロールする。
   幅が足りない時は、検索・ストップウォッチ・並べるを「⋯」のメニュー(js/core.js の moreMenu)にまとめる */
#top { flex-wrap: nowrap; }
#top .spacer { flex: 1 1 0; min-width: 0; }
#top > .view-tools { flex: 0 1 auto; }
@container (max-width: 1040px) {
  #btn-find, #btn-stopwatch, #btn-split { display: none !important; }
  #top #btn-more { display: inline-flex; }
  #top .spacer { display: none; }
  #top > .view-tools { flex: 1 1 auto; justify-content: flex-start; }
  #top > .view-tools > :first-child { margin-left: auto; }
}
/* 道具の列も縮める(入らない分は列の中を横にスクロール)。名前の欄(flex-shrink 6)の方を先に・多く縮める。
   前は 700px 以上で縮めなかったが、電話を横にした時・iPad の並べて表示などで、上の段の右の「⋯」「書き出し」が画面の外に出ていた */
/* 狭い時は道具の列の端を薄くして、横にスクロールできることを見せる */
@container (max-width: 699px) { #top > .view-tools { -webkit-mask-image: linear-gradient(to right, transparent, #000 14px, #000 calc(100% - 14px), transparent); mask-image: linear-gradient(to right, transparent, #000 14px, #000 calc(100% - 14px), transparent); padding-inline: 10px; } }

/* ---------- 開いているファイルのタブ(js/tabs.js。#main の data-tabs = 「設定」の「タブの位置」) ---------- */
#tabs { position: relative; display: flex; align-items: flex-end; gap: 2px; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
  padding: 4px 8px 0; background: var(--bg); border-bottom: 1px solid var(--line); overscroll-behavior-x: contain; }
#tabs[hidden] { display: none; }
.tab { position: relative; display: flex; align-items: center; flex: 0 1 200px; min-width: 112px; max-width: 220px; border: 1px solid transparent; border-bottom: 0;
  border-radius: 8px 8px 0 0; margin-bottom: -1px; }
.tab:hover:not(.on) { background: var(--hover); }
.tab.on { background: var(--panel); border-color: var(--line); }
.tab.on::after { content: ""; position: absolute; left: 10px; right: 10px; top: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tab-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px;
  padding: 7px 2px 7px 10px; min-height: 36px; text-align: left; cursor: pointer; }
.tab.on .tab-open { color: var(--fg); font-weight: 600; }
.tab-open:focus-visible, .tab-x:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-sm); }
.tab-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--k-note); }
.tab-dot.pdf { background: var(--k-pdf); } .tab-dot.sheet { background: var(--k-sheet); } .tab-dot.doc { background: var(--k-doc); } .tab-dot.slides { background: var(--k-slides); }
.tab-x { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; margin-right: 3px; border: 0; border-radius: var(--r-sm); background: none;
  color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer; }
.tab-x:hover { background: var(--hover); color: var(--fg); }
/* 下: 編集する場所の下に、下向きのタブ */
#main[data-tabs="bottom"] { grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: "top" "net" "work" "tabs"; }
#main[data-tabs="bottom"] #tabs { align-items: flex-start; padding: 0 8px calc(4px + env(safe-area-inset-bottom, 0px)); border-bottom: 0; border-top: 1px solid var(--line); }
#main[data-tabs="bottom"] .tab { border-top: 0; border-bottom: 1px solid transparent; border-radius: 0 0 8px 8px; margin: -1px 0 0; }
#main[data-tabs="bottom"] .tab.on { border-color: var(--line); }
#main[data-tabs="bottom"] .tab.on::after { top: auto; bottom: -1px; }
/* 左・右: 編集する場所の横に、縦の列として置く(多い時は列の中でスクロール) */
@media (min-width: 431px) {
  #main[data-tabs="left"] { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "top top" "net net" "tabs work"; }
  #main[data-tabs="right"] { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "top top" "net net" "work tabs"; }
  #main[data-tabs="left"] #tabs, #main[data-tabs="right"] #tabs { flex-direction: column; align-items: stretch; width: 190px; overflow-x: hidden; overflow-y: auto;
    overscroll-behavior: contain; padding: 8px 6px; border-bottom: 0; }
  #main[data-tabs="left"] #tabs { border-right: 1px solid var(--line); }
  #main[data-tabs="right"] #tabs { border-left: 1px solid var(--line); }
  #main[data-tabs="left"] .tab, #main[data-tabs="right"] .tab { flex: none; max-width: none; min-width: 0; border: 1px solid transparent; border-radius: var(--r-md); margin: 0; }
  #main[data-tabs="left"] .tab.on, #main[data-tabs="right"] .tab.on { border-color: var(--line); }
  #main[data-tabs="left"] .tab.on::after, #main[data-tabs="right"] .tab.on::after { left: -1px; right: auto; top: 8px; bottom: 8px; width: 3px; height: auto; }
  #main[data-tabs="right"] .tab.on::after { left: auto; right: -1px; }
}
/* 幅の狭い画面: タブを少し小さく(左・右を選んでいても、上に出す)。上の段は 2 行目に「書き出し」と拡大縮小・ページの道具を並べる */
@media (max-width: 430px) {
  /* 電話の幅: 上の段は 2 行(1 行目: 名前・⋯・書き出し、2 行目: 拡大縮小・ページの道具) */
  #top { flex-wrap: wrap; row-gap: 4px; }
  #title { flex: 1 1 100px; }
  #top > .view-tools { order: 10; flex: 1 1 100%; }
  #tabs { padding-inline: 4px; }
  .tab { min-width: 96px; flex-basis: 150px; }
  .tab-open { font-size: 12.5px; padding-left: 8px; }
}
/* ---------- 長い説明をしまう「＞ 詳細はこちら」(js/core.js の moreInfo。閉じたまま始め、押すと開く。開くと ＞ が下を向く) ---------- */
.more-info { min-width: 0; font-size: 13px; color: var(--muted); }
.more-info > summary { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 2px 6px 2px 0; border-radius: var(--r-sm); color: var(--accent-text); font-size: 12.5px; cursor: pointer; list-style: none; user-select: none; -webkit-user-select: none; }
.more-info > summary::-webkit-details-marker { display: none; }
.more-info > summary::before { content: "＞"; display: inline-block; font-size: 11px; line-height: 1; transition: transform .15s; }
.more-info[open] > summary::before { transform: rotate(90deg); }
.more-info > summary:hover { text-decoration: underline; }
.more-info > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.more-info > p { margin: 2px 0 0; line-height: 1.6; }
.more-info > p + p { margin-top: 6px; }
.auth-card .more-info > p { line-height: 1.7; }
.side-hint.more-info > p { margin: 2px 0 0; font-size: 11px; }
/* ノートのページの下の「＋ ページを追加」: 広い画面は紙の種類ごとのボタン、電話の幅は 1 つのボタン(押すと紙の種類のメニュー) */
.page-actions-wide { display: contents; }
.page-add-one { display: none; }

/* ---------- 電話の幅(600px 以下。利用者の声 2026-10-23: OPPO Reno5 A・393px の幅) ----------
   ・ツールバーは横にスクロールさせず折り返す。1 行に入りきらない時は 1 行だけ見せ、右上の「⋯」(#tb-fold。js/icons.js の ToolbarFold)で全部の道具を出す
   ・上の段(名前の行と、拡大縮小・ページの行)とタブは余白を小さくして、書く場所を広くする
   ・ノートのページの下の「＋ ページを追加」は 1 つのボタン(押すと紙の種類のメニュー)
   ツールバー・上の段・タブ・ページの道具は、窓の幅ではなく編集する場所(#main のコンテナ)の幅で決める
   (iPad の縦でサイドバーを出した時・並べて表示など。js/icons.js の ToolbarFold.narrow と同じ 600px)。
   ノートのページの余白と「＋ ページを追加」は、js/note.js の narrow(窓の幅)と合わせて窓の幅のまま。
   編集する場所が広い画面・タブレット(601px 以上)は変えない */
@container (max-width: 600px) {
  /* overflow: clip … 折った箱を、キーボードで隠れた道具へ移った時にもスクロールさせない(clip を知らないブラウザは hidden。js/icons.js が開く) */
  #toolbar { flex-wrap: wrap; overflow: hidden; overflow: clip; gap: 4px 6px; padding: 4px 8px; min-height: 0; }
  /* 手書きの道具の並び(.seg)の次に「元に戻す・やり直す」(.tb-pin)を置き、折っても見える行に入れる */
  #toolbar > .seg { order: -2; }
  #toolbar > .tb-pin > * { order: -1; }
  #toolbar > * { max-width: 100%; }
  #toolbar .tgroup, #toolbar .seg { flex-wrap: wrap; }
  #toolbar > .fxgroup { flex: 1 1 100%; }
  /* まとまり(.tgroup)の箱をほどいて、1 つずつ詰めて並べる(まとまりごと次の行へ回ると、行の右が大きく空くため) */
  #toolbar > .tgroup:not(.fxgroup):not([hidden]) { display: contents; }
  #work.tb-fold #toolbar { padding-right: 48px; }
  #tb-fold { grid-area: tb; justify-self: end; align-self: start; z-index: 3; display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; margin: 4px 6px 0 0; padding: 0; background: var(--raised-2); border: 1px solid var(--line); }
  #tb-fold[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
  #tb-fold[hidden], .tb-hidden #tb-fold { display: none; }
  /* 上の段: 1 行目に名前・保存の印・⋯・書き出し、2 行目に拡大縮小・ページの道具。余白を小さく */
  #top { flex-wrap: wrap; row-gap: 0; column-gap: 4px; padding: 2px 6px; }
  #title { flex: 1 1 100px; padding: 2px 6px; font-size: 15px; }
  #top .btn.icon-only { min-width: 34px; min-height: 34px; padding: 2px 6px; }
  #top .icon-btn { padding: 4px; }
  #top > .view-tools { order: 10; flex: 1 1 100%; gap: 0 2px; padding-inline: 0; -webkit-mask-image: none; mask-image: none; }
  #top > .view-tools > :first-child { margin-left: 0; }
  html:not(.vt-shown) #top > .view-tools { display: none; }
  .view-tools .tgroup { gap: 0; }
  .view-tools .tgroup + .tgroup { padding-left: 2px; }
  .view-tools .tbtn { min-width: 30px; min-height: 34px; padding-inline: 4px; }
  .view-tools .num { min-width: 34px; }
  /* 1ページずつ・並べ方の切り替えと目次は「ページ ▾」のメニューへ(ページの道具の段を横にはみ出させない。js/note.js の pageMenu) */
  .view-tools .vt-wide { display: none; }
  /* タブ: 低くして、たくさん開いても縮めて並べる */
  #tabs { padding: 2px 4px 0; }
  .tab { flex: 1 1 140px; min-width: 64px; }
  .tab-open { min-height: 30px; padding: 4px 2px 4px 8px; font-size: 12.5px; gap: 5px; }
  .tab-x { width: 26px; height: 26px; margin-right: 2px; font-size: 15px; }
}
@media (max-width: 600px) {
  /* ノートのページ: まわりの余白を小さく(js/page-ops.js の fitZoom と合わせる) */
  .pages { padding: 12px 8px 32px; gap: 18px; }
  .page-actions-wide { display: none; }
  .page-add-one { display: inline-block; }
}
/* 窓が 431px 以上で、編集する場所が 600px 以下の時に左・右のツールバー(縦の列)を選んだ時は、まとまりの箱をそのまま使う */
@media (min-width: 431px) {
  @container (max-width: 600px) {
    #main[data-toolbar="left"] #toolbar > .tgroup:not([hidden]), #main[data-toolbar="right"] #toolbar > .tgroup:not([hidden]) { display: flex; }
  }
}

/* ---------- 高さの低い画面(500px 以下。電話を横にした時など。利用者の声 2026-10-23) ----------
   html の short(js/icons.js の ScreenShort。キーボードの無い高さで決める。キーボードで縮んだだけでは付け外ししない)の時、
   書く場所を広くするため、上の段・タブを低くし、ツールバーは 1 行だけ見せて残りは右上の「⋯」(js/icons.js の ToolbarFold)で出す。
   左・右のツールバー(縦の列)は高さを使わないので、そのまま。幅で決める電話の幅(600px 以下)の決まりは上のまま */
html.short #top { row-gap: 0; column-gap: 6px; padding-block: 2px; }
html.short #title { padding: 2px 6px; font-size: 15px; }
html.short #top .btn.icon-only { min-width: 34px; min-height: 32px; padding: 2px 6px; }
html.short #top .icon-btn { padding: 3px; }
html.short .view-tools .tbtn { min-height: 32px; }
html.short #tabs { padding: 2px 4px 0; }
html.short .tab-open { min-height: 28px; padding: 3px 2px 3px 8px; font-size: 12.5px; gap: 5px; }
html.short .tab-x { width: 26px; height: 26px; font-size: 15px; }
html.short #net-banner { padding-block: 3px; }
html.short #main:not([data-toolbar="left"]):not([data-toolbar="right"]) #toolbar { flex-wrap: wrap; overflow: hidden; overflow: clip; gap: 4px 6px; padding: 3px 8px; min-height: 0; }
html.short #main:not([data-toolbar="left"]):not([data-toolbar="right"]) #toolbar > .seg { order: -2; }
html.short #main:not([data-toolbar="left"]):not([data-toolbar="right"]) #toolbar > .tb-pin > * { order: -1; }
html.short #main:not([data-toolbar="left"]):not([data-toolbar="right"]) #toolbar > * { max-width: 100%; }
html.short #main:not([data-toolbar="left"]):not([data-toolbar="right"]) #toolbar > .tgroup:not(.fxgroup):not([hidden]) { display: contents; }
html.short #work.tb-fold #toolbar { padding-right: 48px; }
html.short #tb-fold { grid-area: tb; justify-self: end; align-self: start; z-index: 3; display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; margin: 3px 6px 0 0; padding: 0; background: var(--raised-2); border: 1px solid var(--line); }
html.short #tb-fold[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
html.short #tb-fold[hidden], html.short.tb-hidden #tb-fold { display: none; }

/* ---------- 切り欠き・ホームのバー(safe area。index.html の viewport-fit=cover)。ふつうの画面とパソコンは 0 ----------
   上の段の上・左右と、いちばん下の部品の下をあける(下に置いたツールバー・タブは、それぞれが下をあける) */
#main { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); background: var(--panel); }
#main[data-toolbar="bottom"], #main[data-tabs="bottom"] { padding-bottom: 0; }
@media (max-width: 430px) { #main[data-toolbar="left"], #main[data-toolbar="right"] { padding-bottom: 0; } }

/* 拡大率の数字(押すと入力欄になる。js/core.js の zoomInput) */
.zoom-num { border: 1px solid transparent; border-radius: var(--r-sm); background: none; color: inherit; padding: 4px 2px; cursor: text; }
.zoom-num:hover { border-color: var(--line); background: var(--hover); }
.zoom-in { width: 52px; min-width: 0; padding: 3px 4px; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--bg); color: inherit; font: inherit; font-size: 12px; }
