:root {
  --app-accent: #4338ca;
  --app-accent-soft: #eef2ff;
  --app-border: #dbe1ea;
  --app-muted: #64748b;
  --paper-bg: #fffdf5;
  --paper-fg: #172033;
  --editor-font: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --editor-size: 20px;
  --editor-line: 2;
  --preview-page-width: 440px;
  --preview-page-height: 622.286px;
  --preview-page-padding: 33.528px;
  --print-page-scale: 1.8045;
  --mini-scale: 0.3864;
}

* { box-sizing: border-box; }
/* JSがhiddenを付け外しする要素にdisplay:flex/gridが当たっていると、作者スタイルが
   UAスタイルのdisplay:noneに勝ってしまい「hidden=trueにしたのに消えない」が起きる
   （インストールバナーが×を押しても残っていたのが実例）。一律で防いでおく。 */
[hidden] { display: none !important; }
body { background: #f5f7fb; color: #172033; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--app-accent); outline-offset: 2px; }
.compact-navbar { min-height: 58px; }
.compact-navbar .container { min-height: 58px; }
.logo-link { text-decoration: none; }

.app-heading { padding-top: 1.1rem; padding-bottom: .85rem; }
.app-heading-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; }
.app-heading-title { min-width: 0; }
.app-heading h1 { margin: .4rem 0 0; font-size: clamp(1.5rem, 3vw, 2.05rem); }
.heading-actions { display: flex; flex: 0 0 auto; gap: .55rem; align-items: center; }
.privacy-chip { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; padding: .48rem .8rem; border: 1px solid #bbf7d0; border-radius: 999px; background: #f0fdf4; color: #166534; font-size: .78rem; font-weight: 700; }
.button { border: 0; border-radius: 8px; padding: .58rem .85rem; font-weight: 700; }
.button-secondary { border: 1px solid var(--app-border); background: white; color: #334155; }

.mode-switch { display: inline-flex; gap: 3px; margin-top: .9rem; padding: 3px; border-radius: 10px; background: #eef1f6; }
.mode-switch button { min-width: 108px; padding: .48rem 1.2rem; border: 0; border-radius: 8px; background: transparent; color: #475569; font-size: .86rem; font-weight: 700; }
.mode-switch button:hover:not(.active) { color: #1e293b; }
.mode-switch button.active { background: var(--app-accent); color: white; }

/* ---------------------------------------------------------------- shell */
.notepad-shell {
  display: flex;
  flex-direction: column;
  max-width: 1700px;
  height: calc(100dvh - 272px);
  min-height: 460px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: white;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .07);
}

.ghost-button { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .7rem; border: 1px solid var(--app-border); border-radius: 8px; background: white; color: #334155; font-size: .78rem; font-weight: 700; }
.ghost-button:hover { border-color: #a5b4fc; background: #f8faff; }
.ghost-button.block { justify-content: center; width: 100%; }
.icon-button { display: inline-grid; width: 34px; height: 34px; padding: 0; place-items: center; border: 1px solid var(--app-border); border-radius: 8px; background: white; color: #334155; font-size: 1.05rem; line-height: 1; }
.icon-button:hover:not(:disabled) { border-color: #a5b4fc; background: #f8faff; }
.icon-button:disabled { opacity: .4; cursor: default; }

.shell-body { display: grid; min-height: 0; flex: 1; grid-template-columns: 262px minmax(0, 1fr) auto; }

/* -------------------------------------------------------------- sidebar */
.sidebar { display: flex; min-width: 0; min-height: 0; flex-direction: column; border-right: 1px solid var(--app-border); background: #f8fafc; }
.sidebar-scroll { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: .85rem .6rem .6rem; }
.sidebar-section[hidden] { display: none; }
.sidebar-primary { display: flex; width: 100%; align-items: center; justify-content: center; gap: .4rem; padding: .62rem; border: 0; border-radius: 9px; background: var(--app-accent); color: white; font-size: .85rem; font-weight: 700; }
.sidebar-primary:hover { filter: brightness(1.06); }
.sidebar-heading { margin: 1.1rem .25rem .5rem; color: #475569; font-size: .78rem; font-weight: 800; }
.sidebar-note { margin: 0 .25rem .4rem; color: var(--app-muted); font-size: .7rem; line-height: 1.5; }
.search-box { display: flex; align-items: center; gap: .45rem; margin: 0 0 .55rem; padding: .45rem .6rem; border: 1px solid var(--app-border); border-radius: 8px; background: white; color: var(--app-muted); }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: .84rem; }
.sidebar-footer { display: grid; flex: 0 0 auto; gap: .1rem; padding: .5rem .6rem .6rem; border-top: 1px solid var(--app-border); }
.sidebar-footer button { display: flex; align-items: center; gap: .5rem; padding: .45rem .5rem; border: 0; border-radius: 6px; background: transparent; color: #475569; font-size: .78rem; text-align: left; }
.sidebar-footer button:hover { background: #eef2f7; color: var(--app-accent); }
.footer-icon { flex: 0 0 auto; width: 17px; color: #94a3b8; font-size: .86rem; text-align: center; }
.sidebar-footer button:hover .footer-icon { color: var(--app-accent); }
.footer-icon-circled { display: inline-grid; height: 17px; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: .62rem; }

/* grid の暗黙カラムは auto（＝max-content）で伸びるため、minmax(0, 1fr) を明示しないと
   長い本文プレビューぶんだけ行が横に広がり、右端の✎・🗑ボタンがサイドバーの外へ
   押し出されてしまう。 */
.notes-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.note-item { display: flex; min-width: 0; align-items: center; width: 100%; padding: 0; border: 0; border-radius: 8px; background: transparent; color: #1e293b; }
.note-item:hover { background: #eef2f7; }
.note-item.active { background: var(--app-accent-soft); color: #312e81; }
.note-item-select { display: flex; align-items: flex-start; gap: .5rem; flex: 1 1 auto; min-width: 0; padding: .62rem .55rem; border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: left; }
.note-item-icon { flex: 0 0 auto; margin-top: .1rem; color: #94a3b8; font-size: .92rem; line-height: 1.2; }
.note-item.active .note-item-icon { color: var(--app-accent); }
.note-item-text { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.note-item-rename,
.note-item-delete,
.project-delete { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: #94a3b8; font-size: .76rem; }
.note-item-rename { transform: scaleX(-1); }
.note-item-rename:hover { background: var(--app-accent-soft); color: var(--app-accent); }
.note-item-delete:hover,
.project-delete:hover { background: #fee2e2; color: #b91c1c; }
.note-item-delete,
.project-delete { margin-right: .25rem; }
/* メモ一覧は「押せば開く」だけの見た目にしたいので、削除はポインタを乗せたとき
   （とキーボードでフォーカスが入ったとき）だけ出す。タップ操作の端末では
   hoverが無いので常時表示のままにする。 */
@media (hover: hover) and (pointer: fine) {
  #notes-list .note-item-delete { visibility: hidden; }
  #notes-list .note-item:hover .note-item-delete,
  #notes-list .note-item:focus-within .note-item-delete { visibility: visible; }
}
.note-item-title { display: block; overflow: hidden; font-size: .86rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.note-item-preview { display: block; overflow: hidden; margin-top: .2rem; color: var(--app-muted); font-size: .73rem; text-overflow: ellipsis; white-space: nowrap; }
.note-item-time { display: block; margin-top: .25rem; color: #94a3b8; font-size: .67rem; }
.empty-list { padding: 1rem .65rem; color: var(--app-muted); font-size: .8rem; line-height: 1.6; text-align: center; }
.empty-list.small { padding: .5rem; font-size: .74rem; }

.project-group { margin-bottom: .2rem; border-radius: 8px; }
.project-head { display: flex; align-items: center; }
.project-select { display: flex; flex: 1 1 auto; min-width: 0; align-items: center; gap: .45rem; padding: .55rem .55rem; border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: .86rem; text-align: left; }
.project-head:hover { background: #eef2f7; border-radius: 8px; }
.project-group.active .project-select { color: var(--app-accent); font-weight: 700; }
.project-icon { flex: 0 0 auto; font-size: .9rem; }
.project-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-chevron { flex: 0 0 auto; color: #94a3b8; font-size: .8rem; }
.project-chapters { margin: .1rem 0 .5rem .95rem; padding-left: .35rem; border-left: 1px solid var(--app-border); }
.chapter-item { display: flex; min-width: 0; align-items: center; border-radius: 7px; }
.chapter-item:hover { background: #eef2f7; }
.chapter-item.active { background: var(--app-accent-soft); }
.chapter-select { display: flex; flex: 1 1 auto; min-width: 0; align-items: center; gap: .45rem; padding: .42rem .5rem; border: 0; border-radius: 7px; background: transparent; color: #334155; font-size: .8rem; text-align: left; }
.chapter-item.active .chapter-select { color: #312e81; font-weight: 700; }
.chapter-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-dot { flex: 0 0 auto; width: 5px; height: 5px; border-radius: 50%; background: #cbd5e1; }
.chapter-item.active .chapter-dot { background: var(--app-accent); }
/* ドラッグ並べ替え（マウス操作時のみ。タッチでは↑↓ボタンを使う） */
.chapter-item[draggable="true"] { cursor: grab; }
.chapter-item.dragging { opacity: .45; cursor: grabbing; }
.chapter-item.drop-before { box-shadow: inset 0 2px 0 0 var(--app-accent); }
.chapter-item.drop-after { box-shadow: inset 0 -2px 0 0 var(--app-accent); }
.chapter-move { flex: 0 0 auto; width: 20px; height: 22px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: #94a3b8; font-size: .7rem; }
.chapter-move:hover:not(:disabled) { color: var(--app-accent); }
.chapter-move:disabled { opacity: .25; cursor: default; }
.add-item-button { width: calc(100% - .35rem); margin: .35rem 0 .2rem; padding: .45rem; border: 1px dashed var(--app-border); border-radius: 8px; background: transparent; color: var(--app-accent); font-size: .77rem; font-weight: 700; }
.add-item-button:hover { background: var(--app-accent-soft); }

/* --------------------------------------------------------- editor panel */
.editor-panel { position: relative; display: flex; min-width: 0; min-height: 0; flex-direction: column; }
.doc-bar { position: relative; display: flex; min-height: 58px; align-items: center; gap: .8rem; padding: .5rem .7rem .5rem 1rem; border-bottom: 1px solid var(--app-border); }
.doc-identity { min-width: 0; flex: 1 1 auto; }
.title-field { position: relative; border-radius: 6px; transition: background-color .12s ease; }
.title-field:hover { background-color: rgba(15, 23, 42, .05); }
.title-field:focus-within { background-color: rgba(15, 23, 42, .05); }
.title-input { width: 100%; padding: .1rem 1.5rem .1rem .35rem; border: 0; outline: 0; background: transparent; color: #172033; font-size: 1.02rem; font-weight: 700; }
.title-input:disabled { color: #94a3b8; }
.title-edit-icon { position: absolute; top: 50%; right: .4rem; color: #94a3b8; font-size: .8rem; pointer-events: none; transform: translateY(-50%) scaleX(-1); }
.doc-context { display: block; overflow: hidden; padding-left: .35rem; color: var(--app-muted); font-size: .71rem; text-overflow: ellipsis; white-space: nowrap; }
.doc-context[hidden] { display: none; }
.doc-meta { display: flex; flex: 0 0 auto; align-items: center; gap: .8rem; }
.doc-count { color: var(--app-muted); font-size: .76rem; white-space: nowrap; }
.save-state { color: #64748b; font-size: .76rem; white-space: nowrap; }
.save-state.saved::before { content: '✓'; margin-right: .28rem; color: #16a34a; font-weight: 700; }
.save-state.saving { color: #a16207; }
.save-state.error { color: #b91c1c; font-weight: 700; }
.doc-actions { display: flex; flex: 0 0 auto; align-items: center; gap: .35rem; }
.view-switch { display: inline-flex; gap: .3rem; }
.view-switch button { padding: .45rem .72rem; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #64748b; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.view-switch button:hover:not(.active) { background: #f1f5f9; color: #334155; }
.view-switch button.active { border-color: var(--app-accent); background: var(--app-accent-soft); color: var(--app-accent); }
.doc-action { display: inline-flex; align-items: center; gap: .3rem; padding: .45rem .62rem; border: 1px solid var(--app-border); border-radius: 8px; background: white; color: #334155; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.doc-action:hover { border-color: #a5b4fc; background: #f8faff; }

.action-menu { position: absolute; z-index: 30; top: 52px; right: .7rem; width: 218px; padding: .35rem; border: 1px solid var(--app-border); border-radius: 10px; background: white; box-shadow: 0 12px 28px rgba(15, 23, 42, .16); }
.action-menu[hidden] { display: none; }
.action-menu button { width: 100%; padding: .55rem .6rem; border: 0; border-radius: 6px; background: transparent; color: #334155; font-size: .8rem; text-align: left; }
.action-menu button[hidden] { display: none; }
.action-menu button { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.action-menu button:hover:not(:disabled) { background: #f1f5f9; }
.action-menu button:disabled { color: #cbd5e1; cursor: default; }
.menu-shortcut { flex: 0 0 auto; color: #94a3b8; font-size: .68rem; }
.action-menu button:disabled .menu-shortcut { color: #dbe1ea; }
.action-menu hr { margin: .3rem .2rem; border: 0; border-top: 1px solid var(--app-border); }
.action-menu .danger-action { color: #b91c1c; }
.action-menu .danger-action:hover { background: #fee2e2; }

.format-bar { display: flex; min-height: 48px; align-items: center; gap: 1.15rem; padding: .45rem 1.15rem; overflow-x: auto; border-bottom: 1px solid var(--app-border); background: white; white-space: nowrap; }
.format-bar label { display: inline-flex; align-items: center; gap: .5rem; color: #64748b; font-size: .76rem; font-weight: 600; }
.format-bar select,
.format-bar input[type="number"] { padding: .34rem .5rem; border: 1px solid var(--app-border); border-radius: 8px; background: white; color: #1e293b; font-size: .78rem; }
.format-bar input[type="number"] { width: 4.2em; }
.format-bar-standalone { padding: .34rem .5rem; border: 1px solid var(--app-border); border-radius: 8px; background: white; color: #1e293b; font-size: .78rem; }

.workspace { display: grid; min-height: 0; flex: 1; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.workspace[data-view="edit"] { grid-template-columns: minmax(0, 1fr); }
.workspace[data-view="edit"] .preview-pane { display: none; }
.workspace[data-view="preview"] { grid-template-columns: minmax(0, 1fr); }
.workspace[data-view="preview"] .input-pane { display: none; }
.input-pane, .preview-pane { min-width: 0; min-height: 0; }
.input-pane { position: relative; border-right: 1px solid var(--app-border); padding: 1.15rem; }
.workspace[data-view="edit"] .input-pane { border-right: 0; }
/* 書体・文字サイズ・行間の設定を入力欄にもそのまま効かせる（設定名どおりの見た目にする）。 */
#input-text { width: 100%; height: 100%; min-height: 0; padding: 1.1rem 1.25rem; resize: none; border: 1px solid var(--app-border); border-radius: 10px; outline: 0; background: white; color: #172033; font-family: var(--editor-font); font-size: var(--editor-size); line-height: var(--editor-line); }
#input-text:focus { border-color: #a5b4fc; }
#input-text:disabled { background: #f8fafc; cursor: default; }
#input-text:disabled::placeholder { color: transparent; }
.editor-empty-hint { display: flex; flex-direction: column; align-items: center; gap: .7rem; position: absolute; inset: 1.15rem; margin: auto; width: min(240px, 80%); height: fit-content; padding: 1.4rem 1.1rem; border: 1px dashed var(--app-border); border-radius: 12px; background: rgba(248, 250, 252, .96); text-align: center; }
.editor-empty-hint p { margin: 0; color: #475569; font-size: .86rem; font-weight: 700; }
.editor-empty-hint .sidebar-primary { width: auto; padding: .55rem 1.1rem; }
.notepad-shell[data-ui-theme="dark"] #input-text:disabled { background: #171f2d; }
.notepad-shell[data-ui-theme="dark"] .editor-empty-hint { border-color: #3a4761; background: rgba(23, 31, 45, .96); }
.notepad-shell[data-ui-theme="dark"] .editor-empty-hint p { color: #94a3b8; }
.line-gutter { display: none; position: absolute; top: 1.15rem; left: 1.15rem; bottom: 1.15rem; width: 2.7rem; overflow: hidden; padding: 1.1rem 0; color: #a1acbd; font-family: var(--editor-font); font-size: var(--editor-size); line-height: var(--editor-line); text-align: right; user-select: none; }
.line-gutter div { padding-right: .5rem; }
.input-pane.show-line-numbers .line-gutter { display: block; }
.input-pane.show-line-numbers #input-text { padding-left: calc(2.7rem + .6rem); }

/* 入力欄をそのまま縦書きにするモード。原稿用紙のような薄い罫線を、1行の送り幅
   （文字サイズ×行間）に合わせて敷く。倍率をかけていないので実際の行位置と一致する。 */
.input-pane.vertical-editing #input-text {
  --line-pitch: calc(var(--editor-size) * var(--editor-line));
  --guide-color: rgba(15, 23, 42, .09);
  padding: 1.25rem 1.35rem;
  /* 英数字も日本語と同じように1文字ずつ立てる（縦書きメモ帳の従来の見え方）。 */
  text-orientation: upright;
  background-origin: content-box;
  background-clip: padding-box;
  background-image: repeating-linear-gradient(
    to left,
    transparent 0,
    transparent calc(var(--line-pitch) - 1px),
    var(--guide-color) calc(var(--line-pitch) - 1px),
    var(--guide-color) var(--line-pitch)
  );
}
.input-pane.vertical-editing.flow-lr #input-text {
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(var(--line-pitch) - 1px),
    var(--guide-color) calc(var(--line-pitch) - 1px),
    var(--guide-color) var(--line-pitch)
  );
}
.preview-pane { overflow: hidden; padding: 0; background: #f1f3f8; }
.vertical-preview { display: flex; width: 100%; height: 100%; min-height: 0; flex-direction: column; align-items: center; gap: 1rem; padding: 1rem; overflow: auto; background: #f1f3f8; --preview-zoom: 1; }
.vertical-preview-page-frame { flex: 0 0 auto; width: calc(var(--preview-page-width) * var(--preview-zoom)); height: calc(var(--preview-page-height) * var(--preview-zoom)); }
.vertical-preview-page { width: var(--preview-page-width); height: var(--preview-page-height); min-height: 0; padding: var(--preview-page-padding); overflow: hidden; background: var(--paper-bg); color: var(--paper-fg); font-family: var(--editor-font); font-size: var(--editor-size); line-height: var(--editor-line); text-orientation: upright; white-space: pre-wrap; writing-mode: vertical-rl; overflow-wrap: break-word; box-shadow: 0 3px 12px rgba(15, 23, 42, .12); transform: scale(var(--preview-zoom)); transform-origin: top left; }
.vertical-preview-page.direction-lr { writing-mode: vertical-lr; }
.vertical-preview-page.direction-horizontal { writing-mode: horizontal-tb; text-orientation: mixed; }
.vertical-preview-page.is-empty { color: #94a3b8; }
.vertical-preview-page rt { font-family: var(--editor-font); color: inherit; opacity: .78; }
.vertical-preview-page.genkoyoushi {
  --genkoyoushi-col-fallback: calc(var(--editor-line) * var(--editor-size));
  --genkoyoushi-row-fallback: var(--editor-size);
  background-origin: content-box;
  background-repeat: no-repeat;
  background-position: right top;
  background-size: var(--genkoyoushi-used-width, 100%) 100%;
  background-image:
    repeating-linear-gradient(to left, transparent 0, transparent calc(var(--genkoyoushi-col, var(--genkoyoushi-col-fallback)) - 1px), rgba(0, 0, 0, .16) calc(var(--genkoyoushi-col, var(--genkoyoushi-col-fallback)) - 1px), rgba(0, 0, 0, .16) var(--genkoyoushi-col, var(--genkoyoushi-col-fallback))),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--genkoyoushi-row, var(--genkoyoushi-row-fallback)) - 1px), rgba(0, 0, 0, .16) calc(var(--genkoyoushi-row, var(--genkoyoushi-row-fallback)) - 1px), rgba(0, 0, 0, .16) var(--genkoyoushi-row, var(--genkoyoushi-row-fallback)));
}
/* いま書いている場所のページ。追従スクロールで飛んだ先が分かるよう控えめに示す。 */
.vertical-preview-page-frame.is-caret-page .vertical-preview-page { box-shadow: 0 0 0 2px var(--app-accent), 0 3px 12px rgba(15, 23, 42, .12); }
.vertical-preview-measure { position: fixed; top: 0; left: -10000px; visibility: hidden; pointer-events: none; }
.genkoyoushi-probe { width: auto; height: auto; padding: 0; }

.status-bar { display: flex; min-height: 38px; align-items: center; gap: 1.15rem; padding: .35rem 1.15rem; border-top: 1px solid var(--app-border); background: white; color: #64748b; font-size: .74rem; }
.status-bar strong { margin-right: .15rem; color: #334155; }
.status-bar span[hidden] { display: none; }
.status-hint { display: inline-flex; align-items: center; gap: .35rem; margin-left: auto; overflow: hidden; color: #94a3b8; text-overflow: ellipsis; white-space: nowrap; }
.status-hint-icon { flex: 0 0 auto; }

/* ----------------------------------------------------------- info panel */
.info-panel { width: 288px; overflow-y: auto; padding: 1rem .9rem 1.2rem; border-left: 1px solid var(--app-border); background: #fbfcfe; }
.info-panel[hidden] { display: none; }
.info-block + .info-block { margin-top: 1.05rem; padding-top: 1.05rem; border-top: 1px solid var(--app-border); }
.info-block-title { margin: 0 0 .6rem; color: #334155; font-size: .8rem; font-weight: 800; }
.mini-preview { display: flex; justify-content: center; padding: .55rem; border-radius: 9px; background: #eef1f7; }
.mini-preview-frame { width: calc(var(--preview-page-width) * var(--mini-scale)); height: calc(var(--preview-page-height) * var(--mini-scale)); overflow: hidden; }
.mini-preview-frame .vertical-preview-page { transform: scale(var(--mini-scale)); transform-origin: top left; box-shadow: 0 2px 8px rgba(15, 23, 42, .14); }
.mini-preview-nav { display: flex; align-items: center; justify-content: center; gap: .35rem; margin-top: .55rem; color: var(--app-muted); font-size: .72rem; }
.mini-preview-nav .icon-button { width: 26px; height: 26px; font-size: .8rem; }
.info-list { display: grid; gap: .4rem; margin: 0 0 .55rem; }
.info-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; font-size: .76rem; }
.info-list dt { color: var(--app-muted); }
.info-list dd { margin: 0; font-weight: 700; }
.progress-bar { height: 6px; overflow: hidden; border-radius: 999px; background: #e2e8f0; }
.progress-bar-fill { height: 100%; width: 0%; background: var(--app-accent); transition: width .2s ease; }
.progress-text { display: block; margin-top: .35rem; color: var(--app-muted); font-size: .71rem; }

/* ------------------------------------------------- settings panel/modal */
.settings-panel { position: fixed; z-index: 200; top: 0; right: 0; bottom: 0; display: flex; width: min(340px, 90vw); flex-direction: column; border-left: 1px solid var(--app-border); background: white; box-shadow: -12px 0 32px rgba(15, 23, 42, .16); }
.settings-panel[hidden] { display: none; }
.settings-panel-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid var(--app-border); font-size: .92rem; }
.settings-panel-body { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: .9rem 1rem 1.4rem; }
.settings-panel-body hr { margin: 1rem 0 .8rem; border: 0; border-top: 1px solid var(--app-border); }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .6rem; color: #475569; font-size: .8rem; font-weight: 700; }
.settings-row.wide { flex-direction: column; align-items: stretch; gap: .3rem; }
.settings-row select,
.settings-row input { min-width: 8.5em; padding: .35rem .5rem; border: 1px solid var(--app-border); border-radius: 6px; background: white; color: #334155; font-size: .8rem; font-weight: 400; }
.settings-row.wide input { width: 100%; }
.settings-check { display: flex; align-items: center; gap: .5rem; margin-bottom: .55rem; color: #475569; font-size: .8rem; }
.settings-check input { accent-color: var(--app-accent); width: 16px; height: 16px; }
.settings-hint { margin: .2rem 0 0; color: var(--app-muted); font-size: .7rem; line-height: 1.65; }
.settings-panel-body .ghost-button.block { margin-top: .6rem; }

.modal { position: fixed; z-index: 210; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(15, 23, 42, .45); }
.modal[hidden] { display: none; }
.modal-card { display: flex; width: 100%; max-width: 480px; max-height: 85dvh; flex-direction: column; border-radius: 14px; background: white; box-shadow: 0 24px 60px rgba(15, 23, 42, .3); }
.modal-header { display: flex; flex: 0 0 auto; align-items: center; gap: .7rem; padding: .9rem 1rem; border-bottom: 1px solid var(--app-border); }
.modal-header h2 { flex: 1 1 auto; margin: 0; font-size: 1rem; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem; }
.modal-body h3 { margin: 1.2rem 0 .6rem; font-size: .84rem; }
.characters-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: .55rem; }
.character-card { display: grid; gap: .35rem; padding: .6rem; border: 1px solid var(--app-border); border-radius: 9px; background: #fafbfc; }
.character-card input, .character-card textarea { width: 100%; padding: .35rem .5rem; border: 1px solid var(--app-border); border-radius: 6px; background: white; color: #172033; font-size: .8rem; }
.character-card textarea { min-height: 3.2em; resize: vertical; }
.character-delete { justify-self: end; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #94a3b8; font-size: .78rem; }
.character-delete:hover { background: #fee2e2; color: #b91c1c; }

#sheet-backdrop { display: none; }
body.sheet-open #sheet-backdrop { display: block; position: fixed; z-index: 150; inset: 0; background: rgba(15, 23, 42, .35); }

.mobile-bottom-nav { display: none; }
.mobile-nav-icon { display: block; margin-bottom: .15rem; font-size: 1rem; line-height: 1; }

.toast { position: fixed; z-index: 300; left: 50%; bottom: 24px; max-width: min(90vw, 460px); transform: translateX(-50%); padding: .7rem 1rem; border-radius: 9px; background: #172033; color: white; box-shadow: 0 10px 30px rgba(15, 23, 42, .25); font-size: .84rem; line-height: 1.6; }
.onboarding-modal { position: fixed; z-index: 220; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(15, 23, 42, .45); }
.onboarding-modal[hidden] { display: none; }
.onboarding-card { width: 100%; max-width: 420px; padding: 1.6rem; border-radius: 16px; background: white; box-shadow: 0 24px 60px rgba(15, 23, 42, .3); text-align: center; }
.onboarding-card h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.onboarding-card p { margin: 0 0 1.2rem; color: var(--app-muted); font-size: .82rem; line-height: 1.6; }
.onboarding-choices { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; }
.onboarding-choice { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 1rem .5rem; border: 1px solid var(--app-border); border-radius: 12px; background: white; color: #172033; font-size: .82rem; font-weight: 700; }
.onboarding-choice:hover { border-color: var(--app-accent); background: var(--app-accent-soft); }
.onboarding-icon { font-size: 1.6rem; }
.onboarding-skip { border: 0; background: transparent; color: var(--app-muted); font-size: .78rem; text-decoration: underline; }

.install-banner { position: fixed; z-index: 90; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: .85rem; max-width: min(500px, calc(100vw - 32px)); padding: .72rem .8rem .72rem 1rem; border: 1px solid #c7d2fe; border-radius: 12px; background: #fff; box-shadow: 0 12px 32px rgba(30, 41, 59, .2); }
/* display:flexがネイティブの[hidden]を上書きしてしまい、JS側でhidden=trueにしても
   画面から消えなかった（×ボタン・追加後もバナーが残るバグの原因）。明示的に打ち消す。 */
.install-banner[hidden] { display: none; }
.install-banner-copy { display: flex; min-width: 0; align-items: center; gap: .6rem; }
.install-banner-copy strong, .install-banner-copy small { display: block; }
.install-banner-copy strong { color: #312e81; font-size: .84rem; }
.install-banner-copy small { margin-top: .12rem; color: #64748b; font-size: .7rem; }
.install-banner-icon { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: var(--app-accent); color: white; }
.install-banner-button { flex: 0 0 auto; padding: .6rem .75rem; border: 0; border-radius: 7px; background: var(--app-accent); color: white; font-size: .76rem; font-weight: 700; touch-action: manipulation; }
.install-banner-close { width: 40px; height: 40px; flex: 0 0 auto; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #64748b; font-size: 1.25rem; line-height: 1; touch-action: manipulation; }
.install-banner-close:hover { background: #f1f5f9; }

/* ------------------------------------------------------------ dark mode */
.notepad-shell[data-ui-theme="dark"] { background: #1b2333; border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .ghost-button,
.notepad-shell[data-ui-theme="dark"] .icon-button,
.notepad-shell[data-ui-theme="dark"] .doc-action { background: #232d40; border-color: #3a4761; color: #cbd5e1; }
.notepad-shell[data-ui-theme="dark"] .ghost-button:hover,
.notepad-shell[data-ui-theme="dark"] .icon-button:hover:not(:disabled),
.notepad-shell[data-ui-theme="dark"] .doc-action:hover { background: #2c374e; border-color: #4c5c7d; }
.notepad-shell[data-ui-theme="dark"] .sidebar { background: #171f2d; border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .sidebar-heading { color: #94a3b8; }
.notepad-shell[data-ui-theme="dark"] .sidebar-note { color: #64748b; }
.notepad-shell[data-ui-theme="dark"] .search-box { background: #232d40; border-color: #3a4761; color: #94a3b8; }
.notepad-shell[data-ui-theme="dark"] .search-box input { color: #e2e8f0; }
.notepad-shell[data-ui-theme="dark"] .note-item { color: #cbd5e1; }
.notepad-shell[data-ui-theme="dark"] .note-item:hover,
.notepad-shell[data-ui-theme="dark"] .project-head:hover,
.notepad-shell[data-ui-theme="dark"] .chapter-item:hover { background: #232d40; }
.notepad-shell[data-ui-theme="dark"] .note-item.active,
.notepad-shell[data-ui-theme="dark"] .chapter-item.active { background: #2d3a56; color: #c7d2fe; }
.notepad-shell[data-ui-theme="dark"] .chapter-item.active .chapter-select { color: #c7d2fe; }
.notepad-shell[data-ui-theme="dark"] .chapter-select { color: #cbd5e1; }
.notepad-shell[data-ui-theme="dark"] .project-select { color: #cbd5e1; }
.notepad-shell[data-ui-theme="dark"] .project-group.active .project-select { color: #a5b4fc; }
.notepad-shell[data-ui-theme="dark"] .project-chapters { border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .note-item-preview { color: #94a3b8; }
.notepad-shell[data-ui-theme="dark"] .note-item-time { color: #64748b; }
.notepad-shell[data-ui-theme="dark"] .note-item-rename,
.notepad-shell[data-ui-theme="dark"] .note-item-delete,
.notepad-shell[data-ui-theme="dark"] .project-delete,
.notepad-shell[data-ui-theme="dark"] .chapter-move { color: #64748b; }
.notepad-shell[data-ui-theme="dark"] .note-item-delete:hover,
.notepad-shell[data-ui-theme="dark"] .project-delete:hover { background: #4c1d1d; color: #fca5a5; }
.notepad-shell[data-ui-theme="dark"] .empty-list { color: #64748b; }
.notepad-shell[data-ui-theme="dark"] .sidebar-footer { border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .sidebar-footer button { color: #94a3b8; }
.notepad-shell[data-ui-theme="dark"] .sidebar-footer button:hover { background: #232d40; }
.notepad-shell[data-ui-theme="dark"] .add-item-button { border-color: #3a4761; color: #a5b4fc; }
.notepad-shell[data-ui-theme="dark"] .doc-bar { border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .title-input { color: #e2e8f0; }
.notepad-shell[data-ui-theme="dark"] .title-field:hover,
.notepad-shell[data-ui-theme="dark"] .title-field:focus-within { background-color: rgba(226, 232, 240, .1); }
.notepad-shell[data-ui-theme="dark"] .title-edit-icon,
.notepad-shell[data-ui-theme="dark"] .doc-context,
.notepad-shell[data-ui-theme="dark"] .doc-count,
.notepad-shell[data-ui-theme="dark"] .save-state { color: #94a3b8; }
.notepad-shell[data-ui-theme="dark"] .view-switch { background: #232d40; }
.notepad-shell[data-ui-theme="dark"] .view-switch button { color: #94a3b8; }
.notepad-shell[data-ui-theme="dark"] .view-switch button.active { background: #3b4a6b; color: #c7d2fe; }
.notepad-shell[data-ui-theme="dark"] .action-menu { background: #1f283a; border-color: #3a4761; box-shadow: 0 12px 25px rgba(0, 0, 0, .35); }
.notepad-shell[data-ui-theme="dark"] .action-menu button { color: #cbd5e1; }
.notepad-shell[data-ui-theme="dark"] .action-menu button:hover { background: #2c374e; }
.notepad-shell[data-ui-theme="dark"] .action-menu hr { border-color: #3a4761; }
.notepad-shell[data-ui-theme="dark"] .action-menu .danger-action { color: #f87171; }
.notepad-shell[data-ui-theme="dark"] .action-menu .danger-action:hover { background: #4c1d1d; }
.notepad-shell[data-ui-theme="dark"] .format-bar { background: #171f2d; border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .format-bar label { color: #94a3b8; }
.notepad-shell[data-ui-theme="dark"] .format-bar select,
.notepad-shell[data-ui-theme="dark"] .format-bar input[type="number"] { background: #232d40; border-color: #3a4761; color: #e2e8f0; }
/* backgroundショートハンドで指定すると background-image ごと打ち消してしまい、
   ダークモードだけ縦書きの罫線が消える。色だけを上書きする。 */
.notepad-shell[data-ui-theme="dark"] #input-text { background-color: #1b2333; color: #e2e8f0; border-color: #3a4761; }
.notepad-shell[data-ui-theme="dark"] .input-pane.vertical-editing #input-text { --guide-color: rgba(226, 232, 240, .12); }
.notepad-shell[data-ui-theme="dark"] .input-pane { border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .line-gutter { color: #5b6b85; }
.notepad-shell[data-ui-theme="dark"] .input-pane.show-line-numbers .line-gutter { background: #171f2d; border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .preview-pane,
.notepad-shell[data-ui-theme="dark"] .vertical-preview { background: #131a27; }
.notepad-shell[data-ui-theme="dark"] .status-bar { background: #171f2d; border-color: #313e56; color: #94a3b8; }
.notepad-shell[data-ui-theme="dark"] .status-hint { color: #64748b; }
.notepad-shell[data-ui-theme="dark"] .info-panel { background: #171f2d; border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .info-block { border-color: #313e56; }
.notepad-shell[data-ui-theme="dark"] .info-block-title { color: #cbd5e1; }
.notepad-shell[data-ui-theme="dark"] .info-list dt,
.notepad-shell[data-ui-theme="dark"] .progress-text { color: #94a3b8; }
.notepad-shell[data-ui-theme="dark"] .info-list dd { color: #e2e8f0; }
.notepad-shell[data-ui-theme="dark"] .mini-preview { background: #101725; }
.notepad-shell[data-ui-theme="dark"] .progress-bar { background: #2c374e; }
.notepad-shell[data-ui-theme="dark"] .mobile-bottom-nav,
.notepad-shell[data-ui-theme="dark"] .mobile-bottom-nav button { background: #171f2d; border-color: #313e56; color: #94a3b8; }

/* ------------------------------------------------------------ 集中表示 */
body.focus-mode .compact-navbar,
body.focus-mode .app-heading,
body.focus-mode .sidebar,
body.focus-mode .format-bar,
body.focus-mode .info-panel,
body.focus-mode .feature-section,
body.focus-mode .help-section,
body.focus-mode .faq-section,
body.focus-mode .related-section,
body.focus-mode .affiliate-section,
body.focus-mode .site-footer,
body.focus-mode .install-banner { display: none; }
body.focus-mode { overflow: hidden; }
body.focus-mode .notepad-shell { width: 100%; max-width: none; height: 100dvh; min-height: 100dvh; border: 0; border-radius: 0; }
body.focus-mode .shell-body { grid-template-columns: minmax(0, 1fr); }

/* ------------------------------------------------------- 説明セクション */
.feature-section, .help-section { padding-top: 3.4rem; padding-bottom: .5rem; }
.feature-section h2, .help-section h2 { margin: 0 0 1.2rem; font-size: clamp(1.35rem, 3vw, 1.8rem); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; }
.feature-grid article { padding: 1.25rem; border: 1px solid var(--app-border); border-radius: 12px; background: white; }
.feature-grid article > span { color: var(--app-accent); font-size: .72rem; font-weight: 800; }
.feature-grid h3 { margin: .35rem 0 .45rem; font-size: 1.02rem; }
.feature-grid p { margin: 0; color: #64748b; font-size: .84rem; line-height: 1.75; }
.help-section ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding: 0; list-style: none; counter-reset: steps; }
.help-section li { position: relative; padding: .9rem 1rem .9rem 3.25rem; counter-increment: steps; border-left: 3px solid #c7d2fe; background: white; }
.help-section li::before { position: absolute; top: .85rem; left: .9rem; display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; background: var(--app-accent); color: white; content: counter(steps); font-size: .75rem; font-weight: 800; }
.help-section li strong, .help-section li span { display: block; }
.help-section li span { margin-top: .3rem; color: #64748b; font-size: .8rem; line-height: 1.6; }
.compact-faq { margin-top: 2.5rem; }
.related-section, .affiliate-section { padding-top: 3.4rem; }
.related-section h2, .affiliate-section h2 { margin: 0 0 1rem; font-size: clamp(1.25rem, 2.6vw, 1.65rem); }
.related-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.related-links a { display: flex; min-height: 92px; flex-direction: column; justify-content: space-between; padding: 1rem; border: 1px solid var(--app-border); border-radius: 10px; background: white; color: #1e293b; text-decoration: none; }
.related-links a:hover { border-color: #a5b4fc; background: #f8faff; }
.related-links span { margin-top: .35rem; color: var(--app-muted); font-size: .78rem; }
.affiliate-section { padding-bottom: 3.4rem; }
.affiliate-kicker { margin: 0 0 .45rem; color: #64748b; font-size: .75rem; font-weight: 700; }
.affiliate-kicker span { display: inline-block; margin-right: .35rem; padding: .12rem .35rem; border-radius: 4px; background: #334155; color: white; font-size: .68rem; }
.affiliate-intro, .affiliate-disclosure { max-width: 720px; color: #64748b; font-size: .84rem; line-height: 1.7; }
.affiliate-disclosure { margin: .85rem 0 0; font-size: .72rem; }
.affiliate-book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.1rem; }
.affiliate-book-card { display: flex; min-width: 0; flex-direction: column; padding: 1rem; border: 1px solid #eadfca; border-radius: 14px; background: linear-gradient(160deg, #fffefa 0%, #fff8eb 100%); box-shadow: 0 10px 24px rgba(120, 53, 15, .08); }
.affiliate-book-cover { display: flex; align-items: center; justify-content: center; height: 186px; padding: .25rem; border-radius: 10px; background: rgba(255,255,255,.75); }
.affiliate-book-cover img { display: block; width: auto; max-width: 100%; height: 100%; max-height: 176px; object-fit: contain; filter: drop-shadow(0 7px 8px rgba(71, 39, 10, .18)); transition: transform .18s ease; }
.affiliate-book-cover:hover img { transform: translateY(-3px); }
.affiliate-book-copy { display: flex; flex: 1; flex-direction: column; padding: .9rem .15rem .8rem; }
.affiliate-book-category { width: fit-content; padding: .18rem .46rem; border-radius: 999px; background: #f5e5c6; color: #8a4b13; font-size: .68rem; font-weight: 800; letter-spacing: .04em; }
.affiliate-book-copy h3 { margin: .58rem 0 .46rem; color: #3f2a16; font-family: var(--editor-font); font-size: 1rem; line-height: 1.55; }
.affiliate-book-copy p { margin: 0; color: #66513a; font-size: .79rem; line-height: 1.72; }
.affiliate-book-copy small { margin-top: auto; padding-top: .7rem; color: #8b7355; font-size: .71rem; }
.affiliate-book-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
.affiliate-book-button { display: flex; min-height: 37px; align-items: center; justify-content: center; padding: .45rem .35rem; border-radius: 8px; color: white; font-size: .73rem; font-weight: 800; line-height: 1.3; text-align: center; text-decoration: none; transition: filter .16s ease, transform .16s ease; }
.affiliate-book-button:hover { color: white; filter: brightness(.94); transform: translateY(-1px); }
.affiliate-book-button.rakuten { background: #bf0000; }
.affiliate-book-button.amazon { background: #d88700; }
.affiliate-book-button:focus-visible, .affiliate-book-cover:focus-visible { outline: 3px solid rgba(67, 56, 202, .35); outline-offset: 3px; }

/* ------------------------------------------------------------ タブレット */
@media (max-width: 1199px) {
  /* 横幅が足りないときは右の情報パネルを出さない（JS側でも非表示にしている）。 */
  .info-panel { display: none; }
}

@media (max-width: 980px) {
  .shell-body { grid-template-columns: 210px minmax(0, 1fr) auto; }
  .doc-action span[aria-hidden] { display: none; }
  .status-hint { display: none; }
  .view-switch button span[aria-hidden] { display: none; }
}

/* -------------------------------------------------------------- モバイル */
@media (max-width: 700px) {
  .compact-navbar .nav-menu { display: none; }
  .app-heading { align-items: start; padding: .85rem 1rem .75rem; }
  .app-heading .tool-breadcrumb { display: none; }
  .app-heading h1 { margin-top: 0; }
  .app-heading p { font-size: .78rem; }
  .privacy-chip { display: none; }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

  /* 見出しの高さは文字の折り返しで変わるため、シェルを「100dvh − 決め打ち」で
     固定すると下部ナビにステータスバーが潜り込む。モバイルではシェル自体は
     内容なりの高さにし、エディタ側だけをビューポート基準の高さにする。 */
  .notepad-shell { height: auto; min-height: 0; border-right: 0; border-left: 0; border-radius: 0; }
  .mode-switch { margin-top: .7rem; }
  .mode-switch button { min-width: 78px; padding: .42rem .9rem; }
  .shell-body { grid-template-columns: minmax(0, 1fr); }
  /* flex:1（＝flex-basis:0）のままだと高さ指定より伸長が優先され、
     親の高さが auto になった途端に潰れてしまう。 */
  .workspace { flex: 0 0 auto; height: 56dvh; }

  /* サイドバーはドロワー。3カラムはもちろん2カラムも組まない。
     画面外へずらすだけだとキーボードのTabで見えない一覧に入り込めてしまうため、
     visibilityでも閉じてフォーカス対象から外す。 */
  .sidebar { position: fixed; z-index: 200; top: 0; bottom: calc(53px + env(safe-area-inset-bottom)); left: 0; width: min(300px, 86vw); visibility: hidden; transform: translateX(-100%); transition: transform .18s ease, visibility .18s ease; border-right: 1px solid var(--app-border); }
  .sidebar[data-open="true"] { visibility: visible; transform: translateX(0); box-shadow: 12px 0 32px rgba(15, 23, 42, .2); }

  .doc-bar { flex-wrap: wrap; gap: .45rem .7rem; padding: .5rem .6rem; }
  .doc-identity { flex-basis: 100%; }
  .doc-meta { order: 3; }
  .doc-actions { order: 4; margin-left: auto; }
  .doc-action { padding: .42rem .5rem; }
  /* 項目数が多く、doc-bar基準のabsoluteだと上方向にビューポート外へはみ出して
     頭の項目が見切れていた。ビューポート基準のfixedにし、下部ナビの上で
     max-height + スクロールに収める。 */
  .action-menu { position: fixed; top: auto; bottom: calc(53px + env(safe-area-inset-bottom) + .5rem); right: .5rem; left: .5rem; width: auto; max-height: 60dvh; overflow-y: auto; }
  .view-switch { display: none; }
  .format-bar { display: none; }

  /* ボトムシート。高さを max-height だけで決めると、中身が flex:1（basis:0）の
     ぶん潰れて設定が1行しか見えなくなる。高さを与えて内側をスクロールさせる。
     下部ナビの上に置き、ナビ操作を塞がないようにする。 */
  .settings-panel { top: auto; right: 0; bottom: calc(53px + env(safe-area-inset-bottom)); left: 0; width: 100%; height: 62dvh; border-left: 0; border-top: 1px solid var(--app-border); border-radius: 14px 14px 0 0; box-shadow: 0 -12px 30px rgba(15, 23, 42, .2); }
  .settings-panel-body { padding-bottom: 1.4rem; }
  .modal-card { max-height: 88dvh; }

  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    z-index: 250;
    left: 0;
    right: 0;
    bottom: 0;
    border-top: 1px solid var(--app-border);
    background: white;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: .5rem .3rem .4rem; border: 0; border-top: 2px solid transparent; background: white; color: #64748b; font-size: .66rem; font-weight: 700; }
  .mobile-bottom-nav button[aria-pressed="true"] { border-top-color: var(--app-accent); color: var(--app-accent); }
  body.focus-mode .mobile-bottom-nav { grid-template-columns: 1fr 1fr; }
  body.focus-mode #nav-list, body.focus-mode #nav-settings { display: none; }

  #input-text { padding: 1rem; }
  .vertical-preview { align-items: flex-start; padding: .7rem; }
  .status-bar { gap: .7rem; overflow-x: auto; white-space: nowrap; }
  .install-banner { right: 10px; bottom: calc(66px + env(safe-area-inset-bottom)); gap: .55rem; max-width: calc(100vw - 20px); padding: .6rem .55rem .6rem .7rem; }
  /* トーストの既定位置(bottom:24px)には下部ナビが重なるため底上げする。 */
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); max-width: calc(100vw - 20px); }
  .install-banner-copy small { display: none; }
  .install-banner-copy strong { font-size: .76rem; }
  .feature-section, .help-section { padding: 2.6rem 1rem 0; }
  .feature-grid, .help-section ol, .related-links, .affiliate-book-grid { grid-template-columns: 1fr; }
  .affiliate-book-card { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: .8rem; }
  .affiliate-book-cover { height: 142px; }
  .affiliate-book-cover img { max-height: 132px; }
  .affiliate-book-copy { min-height: 142px; padding: 0; }
  .affiliate-book-actions { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* ------------------------------------------------------------------ 印刷 */
@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: white !important; padding: 0 !important; }
  body > nav, .app-heading, .sidebar, .doc-bar, .format-bar, .info-panel, .status-bar,
  .mobile-bottom-nav, .input-pane, .settings-panel, .modal, .onboarding-modal, #sheet-backdrop,
  .feature-section, .help-section, .faq-section, .related-section, .affiliate-section, .site-footer,
  .toast, .install-banner { display: none !important; }
  /* 「編集」表示のままでもプレビューを印刷できるよう、印刷時は必ず表示する
     （JS側でも印刷直前にページを組み直している）。 */
  .notepad-shell, .shell-body, .editor-panel, .workspace, .preview-pane { display: block !important; width: 100% !important; min-height: 0 !important; height: auto !important; overflow: visible !important; border: 0 !important; box-shadow: none !important; }
  .preview-pane, .vertical-preview { display: block !important; height: auto !important; padding: 0 !important; overflow: visible !important; background-color: white !important; }
  .vertical-preview-page-frame { display: block !important; width: var(--preview-page-width) !important; height: var(--preview-page-height) !important; }
  .vertical-preview-page { display: block !important; width: var(--preview-page-width) !important; height: var(--preview-page-height) !important; min-height: 0 !important; padding: var(--preview-page-padding) !important; overflow: hidden !important; background-color: white !important; color: black !important; box-shadow: none !important; transform: none !important; break-after: page; page-break-after: always; print-color-adjust: exact; zoom: var(--print-page-scale); }
  .vertical-preview-page:last-child { break-after: auto; page-break-after: auto; }
}
