/*

 */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1f2933;
  --muted: #6b7684;
  --primary: #d6336c;
  --primary-dark: #b0245a;
  --primary-soft: #fde7ef;
  --blue: #2f6fde;
  --blue-soft: #e5eefc;
  --green: #1f9d55;
  --green-soft: #e3f6ea;
  --yellow: #b7791f;
  --yellow-soft: #fdf3dc;
  --red: #d64545;
  --red-soft: #fde8e8;
  --purple: #7c4dcc;
  --purple-soft: #efe8fb;
  --gray-soft: #eef0f3;
  --radius: 8px;
  --sidebar: 228px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.pre { white-space: pre-wrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ---------- レイアウト ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: #1f2430; color: #cfd5de;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 0;
}
.sidebar .brand { color: #fff; font-weight: 700; padding: 0 20px 16px; font-size: 15px; display: block; }
.sidebar .brand span { color: #f06595; }
.sidebar nav a {
  display: flex; align-items: center; gap: 8px; color: #cfd5de; padding: 8px 20px; font-size: 13px;
}
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar .nav-label { font-size: 11px; color: #7d8696; padding: 14px 20px 4px; letter-spacing: .05em; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border); height: 52px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 20;
}
.topbar .menu-toggle { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; }
.topbar .right { display: flex; align-items: center; gap: 16px; }
.bell { position: relative; font-size: 18px; color: var(--text); }
.bell .count {
  position: absolute; top: -6px; right: -10px; background: var(--red); color: #fff; border-radius: 10px;
  font-size: 10px; padding: 0 5px; line-height: 16px;
}
.content { padding: 20px; max-width: 1400px; width: 100%; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* ---------- 部品 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.card-header h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-post { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1100px) { .grid-post { grid-template-columns: minmax(0, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 24px; font-weight: 700; }
.stat .value.danger { color: var(--red); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); border-radius: 6px; padding: 6px 14px; font-size: 13px;
  cursor: pointer; line-height: 1.5; font-family: inherit; white-space: nowrap;
}
.btn:hover { background: var(--gray-soft); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #17824a; }
.btn-danger { color: var(--red); border-color: #f3c1c1; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-link { border: 0; background: none; color: var(--blue); padding: 0; }
.btn-link:hover { background: none; text-decoration: underline; }
form.inline, .button_to { display: inline; }

.badge {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--gray-soft);
  color: var(--muted); white-space: nowrap; font-weight: 600;
}
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-pink { background: var(--primary-soft); color: var(--primary); }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash-notice { background: var(--green-soft); color: #146c3b; }
.flash-alert { background: var(--red-soft); color: #9b2c2c; }

table.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; }
.table tr:hover td { background: #fcfcfd; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap .table th:first-child, .table-wrap .table td:first-child { padding-left: 14px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- フォーム ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 11px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=url], input[type=search], input[type=tel], input[type=month], select, textarea {
  width: 100%; border: 1px solid #cfd5dd; border-radius: 6px; padding: 6px 10px; font-size: 14px; font-family: inherit; background: #fff;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.errors { background: var(--red-soft); color: #9b2c2c; padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }
.filters { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.filters .field { min-width: 140px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; font-size: 13px; }
.nested-row { display: grid; gap: 8px; align-items: end; padding: 8px 0; border-bottom: 1px dashed var(--border); }

/* ---------- ガント ---------- */
.gantt { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.gantt table { border-collapse: collapse; min-width: 100%; }
.gantt th, .gantt td { border-bottom: 1px solid var(--border); font-size: 12px; }
.gantt .task-col { position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 260px; max-width: 320px; padding: 6px 10px; border-right: 1px solid var(--border); }
.gantt .day { width: 26px; min-width: 26px; padding: 0; text-align: center; border-left: 1px solid #f1f3f5; }
.gantt th.day { font-weight: 400; color: var(--muted); font-size: 10px; line-height: 1.2; padding: 4px 0; }
.gantt th.day.weekend, .gantt td.day.weekend { background: #fafafa; }
.gantt .day.today { background: #fff5f8 !important; }
.gantt .cell { position: relative; height: 34px; }
.gantt .bar-plan, .gantt .bar-actual { position: absolute; left: 0; right: 0; }
.gantt .bar-plan { top: 7px; height: 9px; background: #f7c6d8; }
.gantt .bar-actual { top: 18px; height: 9px; background: var(--primary); }
.gantt .bar-plan.delayed { background: #f5b4b4; }
.gantt .month-row th { font-size: 11px; text-align: left; padding: 2px 4px; color: var(--muted); border-left: 1px solid var(--border); }
.gantt-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin: 8px 0; }
.gantt-legend i { display: inline-block; width: 18px; height: 8px; vertical-align: middle; margin-right: 4px; }

/* ---------- かんばん ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kanban-col { background: #eceef2; border-radius: var(--radius); min-width: 220px; width: 220px; flex-shrink: 0; padding: 8px; }
.kanban-col h3 { font-size: 12px; display: flex; justify-content: space-between; padding: 2px 4px 8px; margin: 0; }
.kanban-card { display: block; background: var(--surface); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; box-shadow: var(--shadow); border: 1px solid var(--border); color: var(--text); }
.kanban-card:hover { text-decoration: none; border-color: var(--primary); }
.kanban-card .title { font-weight: 600; font-size: 13px; }
.kanban-card .meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- ステップ ---------- */
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: start; }
.steps .num { width: 24px; height: 24px; border-radius: 50%; background: var(--gray-soft); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.steps li.current .num { background: var(--primary); color: #fff; }
.steps li.done .num { background: var(--green); color: #fff; }
.steps li.returned .num { background: var(--red); color: #fff; }
.step-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; min-width: 180px; }
.step-actions form { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.step-actions textarea { min-height: 40px; font-size: 12px; }
.progress-dots { display: flex; gap: 3px; }
.progress-dots span { width: 10px; height: 4px; border-radius: 2px; background: var(--gray-soft); }
.progress-dots span.done { background: var(--green); }
.progress-dots span.current { background: var(--primary); }
.progress-dots span.returned { background: var(--red); }

/* ---------- カレンダー ---------- */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); background: var(--surface); }
.calendar .dow { font-size: 12px; text-align: center; padding: 4px; background: #fafbfc; color: var(--muted); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.calendar .day { min-height: 110px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; font-size: 12px; }
.calendar .day.other { background: #fafbfc; color: #b0b7c1; }
.calendar .day.today .date { background: var(--primary); color: #fff; border-radius: 10px; padding: 0 6px; }
.calendar .day.drag-over { background: var(--primary-soft); }
.calendar.week .day { min-height: 320px; }
.cal-item { display: block; background: var(--blue-soft); color: var(--text); border-left: 3px solid var(--blue); border-radius: 4px; padding: 2px 6px; margin-top: 4px; font-size: 11px; cursor: grab; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item:hover { text-decoration: none; filter: brightness(.97); }
.cal-item.published { background: var(--green-soft); border-left-color: var(--green); }
.cal-item.failed { background: var(--red-soft); border-left-color: var(--red); }
.cal-item.ready, .cal-item.scheduled { background: var(--yellow-soft); border-left-color: var(--yellow); }

/* ---------- ハッシュタグゲージ ---------- */
.gauges { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.gauge .bar { height: 10px; background: var(--gray-soft); border-radius: 5px; overflow: hidden; margin-top: 4px; }
.gauge .fill { height: 100%; background: var(--primary); }
.gauge .fill.over { background: var(--yellow); }
.gauge .fill.full { background: var(--green); }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { display: inline-flex; gap: 4px; align-items: center; border: 1px solid var(--border); border-radius: 14px; padding: 2px 10px; font-size: 12px; background: #fff; cursor: pointer; }
.tag-chip input { margin: 0; }
.tag-chip.recommended { border-color: var(--green); }

/* ---------- チェック ---------- */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 10px 4px; border-bottom: 1px solid var(--border); }
.checklist label { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.checklist input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); }
.checklist li.done label { color: var(--muted); text-decoration: line-through; }
.matrix td.cell { text-align: center; font-size: 12px; }
.matrix .ok { background: var(--green-soft); color: var(--green); }
.matrix .ng { background: var(--red-soft); color: var(--red); }
.matrix .partial { background: var(--yellow-soft); color: var(--yellow); }

/* ---------- ストーリーズ ---------- */
.story-week { display: grid; grid-template-columns: 90px repeat(7, minmax(150px, 1fr)); overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.story-week > div { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; font-size: 12px; }
.story-week .head { background: #fafbfc; font-weight: 600; text-align: center; }
.story-slot { min-height: 100px; }
.story-slot.done { background: #f3fbf6; }
.story-slot details summary { cursor: pointer; list-style: none; }
.story-slot details summary::-webkit-details-marker { display: none; }
.story-slot form { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.story-slot input, .story-slot select, .story-slot textarea { font-size: 12px; padding: 3px 6px; }

/* ---------- 通知 ---------- */
.notice-list { list-style: none; padding: 0; margin: 0; }
.notice-list li { padding: 10px 4px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.notice-list li.unread { background: #fff9fb; }
.notice-list .when { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- ログイン ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; }
.auth h1 { text-align: center; margin-bottom: 16px; }

/* ---------- レポート印刷 ---------- */
.report-page { background: #fff; max-width: 900px; margin: 0 auto; padding: 32px; }
@media print {
  @page { size: A4; margin: 12mm; }
  .sidebar, .topbar, .no-print, .page-header .actions, .tabs, .breadcrumb, .flash, .menu-toggle { display: none !important; }
  /* 「背景のグラフィック」をオンにしてもサイドバーの帯が出ないようにする */
  html, body, .app, .main { background: #fff !important; display: block !important; min-height: 0 !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .grid-2, .grid-3, .grid-4 { gap: 8px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* グラフは印刷時に画像へ差し替え（canvas は画面幅のまま切れるため） */
  [data-controller~="chart"] { height: auto !important; }
  [data-controller~="chart"] canvas { display: none !important; }
  .chart-print { display: block !important; width: 100%; height: auto; }
}
.chart-print { display: none; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar)); z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 4px 0 16px rgba(0,0,0,.2); }
  .topbar .menu-toggle { display: block; }
  .topbar .topbar-date, .topbar .topbar-user { display: none; }
  .content { padding: 12px; }
  .grid-2, .grid-3, .grid-4, .form-grid, .gauges { grid-template-columns: minmax(0, 1fr); }
  .steps li { grid-template-columns: 28px 1fr; }
  .step-actions { grid-column: 2; align-items: stretch; }
  .calendar .day { min-height: 70px; }
  .cal-item { white-space: normal; }
}

/* ---------- レベルアップ ---------- */
.level-chip { display: inline-flex; align-items: center; gap: 4px; background: linear-gradient(90deg, #f59f00, #d6336c); color: #fff; border-radius: 12px; padding: 1px 10px; font-size: 12px; font-weight: 700; }
.level-chip span { font-weight: 400; opacity: .95; }
.level-chip:hover { text-decoration: none; filter: brightness(1.05); }
.level-card { display: flex; align-items: center; gap: 20px; }
.level-badge { width: 92px; height: 92px; border-radius: 50%; background: linear-gradient(135deg, #f59f00, #d6336c); color: #fff; display: flex; align-items: baseline; justify-content: center; padding-top: 22px; font-size: 16px; flex-shrink: 0; box-shadow: 0 4px 12px rgba(214, 51, 108, .3); }
.level-badge strong { font-size: 36px; line-height: 1; margin-left: 2px; }
.level-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.level-bar { height: 12px; background: var(--gray-soft); border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.level-bar div { height: 100%; background: linear-gradient(90deg, #f59f00, #d6336c); border-radius: 6px; }
.table tr.me td { background: #fff5f8; }
@media (max-width: 768px) { .level-chip span { display: none; } }

/* サイドバーの背景を縦長ページの下端まで伸ばす（PC表示） */
@media screen and (min-width: 769px) {
  .app { background: linear-gradient(to right, #1f2430 var(--sidebar), var(--bg) var(--sidebar)); }
}

/* 素材の動画プレビュー */
.asset-preview { margin-top: 4px; }
.asset-preview summary { cursor: pointer; color: var(--primary); }
.asset-preview video { display: block; width: 100%; max-width: 360px; max-height: 360px; margin: 6px 0; background: #000; border-radius: 6px; }
