/* NOVA 動画発注 叩き台 — 配色は管理ツール (ace-progress discord.css) に合わせる */
:root {
  --bg: #1c1d20; --panel: #181a1c; --deep: #0e0f10; --hover: #2b2d31; --hover2: #3a3c41; --line: #000;
  --row-line: #111214; --row-hover: #202226;
  --text: #dbdee1; --muted: #949ba4; --white: #fff; --link: #00a8fc;
  --accent: #5865F2; --accent-h: #4752C4;
  --green: #23a55a; --yellow: #f0b232; --red: #f23f43; --pink: #eb459e;
  --t-new-bg: #2b2d31; --t-new: #b5bac1; --t-wip-bg: #1e3a2a; --t-wip: #57d38c;
  --t-check-bg: #3a2a1a; --t-check: #f0b232; --t-fix-bg: #3a1a2a; --t-fix: #f47fb5;
  --t-done-bg: #1e2a4a; --t-done: #8ea1ff; --t-hold-bg: #3a1a1a; --t-hold: #ff8a8d;
  --n-info: #aab6ff; --mention-bg: #3c4270; --mention: #c9cdfb; --dc-bg: #2b2d31; --dc-line: #4e5058;
  --elig-bg: #1d4630; --elig-line: #3fbf78;
  color-scheme: dark;
}
/* ライト表示 (右上のボタンで切り替え・--white は「いちばん濃い文字色」として使う) */
:root[data-theme="light"] {
  --bg: #f7f8fa; --panel: #ffffff; --deep: #e9eaed; --hover: #e6e8ec; --hover2: #d9dce1; --line: #d4d7dc;
  --row-line: #e6e8ec; --row-hover: #f0f1f4;
  --text: #2e3338; --muted: #5c6370; --white: #060607; --link: #006ce7;
  --green: #1f8b4c; --yellow: #9a6700; --red: #d83c3e;
  --t-new-bg: #e6e8ec; --t-new: #4e5058; --t-wip-bg: #d7f5e3; --t-wip: #1a7a44;
  --t-check-bg: #fdf0d5; --t-check: #8a5a00; --t-fix-bg: #fde2ef; --t-fix: #b0306e;
  --t-done-bg: #e0e6ff; --t-done: #3949c7; --t-hold-bg: #fde2e2; --t-hold: #b42326;
  --n-info: #3949c7; --mention-bg: #e0e3ff; --mention: #4752c4; --dc-bg: #f2f3f5; --dc-line: #c4c9d0;
  --elig-bg: #d3f2df; --elig-line: #1f8b4c;
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "gg sans", -apple-system, "Segoe UI", "Hiragino Sans", sans-serif; font-size: 14px; color: var(--text); background: var(--deep); }
a { color: var(--link); text-decoration: none; }
button { cursor: pointer; background: var(--hover); color: var(--white); border: none; border-radius: 4px; padding: 6px 14px; font-size: 13px; font-weight: 500; font-family: inherit; }
button:hover { background: var(--hover2); }
button.primary, button.success { color: #fff; }
button.primary { background: var(--accent); }
button.primary:hover { background: var(--accent-h); }
button.success { background: var(--green); }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
button:disabled { opacity: .4; cursor: not-allowed; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-family: inherit; font-size: 13px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 72px; resize: vertical; }

/* ヘッダーと視点切り替え */
header.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--deep); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
header.top .brand { font-weight: 700; color: var(--white); }
header.top .brand small { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--pink)); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; }
.role-switch { display: flex; gap: 6px; align-items: center; padding: 6px 16px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.role-switch a { padding: 4px 10px; border-radius: 4px; background: var(--bg); color: var(--text); }
.role-switch a.active { background: var(--accent); color: #fff; }
.role-switch .note { margin-left: auto; }

/* レイアウト */
.app { display: grid; grid-template-columns: 200px 1fr; min-height: calc(100vh - 82px); }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 8px 0; }
.side a { display: flex; justify-content: space-between; color: var(--muted); padding: 8px 10px; margin: 2px 6px; border-radius: 4px; font-size: 13px; }
.side a:hover { background: var(--hover); color: var(--text); }
.side a.active { background: var(--hover); color: var(--white); }
.side .cnt { background: var(--red); color: #fff; border-radius: 8px; font-size: 11px; padding: 0 6px; }
.side hr { border: 0; border-top: 1px solid var(--line); margin: 8px 12px; }
.side .cap { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .5px; padding: 8px 16px 4px; }
main { background: var(--bg); padding: 16px; overflow: auto; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.section > h2 { color: var(--muted); font-size: 11px; letter-spacing: .5px; font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); font-size: 12px; }
.row-label { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.row-label:last-child { border-bottom: none; }
.row-label > span:first-child { color: var(--muted); flex-shrink: 0; }
.row-label > span:last-child { text-align: right; word-break: break-all; }

/* 集計カード */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.stat .n { font-size: 22px; font-weight: 700; color: var(--white); margin-top: 4px; }
.stat .n small { font-size: 12px; color: var(--muted); font-weight: 400; }
.stat.warn .n { color: var(--yellow); }
.stat.alert .n { color: var(--red); }

/* 状態タグ */
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag.s-new { background: var(--t-new-bg); color: var(--t-new); }
.tag.s-wip { background: var(--t-wip-bg); color: var(--t-wip); }
.tag.s-check { background: var(--t-check-bg); color: var(--t-check); }
.tag.s-fix { background: var(--t-fix-bg); color: var(--t-fix); }
.tag.s-done { background: var(--t-done-bg); color: var(--t-done); }
.tag.s-hold { background: var(--t-hold-bg); color: var(--t-hold); }
.tag.late { background: var(--red); color: #fff; }

/* 一覧表 */
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th { text-align: left; color: var(--muted); font-size: 11px; font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 8px; border-bottom: 1px solid var(--row-line); vertical-align: middle; }
table.list tr.r { cursor: pointer; }
table.list tr.r:hover td { background: var(--row-hover); }
table.list tr.r.active td { background: var(--hover); }
.filters { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 12px; background: var(--bg); color: var(--muted); cursor: pointer; border: 1px solid var(--line); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 進行ステップ */
.steps { display: flex; gap: 4px; margin: 4px 0 12px; }
.steps div { flex: 1; text-align: center; font-size: 11px; padding: 6px 2px; border-radius: 4px; background: var(--bg); color: var(--muted); }
.steps div.done { background: var(--t-done-bg); color: var(--t-done); }
.steps div.now { background: var(--accent); color: #fff; font-weight: 700; }

/* やり取り (スレッド) */
.thread { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; padding-right: 4px; }
.compose { display: flex; gap: 8px; margin-top: 10px; }
.compose textarea { min-height: 40px; }

.notice { background: var(--t-check-bg); color: var(--t-check); border-radius: 6px; padding: 8px 10px; font-size: 12px; margin-bottom: 10px; }
.notice.info { background: var(--t-done-bg); color: var(--n-info); }
.notice.red { background: var(--t-hold-bg); color: var(--t-hold); }
.price { font-size: 20px; font-weight: 700; color: var(--white); }
.pending { color: var(--muted); font-size: 13px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.field .req { color: var(--red); margin-left: 4px; }
.radios { display: flex; gap: 8px; flex-wrap: wrap; }
.radios label { display: flex; align-items: center; gap: 4px; background: var(--bg); border: 1px solid var(--line); padding: 6px 10px; border-radius: 6px; font-size: 13px; color: var(--text); font-weight: 400; cursor: pointer; }
.radios input { width: auto; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.quota { display: flex; gap: 4px; margin-top: 6px; }
.quota span { flex: 1; height: 8px; border-radius: 4px; background: var(--hover); }
.quota span.used { background: var(--accent); }
.log { font-size: 12px; color: var(--muted); }
.log div { padding: 4px 0; border-bottom: 1px solid var(--row-line); }
.log b { color: var(--link); font-weight: 500; }
.hidden { display: none !important; }

/* 折り畳み式の詳細 (行の下に広げる) */
table.list tr.r td:first-child::before { content: '›'; display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
table.list tr.r.active td:first-child::before { transform: rotate(90deg); color: var(--white); }
table.list tr.exp > td { padding: 0 0 14px; background: var(--hover); border-bottom: 1px solid var(--line); }
.exp-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; padding: 12px; }
.exp-grid .section { margin-bottom: 0; background: var(--panel); }
.exp-grid .col { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 900px) { .exp-grid { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .side { display: flex; flex-wrap: wrap; } .stats { grid-template-columns: repeat(2, 1fr) !important; } }
.compose button { white-space: nowrap; align-self: flex-end; }

/* 共有ページ用: 暗い配色で固定・スマホ幅で表は枠内で横スクロール */
header.top { top: env(safe-area-inset-top, 0px); }
main { min-width: 0; }
.section:has(> table.list) { overflow-x: auto; }
table.list { min-width: 640px; }

/* 月次レポート (管理ツールの月次レポートと同じ並び) */
.rep-head { font-size: 16px !important; color: var(--white) !important; letter-spacing: 0 !important; }
.rep-nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 13px; margin-bottom: 14px; }
table.list .num { text-align: right; font-variant-numeric: tabular-nums; }
table.list tfoot td { padding: 10px 8px; border-top: 1px solid var(--line); font-weight: 700; color: var(--white); }
#rep-stats { grid-template-columns: repeat(2, 1fr); }

/* 記載項目の案内 (新しく依頼する) */
.guide { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; font-size: 13px; line-height: 1.7; }
.guide-title { color: var(--white); font-weight: 700; margin-bottom: 8px; }
.guide dl { display: grid; gap: 4px; }
.guide dt { color: var(--white); font-weight: 600; margin-top: 6px; }
.guide dd { color: var(--text); padding-left: 1.2em; }
.guide ul { margin: 4px 0 0 1.2em; color: var(--muted); }

/* 長文の入力欄は書いた分だけ縦に広がる (中でスクロールさせない) */
textarea { overflow: hidden; resize: none; min-height: 72px; }
#n-memo { min-height: 120px; }
.field.back { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.field.back select { width: auto; }

/* Discord 連携の説明ページ */
.dc-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 14px; align-items: start; }
.dc-lead { font-size: 13px; line-height: 1.7; margin-bottom: 14px; max-width: 80ch; }
.flow { list-style: none; counter-reset: f; display: grid; gap: 10px; }
.flow > li { counter-increment: f; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.flow > li::before { content: counter(f); width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.flow .when { color: var(--white); font-weight: 700; font-size: 14px; }
.flow .what { font-size: 13px; line-height: 1.65; margin-top: 4px; }
.flow .what ul { margin: 4px 0 0 1.2em; }
.flow .to { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.mention { background: var(--mention-bg); color: var(--mention); border-radius: 3px; padding: 0 4px; font-weight: 600; font-size: 12px; }
.dc-mock { background: var(--dc-bg); border-radius: 8px; padding: 10px 8px; font-size: 13px; }
.dc-mock .cat { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .5px; padding: 4px 6px; }
.dc-mock .ch { color: var(--text); padding: 5px 8px; border-radius: 4px; display: flex; gap: 6px; align-items: center; }
.dc-mock .ch .hash { color: var(--muted); font-weight: 700; }
.dc-mock .lock { color: var(--muted); font-size: 11px; margin-left: auto; }
.dc-mock .th { color: var(--muted); padding: 3px 8px 3px 26px; font-size: 12px; border-left: 1px solid var(--dc-line); margin-left: 16px; }
.dc-mock .th.done { opacity: .55; }
.dc-name { background: var(--bg); border-radius: 6px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.dc-name b { color: var(--link); font-weight: 600; }
@media (max-width: 1100px) { .dc-wrap { grid-template-columns: 1fr; } }

/* 表示切り替えボタン */
.theme-btn { background: var(--hover); color: var(--text); font-size: 12px; padding: 4px 10px; margin-right: 6px; }
.tag.nth { background: transparent; border: 1px solid var(--hover2); color: var(--muted); }

/* ログイン画面・エラー画面 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--deep); }
.login-box { max-width: 380px; margin: 12vh auto 0; padding: 28px 24px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.login-wrap .login-box { margin: 0; width: 100%; }
.login-box h1 { font-size: 20px; color: var(--white); margin-bottom: 8px; }
.login-box p { color: var(--muted); font-size: 13px; line-height: 1.7; margin-bottom: 18px; }
.login-box .notice { text-align: left; margin-top: 14px; }
.login-btn { display: block; width: 100%; padding: 11px 14px; border-radius: 4px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; text-align: center; }
.login-btn:hover { background: var(--accent-h); }
.who button.logout { margin-left: 6px; padding: 0; background: none; border-radius: 0; color: var(--link); font-size: 12px; font-weight: 400; }
.who button.logout:hover { background: none; text-decoration: underline; }
#who-area { display: flex; align-items: center; gap: 8px; }

/* 赤い塗りのボタン (修正を依頼する) */
button.danger-fill { background: var(--red); color: #fff; }
button.danger-fill:hover { filter: brightness(1.1); background: var(--red); }

/* 校了の確認 */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal-card { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(440px, 100%); display: grid; gap: 12px; }
.modal-card h3 { color: var(--white); font-size: 16px; }
.modal-card p { font-size: 13px; line-height: 1.7; }
.modal-card .check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.modal-card .check input { width: auto; }

/* 長い文章 (演出指示・修正指示) は見出しの下に左寄せで、入力した改行をそのまま出す */
.row-label.block { flex-direction: column; gap: 6px; }
.row-label.block > span:last-child { text-align: left; white-space: pre-wrap; line-height: 1.7; }

/* ご連絡について */
.contact { font-size: 13px; line-height: 1.7; margin-bottom: 10px; }
.contact b { color: var(--link); font-weight: 600; }
a.btn-link { display: inline-block; background: var(--accent); color: #fff; border-radius: 4px; padding: 6px 14px; font-size: 13px; font-weight: 500; }
a.btn-link:hover { background: var(--accent-h); }

/* 依頼者メンバー (対象の人は緑の背景と左の線) */
.mem-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.mem-sort { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.mem-sort select { width: auto; }
table.list tr.mem-row td:first-child::before { content: none; }
table.list tr.mem-row td:first-child { border-left: 4px solid transparent; }
table.list tr.mem-row.elig td { background: var(--elig-bg); }
table.list tr.mem-row.elig td:first-child { border-left-color: var(--elig-line); }
table.list tr.mem-row.elig:hover td { background: var(--elig-bg); filter: brightness(1.08); }
table.list tr.mem-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mem-chip { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--t-new-bg); color: var(--t-new); }
.mem-chip.on { background: var(--elig-bg); color: var(--white); box-shadow: inset 0 0 0 1px var(--elig-line); }
.mem-gone { margin-left: 6px; border: 1px solid var(--hover2); border-radius: 8px; padding: 0 6px; }

.memo { white-space: pre-wrap; line-height: 1.75; font-size: 13px; }
.section > h2.memo-sub { margin-top: 16px; }
.exp-grid { align-items: start; }

/* 依頼者メンバー: 列の幅を固定 (「対象」「対象外」の切り替えで列がずれないように) */
#v-members table.list { table-layout: fixed; }
#v-members th.mem-state { width: 96px; }
.mem-chip { display: inline-block; min-width: 4.5em; text-align: center; }

/* 依頼の対象外の月: 「新しく依頼する」全体を赤く */
#n-box.ineligible { border-color: var(--red); background: var(--t-hold-bg); }
#n-box.ineligible > h2, #n-box.ineligible label, #n-box.ineligible .muted { color: var(--t-hold); }
#n-box.ineligible input, #n-box.ineligible textarea, #n-box.ineligible .guide, #n-box.ineligible .radios label { border-color: var(--red); }
#n-box.ineligible .notice.info { background: transparent; color: var(--t-hold); border: 1px solid var(--red); }
#n-box.ineligible button { background: var(--red); color: #fff; }

/* 担当者の選択 (一覧の中) */
input.assign { width: 120px; padding: 4px 8px; font-size: 12px; }

/* スマホ幅 (900px 以下) の調整: メニューは横一列でスクロール・詳細は画面幅に収める・表の文字は折り返さない */
@media (max-width: 900px) {
  .app { grid-template-rows: auto 1fr; align-content: start; }
  .side { flex-wrap: nowrap; overflow-x: auto; align-items: center; gap: 4px; padding: 6px 8px; }
  .side .cap, .side hr { display: none; }
  .side a { flex: 0 0 auto; white-space: nowrap; margin: 0; }
  header.top .brand small, .who > span:not(.avatar) { display: none; }
  .who button, .who .logout { white-space: nowrap; }
  table.list th, table.list td { white-space: nowrap; }
  table.list tr.exp > td { white-space: normal; }
  table.list tr.exp > td > .exp-grid { position: sticky; left: 0; width: calc(100vw - 64px); }
  #v-list table.list { min-width: 0; }
}

/* 月次レポートの請求書ボタン */
.rep-inv { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
