:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5d6570;
  --line: #dcd9cf;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --accent-soft: #e3f1ed;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --danger: #a63232;
  --danger-soft: #fbe9e7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --surface: #1f2226;
    --text: #e6e8ea;
    --muted: #9aa3ad;
    --line: #353a42;
    --accent: #6fcdb4;
    --accent-text: #0d1f1a;
    --accent-soft: #1d332e;
    --warn: #f0b860;
    --warn-soft: #3a2d15;
    --danger: #f08a80;
    --danger-soft: #3d1f1c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", Meiryo, system-ui, sans-serif;
  font-size: 16px; line-height: 1.7;
}
a { color: var(--accent); }   /* ブラウザ標準の青は、暗い配色で読めない */
button, .button {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block;
  line-height: 1.5; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; border-color: var(--line); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
button.quiet:hover { color: var(--danger); border-color: transparent; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px;
  max-width: 880px; margin: 0 auto; padding: 24px 16px 8px;
}
.top h1 { font-size: 22px; margin: 0; }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 14.5px; color: var(--muted); }
.pill { border-radius: 99px; padding: 2px 12px; font-size: 13px; font-weight: 600; background: var(--line); color: var(--text); }
.pill.on { background: var(--accent-soft); color: var(--accent); }
.pill.off { background: var(--warn-soft); color: var(--warn); }

main { max-width: 880px; margin: 0 auto; padding: 8px 16px 80px; }
.drop {
  border: 2px dashed var(--line); border-radius: 14px; padding: 28px 20px; text-align: center;
  background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop.full { cursor: default; border-style: solid; background: var(--warn-soft); border-color: var(--warn); }
.drop.full:hover, .drop.full:focus-visible { background: var(--warn-soft); border-color: var(--warn); }
.drop.full .drop-title { color: var(--warn); }
.drop-title { margin: 0; font-size: 17px; font-weight: 600; }
.drop-note { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.upload { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 14px; color: var(--muted); }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.error { color: var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 8px 12px; margin: 12px 0 0; font-size: 14.5px; text-align: left; }
.empty { color: var(--muted); text-align: center; margin-top: 40px; }

/* 状況ボード: 処理PC とレーン */
.board { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin-bottom: 14px; display: grid; gap: 12px; }
.worker-card { display: flex; align-items: center; gap: 12px; }
.worker-text { display: grid; line-height: 1.5; }
.board-sub { color: var(--muted); font-size: 14px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); flex: none; position: relative; }
.dot.on { background: var(--accent); }
.dot.on::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent); animation: ping 1.8s ease-out infinite; }
.dot.hold { background: var(--warn); }
.dot.off { background: var(--muted); opacity: .6; }
@keyframes ping { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dot.on::after { animation: none; display: none; } }
.lanes { display: grid; gap: 10px; }
.lane { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; }
.lane-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lane-name { font-weight: 600; }
.lane-level { font-size: 13px; font-weight: 600; border-radius: 99px; padding: 1px 10px; background: var(--accent-soft); color: var(--accent); }
.lane.is-mid .lane-level { background: var(--warn-soft); color: var(--warn); }
.lane.is-high .lane-level, .lane.is-closed .lane-level { background: var(--danger-soft); color: var(--danger); }
.lane-text { margin: 0; color: var(--muted); font-size: 14px; }
.lane-text.mine { color: var(--text); font-weight: 600; }

.videos { display: grid; gap: 14px; margin-top: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card h2 { font-size: 16.5px; margin: 0; word-break: break-all; line-height: 1.45; }
.meta { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
/* 処理が進んでいることを示すクルクル（検査中・順番待ち・処理中の行） */
.spinner { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -2px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--line); } }
.jobs { display: grid; gap: 10px; margin-top: 12px; }
.job { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; }
.job-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
/* 文が長いときは文のほうを折り返し、ボタンは右に残す（ボタンだけ次の行に落ちないように） */
.job-row > div:first-child { flex: 1 1 240px; min-width: 0; }
.job-name { font-weight: 600; }
.job-note { color: var(--muted); font-size: 14px; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: none; }
.job .error { margin: 0; }

.viewer { position: fixed; inset: 0; z-index: 10; background: #101214; color: #e7e9ec; display: grid; grid-template-rows: auto 1fr auto; }
.viewer[hidden] { display: none; }
.viewer button, .viewer .button { background: transparent; color: #e7e9ec; border-color: #3a4048; }
.viewer .button.primary { background: #6fcdb4; border-color: #6fcdb4; color: #0d1f1a; }
.viewer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 14px; border-bottom: 1px solid #2a2f36; }
.viewer-bar strong { flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-wrap { position: relative; overflow: hidden; background: #000; user-select: none; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage video { position: absolute; left: 0; top: 0; display: block; }
/* 処理後は、境界から右だけを枠で見せる（動画に clip-path を使うとスマホで描画が遅くなる） */
.after-wrap { position: absolute; top: 0; right: 0; bottom: 0; overflow: hidden; }
.divider { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none; }
.tag { position: absolute; top: 10px; padding: 2px 10px; border-radius: 99px; background: rgba(0, 0, 0, .65); font-size: 12.5px; pointer-events: none; }
.tag.left { left: 10px; } .tag.right { right: 10px; }
.viewer-foot { display: grid; grid-template-columns: auto 1fr auto 2fr; align-items: center; gap: 10px 12px; padding: 10px 14px; border-top: 1px solid #2a2f36; font-size: 13.5px; }
input[type=range] { width: 100%; accent-color: #6fcdb4; }

@media (max-width: 600px) {
  .viewer-foot { grid-template-columns: auto 1fr; }
  .job-actions { flex: 1 1 auto; }
  .job-actions button, .job-actions .button { flex: 1; text-align: center; }
  /* スマホでは題名に 1 行目を丸ごと使う（切れて「試し処理」か「本処理」か分からなくならないように。長ければ 2 行まで） */
  .viewer-bar strong { flex: 1 1 100%; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}

/* ログインと利用者 */
.user { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.user > * { white-space: nowrap; }   /* 名前や「管理」が 1 文字ずつ折り返さないように。入りきらなければ項目ごとに次の行へ */
.user form { display: inline; }
.user a { color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.foot { margin-top: 40px; text-align: center; font-size: 13.5px; color: var(--muted); }
.foot a { color: var(--muted); }
/* 退会は、押し間違えないようページの一番下に、文字のリンクの形で置く */
.foot button { font: inherit; color: var(--muted); background: none; border: 0; padding: 0; text-decoration: underline; }
.foot button:hover { color: var(--danger); }
.login { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 36px 20px; text-align: center; margin-top: 24px; }
.login-title { font-size: 17px; font-weight: 600; margin: 0 0 18px; }
.login-message { color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 8px 12px; margin: 0 0 18px; font-size: 14.5px; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; font-size: 14.5px; }
.card > .meta, .card > .error { margin-top: 10px; }
