/* ======================================================================
   app/static/style.css
   目的: 重複定義の解消 / 責務分離（共通→ページ固有→テーマ→サイドバー）
   方針: 既存画面の見た目・挙動を変えない（リファクタリング）
   NOTE: sidebar未読赤丸（.sidebar-toggle-floating.has-unread ...）は変更しない
   ====================================================================== */

/* =========================
   0) Tokens / Base
   ========================= */
:root {
  --border: #e2e8f0;
  --fg: #1e293b;
  --muted: #64748b;
  --bg: #f8fafc;
  --accent: #2563eb;
  --success: #10b981;
  --danger: #ef4444;

  /* spacing scale */
  --space-0: 0px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  /* デザイン刷新後のトークン */
  --theme-accent: #2563eb;
  --theme-bg: #f8fafc;
  --theme-card: #ffffff;
  --theme-font: 16px;
  --theme-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --header-height: 72px;
  /* main-header（ポータル用） */
  --header-nav: 50px;
  /* .navbar（案件画面用） */
  --container-pad-top: 0px;
  --container-pad-inline: 24px;
  --container-pad-bottom: 24px;
}


* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  color: var(--fg);
  line-height: 1.6;
  background: var(--theme-bg);
  font-size: var(--theme-font);
  margin: 0;
  padding-top: var(--header-height);
  /* デフォルト 72px (ポータル用) */
}

/* 案件画面：.navbar（50px）使用時の補正 */
body.project-index-page,
body.edit,
body.settings {
  padding-top: var(--header-nav);
  /* 50px */
}



.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--container-pad-top) var(--container-pad-inline) var(--container-pad-bottom);
  /* 上0px、左右24px、下24px (Sticky要素の吸い付きを保証) */
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-2);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

/* ホバー時の下線は廃止（UIリンクは基本ノンアンダーライン） */
a:hover {
  text-decoration: none;
  color: color-mix(in srgb, var(--accent) 80%, #000000 20%);
}

.muted {
  color: var(--muted);
}

/* =========================
   1) Utilities
   ========================= */
.hidden {
  display: none !important;
}

.w100 {
  width: 100%;
}

.w-100 {
  width: 100%;
}

/* テンプレ側のクラス表記ゆれ吸収 */
.hide-check-update {
  display: none !important;
}

.alert {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.alert.info {
  background: #eef6ff;
  border-color: #cfe2ff;
  color: #0b5ed7;
}

/* =========================
   2) Form / Buttons
   ========================= */
input[type="text"],
textarea,
select {
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  background: #fff;
}

label {
  font-weight: 600;
  display: inline-block;
  margin-bottom: var(--space-1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  height: 32px;
  min-width: 68px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 32px;
  box-sizing: border-box;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  transition: all 0.15s ease-in-out;
}

.btn:hover {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.btn:active {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn.primary {
  background: var(--theme-accent);
  color: #fff;
  border-color: var(--theme-accent);
}

.btn.success {
  border-color: var(--success);
  color: #fff;
  background: var(--success);
}

.btn.danger {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff;
}

/* ボタン群の共通調整 */
.btn-group {
  display: inline-flex;
  gap: 8px;
}

.btn-group .btn {
  margin: 0 !important;
}

/* 小さめボタン */
.btn.sm {
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.4;
  height: 26px;
}

/* クリアボタン専用の調整 */
.btn.danger.sm {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  padding: 2px 8px;
  font-size: 12px;
}

.btn.danger.sm:hover {
  background: #b71c1c;
  border-color: #b71c1c;
}

/* =========================
   3) Layout / Cards
   ========================= */
.container {
  max-width: 1100px;
  margin: 0 auto;
}

@media (min-width: 1280px) {
  .container {
    max-width: 1200px;
  }
}

@media (min-width: 1536px) {
  .container {
    max-width: 1400px;
  }
}

/* === 幅制限用ユーティリティ（コメント欄など） === */
.narrow-container {
  max-width: 900px;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-1) 0 var(--space-4);
}

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--theme-card);
  margin: var(--space-4) 0;
  overflow: hidden;
  box-shadow: var(--theme-shadow);
  width: 100%;
  max-width: 100%;
}

/* テーマで色を変えられる見出し背景 */
.card-header {
  background: var(--theme-header-bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: var(--space-4);
}

.row {
  margin-bottom: var(--space-3);
}

.row.inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

@media (max-width: 720px) {
  .row.inline {
    grid-template-columns: 1fr;
  }
}

/* ===== Settings ページ専用の行レイアウト ===== */
.row.flex-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.row.flex-inline:last-child {
  margin-bottom: 0;
}

/* フォームは通常のブロック表示でカードの幅を崩さない */
.card-body form {
  display: block;
  width: 100%;
}

/* 入力要素やセレクトがカード幅からはみ出さないように */
.card-body input,
.card-body select,
.card-body textarea {
  max-width: 100%;
}

/* =========================
   4) Task List / Summary / Comments
   ========================= */
.task-list {
  display: block;
}

/* ==== タスク1件をカード風にまとめる ==== */
.task-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  background: var(--theme-card);
  box-shadow: var(--theme-shadow);
  position: relative;
  /* drag-handle基準 */
}

.task-item:last-child {
  margin-bottom: 0;
}

/* ==== タスク行 ==== */
.task-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.task-main {
  flex: 1;
  min-width: 0;
}

.task-actions {
  white-space: nowrap;
}

/* タスクIDの見た目 */
.task-id {
  font-family: "Courier New", monospace;
  font-weight: 600;
  font-size: 0.9rem;
  color: #444;
  margin-right: 6px;
}

/* カテゴリ */
.task-category {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--theme-accent);
}

.category-count {
  margin-left: 8px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
}

/* タイトル */
.task-title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.5;
  word-break: break-word;
}

/* 進捗バッジ */
.task-progress-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 8px;
  margin-left: 6px;
  font-size: 0.83rem;
  line-height: 1.4;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
  white-space: nowrap;
  vertical-align: middle;
  transform: translateY(-2px);
}

/* タスクメタ情報 */
.task-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
  font-size: .92rem;
  color: var(--muted);
  line-height: 1.6;
}

.task-meta .task-created,
.task-meta .task-author,
.task-meta .task-assign-deadline,
.task-meta .task-completed {
  display: inline-flex;
  align-items: center;
}

.task-meta .task-author,
.task-meta .task-completed {
  margin-left: 4px;
}

.task-meta .task-meta-label {
  font-weight: 600;
  margin-right: 2px;
}

/* === 優先度の強調表示 === */
.task-priority[data-priority="緊急"] {
  color: var(--danger);
  font-weight: 700;
}

.task-priority[data-priority="高"] {
  color: #f57c00;
  /* オレンジ */
  font-weight: 700;
}

/* 概要（WYSIWYGのHTML想定） */
.task-summary {
  margin: var(--space-1) 0 0 calc(1.25em);
  line-height: 1.5;
  font-size: .96rem;
}

.task-summary :is(p, ul, ol) {
  margin: .25em 0;
}

.task-summary a {
  text-decoration: underline;
  word-break: break-all;
}

.task-summary span[style*="background-color"] {
  border-radius: 2px;
  padding: 0 2px;
}

.task-summary .comment-line {
  white-space: pre-wrap;
  word-break: break-word;
}

/* 画像挿入対応 */
.task-summary img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 6px 0;
}

/* コードブロック/インライン */
.task-summary pre {
  background: #f5f5f5;
  padding: 8px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
}

.task-summary code {
  background: #eee;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
}

/* 既存の区切り線は無効化（カード化のため） */
.task-sep {
  display: none;
}

/* ==== コメント周り（共通） ==== */
/* NOTE: 既存ファイルの“後勝ち”定義を共通定義として固定（見た目維持） */
.comment-line {
  margin: 4px 0;
  padding-left: 4px;
  border-left: 2px solid var(--border);
  font-size: 13px;
  line-height: 1.4;
  display: block;
}

.comment-line+.comment-line {
  margin-top: var(--space-1);
}

.comments {
  margin: var(--space-2) 0 0 var(--comment-indent);
  padding-right: 0;
  font-size: .85rem;
  color: var(--fg);
  line-height: 1.4;
}

/* コメントセクションにだけ区切り線を表示 */
.comment-section {
  border-top: 1px dashed var(--border);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
}

/* チェックリスト（全員タスク） */
.checklist {
  margin: var(--space-2) 0 var(--space-2) calc(1em);
}

.checklist label {
  font-weight: 400;
  margin-right: var(--space-2);
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.checklist input[disabled]+span,
.checklist input[disabled] {
  opacity: .6;
  cursor: not-allowed;
}

/* カテゴリ・ブロック間の余白 */
.category-block+.category-block {
  margin-top: var(--space-2);
}

/* === アンカーリンク時のスクロール補正 === */
.category-block {
  scroll-margin-top: calc(var(--header-height) + 50px);
}

.card:has(#overview-body),
.card:has(#notice-body),
.card:has(#newtask-body) {
  scroll-margin-top: calc(var(--header-height) + 50px);
}

/* Safari等: :has()未対応ブラウザ向けフォールバック */
#overview-body,
#notice-body,
#newtask-body {
  scroll-margin-top: calc(var(--header-height) + 50px);
}

body.project-index-page .category-block,
body.edit .category-block,
body.settings .category-block {
  scroll-margin-top: calc(var(--header-nav) + 50px);
}

body.project-index-page .card:has(#overview-body),
body.project-index-page .card:has(#notice-body),
body.project-index-page .card:has(#newtask-body),
body.edit .card:has(#overview-body),
body.edit .card:has(#notice-body),
body.edit .card:has(#newtask-body),
body.project-index-page #overview-body,
body.project-index-page #notice-body,
body.project-index-page #newtask-body,
body.edit #overview-body,
body.edit #notice-body,
body.edit #newtask-body {
  scroll-margin-top: calc(var(--header-nav) + 50px);
}

/* 並び替え中のゴースト */
.drag-ghost,
.sortable-ghost {
  opacity: 0.7;
  background: #f9f9f9;
  border: 2px dashed var(--accent);
  border-radius: 8px;
}

/* 選択中の要素 */
.sortable-chosen {
  opacity: 0.9;
}

/* === 完了タスクのフェードアウトアニメーション === */
.task-item.fade-out {
  transition: opacity 0.8s ease, transform 0.4s ease;
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

/* ==== タスクドラッグハンドル ==== */


/* =========================
   5) Editors (Quill / TinyMCE)
   ========================= */
.ql-container {
  min-height: 120px;
  background: #fff;
  border-radius: 8px;
}

.ql-toolbar.ql-snow {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.ql-container.ql-snow {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* ▼ グローバル select{width:100%} がツールバーに掛からないように限定解除 */
.ql-toolbar select {
  width: auto !important;
}

.ql-toolbar .ql-picker {
  width: auto;
}

.ql-toolbar .ql-formats {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Quill・概要欄共通の背景／文字色補正 */
.quill-editor,
.task-summary,
.ql-editor {
  background: #fff;
  color: var(--fg);
  border-radius: 8px;
}

/* === TinyMCE 出力スタイル統一 === */
pre.prettyprint {
  background: #f6f8fa;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
  font-family: "Courier New", monospace;
  overflow-x: auto;
}

blockquote {
  border-left: 4px solid #ccc;
  margin: 10px 0;
  padding: 8px 12px;
  color: #555;
  background: #fafafa;
}

.tox .tox-tbtn--select {
  min-width: 34px;
}

/* === Quill-better-table（表機能） === */
.ql-editor table,
.task-summary table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
}

.ql-editor td,
.ql-editor th,
.task-summary td,
.task-summary th {
  border: 1px solid #ccc;
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}

.ql-editor th,
.task-summary th {
  background: #f5f5f5;
  font-weight: 600;
}

/* =========================
   6) Pages: Edit / Settings / MyPage / Schedule
   ========================= */
/* === 3カラム行（期限・予定・進捗）を強制（edit） === */
.edit .row.inline.three {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-3);
  align-items: start;
}

.edit .row.inline.three .form-group {
  align-self: start;
}

@media (max-width: 960px) {
  .edit .row.inline.three {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .edit .row.inline.three {
    grid-template-columns: 1fr;
  }
}

/* edit.html 固有 */
.edit .container {
  max-width: 1200px;
}

@media (min-width: 1280px) {
  .edit .container {
    max-width: 1200px;
  }
}

@media (min-width: 1536px) {
  .edit .container {
    max-width: 1400px;
  }
}

.edit .comment-line {
  padding: 2px 0;
  border-bottom: 1px dashed var(--border);
}

.edit .comment-actions {
  margin-top: 2px;
}

.edit .empty {
  padding: 2px;
  color: var(--muted);
}

/* 読み取り専用フォーム（can_edit = False の時に付けられるクラス想定） */
form.readonly * {
  pointer-events: none !important;
  opacity: .6;
}

.only-edit {
  display: initial;
}

.readonly .only-edit {
  display: none !important;
}

/* ===== 通知設定グリッド ===== */
.notify-grid {
  display: grid;
  grid-template-columns: repeat(5, auto);
  gap: 12px;
  align-items: center;
}

.notify-grid label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

@media (max-width: 960px) {
  .notify-grid {
    grid-template-columns: repeat(3, auto);
  }
}

@media (max-width: 560px) {
  .notify-grid {
    grid-template-columns: repeat(2, auto);
  }
}

.notify-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.notify-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.notify-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-left: 8px;
}

/* ==== indexUI変更による追加 ==== */
.compact-pair {
  display: flex;
  gap: 24px;
  align-items: flex-end;
}

.compact-pair .form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* editページだけ 2カラム grid にして高さを揃える */
.edit .compact-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.edit .compact-pair .form-group {
  align-self: start;
}

@media (max-width: 720px) {
  .edit .compact-pair {
    grid-template-columns: 1fr;
  }
}

.short-select {
  max-width: 260px;
}

/* =========================================================
   追加: index/edit の「担当者・カテゴリ・優先度（＋進捗）」を 1行化
   重要: .row.inline (2カラムgrid) の方が .compact-pair より強く効くため
         「.row.inline.compact-pair」で上書きする
   ========================================================= */
/* index: 3列（担当者 / カテゴリ / 優先度） */
.row.inline.compact-pair {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .row.inline.compact-pair {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 720px) {
  .row.inline.compact-pair {
    grid-template-columns: 1fr;
  }
}

/* edit: 4列（担当者 / カテゴリ / 優先度 / 進捗） */
.edit .row.inline.compact-pair {
  grid-template-columns: repeat(4, minmax(200px, 1fr));
}

@media (max-width: 1100px) {
  .edit .row.inline.compact-pair {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 720px) {
  .edit .row.inline.compact-pair {
    grid-template-columns: 1fr;
  }
}

/* edit.html で使用している full-span を有効化 */
.edit .row.inline.compact-pair .full-span {
  grid-column: 1 / -1;
}

/* 担当者 select と「－」ボタンを横並びにして崩れを抑制（index/edit共通） */
.assignee-block {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.assignee-block select {
  flex: 1 1 auto;
  min-width: 0;
}

.assignee-block .btn {
  flex: 0 0 auto;
}

/* =========================================================
    追加: チェックボックス機能（index/edit 共通）を 1行で表示
    - ラベル + 注記 を同一行にまとめる
    - 折り返し時に注記が左端へ戻らないようインデントを付与
    - 既存JS/フォームname/idに影響なし
    ========================================================= */
.checks-toggle-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.checks-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
  /* ラベルは基本1行維持 */
}

.checks-toggle-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  /* 折り返し時の視線誘導：チェックボックス幅分インデント */
  padding-left: 22px;
}

.checks-toggle-note strong {
  font-weight: 600;
  display: inline-block;
  margin-left: 8px;
  /* 「※」前後を詰めすぎない */
}

/* マイページのコンテンツ領域の上部余白を調整（portal-navbarを使用） */
.portal-navbar+.wrap {
  padding-top: 70px;
}

/* === マイページ用: 強調カード（未チェック・期限切れ） === */
.highlight-card {
  border: 2px solid var(--danger) !important;
  border-radius: 10px;
  box-shadow: var(--theme-shadow);
}

.attention-msg {
  color: var(--danger);
  font-weight: bold;
  margin-top: 6px;
}

.due-soon {
  color: #d17f00;
  font-weight: bold;
  margin-top: 6px;
}

.due-over {
  color: var(--danger);
  font-weight: bold;
  margin-top: 6px;
}

/* === マイページ用: コメント整形 === */
.task-comments {
  margin-top: 8px;
  padding-left: 8px;
  border-left: 2px solid var(--border);
}

.comment-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.comment-text {
  display: inline-block;
  margin-top: 2px;
}

.biz-open {
  font-weight: bold;
  color: #a8ff60;
  font-size: 20px;
  margin-left: 12px;
}

.biz-closed {
  font-weight: bold;
  color: #ff8080;
  font-size: 20px;
  margin-left: 12px;
}

/* ==== Schedule専用（日付＋営業日表示） ==== */
.schedule-date-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
}

.schedule-date {
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
}

.schedule-biz-open {
  font-size: 1.3rem;
  font-weight: 600;
  color: #2e7d32;
}

.schedule-biz-closed {
  font-size: 1.3rem;
  font-weight: 600;
  color: #c62828;
}

/* =========================
   7) Navbars (Index / Category nav / Back-to-top)
   ========================= */
/* ナビゲーションバー */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--theme-accent);
  padding: 8px 16px;
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  margin: 0;
  height: var(--header-nav);
  /* 50px */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}


/* 案件ページ用ナビゲーションバー（index.html 他） */
.navbar-left {
  display: flex;
  align-items: center;
}

.navbar .title {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 20px;
  font-weight: 700;
  margin-left: 24px;
}

/* 案件ページナビ内の日付だけを専用クラスで制御 */
.navbar-date {
  color: #f0f0f0;
  font-size: 18px;
  font-weight: 500;
  margin-left: 2px;
}

.navbar-logo {
  height: 36px;
  width: auto;
  display: block;
}

/* ▼ 狭い画面用 */
@media (max-width: 720px) {
  .navbar-logo {
    height: 30px;
  }

  .navbar-date {
    font-size: 12px;
  }
}

/* indexのナビ内ボタン */
.navbar .links .btn {
  background: #fff;
  color: var(--theme-accent);
  border: 1px solid var(--theme-accent);
  padding: 6px 12px;
  height: auto;
  line-height: 1.4;
  font-weight: 600;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic Medium", sans-serif;
}

.navbar .links .btn.sm {
  padding: 2px 8px;
  font-size: 12px;
}

.navbar .links {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.navbar-button-group,
.navbar-icon-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-button-group form {
  margin: 0;
}

.navbar-icon-group {
  margin-left: auto;
}

.navbar .header-icon-button,
.navbar .header-user-trigger {
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 0;
  background: rgba(255, 255, 255, 0.98);
  color: var(--theme-accent);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.navbar .header-icon-button:hover,
.navbar .header-user-trigger:hover {
  background: #fff;
  color: var(--theme-accent);
  border-color: #fff;
}

.navbar .header-icon-button .material-symbols-outlined,
.navbar .header-user-trigger .material-symbols-outlined {
  font-size: 20px;
}

/* =========================
   カテゴリナビゲーションバー（統合・確定版）
   ========================= */
.category-nav {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  margin: 0 0 16px 0;
  background: #fff;
  border-bottom: 2px solid var(--theme-accent);
  position: sticky;
  /* デフォルト：main-header（72px）用 */
  top: var(--header-height);
  z-index: 999;
  scrollbar-width: thin;
  scrollbar-color: var(--theme-accent) #e5e5e5;
}

/* 案件画面：.navbar（50px）用に上書き */
body.project-index-page .category-nav {
  top: var(--header-nav);
}


.category-nav::-webkit-scrollbar {
  height: 6px;
}

.category-nav::-webkit-scrollbar-thumb {
  background-color: var(--theme-accent);
  border-radius: 3px;
}

.category-nav::-webkit-scrollbar-track {
  background-color: #f0f0f0;
}

.category-nav a {
  display: inline-block;
  padding: 10px 18px;
  text-decoration: none;
  color: var(--theme-accent);
  font-size: 13px;
  font-weight: 600;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic Medium", sans-serif;
  background: #f8f9fc;
  border-right: 1px solid var(--border);
  transition: all 0.2s ease;
}


.category-nav a:last-child {
  border-right: none;
}

.category-nav a:hover {
  background: color-mix(in srgb, var(--theme-accent) 10%, white 90%);
}

.category-nav a.active {
  background: var(--theme-accent);
  color: #fff;
  border-bottom: 2px solid var(--theme-accent);
}

/* ページ内戻るリンク */
.back-to-top {
  margin-top: 10px;
  text-align: right;
}

.back-to-top a {
  font-size: 13px;
  text-decoration: none;
  color: var(--theme-accent);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic Medium", sans-serif;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.10s ease, box-shadow 0.15s ease;
}

.back-to-top a:hover {
  background: color-mix(in srgb, var(--theme-accent) 8%, #ffffff 92%);
  color: var(--theme-accent);
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--theme-accent) 16%, #ffffff 84%);
}

/* =========================
   8) Portal
   ========================= */
/* Portal ページ専用の上マージン補正 */
body.portal-page {
  margin-top: 0px;
}

/* =========================
   Portal: 直近シフト表示（局所）
   - 他の表/カードへ影響を出さないため、コンテナ限定で指定
   ========================= */
.portal-shift-preview {
  /* シフト表示ブロックだけ少し詰める */
  font-size: 16px;
  line-height: 1.35;
}

.portal-shift-preview .shift-table th,
.portal-shift-preview .shift-table td {
  font-size: inherit;
  line-height: inherit;
  padding: 6px 10px;
  /* 行高を抑えつつ読みやすく */
  vertical-align: top;
}

/* 1列あたりを少し広げたいので、表のレイアウトを固定しつつ余白を増やす */
.portal-shift-preview .shift-table {
  width: 100%;
  table-layout: fixed;
  /* 列幅を安定させる */
}

/* テキストが長い場合の折返し制御（1文が長くても崩れにくい） */
.portal-shift-preview .shift-cell {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* =========================================================
   Portal: シフト表示（昨日〜明々後日 / 5日）
   - portal.html からレイアウト定義を移管
   - 既存カード/テーマに合わせて見た目を崩さない
   ========================================================= */
.portal-shift-grid {
  display: grid;
  /* 画面幅に応じて自動で列数を調整（5日でも崩れにくい） */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

/* かなり横が広い場合は、1枚が間延びし過ぎないよう少し締める */
@media (min-width: 1400px) {
  .portal-shift-grid {
    grid-template-columns: repeat(5, minmax(220px, 1fr));
  }
}

/* =========================================================
   Portal: 直近シフト（4日表示）だけ「1列を広く」したい
   - portal.html 側で .card portal-shift-preview を付与済み
   - ここで portal-shift-preview 配下だけ上書きする（他画面へ影響なし）
   ========================================================= */
.portal-shift-preview .portal-shift-grid {
  /* 4日分の横並びを優先し、各列の最小幅を引き上げる */
  grid-template-columns: repeat(4, minmax(280px, 1fr));
  gap: 14px;
  /* 少しだけ余白も増やす（任意） */
}

@media (max-width: 1200px) {

  /* 画面が狭いときは自然に2列→1列へ落とす */
  .portal-shift-preview .portal-shift-grid {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }
}

@media (max-width: 720px) {
  .portal-shift-preview .portal-shift-grid {
    grid-template-columns: 1fr;
  }
}

.shift-col {
  background: var(--theme-card);
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* ブロック間の間隔を安定させる */
}

.shift-col-title {
  font-weight: 700;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.shift-date {
  font-weight: 400;
}

/* Portal（直近シフトカード）だけ日付の見た目を揃える */
.portal-shift-preview .shift-col-title span:first-child {
  font-size: 15px;
}

.portal-shift-preview .shift-date {
  font-size: 12px;
  white-space: nowrap;
}

/* 小見出し（🗓 スケジュール / 👥 シフト） */
.portal-shift-preview .shift-subtitle {
  font-size: 12px;
  font-weight: 800;
  color: color-mix(in srgb, var(--fg) 80%, var(--theme-accent) 20%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: .02em;
  margin-top: 2px;
}

.portal-shift-preview .shift-schedule-list {
  margin: 0;
  padding: 0;
  list-style: none;
  /* 中点を消す */
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-shift-preview .shift-schedule-list li {
  margin: 0;
}

.portal-shift-preview .shift-schedule-item {
  background: #fffbef;
  /* 薄い黄色 */
  border: 1px solid #ffecb3;
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.portal-shift-preview .shift-schedule-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  min-width: 80px;
  text-align: center;
}

.portal-shift-preview .shift-schedule-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
}


/* シフト側リスト */
.portal-shift-preview .shift-list {
  margin: 0;
  padding-left: 18px;
}

.portal-shift-preview .shift-list li {
  margin: 2px 0;
  line-height: 1.4;
}

/* 「予定なし / シフトなし」 */
.portal-shift-preview .shift-empty {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.shift-analysis {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.shift-alert {
  color: #c62828;
  font-weight: 700;
}

.shift-warn {
  color: #ef6c00;
  font-weight: 700;
}

.shift-error {
  color: #c62828;
  font-size: 11px;
  margin-bottom: 5px;
}

/* 区切り線（hr.shift-sep）を軽くする：portalだけに限定 */
.portal-shift-preview .shift-sep {
  border: none;
  height: 1px;
  background: color-mix(in srgb, var(--border) 85%, transparent 15%);
  margin: 6px 0 4px;
}

/* 注意/警告表示：囲い＋背景で“塊”にする（portalだけ） */
.portal-shift-preview .shift-analysis {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-shift-preview .shift-analysis>div {
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent 20%);
  border-radius: 8px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--theme-accent) 6%, var(--theme-card) 94%);
  font-size: 12px;
  line-height: 1.35;
}

.portal-shift-preview .shift-analysis .shift-alert {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border) 45%);
  background: color-mix(in srgb, var(--danger) 10%, var(--theme-card) 90%);
}

.portal-shift-preview .shift-analysis .shift-warn {
  border-color: color-mix(in srgb, #ef6c00 55%, var(--border) 45%);
  background: color-mix(in srgb, #ef6c00 10%, var(--theme-card) 90%);
}

/* ダークテーマ時の背景補正（portalだけ） */
[data-theme="dark"] .portal-shift-preview .shift-analysis>div {
  background: color-mix(in srgb, var(--theme-accent) 14%, var(--theme-card) 86%);
}

[data-theme="dark"] .portal-shift-preview .shift-analysis .shift-alert {
  background: color-mix(in srgb, var(--danger) 18%, var(--theme-card) 82%);
}

[data-theme="dark"] .portal-shift-preview .shift-analysis .shift-warn {
  background: color-mix(in srgb, #ef6c00 18%, var(--theme-card) 82%);
}

/* =========================
   3) Layout Components
   ========================= */

/* メインヘッダー */
.main-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-left {
  min-width: 0;
}

.header-right {
  margin-left: 14px;
  gap: 12px;
}

.header-logo,
.portal-logo,
.sidebar-logo,
.navbar-logo,
.header-logo-link img,
.main-header img,
.navbar img {
  max-height: 32px !important;
  max-width: 180px !important;
  width: auto !important;
  height: auto !important;
  display: block !important;
  object-fit: contain !important;
}



.header-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  margin-left: 8px;
  gap: 10px;
}


.header-title-stack {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
}

.header-system-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.01em;
}

.header-company-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  min-height: 1em;
}

/* ヘッダー内ナビゲーション */
.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
}

.header-date {
  font-size: 0.9rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  line-height: 1;
}

.tools-index-page .header-right,
.tools-settings-page .header-right {
  align-items: center;
}

.tools-index-page .header-date,
.tools-settings-page .header-date {
  display: inline-flex;
  align-items: center;
  height: 40px;
}

.nav-link {
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--fg);
  background: #fff;
}

.nav-link.active {
  background: #fff;
  color: var(--theme-accent);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* ヘッダー内サイドバーボタン */
.sidebar-toggle-in-header {
  background: transparent;
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-toggle-in-header:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* ========================================
   ヘッダー内ハンバーガーボタン（三本線）
   セレクタを親で限定して競合を解消
   ======================================== */
.sidebar-toggle-in-header .sidebar-toggle-icon {
  width: 20px;
  height: 2px;
  background: var(--muted);
  position: relative;
  display: block;
}

.sidebar-toggle-in-header .sidebar-toggle-icon::before,
.sidebar-toggle-in-header .sidebar-toggle-icon::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background: inherit;
  left: 0;
}

.sidebar-toggle-in-header .sidebar-toggle-icon::before {
  top: -6px;
}

.sidebar-toggle-in-header .sidebar-toggle-icon::after {
  bottom: -6px;
}

/* 未読通知バッジ（赤丸）: ハンバーガーボタン右上に表示 */
.sidebar-toggle-in-header {
  position: relative;
}

.sidebar-toggle-in-header.has-unread::after {
  display: block;
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d32f2f;
  border: 2px solid #fff;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 1;
}

/* プロジェクトナビ（背景色あり）向けに、アイコンを白に強制 */
.navbar .sidebar-toggle-in-header {
  border-color: rgba(255, 255, 255, 0.4);
}

.navbar .sidebar-toggle-in-header .sidebar-toggle-icon,
.navbar .sidebar-toggle-in-header .sidebar-toggle-icon::before,
.navbar .sidebar-toggle-in-header .sidebar-toggle-icon::after {
  background: #fff !important;
}

.navbar .sidebar-toggle-in-header:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
}


/* Portal: プロジェクト一覧（重複統合） */
.project-list,
.card-body .project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.project-item,
.card-body .project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--theme-card);
  box-shadow: var(--theme-shadow);
  margin: 0;
  width: 100%;
  max-width: none;
}

@media (max-width: 800px) {
  .card-body .project-list {
    grid-template-columns: 1fr !important;
  }
}

.project-item:last-child {
  border-bottom: none;
}

.project-name {
  font-weight: 600;
  margin-right: 12px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-actions {
  display: flex;
  gap: 8px;
}

/* 各休憩行 */
#breaks-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.break-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
  width: 140px;
  height: 160px;
}

.break-header {
  display: flex;
  align-items: center;
  gap: 4px;
}

.break-time {
  width: 90px;
}

.remove-break {
  width: 20px;
  height: 20px;
  background: #d9534f;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.break-list {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.break-item {
  white-space: nowrap;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--theme-card);
  box-shadow: var(--theme-shadow);
}

/* ユーザー一覧用 */
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.user-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--theme-card);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}

.user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.user-avatar-container {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-3);
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--theme-bg);
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar-placeholder {
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar-placeholder .material-symbols-outlined {
  font-size: 40px;
}

.user-info {
  margin-bottom: var(--space-3);
  text-align: center;
}

.user-name {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: var(--space-1);
}

.user-id {
  font-size: 0.9rem;
  color: var(--muted);
}

.user-actions {
  text-align: center;
}

.user-card label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.35;
}

@media (max-width: 800px) {
  .user-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   9) Theme (data-theme)
   ========================= */
/* Light */
[data-theme="light"] {
  --theme-header-bg: var(--bg);
}

/* Dark */
[data-theme="dark"] {
  --fg: #e9eef5;
  --muted: #aeb6c2;
  --bg: #0f1115;
  --border: #2a2f3a;
  --theme-bg: #0f1115;
  --theme-card: #171a21;
  --theme-shadow: 0 2px 12px rgba(0, 0, 0, .5);
  --theme-accent: #4ea3ff;
  --success: #2ecc71;
  --danger: #ff6b6b;
  --theme-header-bg: #141821;
}

[data-theme="dark"] body {
  color: var(--fg);
  background: var(--theme-bg);
}

[data-theme="dark"] input[type="text"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: #1b1f27;
  color: var(--fg);
  border-color: var(--border);
}

[data-theme="dark"] .btn {
  background: #1b1f27;
  color: var(--fg);
  border-color: var(--border);
}

[data-theme="dark"] .btn.primary {
  color: #fff;
}

/* ダークテーマ時も白背景・黒文字で視認性を維持（既存仕様維持） */
[data-theme="dark"] .quill-editor,
[data-theme="dark"] .task-summary,
[data-theme="dark"] .ql-editor {
  background: #fff;
  color: #111;
}

[data-theme="dark"] .ql-editor a,
[data-theme="dark"] .task-summary a {
  color: #0b5ed7;
}

[data-theme="dark"] .ql-editor pre,
[data-theme="dark"] .task-summary pre {
  background: #f5f5f5;
  color: #111;
}

[data-theme="dark"] .ql-editor code,
[data-theme="dark"] .task-summary code {
  background: #f0f0f0;
  color: #000;
}

/* 既存の後勝ち定義も維持（見た目変更を避ける） */
[data-theme="dark"] .task-summary a,
[data-theme="dark"] .task-summary pre {
  background: #1e1e1e;
  color: #f1f1f1;
}

[data-theme="dark"] .task-summary code {
  background: #2a2a2a;
  color: #f1f1f1;
}

[data-theme="dark"] .comment-section a {
  color: #8ab4ff;
}

/* Dark theme表サポート */
[data-theme="dark"] .ql-editor table,
[data-theme="dark"] .task-summary table {
  border-color: #3a3f4b;
}

[data-theme="dark"] .ql-editor th,
[data-theme="dark"] .task-summary th {
  background: #242731;
  color: #e9eef5;
}

[data-theme="dark"] .ql-editor td,
[data-theme="dark"] .task-summary td {
  background: #1c1f26;
  color: #dce3ed;
}

/* Blue */
[data-theme="blue"] {
  --theme-accent: #0b5ed7;
  --theme-header-bg: #eaf2ff;
}

[data-theme="blue"] .card-header {
  color: #0b5ed7;
}

/* Green */
[data-theme="green"] {
  --theme-accent: #2e7d32;
  --theme-header-bg: #e8f5ec;
}

[data-theme="green"] .card-header {
  color: #2e7d32;
}

/* Yellow */
[data-theme="yellow"] {
  --theme-accent: #f9a825;
  --theme-header-bg: #fff8e1;
}

[data-theme="yellow"] .card-header {
  color: #a97600;
}

/* Red */
[data-theme="red"] {
  --theme-accent: #c62828;
  --theme-header-bg: #ffebee;
}

[data-theme="red"] .card-header {
  color: #b71c1c;
}

/* 共通: 見出し背景と左アクセント帯（カテゴリブロック） */
.category-block .card-header {
  background: var(--theme-header-bg);
  border-left: 4px solid var(--theme-accent);
}

.task-category {
  color: var(--theme-accent);
}

/* ボタンのアクセント（success もテーマ色に揃える運用） */
button.btn.primary,
a.btn.primary {
  background: color-mix(in srgb, var(--theme-accent) 95%, black 0%) !important;
  border-color: var(--theme-accent) !important;
  color: #fff !important;
}

.btn.primary {
  background: color-mix(in srgb, var(--theme-accent) 95%, black 0%) !important;
  border-color: var(--theme-accent) !important;
  color: #fff !important;
}

.btn.success {
  background: color-mix(in srgb, var(--theme-accent) 20%, black 0%);
  border-color: var(--theme-accent);
  color: color-mix(in srgb, var(--theme-accent) 100%, black 15%);
  font-weight: bold;
}

/* 期限・予定超過（赤文字強調） */
.overdue {
  color: #c62828;
  font-weight: bold;
}

/* 非営業日（カレンダー/日次/タスク一覧の共通スタイル） */
.biz-closed {
  color: #c62828;
  font-weight: bold;
}

/* =========================
   10) Sidebar (現状維持：位置移動のみ)
   ========================= */
/* =========================
   10) Sidebar (刷新：新構造対応)
   ========================= */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: var(--header-height);
  /* デフォルト 72px */
  left: 0;
  width: 280px;
  max-width: 85%;
  height: calc(100vh - var(--header-height));
  background: #fff;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  border-right: 1px solid var(--border);
}

/* 案件画面（50pxヘッダー）向け補正 */
.project-index-page .sidebar,
.edit .sidebar,
.settings .sidebar {
  top: var(--header-nav);
  /* 50px */
  height: calc(100vh - var(--header-nav));
}

body.sidebar-open .sidebar {
  transform: translateX(0);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 未読メッセージ通知エリア */
#sidebar-unread-message {
  margin: 4px 8px;
  padding: 8px 12px;
  background: #fde8e8;
  color: #c62828;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  border-left: 3px solid #e53935;
}

.sidebar-label {
  padding: 0 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}

.sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.sidebar-item:hover {
  background: #f1f5f9;
  color: var(--theme-accent);
}

.sidebar-item.active {
  background: #eff6ff;
  color: var(--theme-accent);
  font-weight: 600;
}

.sidebar-item.logout {
  color: var(--danger);
  margin-top: auto;
}

.sidebar-item.logout:hover {
  background: #fef2f2;
  color: var(--danger);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-empty {
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ダークテーマ対応 */
[data-theme="dark"] .sidebar {
  background: #1e293b;
  border-right-color: #334155;
}

[data-theme="dark"] .sidebar-item:hover {
  background: #334155;
}

[data-theme="dark"] .sidebar-item.active {
  background: #1e3a8a;
  color: #60a5fa;
}


/* ナビに置くトグルボタン例 */
.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
}

/* サイドバー用「栞」アイコン */
.sidebar-toggle-floating {
  position: fixed;
  top: 90px;
  /* ヘッダー(72px)より下に配置 */
  left: -8px;
  z-index: 9999;
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .25s ease, left .25s ease, top .25s ease;
}


body.sidebar-open .sidebar-toggle-floating {
  left: 253px;
}

.sidebar-toggle-floating.sticky {
  position: fixed;
}

/* ========================================
   フローティング栞ボタン（刷新）
   こちらも親で限定
   ======================================== */
.sidebar-toggle-floating .sidebar-toggle-icon {
  position: relative;
  display: block;
  width: 24px;
  height: 30px;
  background: var(--theme-accent);
  border-radius: 0 8px 8px 0;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.25);
}

.sidebar-toggle-floating .sidebar-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  border-style: solid;
  border-width: 6px 9px 0 0;
  border-color: var(--theme-accent) transparent transparent transparent;
}

/* ::before は栞ボタンでは不要（未読赤丸以外）なので定義しないか隠す */
.sidebar-toggle-floating .sidebar-toggle-icon::before {
  display: none;
}

/* 未読表示がある場合のみ ::before を使う（チャットスクリプト用） */
.sidebar-toggle-floating.has-unread .sidebar-toggle-icon::before {
  display: block !important;
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d32f2f;
  border: 2px solid #fff;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 1;
}

/* Material Symbols アイコンサイズ調整 */
.sidebar-icon {
  font-family: 'Material Symbols Outlined';
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.sidebar-item.active .sidebar-icon {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}

/* サイドバーのポータルリンク / 更新リンク */
.sidebar-portal-link,
.sidebar-refresh-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic Medium", sans-serif;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.10s ease, box-shadow 0.15s ease;
}

.sidebar-portal-link:hover,
.sidebar-refresh-link:hover {
  text-decoration: none;
  background: color-mix(in srgb, var(--theme-accent) 10%, #ffffff 90%);
  color: var(--theme-accent);
  transform: translateX(2px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--theme-accent) 25%, #ffffff 75%);
}

[data-theme="dark"] .sidebar-portal-link:hover,
[data-theme="dark"] .sidebar-refresh-link:hover {
  background: color-mix(in srgb, #ffffff 8%, var(--theme-bg) 92%);
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* サイドバー上部のナビボタン共通スタイル */
.sidebar-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic Medium", sans-serif;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.10s ease, box-shadow 0.15s ease;
}

.sidebar-nav-btn:hover {
  text-decoration: none;
  background: color-mix(in srgb, var(--theme-accent) 10%, #ffffff 90%);
  color: var(--theme-accent);
  transform: translateX(2px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--theme-accent) 25%, #ffffff 75%);
}

[data-theme="dark"] .sidebar-nav-btn {
  background: #1b1f27;
  border-color: var(--border);
}

[data-theme="dark"] .sidebar-nav-btn:hover {
  background: color-mix(in srgb, #ffffff 8%, var(--theme-bg) 92%);
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

/* =========================
   11) Remaining small rules
   ========================= */
/* サブタスク表示 */
.task-item.subtask {
  margin-left: 32px;
  border-left: 3px solid var(--theme-accent);
  background: color-mix(in srgb, var(--theme-accent) 5%, white 95%);
  opacity: 0.95;
  margin-top: 12px;
  padding-top: 10px;
  position: relative;
  z-index: 0;
}

.task-item.subtask .task-drag-handle {
  top: -3px;
  background: color-mix(in srgb, var(--theme-accent) 10%, white 90%);
}

.task-item.subtask .task-drag-handle:hover {
  background: color-mix(in srgb, var(--theme-accent) 20%, white 80%);
}

.task-item.subtask .task-drag-handle:active {
  background: color-mix(in srgb, var(--theme-accent) 25%, white 75%);
}

.task-item.subtask .subtask-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 4px 4px;
}

/* 親タスク完了制限の視覚効果 */
button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

button[disabled]:hover {
  opacity: 0.5;
}

/* テンプレート選択行（タスク追加フォーム） */
.template-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.template-row span {
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 0;
  display: inline-block;
}

.template-row select {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.template-row .btn {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .template-row {
    flex-wrap: wrap;
  }

  .template-row select {
    flex: 1 1 100%;
    max-width: none;
  }
}

/* タスク追加・編集フォームの第1段階UI改善
   - 適用対象を .task-form--enhanced に限定
   - 既存の name / id / JS フックは変更しない */
.task-form--enhanced {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.task-form--enhanced .task-form-section {
  border: 1px solid color-mix(in srgb, var(--border) 88%, var(--theme-accent) 12%);
  border-radius: 12px;
  padding: 16px 18px;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--theme-card) 96%, #ffffff 4%) 0%,
      color-mix(in srgb, var(--theme-card) 90%, #eff6ff 10%) 100%
    );
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.task-form--enhanced .task-form-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 92%, var(--theme-accent) 8%);
}

.task-form--enhanced .task-form-section-title-row,
.task-form--enhanced .task-form-label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.task-form--enhanced .task-form-section-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--fg);
}

.task-form--enhanced .task-form-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--border) 82%, var(--theme-accent) 18%);
  border-radius: 999px;
  background: #fff;
  color: var(--theme-accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.task-form--enhanced .task-form-help::before,
.task-form--enhanced .task-form-help::after {
  position: absolute;
  left: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.task-form--enhanced .task-form-help::before {
  content: "";
  top: calc(100% + 6px);
  left: 8px;
  transform: translateY(-4px);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(15, 23, 42, 0.92);
}

.task-form--enhanced .task-form-help::after {
  content: attr(data-help);
  top: calc(100% + 12px);
  width: 260px;
  max-width: calc(100vw - 40px);
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
  transform: translateY(-4px);
  z-index: 10;
}

.task-form--enhanced .task-form-help:hover::before,
.task-form--enhanced .task-form-help:hover::after,
.task-form--enhanced .task-form-help:focus-visible::before,
.task-form--enhanced .task-form-help:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.task-form--enhanced .task-form-help:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--theme-accent) 28%, transparent);
  outline-offset: 2px;
}

.task-form--enhanced .task-form-section-note,
.task-form--enhanced .task-form-helper {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.task-form--enhanced .row {
  margin-bottom: 16px;
}

.task-form--enhanced .row:last-child {
  margin-bottom: 0;
}

.task-form--enhanced label {
  font-size: 13px;
  font-weight: 700;
  color: color-mix(in srgb, var(--fg) 90%, var(--theme-accent) 10%);
}

.task-form--enhanced input[type="text"],
.task-form--enhanced input[type="date"],
.task-form--enhanced input[type="time"],
.task-form--enhanced textarea,
.task-form--enhanced select {
  min-height: 40px;
  border-color: color-mix(in srgb, var(--border) 85%, #cbd5e1 15%);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.task-form--enhanced textarea {
  min-height: 132px;
}

.task-form--enhanced input[type="text"]:focus,
.task-form--enhanced input[type="date"]:focus,
.task-form--enhanced input[type="time"]:focus,
.task-form--enhanced textarea:focus,
.task-form--enhanced select:focus {
  border-color: color-mix(in srgb, var(--theme-accent) 72%, #ffffff 28%);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-accent) 16%, transparent);
}

.task-form--enhanced .tox-tinymce {
  border-radius: 10px;
  border-color: color-mix(in srgb, var(--border) 82%, #cbd5e1 18%);
  overflow: hidden;
}

.task-form--enhanced .template-row {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed color-mix(in srgb, var(--border) 84%, var(--theme-accent) 16%);
  border-radius: 10px;
  background: color-mix(in srgb, var(--theme-card) 94%, #f8fbff 6%);
}

.task-form--enhanced .task-form-meta-grid .form-group,
.task-form--enhanced .task-form-date-grid > div,
.task-form--enhanced .task-form-date-grid > .form-group {
  min-height: 100%;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--border) 90%, #dbeafe 10%);
  border-radius: 10px;
  background: #fff;
}

.task-form--enhanced .task-form-meta-grid .short-select {
  max-width: none;
}

.task-form--enhanced .task-form-checks-row,
.task-form--enhanced .task-form-checks-panel {
  padding: 12px 14px;
  border: 1px dashed color-mix(in srgb, var(--border) 88%, var(--theme-accent) 12%);
  border-radius: 10px;
  background: color-mix(in srgb, var(--theme-card) 96%, #f8fafc 4%);
}

.task-form--enhanced .task-form-checks-row > label,
.task-form--enhanced .task-form-checks-panel > label {
  display: block;
  margin-bottom: 8px;
}

.task-form--enhanced .task-form-checks-row > .task-form-label-with-help {
  display: inline-flex;
  margin-bottom: 8px;
}

.task-form--enhanced .task-form-checks-panel .checked-members {
  margin-top: 8px;
}

.task-form--enhanced .task-form-notify-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 14px;
  border: 1px dashed color-mix(in srgb, var(--border) 88%, var(--theme-accent) 12%);
  border-radius: 10px;
  background: #fff;
}

.task-form--enhanced .task-form-notify-row > label {
  margin: 0;
  flex: 0 0 auto;
}

.task-form--enhanced .task-form-notify-row > .task-form-label-with-help {
  margin: 0;
  flex: 0 0 auto;
}

.task-form--enhanced .notify-checkboxes {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  flex: 1 1 auto;
  margin-left: 0;
  gap: 10px;
}

.task-form--enhanced .task-form-inline-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.task-form--enhanced .task-form-notify-row .task-form-helper {
  flex: 0 0 100%;
}

.task-form--enhanced .notify-checkboxes label,
.task-form--enhanced .radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 12px;
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--border) 84%, #cbd5e1 16%);
  border-radius: 999px;
  background: #fff;
  color: var(--fg);
  white-space: nowrap;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.task-form--enhanced .notify-checkboxes label:has(input:checked),
.task-form--enhanced .radio-row label:has(input:checked) {
  border-color: color-mix(in srgb, var(--theme-accent) 38%, #ffffff 62%);
  background: color-mix(in srgb, var(--theme-accent) 14%, #ffffff 86%);
  color: color-mix(in srgb, var(--theme-accent) 78%, #0f172a 22%);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.12);
}

.task-form--enhanced .notify-checkboxes label:has(input:disabled),
.task-form--enhanced .radio-row label:has(input:disabled) {
  opacity: 0.7;
}

.task-form--enhanced .notify-checkboxes input,
.task-form--enhanced .radio-row input {
  margin: 0;
  accent-color: var(--theme-accent);
}

.task-form--enhanced .radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.task-form--enhanced .task-form-inline-actions,
.task-form--enhanced .task-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.task-form--enhanced .task-form-actions {
  padding-top: 2px;
}

@media (max-width: 720px) {
  .task-form--enhanced .task-form-section {
    padding: 14px;
  }

  .task-form--enhanced .task-form-meta-grid .form-group,
  .task-form--enhanced .task-form-date-grid > div,
  .task-form--enhanced .task-form-date-grid > .form-group {
    padding: 12px;
  }

  .task-form--enhanced .task-form-notify-row,
  .task-form--enhanced .task-form-checks-row,
  .task-form--enhanced .task-form-checks-panel {
    padding: 12px;
  }

  .task-form--enhanced .notify-checkboxes label,
  .task-form--enhanced .radio-row label {
    white-space: normal;
  }

  .task-form--enhanced .notify-checkboxes {
    flex-wrap: wrap;
  }

  .task-form--enhanced .task-form-inline-actions {
    margin-left: 0;
  }
}

/* 設定画面の第1段階UI改善
   - 適用対象を .settings-form--enhanced に限定
   - 一般設定 / 通知設定のみを対象にする */
.settings-page-shell {
  padding-bottom: 28px;
}

.settings-form--enhanced .settings-card {
  overflow: visible;
}

.settings-form--enhanced .settings-card-header {
  padding: 10px 14px;
  background: var(--theme-header-bg);
  border-bottom: 1px solid var(--border);
}

.settings-form--enhanced .settings-card-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  color: inherit;
}

.settings-form--enhanced .settings-card-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: color-mix(in srgb, currentColor 70%, var(--muted) 30%);
}

.settings-form--enhanced .settings-card-body {
  padding: 18px;
}

.settings-form--enhanced .settings-form-layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-form--enhanced .settings-form-section {
  border: 1px solid color-mix(in srgb, var(--border) 88%, var(--theme-accent) 12%);
  border-radius: 12px;
  padding: 16px 18px;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--theme-card) 96%, #ffffff 4%) 0%,
      color-mix(in srgb, var(--theme-card) 91%, #f8fbff 9%) 100%
    );
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.settings-form--enhanced .settings-form-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 92%, var(--theme-accent) 8%);
}

.settings-form--enhanced .settings-form-section-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-form--enhanced .settings-label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.settings-form--enhanced .settings-label-with-help label {
  margin-bottom: 0;
}

.settings-form--enhanced .settings-form-section-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--fg);
}

.settings-form--enhanced .settings-form-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--border) 82%, var(--theme-accent) 18%);
  border-radius: 999px;
  background: #fff;
  color: var(--theme-accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.settings-form--enhanced .settings-form-help::before,
.settings-form--enhanced .settings-form-help::after {
  position: absolute;
  left: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.settings-form--enhanced .settings-form-help::before {
  content: "";
  top: calc(100% + 6px);
  left: 8px;
  transform: translateY(-4px);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(15, 23, 42, 0.92);
}

.settings-form--enhanced .settings-form-help::after {
  content: attr(data-help);
  top: calc(100% + 12px);
  width: 280px;
  max-width: min(280px, calc(100vw - 40px));
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
  transform: translateY(-4px);
  z-index: 10;
}

.settings-form--enhanced .settings-form-help:hover::before,
.settings-form--enhanced .settings-form-help:hover::after,
.settings-form--enhanced .settings-form-help:focus-visible::before,
.settings-form--enhanced .settings-form-help:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.settings-form--enhanced .settings-form-help:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--theme-accent) 28%, transparent);
  outline-offset: 2px;
}

.settings-form--enhanced .settings-form-grid {
  display: grid;
  gap: 14px;
}

.settings-form--enhanced .settings-form-grid--display {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.settings-form--enhanced .settings-form-grid--categories {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.settings-form--enhanced .settings-form-grid--metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.settings-form--enhanced .settings-form-grid--reset-pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.settings-form--enhanced .settings-field-card,
.settings-form--enhanced .settings-surface,
.settings-form--enhanced .settings-note-row,
.settings-form--enhanced .settings-toggle-card {
  min-height: 100%;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--border) 90%, #dbeafe 10%);
  border-radius: 10px;
  background: #fff;
}

.settings-form--enhanced .settings-field-card--wide {
  grid-column: span 2;
}

.settings-form--enhanced .settings-field-card label,
.settings-form--enhanced .settings-inline-field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: color-mix(in srgb, var(--fg) 90%, var(--theme-accent) 10%);
}

.settings-form--enhanced .settings-field-card--inline {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
}

.settings-form--enhanced .settings-field-card--inline label,
.settings-form--enhanced .settings-field-card--inline .settings-label-with-help {
  margin-bottom: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.settings-form--enhanced .settings-field-card--inline .settings-input,
.settings-form--enhanced .settings-field-card--inline .settings-select,
.settings-form--enhanced .settings-field-control,
.settings-form--enhanced .settings-field-card--inline .settings-input-with-unit {
  flex: 0 0 auto;
  width: auto;
}

.settings-form--enhanced .settings-input,
.settings-form--enhanced .settings-select,
.settings-form--enhanced input[type="text"],
.settings-form--enhanced input[type="number"],
.settings-form--enhanced input[type="time"],
.settings-form--enhanced select {
  width: 100%;
  min-height: 40px;
  border-color: color-mix(in srgb, var(--border) 85%, #cbd5e1 15%);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.settings-form--enhanced .settings-input:focus,
.settings-form--enhanced .settings-select:focus,
.settings-form--enhanced input[type="text"]:focus,
.settings-form--enhanced input[type="number"]:focus,
.settings-form--enhanced input[type="time"]:focus,
.settings-form--enhanced select:focus {
  border-color: color-mix(in srgb, var(--theme-accent) 72%, #ffffff 28%);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-accent) 16%, transparent);
}

.settings-form--enhanced .settings-input--display-name {
  max-width: 360px;
}

.settings-form--enhanced .settings-field-control--xs {
  max-width: 88px;
}

.settings-form--enhanced .settings-field-control--sm {
  max-width: 140px;
}

.settings-form--enhanced .settings-field-control--time {
  max-width: 140px;
}

.settings-form--enhanced .settings-field-card .hint,
.settings-form--enhanced .settings-note-row .hint,
.settings-form--enhanced .settings-section-hint {
  display: block;
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.settings-form--enhanced .settings-section-hint {
  margin-top: 10px;
}

.settings-form--enhanced .settings-input-with-unit,
.settings-form--enhanced .settings-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-form--enhanced .settings-inline-field {
  flex-direction: column;
  align-items: flex-start;
}

.settings-form--enhanced .settings-inline-field-label--inline {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0;
}

.settings-form--enhanced .settings-inline-field--grow {
  flex: 1 1 260px;
  min-width: min(320px, 100%);
}

.settings-form--enhanced .settings-inline-field .settings-input,
.settings-form--enhanced .settings-inline-field .settings-select,
.settings-form--enhanced .settings-input-with-unit .settings-input {
  width: auto;
}

.settings-form--enhanced .settings-toggle-card,
.settings-form--enhanced .settings-toggle-chip,
.settings-form--enhanced .settings-note-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
}

.settings-form--enhanced .settings-toggle-card {
  align-self: stretch;
  justify-content: flex-start;
  cursor: pointer;
}

.settings-form--enhanced .settings-toggle-chip,
.settings-form--enhanced .settings-note-toggle {
  cursor: pointer;
}

.settings-form--enhanced .settings-toggle-card input,
.settings-form--enhanced .settings-toggle-chip input,
.settings-form--enhanced .settings-note-toggle input,
.settings-form--enhanced .settings-chip-row input {
  margin: 0;
  accent-color: var(--theme-accent);
}

.settings-form--enhanced .settings-surface {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-form--enhanced .settings-reset-row,
.settings-form--enhanced .settings-notify-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 14px;
}

.settings-form--enhanced .settings-note-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.settings-form--enhanced .settings-reset-inline-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  min-height: 100%;
}

.settings-form--enhanced .settings-reset-inline-row .settings-toggle-chip {
  flex: 0 0 auto;
}

.settings-form--enhanced .settings-reset-inline-row .settings-input-with-unit {
  flex-wrap: nowrap;
}

.settings-form--enhanced .settings-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-form--enhanced .settings-chip-row--notify {
  flex: 1 1 auto;
}

.settings-form--enhanced .settings-chip-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 12px;
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--border) 84%, #cbd5e1 16%);
  border-radius: 999px;
  background: #fff;
  color: var(--fg);
  white-space: nowrap;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.settings-form--enhanced .settings-chip-row label:has(input:checked) {
  border-color: color-mix(in srgb, var(--theme-accent) 38%, #ffffff 62%);
  background: color-mix(in srgb, var(--theme-accent) 14%, #ffffff 86%);
  color: color-mix(in srgb, var(--theme-accent) 78%, #0f172a 22%);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.12);
}

.settings-form--enhanced .settings-inline-actions,
.settings-form--enhanced .settings-card-footer,
.settings-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-form--enhanced .settings-inline-actions {
  margin-left: auto;
}

.settings-form--enhanced .settings-card-footer {
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  min-height: 56px;
}

.settings-dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  width: min(360px, calc(100% - 32px));
}

.settings-dialog-form {
  margin: 0;
  padding: 16px;
}

.settings-dialog-title {
  margin-bottom: 10px;
  font-weight: 700;
}

.settings-dialog-body {
  margin: 0 0 14px;
}

.settings-dialog-actions {
  justify-content: flex-end;
}

@media (max-width: 960px) {
  .settings-form--enhanced .settings-form-grid--display,
  .settings-form--enhanced .settings-form-grid--categories,
  .settings-form--enhanced .settings-form-grid--metrics,
  .settings-form--enhanced .settings-form-grid--reset-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .settings-form--enhanced .settings-card-body,
  .settings-form--enhanced .settings-card-header,
  .settings-form--enhanced .settings-card-footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .settings-form--enhanced .settings-form-section {
    padding: 14px;
  }

  .settings-form--enhanced .settings-form-grid--display,
  .settings-form--enhanced .settings-form-grid--categories,
  .settings-form--enhanced .settings-form-grid--metrics,
  .settings-form--enhanced .settings-form-grid--reset-pair {
    grid-template-columns: 1fr;
  }

  .settings-form--enhanced .settings-field-card--wide {
    grid-column: auto;
  }

  .settings-form--enhanced .settings-input--display-name,
  .settings-form--enhanced .settings-field-control--xs,
  .settings-form--enhanced .settings-field-control--sm,
  .settings-form--enhanced .settings-field-control--time,
  .settings-form--enhanced .settings-inline-field .settings-input,
  .settings-form--enhanced .settings-inline-field .settings-select,
  .settings-form--enhanced .settings-input-with-unit .settings-input {
    width: 100%;
    max-width: none;
  }

  .settings-form--enhanced .settings-input-with-unit,
  .settings-form--enhanced .settings-inline-field,
  .settings-form--enhanced .settings-inline-actions {
    width: 100%;
  }

  .settings-form--enhanced .settings-chip-row label {
    white-space: normal;
  }

  .settings-form--enhanced .settings-inline-actions {
    margin-left: 0;
  }
}


.tab-link {
  padding: 6px 14px;
  border-radius: 20px;
  text-decoration: none;
  color: #666;
  background: #eee;
  white-space: nowrap;
  font-size: 13px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.tab-link:hover {
  background: #ddd;
}

.tab-link.active {
  background: var(--theme-accent);
  color: #fff;
}

/* ==================================
   タスクカードのドラッグハンドル
   ================================== */
.task-drag-handle {
  display: block;
  height: 18px;
  margin: calc(-1 * var(--space-3)) calc(-1 * var(--space-3)) var(--space-2) calc(-1 * var(--space-3));
  background-color: color-mix(in srgb, var(--theme-accent) 12%, transparent);
  cursor: grab;
  text-align: center;
  line-height: 18px;
  font-size: 14px;
  color: var(--theme-accent);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  user-select: none;
  border-bottom: 1px solid var(--border);
  letter-spacing: 5px;
}

.task-drag-handle:hover {
  background-color: color-mix(in srgb, var(--theme-accent) 22%, transparent);
}

.task-drag-handle:active {
  cursor: grabbing;
}
/* Header user dropdown (portal) */
.header-notification-menu,
.header-user-menu {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}

.header-icon-button {
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 0;
  cursor: pointer;
  color: var(--muted);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.header-icon-button:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: var(--fg);
}

.header-notification-trigger {
  position: relative;
}

.header-notification-trigger .material-symbols-outlined {
  font-size: 22px;
}

.header-notification-trigger.has-unread::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d32f2f;
  border: 2px solid #fff;
  box-sizing: border-box;
}

.header-user-trigger {
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 0;
  cursor: pointer;
  overflow: hidden;
  color: var(--muted);
}

.header-user-trigger:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.header-user-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-notification-dropdown,
.header-user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: var(--theme-card, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  display: none;
  z-index: 1200;
}

.header-notification-dropdown {
  min-width: 260px;
  max-width: min(320px, calc(100vw - 24px));
}

.header-notification-menu.open .header-notification-dropdown,
.header-user-menu.open .header-user-dropdown {
  display: block;
}

.header-notification-empty {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 14px;
}

.header-notification-item {
  display: block;
  padding: 12px 14px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
}

.header-notification-item:hover {
  background: #f8fafc;
}

.header-user-info {
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.header-user-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
}

.header-user-id {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.header-user-link {
  display: block;
  padding: 10px 14px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
}

.header-user-link:hover {
  background: #f8fafc;
}

.header-user-link.danger {
  border-top: 1px solid var(--border);
}

/* 期限・実施予定日のグリッド幅調整 */
.task-form-date-grid {
  grid-template-columns: 1.3fr 0.7fr !important;
}
@media (max-width: 960px) {
  .task-form-date-grid {
    grid-template-columns: 1fr !important;
  }
}
  
/* Navbar Tool Shortcuts */  
.tool-nav-icon { position: relative; transition: transform 0.2s; }  
.tool-nav-icon:hover { transform: translateY(-2px); color: var(--theme-accent); }  
.tool-nav-icon .material-symbols-outlined { font-size: 20px; }  
.navbar-icon-divider { width: 1px; height: 24px; background: var(--border); margin: 0 8px; align-self: center; } 

/* =========================
   9) Others / Badges
   ========================= */
.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  vertical-align: middle;
  line-height: 1;
}
.badge.danger {
  background-color: var(--danger);
  color: #fff;
}
