:root {
  --bg: #0f1419; --bg2: #1a2029; --bg3: #242c38; --line: #2f3a48; --ink: #e6ebf0; --muted: #8a97a6;
  --accent: #ff6a1f; --blue: #2f7fc1; --green: #3ec46d; --red: #e0493a; --yellow: #f2b134; --sel: #1e3a5f;
  --font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 13px; color: var(--ink); background: var(--bg); overflow: hidden; }
.hidden { display: none !important; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--bg3); border: 1px solid var(--line); border-radius: 4px; padding: 4px 9px; cursor: pointer; }
button:hover { background: #2d3744; }
button.on { background: var(--sel); border-color: var(--blue); }
button.link { background: none; border: none; color: #9cc4ea; padding: 2px 6px; }
button.link:hover { text-decoration: underline; background: none; }
button.danger { color: #ff9a8f; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; padding: 8px 22px; font-weight: 600; }
.btn.primary:hover { background: #3a8fd4; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; width: 100%; }
label { display: block; margin: 8px 0 4px; color: var(--muted); font-size: 12px; }
label.chk { display: flex; align-items: center; gap: 6px; color: var(--ink); }
label.chk input { width: auto; }
.spacer { flex: 1; }
.error { color: #ff9a8f; min-height: 1.2em; }
.pill { background: var(--sel); border: 1px solid var(--blue); border-radius: 12px; padding: 2px 10px; font-size: 12px; }

/* ログイン */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-box { width: 340px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 28px; }
.login-logo { font-size: 20px; margin-bottom: 16px; }
.login-box .btn { width: 100%; margin-top: 14px; }
.login-box .btn.enter { font-size: 20px; padding: 16px; margin-top: 4px; }
.login-box > .link { display: block; width: 100%; margin-top: 10px; text-align: center; }

/* アプリ全体 */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 18px; height: 46px; padding: 0 16px; background: #000; border-bottom: 1px solid var(--line); }
.brand { font-size: 15px; }
.topnav a { color: #c9d1d8; text-decoration: none; margin-right: 16px; padding: 12px 0; }
.topnav a.active { color: #fff; border-bottom: 2px solid var(--accent); }
.upload-btn { background: var(--bg3); padding: 6px 14px; border-radius: 4px; color: #fff; text-decoration: none; }
.user { color: var(--muted); }
.page { flex: 1; min-height: 0; }

/* ライブラリ */
.library { display: flex; flex-direction: column; }
.upper { display: flex; min-height: 0; height: var(--upper-h, 58%); }
.splitter { height: 6px; background: var(--line); cursor: row-resize; }
.splitter::after { content: '⋯ ダブルクリックで映像に合わせる'; display: block; text-align: center; font-size: 9px; line-height: 6px; color: var(--muted); }
.splitter:hover { background: var(--blue); }
.lower { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.player { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; background: #000; }
.overlay { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: flex-start; gap: 8px; background: rgba(0,0,0,.45); padding: 1px 6px; min-height: 26px; text-shadow: 0 1px 2px #000; }
.overlay.collapsed .overlay-items { display: none; }
.overlay-toggle { background: none; border: none; color: #fff; font-size: 11px; padding: 1px 3px; }
.overlay-items { display: flex; flex-wrap: wrap; gap: 0 16px; }
.overlay-items .item { display: flex; flex-direction: column; }
.overlay-items .k { font-size: 9px; color: #c9d1d8; letter-spacing: .03em; line-height: 1; }
.overlay-items .v { font-size: 13px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.video-wrap { position: relative; flex: 1; min-height: 0; background: #000; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.video-wrap.drawing svg { pointer-events: auto; cursor: crosshair; }
.video-wrap svg .ann-text { pointer-events: auto; cursor: move; }
.video-wrap svg .ann-text:hover rect { stroke: var(--yellow); }
.video-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 15px; }
.controls { position: absolute; left: 0; right: 0; bottom: 22px; z-index: 3; display: flex; align-items: center; gap: 4px; padding: 1px 6px; background: rgba(0,0,0,.45); height: 26px; }
.controls button { background: none; border: none; color: #fff; font-size: 11px; padding: 2px 5px; line-height: 1; display: inline-flex; align-items: center; }
.controls button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.controls button:hover { background: #222; }
.controls button.on { color: var(--yellow); }
.ctl-left, .ctl-mid, .ctl-right { display: flex; align-items: center; gap: 2px; }
.ctl-mid { flex: 1; justify-content: center; }
.ctl-mid .sep { width: 1px; height: 14px; background: #444; margin: 0 6px; }
.ctl-mid #penWidth { width: auto; flex: 0 0 auto; font-size: 11px; padding: 1px 2px; height: 20px; margin-left: 2px; background: #111; color: #ddd; border: 1px solid #444; }
.ctl-mid [data-act] { white-space: nowrap; }
.ctl-mid [data-act] { font-size: 11px; color: #c9d1d8; }
.time { font-variant-numeric: tabular-nums; font-size: 11px; margin-right: 4px; }
#speed { width: auto; padding: 0 2px; font-size: 11px; height: 20px; }
.clipnav { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; align-items: center; padding: 0 8px 2px; background: rgba(0,0,0,.45); height: 22px; }
.clipnav button { background: none; border: none; color: #fff; font-size: 15px; padding: 2px 7px; }
.clipnav button.on { color: var(--yellow); }

/* タイムライン：緑=開始 / 赤=終了 / 白=現在位置（ドラッグ可） */
.timeline { position: relative; flex: 1; height: 20px; margin-left: 0; cursor: pointer; touch-action: none; user-select: none; }
.tl-track { position: absolute; left: 0; right: 0; top: 8px; height: 5px; background: #3a3a3a; border-radius: 3px; }
.tl-range { position: absolute; top: 8px; height: 5px; background: #6d6d6d; }
.tl-marks { position: absolute; inset: 0; pointer-events: none; }
.tl-mark { position: absolute; top: 0px; width: 9px; height: 9px; margin-left: -4px; border-radius: 50%; background: var(--yellow); pointer-events: auto; cursor: pointer; }
.tl-mark.comment { background: #9cc4ea; top: 13px; width: 7px; height: 7px; margin-left: -3px; }
.tl-start, .tl-end { position: absolute; top: 3px; width: 7px; height: 15px; border-radius: 3px; cursor: ew-resize; }
.tl-start { background: var(--green); margin-left: -4px; }
.tl-end { background: var(--red); margin-left: -4px; }
.tl-cursor { position: absolute; top: 1px; width: 4px; height: 19px; margin-left: -2px; background: #fff; border-radius: 2px; cursor: grab; box-shadow: 0 0 3px #000; }
.timeline.scrubbing .tl-cursor { cursor: grabbing; background: var(--yellow); }
.timeline.scrubbing .tl-cursor::after { content: ""; position: absolute; inset: -12px; }

/* 右パネル */
.side { width: 300px; flex: none; display: flex; flex-direction: column; background: var(--bg2); border-left: 1px solid var(--line); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: none; border-radius: 0; padding: 9px 0; color: var(--muted); }
.tabs button.active { color: #fff; background: var(--blue); }
.tab-body { flex: 1; min-height: 0; overflow: auto; overflow-x: hidden; padding: 8px; }
.tree-tools { display: flex; justify-content: flex-end; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree > ul { padding-left: 0; }
.tree li { margin: 1px 0; }
.tree .node { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 3px; white-space: nowrap; min-width: 0; }
.tree .node .title { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tree .node:hover { background: var(--bg3); }
.tree .node:hover .actions { visibility: visible; }
.tree .actions { visibility: hidden; margin-left: auto; display: flex; gap: 2px; }
.tree .actions button { background: none; border: none; color: var(--muted); padding: 0 4px; font-size: 12px; }
.tree .actions button:hover { color: #fff; }
.tree .tog { width: 14px; color: var(--muted); cursor: pointer; text-align: center; }
.tree .cat { font-weight: 700; }
.tree .no { color: var(--muted); font-size: 11px; margin-left: 2px; }
.tree .per { color: var(--muted); }
.tree .game { cursor: pointer; }
.tree .game.selected { background: var(--sel); }
.tree .game input { margin: 0; }
.tree .status { font-size: 11px; color: var(--yellow); }
.tree .status.error { color: #ff9a8f; }
.tree .count { font-size: 11px; color: var(--muted); }

.comments .c { border-bottom: 1px solid var(--line); padding: 6px 2px; }
.comments .meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; }
.comments .meta .t { color: #9cc4ea; cursor: pointer; }
.comments .meta button { margin-left: auto; }
.comment-form { margin-top: 10px; }
.comment-form .btn { margin-top: 6px; }
.report-tools { display: flex; gap: 8px; }
.report-tools label { flex: 1; }
.report table { border-collapse: collapse; width: 100%; margin-top: 10px; font-size: 12px; }
.report th, .report td { border: 1px solid var(--line); padding: 3px 6px; text-align: right; }
.report th:first-child, .report td:first-child { text-align: left; }
.report th { background: var(--bg3); }
.playlists .pl { padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 8px; }
.playlists .pl:hover { background: var(--bg3); }
.playlists .pl small { color: var(--muted); }

/* データ表 */
.gridbar { display: flex; align-items: center; gap: 6px; padding: 3px 8px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.gridbar .count { color: var(--muted); margin-right: 6px; }
.dropdown { position: relative; }
.menu { position: absolute; top: 100%; left: 0; z-index: 20; min-width: 260px; max-height: 60vh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.5); padding: 6px; }
.menu h4 { margin: 6px 4px 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.menu .mi { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 4px; cursor: pointer; }
.menu .mi:hover { background: var(--bg3); }
.menu .mi.active { background: var(--sel); }
.menu .mi small { color: var(--muted); margin-left: auto; }
.menu .mi input { width: auto; margin: 0; }
.menu .mi button { padding: 0 5px; background: none; border: none; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.grid-wrap { flex: 1; overflow: auto; min-height: 0; }
.grid { border-collapse: separate; border-spacing: 0; font-size: 12px; min-width: 100%; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0 5px; height: 21px; line-height: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.grid th { position: sticky; top: 0; z-index: 2; background: var(--bg3); text-align: left; font-weight: 600; font-size: 11px; color: #c9d1d8; }
.grid th .rz { position: absolute; right: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; }
.grid th[data-col] { cursor: pointer; user-select: none; }
.grid th[data-col]:hover { color: #fff; background: #2a3440; }
.grid th.sorted { color: var(--yellow); }
.grid th .sortmark { margin-left: 3px; font-size: 9px; }
.grid th .sortmark small { font-size: 8px; vertical-align: super; margin-left: 1px; }
.pill.sort { border-color: var(--yellow); background: #2a2416; color: #e6d9a8; }
.pill.sort .x { background: none; border: none; color: var(--yellow); padding: 0 2px; font-size: 12px; cursor: pointer; }
.grid th.handle, .grid td.handle { width: 58px; text-align: center; padding: 0 2px; position: sticky; left: 0; z-index: 1; background: var(--bg2); }
.grid th.handle { z-index: 3; background: var(--bg3); }
.grid td.handle button { background: none; border: none; color: var(--muted); padding: 0 3px; font-size: 12px; }
.grid td.handle button:hover { color: #fff; }
.grid td.handle .drag { cursor: grab; }
.grid td.handle input { width: auto; margin: 0 2px; }
.grid tr.selected td { background: var(--sel); }
.grid tr.checked td.handle { background: #26313f; }
.grid tr:hover td { background: #1f2733; }
.grid tr.selected:hover td { background: var(--sel); }
.grid td.num { text-align: right; }
.grid td.editing { padding: 0; }
.grid td.editing input, .grid td.editing select { height: 21px; border-radius: 0; border: 2px solid var(--blue); background: var(--bg2); }
.grid.edit-mode td.cell { cursor: text; }
.grid.edit-mode td.cell:hover { box-shadow: inset 0 0 0 1px var(--blue); }
.grid tr.drag-over td { border-top: 2px solid var(--yellow); }
.grid td .badge { font-size: 10px; color: var(--yellow); margin-left: 4px; }

/* アップロード・設定 */
.upload, .settings { overflow: auto; padding: 30px 20px; }
.upload-box { max-width: 640px; margin: 0 auto 30px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 22px 28px; }
.upload-box h2 { margin: 0 0 10px; font-size: 17px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dropzone { margin-top: 16px; border: 2px dashed var(--line); border-radius: 8px; padding: 28px; text-align: center; }
.dropzone.over { border-color: var(--blue); background: #141d28; }
.dropzone p { font-size: 16px; margin: 12px 0 4px; }
.dropzone small { color: var(--muted); }
.dropzone.small { padding: 14px; display: flex; gap: 12px; align-items: center; justify-content: center; }
.upload-list .up { margin-top: 10px; background: var(--bg3); border-radius: 6px; padding: 8px 12px; }
.upload-list .bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.upload-list .bar i { display: block; height: 100%; background: var(--blue); width: 0; transition: width .3s; }
.upload-list .bar.conv i { background: var(--green); }
.upload-list .st { font-size: 12px; color: var(--muted); margin-top: 4px; }
.imp-preview { overflow: auto; margin-top: 10px; max-height: 180px; }
.imp-preview table { border-collapse: collapse; font-size: 11px; }
.imp-preview th, .imp-preview td { border: 1px solid var(--line); padding: 2px 6px; white-space: nowrap; }
table.simple { border-collapse: collapse; width: 100%; font-size: 12.5px; margin-bottom: 10px; }
table.simple th, table.simple td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; }
table.simple th { color: var(--muted); font-weight: 600; font-size: 11px; }
table.simple input[type=text] { padding: 3px 6px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 110px; }
.inline-form label { margin: 0; }

/* モーダル・トースト */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 20px 24px; min-width: 360px; max-width: 90vw; max-height: 85vh; overflow: auto; }
.modal-box h3 { margin: 0 0 12px; font-size: 15px; }
.modal-box .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-box .cols { columns: 2; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #2b3542; color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 200; box-shadow: 0 4px 14px rgba(0,0,0,.5); }
.toast.err { background: #6b2b24; }

/* 書き込みの表示／非表示ボタン（目のアイコン＋文字。非表示のときは斜線が入って薄くなる） */
.controls .ann-btn { gap: 4px; color: var(--yellow); }
.controls .ann-btn span { font-size: 11px; }
.controls .ann-btn svg .off { display: none; }
.controls .ann-btn.off { color: #8a97a6; }
.controls .ann-btn.off svg .off { display: block; }
.player.ann-hidden .tl-mark { opacity: .35; }

/* 画角バー：再生する画角のチェック + 切替ボタン */
.anglebar .pick-label { font-size: 10px; color: var(--muted); margin-right: 2px; letter-spacing: .05em; }
.anglebar .ang { display: inline-flex; align-items: center; gap: 2px; }
.anglebar .ang.picked button:not(.on) { border-color: rgba(63,195,111,.6); }
.anglebar label.pick { display: inline-flex; margin: 0; padding: 2px; cursor: pointer; }
.anglebar label.pick input { width: 14px; height: 14px; margin: 0; accent-color: var(--green); cursor: pointer; }
.anglebar .hint { white-space: nowrap; }
/* 狭い PC 画面では操作バーの文字を減らして右端が隠れないようにする */
@media (min-width: 1001px) and (max-width: 1300px) {
  .controls .ann-btn span, .anglebar .hint { display: none; }
  .ctl-mid [data-act] { font-size: 10.5px; padding: 2px 4px; }
  .ctl-mid .sep { margin: 0 3px; }
}

/* 全画面：映像だけ */
.player:fullscreen { width: 100vw; height: 100vh; background: #000; }
.gridbar button { padding: 2px 8px; font-size: 12px; }

@media (max-width: 900px) {
  .side { width: 280px; }
  .overlay-items .v { font-size: 14px; }
}

/* ===== 別冊（フォルダ・年度・画角）で追加 ===== */
.muted { color: var(--muted); }
.warn { color: var(--yellow); }
.tree-head { display: flex; flex-direction: column; gap: 6px; padding: 2px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.tree-year { display: flex; align-items: center; gap: 6px; }
.tree-year select { width: auto; flex: 1; padding: 4px 6px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.seg button { flex: 1; border: none; border-radius: 0; background: var(--bg2); padding: 5px 0; font-size: 12px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--blue); color: #fff; }
.tree-search { display: flex; gap: 4px; align-items: center; }
.tree-search input { padding: 4px 8px; font-size: 12px; }
.tree-search .link { white-space: nowrap; }
.tree .node.folder .fname { font-weight: 600; }
.tree .node.folder { cursor: default; }
.tree .node.folder.new { background: var(--bg3); }
.tree .inline-edit { padding: 2px 6px; font-size: 12px; width: auto; flex: 1; min-width: 0; }
.tree .side { width: auto; flex: 0 0 auto; display: inline-block; flex-direction: row; font-size: 10px; border-radius: 3px; padding: 0 4px; background: var(--bg3); color: #c9d1d8; }
.tree .side.OFF { background: #3a2a1a; color: #ffb27a; }
.tree .side.DEF { background: #1a2e3a; color: #7ec8ff; }
.tree .side.KICK { background: #2a3a1a; color: #b6f27a; }
.tree .side.dim { opacity: .6; }
.tree .ang, .tree .link-mark { font-size: 11px; color: var(--muted); }
.tree .node.drop-into { outline: 2px solid var(--blue); background: var(--sel); }
.tree .node.drop-before { box-shadow: inset 0 3px 0 var(--yellow); }
.tree .node.drop-after { box-shadow: inset 0 -3px 0 var(--yellow); }
.tree .node.drop-into.copy, .seg button.drop-into.copy { outline-color: #3f9a50; background: #1e3324; }
.tree .node.drop-into.copy::after { content: 'コピー'; font-size: 10px; color: #b6f27a; margin-left: 6px; }
.tree .node.drop-into.files { outline-color: var(--yellow); background: #2a2416; }
.tree .node.drop-into.files::after { content: 'ここにアップロード'; font-size: 10px; color: var(--yellow); margin-left: 6px; }
.seg button.drop-into { outline: 2px solid var(--blue); }
.tree-hint { font-size: 10px; color: var(--muted); margin: 2px 0 4px; line-height: 1.3; }
.tree .node.game .title { flex: 1; }
.tree .actions button[data-act=menu] { font-weight: 700; }
.ctxmenu { position: fixed; z-index: 300; min-width: 220px; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.6); padding: 4px; }
.ctxmenu button { display: block; width: 100%; text-align: left; background: none; border: none; border-radius: 4px; padding: 6px 10px; font-size: 12.5px; }
.ctxmenu button:hover:not(:disabled) { background: var(--sel); }
.ctxmenu button:disabled { color: #555; cursor: default; }
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.order-list { list-style: none; padding: 0; margin: 0; }
.order-list li { display: flex; justify-content: space-between; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.modal-box.wide { min-width: 560px; }
.modal-box .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-box .opts { margin-top: 10px; }
/* 画角バー */
.anglebar { position: absolute; left: 0; bottom: 50px; z-index: 3; display: flex; gap: 3px; align-items: center; padding: 2px 6px; background: rgba(0,0,0,.45); border-radius: 0 6px 0 0; }
.anglebar button { background: none; border: 1px solid #555; color: #ddd; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.anglebar button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.anglebar button.na { opacity: .45; }
.anglebar .hint { font-size: 10px; color: var(--muted); margin-left: 4px; }
.anglebar .arrow { color: var(--muted); font-size: 11px; margin: 0 2px; }
.anglebar button.cycle { border-style: dashed; }
.anglebar button.cycle.on { background: #2f6b3a; border-color: #3f9a50; border-style: solid; }
.tl-range.override { background: #8a6d2f; }
.overlay-items .v.note { color: var(--yellow); font-weight: 600; }
.grid th.angles, .grid td.angles { width: 46px; text-align: center; letter-spacing: 1px; color: var(--blue); }
/* フォルダ選択 */
.fpicker { border: 1px solid var(--line); border-radius: 6px; background: var(--bg); margin: 4px 0 10px; }
.fp-head { display: flex; gap: 8px; align-items: center; padding: 6px; border-bottom: 1px solid var(--line); }
.fp-head select { width: auto; padding: 4px 6px; }
.fp-head .seg { flex: 1; }
.fp-tree { max-height: 220px; overflow: auto; padding: 4px; }
.fp-row { display: flex; align-items: center; gap: 4px; padding: 3px 4px; border-radius: 3px; cursor: pointer; white-space: nowrap; }
.fp-row:hover { background: var(--bg3); }
.fp-row.selected { background: var(--sel); }
.fp-row .tog { width: 14px; color: var(--muted); text-align: center; }
.fp-row .fp-add { visibility: hidden; margin-left: auto; }
.fp-row:hover .fp-add { visibility: visible; }
.fp-row input { padding: 2px 6px; width: auto; flex: 1; }
.folder-label { color: #fff; }
/* アップロード */
.upload-box h3.step { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 22px 0 6px; }
.upload-box h3.step .no { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 50%; background: var(--blue); color: #fff; font-size: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.modes { display: flex; gap: 18px; margin: 6px 0; }
.upgroups { margin-top: 12px; }
.upgroup { background: var(--bg3); border-radius: 6px; padding: 8px 12px; margin-top: 8px; }
.upgroup-head { display: flex; align-items: center; gap: 8px; }
.upgroup-head select, .upgroup-head input { width: auto; padding: 3px 6px; }
.upgroup-head .badge { background: var(--blue); color: #fff; border-radius: 3px; padding: 0 6px; font-size: 11px; }
.upgroup-head small { color: var(--muted); }
.upgroup-head [data-removegroup] { margin-left: auto; }
.upfiles { margin: 6px 0 0; padding-left: 22px; font-size: 12px; color: #c9d1d8; }
.upfiles li small { color: var(--muted); margin-left: 6px; }
.upgroup .chk { margin-top: 6px; font-size: 12px; }
#upStartBtn { margin-right: 10px; }

/* アップロード：画角の枠と突き合わせ表 */
#pageUpload .upload-box { max-width: 760px; }   /* 画角3枠が横に並ぶ幅 */
.upslots { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 10px; }
.upslot .chk { font-size: 11.5px; margin-top: 8px; align-items: flex-start; line-height: 1.35; }
.upslot .chk input { margin-top: 2px; }
.upslot { background: var(--bg3); border-radius: 8px; padding: 8px 10px; border: 1px solid transparent; }
.upslot.has { border-color: rgba(63,195,111,.45); }
.upslot.warn { border-color: var(--yellow); }
.upslot-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.upslot-head select, .upslot-head input { width: auto; flex: 1; min-width: 80px; padding: 3px 6px; }
.upslot-head .badge { background: var(--blue); color: #fff; border-radius: 3px; padding: 0 6px; font-size: 11px; white-space: nowrap; }
.upslot-drop { border: 2px dashed var(--line); border-radius: 6px; padding: 10px 8px; text-align: center; margin-top: 8px; min-height: 84px; font-size: 12px; }
.upslot-drop.over { border-color: var(--blue); background: #141d28; }
.upslot-drop .names { font-size: 11px; margin: 4px 0; word-break: break-all; }
.upslot-drop .acts { display: flex; justify-content: center; gap: 2px; flex-wrap: wrap; }
.upslot .upfiles { max-height: 180px; overflow: auto; }
.slot-tools { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.slot-tools .dropzone.small { flex: 1; margin-top: 0; padding: 8px 12px; }
.upcheck { margin-top: 14px; }
.upcheck h4 { margin: 0 0 6px; font-size: 13px; }
.upcheck .sum { font-size: 12px; margin: 3px 0; }
.upcheck .sum.warn { color: var(--yellow); }
.upcheck .sum.ok { color: var(--green); }
.upcheck .sum.muted { color: var(--muted); }
.upcheck .tools { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.upcheck .tools .chk { font-size: 12px; }
.upcheck .box { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.upcheck table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
.upcheck th, .upcheck td { border-bottom: 1px solid var(--line2); padding: 3px 6px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.upcheck th { position: sticky; top: 0; background: var(--bg3); color: var(--muted); font-weight: 600; font-size: 11px; }
.upcheck th small { font-weight: 400; }
.upcheck td:first-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.upcheck tr.problem td:first-child { color: var(--yellow); font-weight: 700; }
.upcheck td.miss { background: rgba(226,81,63,.22); color: #ff9a8f; font-weight: 600; }
.upcheck td.flag { background: rgba(243,181,58,.18); color: #f1dfb0; }
.upload-list .up.warn { border-left: 3px solid var(--yellow); }

/* Excel 取込：表へのドロップ、プレビューの空列 */
.grid-wrap.over { box-shadow: inset 0 0 0 3px var(--blue); }
.imp-preview th.dim { color: #4f5a68; font-weight: 400; }
.modal-box .imp-preview { max-height: 220px; }
.modal-box .dropzone.small { margin-top: 6px; }

/* プレー入力モード（別冊 §4.3） */
.playinput { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 3px 10px; font-size: 12px; background: #2a2416; border-bottom: 1px solid #6b5a1f; color: #e6d9a8; }
.playinput .mode { color: var(--yellow); font-weight: 600; }
.playinput kbd { font-family: inherit; font-size: 11px; background: #111; border: 1px solid #555; border-radius: 3px; padding: 0 4px; color: #fff; }
.playinput label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.playinput span { white-space: nowrap; }
.playinput select { width: auto; font-size: 12px; padding: 1px 4px; }
.playinput .spacer { flex: 1; }
.playinput button { padding: 1px 8px; font-size: 12px; }
.gridbar #playInputBtn.on { background: var(--yellow); color: #111; border-color: var(--yellow); }
.grid td.draft { color: var(--muted); font-style: italic; }
/* 手動同期ダイアログ（別冊 §12.7） */
.sync-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0; }
.sync-pane video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 4px; display: block; cursor: pointer; }
.sync-title { font-weight: 600; margin-bottom: 4px; }
.sync-range { width: 100%; margin: 6px 0 2px; }
.sync-ctl { display: flex; align-items: center; gap: 4px; }
.sync-ctl button { padding: 2px 8px; font-size: 12px; }
.sync-ctl .time { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.sync-offset { margin: 6px 0; }
.modal-box.wide:has(.sync-grid) { min-width: 860px; max-width: 95vw; }


/* ===================================================================
   2026-08-28 見た目の調整：色数は増やさず、余白・角丸・境界線・ホバー・文字組みを整える
   =================================================================== */
:root {
  --bg: #0b1016; --bg2: #141a22; --bg3: #1d2530; --line: #273140; --line2: rgba(255,255,255,.06);
  --ink: #e9eef4; --muted: #8592a3; --blue: #3b8ad8; --blue2: #2c6fb3; --sel: #1a3253;
  --yellow: #f3b53a; --green: #3fc36f; --red: #e2513f;
  --radius: 6px; --shadow: 0 10px 30px rgba(0,0,0,.45), 0 1px 0 rgba(255,255,255,.04) inset;
  --font: -apple-system, "Inter", "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}
html { -webkit-font-smoothing: antialiased; }
body { font-size: 13px; letter-spacing: .005em; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b3542; border: 2px solid var(--bg2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #3a4656; }
::selection { background: rgba(59,138,216,.45); }

/* ボタン・入力 */
button { border-radius: var(--radius); border-color: var(--line); background: var(--bg3); transition: background .12s, border-color .12s, color .12s, box-shadow .12s; }
button:hover { background: #26303d; border-color: #35414f; }
button:active { transform: translateY(.5px); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(59,138,216,.55); }
button.on { background: var(--sel); border-color: var(--blue2); color: #fff; }
button.link { color: #8fbdea; }
button.link:hover { color: #b9d7f5; text-decoration: none; background: rgba(143,189,234,.08); border-radius: 4px; }
.btn.primary { background: linear-gradient(180deg, #4393e0, #2f78c2); border-color: #2a6bb0; box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 2px 6px rgba(0,0,0,.35); letter-spacing: .02em; }
.btn.primary:hover { background: linear-gradient(180deg, #4d9be6, #357fc9); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea { background: #0f151c; border-color: var(--line); border-radius: var(--radius); transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
label { letter-spacing: .02em; }
.pill { background: rgba(59,138,216,.12); border-color: rgba(59,138,216,.5); color: #cfe3f7; font-weight: 500; }
.pill.sort { background: rgba(243,181,58,.1); border-color: rgba(243,181,58,.5); color: #f1dfb0; }

/* ログイン */
.login { background: radial-gradient(1200px 600px at 50% -10%, #17202c 0%, var(--bg) 60%); }
.login-box { border-radius: 12px; box-shadow: var(--shadow); padding: 30px 30px 24px; }
.login-logo { font-size: 21px; letter-spacing: .01em; }

/* 上部バー */
.topbar { height: 44px; background: linear-gradient(180deg, #0d1218, #0a0e13); border-bottom: 1px solid #1c2430; gap: 14px; }
.brand { font-size: 14.5px; letter-spacing: .02em; }
.brand b { font-weight: 700; }
.topnav a { margin-right: 4px; padding: 6px 11px; border-radius: 6px; font-size: 13px; color: #aab6c4; transition: background .12s, color .12s; }
.topnav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.topnav a.active { color: #fff; background: rgba(255,255,255,.08); border-bottom: none; }
.upload-btn { background: rgba(59,138,216,.15); border: 1px solid rgba(59,138,216,.5); color: #d6e8fa; border-radius: var(--radius); padding: 5px 12px; font-size: 12.5px; transition: background .12s; }
.upload-btn:hover { background: rgba(59,138,216,.3); }
.user { font-size: 12px; }

/* 分割線 */
.splitter { height: 7px; background: var(--bg2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.splitter::after { line-height: 5px; color: #5c6877; }
.splitter:hover { background: var(--sel); }

/* プレイヤー：帯はグラデーションで映像に溶け込ませる */
.overlay { background: linear-gradient(180deg, rgba(0,0,0,.6), rgba(0,0,0,.25) 80%, transparent); padding: 3px 8px 6px; min-height: 30px; }
.overlay-items { gap: 0 18px; }
.overlay-items .k { color: #aab6c4; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.overlay-items .v { font-size: 13.5px; }
.controls { background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,.6)); height: 28px; bottom: 22px; gap: 2px; }
.controls button { border-radius: 5px; padding: 3px 6px; color: #e6ebf0; }
.controls button:hover { background: rgba(255,255,255,.12); }
.ctl-mid .sep { background: rgba(255,255,255,.18); }
.ctl-mid #penWidth, #speed { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); border-radius: 5px; color: #e6ebf0; }
.clipnav { background: rgba(0,0,0,.6); height: 22px; }
.tl-track { background: rgba(255,255,255,.18); height: 4px; top: 8px; border-radius: 2px; }
.tl-range { background: rgba(255,255,255,.45); height: 4px; top: 8px; border-radius: 2px; }
.tl-range.override { background: rgba(243,181,58,.7); }
.tl-start, .tl-end { width: 6px; height: 14px; top: 3px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.6); }
.tl-cursor { width: 3px; height: 18px; top: 1px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.7), 0 0 6px rgba(255,255,255,.35); }
.tl-mark { box-shadow: 0 0 0 1px rgba(0,0,0,.7); }
.anglebar { background: rgba(0,0,0,.55); border-radius: 0 8px 0 0; padding: 3px 8px; gap: 4px; backdrop-filter: blur(6px); }
.anglebar button { border-color: rgba(255,255,255,.22); color: #e6ebf0; border-radius: 11px; padding: 2px 9px; }
.anglebar button:hover { background: rgba(255,255,255,.1); }
.anglebar button.on { background: var(--blue); border-color: var(--blue); }
.anglebar button.cycle.on { background: #2b6b3d; border-color: #3f9a50; }
.video-empty { font-size: 14px; letter-spacing: .02em; }

/* 右パネル */
.side { background: var(--bg2); border-left: 1px solid var(--line); }
.tabs { border-bottom: 1px solid var(--line); background: #10161e; }
.tabs button { padding: 10px 0; font-size: 12.5px; color: var(--muted); position: relative; letter-spacing: .02em; }
.tabs button:hover { color: #dbe3ec; background: rgba(255,255,255,.03); }
.tabs button.active { background: none; color: #fff; }
.tabs button.active::after { content: ''; position: absolute; left: 18%; right: 18%; bottom: -1px; height: 2px; background: var(--blue); border-radius: 2px; }
.tab-body { padding: 10px; }
.tree-head { gap: 7px; padding: 0 0 9px; }
.tree-year select { font-weight: 600; background: #0f151c; }
.seg { border-radius: 7px; background: #0f151c; padding: 2px; gap: 2px; border-color: var(--line); }
.seg button { background: transparent; border-radius: 5px; padding: 4px 0; color: var(--muted); }
.seg button + button { border-left: none; }
.seg button:hover { color: #dbe3ec; background: rgba(255,255,255,.04); }
.seg button.on { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.tree-search input { background: #0f151c; }
.tree-hint { color: #5f6b7a; }
.tree .node { padding: 3px 6px; border-radius: 5px; gap: 6px; }
.tree .node:hover { background: rgba(255,255,255,.045); }
.tree .node.folder .fname { font-weight: 600; color: #dfe6ee; }
.tree .tog { color: #5f6b7a; }
.tree .game.selected { background: var(--sel); box-shadow: inset 2px 0 0 var(--blue); }
.tree .side { font-weight: 600; letter-spacing: .04em; border-radius: 4px; padding: 1px 5px; line-height: 14px; }
.tree .side.OFF { background: rgba(255,140,60,.16); color: #ffb27a; }
.tree .side.DEF { background: rgba(80,180,255,.14); color: #86caff; }
.tree .side.KICK { background: rgba(160,230,90,.14); color: #bdf08a; }
.tree .count { background: rgba(255,255,255,.06); border-radius: 9px; padding: 0 6px; line-height: 15px; font-variant-numeric: tabular-nums; }
.tree .actions button { border-radius: 4px; }
.tree .actions button:hover { background: rgba(255,255,255,.08); }
.comments .c { border-bottom-color: var(--line2); padding: 8px 2px; }
.playlists .pl { border-bottom-color: var(--line2); border-radius: 5px; }

/* データ表 */
.gridbar { padding: 4px 10px; gap: 6px; background: #10161e; }
.gridbar button { border-radius: 5px; padding: 3px 9px; }
.gridbar .count { font-variant-numeric: tabular-nums; }
.grid { font-size: 12px; }
.grid th, .grid td { border-right-color: var(--line2); border-bottom-color: var(--line2); padding: 0 6px; height: 22px; line-height: 22px; }
.grid th { background: #161d27; color: #aab6c4; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.grid th.handle { background: #161d27; }
.grid td.handle { background: #121820; }
.grid th[data-col]:hover { background: #1b2430; color: #fff; }
.grid th.sorted { color: var(--yellow); }
.grid tr:hover td { background: #171e28; }
.grid tr.selected td { background: var(--sel); }
.grid tr.selected td.handle { box-shadow: inset 2px 0 0 var(--blue); }
.grid tr.selected:hover td { background: #1d3a5f; }
.grid td.num { font-variant-numeric: tabular-nums; }
.grid td.editing input, .grid td.editing select { height: 22px; border: 1.5px solid var(--blue); background: #0f151c; }
.grid.edit-mode td.cell:hover { box-shadow: inset 0 0 0 1px rgba(59,138,216,.6); }
.playinput { background: #211d12; border-bottom-color: #4a3f18; }

/* メニュー・ダイアログ・トースト */
.menu, .ctxmenu { border-radius: 8px; box-shadow: var(--shadow); background: #171e28; border-color: #2b3542; padding: 5px; }
.menu .mi, .ctxmenu button { border-radius: 5px; }
.menu .mi:hover, .ctxmenu button:hover:not(:disabled) { background: rgba(59,138,216,.18); }
.menu h4 { text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
.modal { background: rgba(5,8,12,.6); backdrop-filter: blur(3px); }
.modal-box { border-radius: 12px; box-shadow: var(--shadow); padding: 22px 26px; border-color: #2b3542; }
.modal-box h3 { font-size: 15px; letter-spacing: .01em; margin-bottom: 14px; }
.modal-box .actions { gap: 8px; margin-top: 18px; }
.modal-box .actions .btn.danger, .modal-box .actions button.danger { color: #ff9a8f; }
.toast { border-radius: 999px; padding: 9px 18px; background: rgba(28,36,46,.95); border: 1px solid #34404e; box-shadow: 0 8px 24px rgba(0,0,0,.5); backdrop-filter: blur(6px); font-size: 12.5px; }
.toast.err { background: rgba(96,36,30,.95); border-color: #7a3a32; }

/* アップロード・設定 */
.upload-box { border-radius: 12px; box-shadow: var(--shadow); }
.upload-box h2 { font-size: 16px; letter-spacing: .01em; }
.dropzone { border-radius: 10px; border-color: #34404e; transition: background .12s, border-color .12s; }
.dropzone:hover { background: rgba(255,255,255,.02); }
.upgroup, .upload-list .up { border-radius: 8px; }
table.simple th { text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; }
table.simple th, table.simple td { border-bottom-color: var(--line2); }
.fpicker { border-radius: 8px; }
.fp-row { border-radius: 5px; }
.fp-row.selected { background: var(--sel); box-shadow: inset 2px 0 0 var(--blue); }
/* テキストの大きさ選択（ダイアログ） */
.seg.sizes { display: inline-flex; width: auto; margin-left: 8px; vertical-align: middle; }
.seg.sizes button { padding: 3px 12px; }


/* ===================================================================
   スマホ・タブレット対応
   - 幅 1000px 以下：操作バー・タイムラインを映像の下に固定配置（指で押せる大きさ）
   - タブレット（761〜1000px）：PC と同じ左右配置のまま、上段の高さは映像に合わせる
   - スマホ（760px 以下・横向きは高さ 500px 以下）：映像の下は「表」か「パネル」を下タブで切替
   =================================================================== */
.mtabs, .m-only, .controls .m-only, .gridbar .m-only { display: none; }
@supports (height: 100dvh) { .app { height: 100dvh; } }

/* ---------- 幅 1000px 以下：共通 ---------- */
@media (max-width: 1000px) {
  /* 上部バー：折り返さない */
  .topbar { gap: 8px; padding: 0 12px; }
  .brand { white-space: nowrap; flex: none; }
  .topnav { display: flex; gap: 0; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { margin: 0; padding: 6px 8px; font-size: 13px; white-space: nowrap; flex: none; }
  .topbar .spacer { display: none; }
  .upload-btn { display: none; }               /* ナビの「アップロード」で代用 */
  .user { white-space: nowrap; flex: none; }
  .user #userName { display: none; }
  .user .link { font-size: 12px; padding: 6px 4px; }

  /* プレイヤー：映像は 16:9 で上に、操作は下に固定 */
  .video-wrap { flex: none; aspect-ratio: 16 / 9; max-height: 42vh; }
  .video-empty { font-size: 13px; padding: 0 16px; text-align: center; }
  .overlay { padding: 2px 8px 6px; min-height: 26px; }
  .overlay-items { gap: 0 12px; }
  .overlay-items .v { font-size: 13px; }
  .overlay-toggle { font-size: 12px; padding: 2px 6px; }

  .anglebar, .controls, .clipnav { flex: none; }   /* 上段が足りなくても操作部は潰さない（高さは fitUpper が合わせる） */
  .tree-search input { width: auto; flex: 1; min-width: 0; }
  /* 操作バー：3〜4段（再生系 / 時間・速度・全画面 / 書き込み / 切り出し） */
  .controls { position: static; height: auto; flex-wrap: wrap; padding: 4px 6px 2px; gap: 2px; background: #0d1218; border-top: 1px solid var(--line); }
  .controls button { min-width: 34px; min-height: 32px; font-size: 13px; justify-content: center; padding: 4px 6px; }
  .controls button svg { width: 18px; height: 18px; }
  .ctl-left { order: 0; width: 100%; justify-content: space-between; }
  .ctl-right { order: 1; width: 100%; justify-content: flex-end; gap: 6px; }
  .ctl-right .time { margin-right: auto; font-size: 12px; padding-left: 4px; }
  .ctl-mid { order: 2; width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 2px; padding-bottom: 2px; }
  .ctl-mid > * { flex: none; }
  .ctl-mid .sep { display: none; }
  .ctl-mid [data-tool=undo] { font-size: 0; }
  .ctl-mid [data-tool=undo]::before { content: '↶'; font-size: 18px; }
  .ctl-mid [data-act] { flex: 1 1 auto; font-size: 12.5px; border: 1px solid rgba(255,255,255,.18); margin-top: 2px; }
  .ctl-mid #penWidth, #speed { height: 28px; font-size: 12px; padding: 0 4px; }
  .anglebar { position: static; border-radius: 0; background: #0d1218; padding: 4px 8px; backdrop-filter: none; overflow-x: auto; scrollbar-width: none; }
  .anglebar::-webkit-scrollbar { display: none; }
  .anglebar button { min-height: 28px; padding: 3px 11px; font-size: 12px; white-space: nowrap; }
  .anglebar { flex-wrap: wrap; row-gap: 4px; overflow: visible; }
  .anglebar label.pick { padding: 6px 4px; }
  .anglebar label.pick input { width: 20px; height: 20px; }
  .anglebar .hint { display: none; }

  /* タイムライン：太く・つまみを大きく */
  .clipnav { position: static; height: 36px; padding: 0 14px; background: #0d1218; border-bottom: 1px solid var(--line); }
  .timeline { height: 32px; }
  .tl-track, .tl-range { top: 14px; height: 4px; }
  .tl-start, .tl-end { top: 7px; height: 18px; width: 8px; margin-left: -4px; }
  .tl-cursor { top: 5px; height: 22px; width: 4px; margin-left: -2px; }
  .tl-cursor::after, .tl-start::after, .tl-end::after { content: ''; position: absolute; inset: -8px -12px; }
  .tl-mark { top: 2px; }
  .tl-mark.comment { top: 22px; }

  /* 全画面：映像を目一杯に、操作バー（画角・次のプレー・5秒送り・タイムライン）は下に残す
     .m-full はスマホ用にアプリ側で画面いっぱいに広げたもの（iPhone は要素の全画面が使えない） */
  .player.m-full { position: fixed; inset: 0; z-index: 50; width: auto; height: 100vh; height: 100dvh; }
  .player:fullscreen .video-wrap, .player.m-full .video-wrap { aspect-ratio: auto; max-height: none; flex: 1; min-height: 0; }
  .player.m-full .clipnav { padding-bottom: env(safe-area-inset-bottom); height: auto; min-height: 36px; }
  .player.m-full #fullBtn { font-size: 0; border: 1px solid rgba(255,255,255,.25); padding: 4px 10px; }
  .player.m-full #fullBtn::before { content: '✕ 閉じる'; font-size: 12px; }

  /* 右パネルのタブは 2×2 に */
  .tabs { flex-wrap: wrap; }
  .tabs button { flex: 1 1 50%; padding: 9px 0; }
  .tabs button.active::after { left: 22%; right: 22%; }
}

/* ---------- タブレット（761〜1000px・縦長）：左右配置のまま、上段の高さを映像に合わせる ---------- */
@media (min-width: 761px) and (max-width: 1000px) and (min-height: 501px) {
  /* 上段の高さは appController.fitUpper が「映像＋操作バー」の高さから決める（--upper-h） */
  .side { width: 280px; }
  .splitter { display: none; }
  .video-wrap { max-height: 48vh; }
  .seg button { font-size: 11.5px; padding: 5px 0; }
}

/* ---------- スマホ（縦）／横向きスマホ ---------- */
@media (max-width: 760px), (max-width: 1000px) and (max-height: 500px) {
  .topbar { height: 44px; padding: 0 12px; gap: 8px; }
  .topnav a { padding: 6px 8px; }

  /* スマホは「見る」だけ：アップロード・設定・書き込み・編集は出さない（書き込み／編集は展開ボタンで出せる） */
  .topnav a[data-nav=upload], .topnav a[data-nav=settings] { display: none; }
  .m-only, .controls .m-only, .gridbar .m-only { display: inline-flex; align-items: center; }
  .ctl-mid { display: none; }               /* 書き込み・切り出しの道具はスマホでは出さない */
  .controls .ann-btn { border: 1px solid rgba(255,255,255,.15); padding: 4px 10px; }
  .controls .ann-btn span { font-size: 12px; }
  .gridbar > :is(#savePlaylistBtn, #editDataBtn, #playInputBtn, #bulkEditBtn, #deleteClipsBtn, #exportBtn, #importBtn) { display: none; }
  .lower.m-more .gridbar > :is(#savePlaylistBtn, #editDataBtn, #playInputBtn, #bulkEditBtn, #deleteClipsBtn, #exportBtn) { display: inline-flex; align-items: center; }
  #gridMoreBtn { color: #aab6c4; }
  #gridMoreBtn.on { color: #fff; background: var(--sel); border-color: var(--blue2); }
  .mtabs [data-mtab=reports] { display: none; }
  .tree .actions, .tree-hint, .tree-search .link, .tree-year .link { display: none; }

  /* ライブラリ：映像 → 表 or パネル → 下タブ */
  .upper { display: contents; }
  .splitter { display: none; }
  .player { flex: none; }

  /* パネル（ツリー・コメント・レポート・リスト）と表の切替 */
  .side { display: none; width: auto; flex: 1; min-height: 0; border-left: none; }
  .side .tabs { display: none; }
  .library.m-panel .side { display: flex; }
  .library.m-panel .lower { display: none; }
  .tab-body { padding: 10px 12px; }
  .tree-year select { min-height: 34px; }
  .seg button { padding: 7px 0; }
  .tree-search input { min-height: 34px; }
  .comment-form textarea { min-height: 72px; }
  .comment-form .btn { width: 100%; min-height: 40px; }

  /* 下タブ */
  .mtabs { display: flex; flex: none; background: #0d1218; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .mtabs button { flex: 1; background: none; border: none; border-radius: 0; padding: 7px 0 6px; color: var(--muted); font-size: 10.5px; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 50px; letter-spacing: .02em; }
  .mtabs button i { font-style: normal; font-size: 17px; line-height: 1; }
  .mtabs button:hover { background: none; }
  .mtabs button.active { color: #fff; }
  .mtabs button.active i { color: var(--blue); }
  .mtabs button:active { background: rgba(255,255,255,.05); transform: none; }

  /* 表 */
  .gridbar { flex-wrap: wrap; gap: 4px; padding: 6px 8px; }
  .gridbar .count { width: 100%; margin: 0 0 2px; }
  .gridbar .spacer { display: none; }
  .gridbar button { min-height: 32px; padding: 4px 10px; font-size: 12px; }
  .gridbar .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dropdown { position: static; }
  .menu { position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(58px + env(safe-area-inset-bottom)); min-width: 0; max-height: 55vh; }
  .grid th, .grid td { height: 30px; line-height: 30px; padding: 0 8px; }
  .grid th.handle, .grid td.handle { width: 84px; min-width: 84px; }
  .grid td.handle button { padding: 0 5px; font-size: 14px; }
  .grid td.handle input { width: 16px; height: 16px; }
  .grid td.editing input, .grid td.editing select { height: 30px; }
  .playinput { gap: 6px; padding: 6px 8px; }
  .playinput span:not(.mode):not(.spacer) { display: none; }
  .playinput button { min-height: 32px; padding: 4px 10px; }
  .playinput select { min-height: 30px; }

  /* アップロード・設定 */
  .upload, .settings { padding: 14px 10px; }
  .upload-box { padding: 16px 14px; margin-bottom: 16px; border-radius: 10px; }
  .settings .upload-box { overflow-x: auto; }
  .settings table.simple { min-width: 560px; }
  .settings table.simple th, .settings table.simple td { white-space: nowrap; }
  .upload-box h2 { font-size: 15px; }
  .row2, .row3, .modal-box .row2, .sync-grid { grid-template-columns: 1fr; gap: 4px; }
  .modes { flex-direction: column; gap: 8px; }
  .dropzone { padding: 20px 12px; }
  .dropzone p { font-size: 14px; }
  .dropzone.small { flex-wrap: wrap; }
  .upgroup-head { flex-wrap: wrap; }
  .inline-form input, .inline-form select { flex: 1 1 100%; }
  .inline-form .btn { width: 100%; min-height: 40px; }
  #upStartBtn { width: 100%; margin: 0 0 8px; min-height: 44px; }
  #impRunBtn { width: 100%; min-height: 40px; }

  /* ダイアログは下から出るシート、トーストは下タブの上 */
  .modal { align-items: flex-end; }
  .modal-box, .modal-box.wide, .modal-box.wide:has(.sync-grid) { min-width: 0; width: 100%; max-width: 100%; max-height: 88vh; border-radius: 14px 14px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  .modal-box .cols { columns: 1; }
  .modal-box .actions { flex-wrap: wrap; }
  .modal-box .actions .btn { flex: 1; min-height: 42px; }
  .toast { left: 12px; right: 12px; transform: none; text-align: center; bottom: calc(64px + env(safe-area-inset-bottom)); border-radius: 10px; }

  /* ログイン */
  .login-box { width: calc(100% - 32px); max-width: 360px; padding: 24px 20px 20px; }
}

/* ---------- 横向きスマホ：映像を左、表／パネルを右、下タブは右端の縦帯 ---------- */
@media (max-width: 1000px) and (max-height: 500px) {
  .library { flex-direction: row; }
  .player { width: 52%; flex: none; min-height: 0; }
  .video-wrap { flex: 1; aspect-ratio: auto; max-height: none; min-height: 0; }
  .side, .lower { min-width: 0; }
  .side { border-left: 1px solid var(--line); border-top: none; }
  .mtabs { flex-direction: column; width: 62px; border-top: none; border-left: 1px solid var(--line); padding-bottom: 0; padding-right: env(safe-area-inset-right); }
  .mtabs button { min-height: 0; flex: 1; padding: 4px 0; }
  .menu { left: auto; right: 70px; bottom: 8px; width: min(420px, 46vw); }
  .toast { left: 52%; right: 74px; bottom: 12px; }
  .modal { align-items: center; }
  .modal-box, .modal-box.wide, .modal-box.wide:has(.sync-grid) { width: auto; min-width: 60vw; max-width: 92vw; max-height: 92vh; border-radius: 12px; padding: 16px 18px; }
  .sync-grid { grid-template-columns: 1fr 1fr; }
  .upload, .settings { padding: 12px 10px; }
  /* 横向きの全画面：操作を1段にまとめ、画角バーは映像の左下に重ねて映像を大きく */
  .player.m-full .controls { flex-wrap: nowrap; padding: 2px 6px; }
  .player.m-full .ctl-left { width: auto; flex: 1; justify-content: space-between; }
  .player.m-full .ctl-right { width: auto; flex: none; margin-left: 8px; }
  .player.m-full .anglebar { position: absolute; left: 0; bottom: 78px; z-index: 3; background: rgba(0,0,0,.55); border-radius: 0 8px 0 0; backdrop-filter: blur(6px); }
}

/* ---------- 指で操作する端末（タブレット含む）：ホバーで出る操作を常時表示、押しやすい大きさ、iOS の入力ズーム防止 ---------- */
@media (pointer: coarse) {
  .tree .actions, .fp-row .fp-add { visibility: visible; }
  .tree .node { padding: 6px 6px; }
  .tree .actions button { padding: 0 8px; font-size: 14px; min-height: 26px; }
  .tree .tog { width: 20px; font-size: 14px; }
  .video-wrap svg { touch-action: none; }
  .ctxmenu { min-width: 240px; }
  .ctxmenu button { padding: 10px 12px; font-size: 14px; }
  .menu .mi { padding: 9px 10px; }
  .tabs button { padding: 12px 0; }
  .playlists .pl, .comments .c { padding: 9px 4px; }
  .fp-row { padding: 6px 6px; }
  .grid th .rz { width: 14px; right: -7px; }
  .upload-box :is(input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea),
  .modal-box :is(input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea),
  .comment-form textarea, .login-box input, .tree-search input { font-size: 16px; }
}

/* ペン（鉛筆）選択中は鉛筆カーソル（先端が書き込み位置） */
.video-wrap[data-drawtool="pen"].drawing svg {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M2 22l1.5-5L18 2.5a2 2 0 0 1 3 0l.5.5a2 2 0 0 1 0 3L7 20.5z' fill='%23f5c542' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M2 22l1.5-5 3.5 3.5z' fill='white' stroke='black'/%3E%3C/svg%3E") 2 22, crosshair;
}

/* フォルダ選択：常に見える「＋ フォルダを作る」ボタン */
.fp-head .fp-newbtn { margin-left: auto; background: var(--blue); color: #fff; border: none; font-weight: 700; white-space: nowrap; }
.fp-head .fp-newbtn:hover { filter: brightness(1.1); }

/* 画角ダイアログの並べ替えボタン */
.ord { display:inline-flex; flex-direction:column; gap:1px; margin-left:6px; vertical-align:middle; }
.ord button { line-height:1; padding:0 3px; font-size:10px; }
