/* 色：深緑 #2f5039 とグレー */
:root {
  --bg-main: #eceeed;
  --bg-side: #f6f7f6;
  --card: #fbfbfb;
  --card-hover: #f1f3f2;
  --field: #ffffff;
  --border: #dcdfdd;
  --border-strong: #c6cac7;
  --text: #222624;
  --text-sub: #6d7470;
  --text-faint: #9ca29e;
  --accent: #2f5039;
  --accent-hover: #23402c;
  --accent-soft: #e3ebe5;
  --on-accent: #ffffff;
  --danger: #b0413e;
  --danger-soft: #f6e1e0;
  --done: #3f7d52;
  --done-soft: #e2eee5;
  --tag: #5d6b80;
  --pri-high-bg: #f6e1e0; --pri-high: #b0413e;
  --pri-mid-bg: #f3edd6;  --pri-mid: #75621c;
  --pri-low-bg: #e9ebea;  --pri-low: #666d69;
  --st-before: #5d6b80; --st-before-bg: #e6e9ee;
  --st-active: #2f5039; --st-active-bg: #e3ebe5;
  --st-done: #6d7470;   --st-done-bg: #eceeed;
  --toast: #222624;
  --mono: "Consolas", "SFMono-Regular", "Menlo", "Courier New", monospace;
}
:root[data-theme="dark"] {
  --bg-main: #151816;
  --bg-side: #1b1f1c;
  --card: #212622;
  --card-hover: #29302b;
  --field: #191d1a;
  --border: #313833;
  --border-strong: #434b45;
  --text: #e5e9e6;
  --text-sub: #a1a9a4;
  --text-faint: #6e7671;
  --accent: #7fb08f;
  --accent-hover: #95c3a4;
  --accent-soft: #24332a;
  --on-accent: #151816;
  --danger: #e58a84;
  --danger-soft: #3b2423;
  --done: #7fb08f;
  --done-soft: #24332a;
  --tag: #a3b1c7;
  --pri-high-bg: #3b2423; --pri-high: #f0a39e;
  --pri-mid-bg: #37321f;  --pri-mid: #dcc67e;
  --pri-low-bg: #2b302d;  --pri-low: #b0b7b2;
  --st-before: #a3b1c7; --st-before-bg: #2a303a;
  --st-active: #7fb08f; --st-active-bg: #24332a;
  --st-done: #a1a9a4;   --st-done-bg: #2b302d;
  --toast: #e5e9e6;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-main);
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 15px;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; color: inherit; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }

/* ---------- 共通の部品 ---------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--on-accent);
  border: none; border-radius: 6px;
  padding: 9px 16px; font-weight: 700;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; }
.btn-primary.wide { width: 100%; margin-top: 20px; }
.btn-outline {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px;
}
.btn-outline:hover { background: var(--card-hover); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--text-sub);
  padding: 6px 8px; border-radius: 6px;
}
.btn-ghost:hover { background: var(--card-hover); }
.btn-ghost.on { color: var(--accent); }
.btn-danger {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); color: var(--danger);
  border: 1px solid var(--danger-soft); border-radius: 6px; padding: 8px 14px;
}
.btn-danger:hover { background: var(--danger-soft); }
.field {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; background: var(--field); max-width: 100%;
}
.field:focus { outline: none; border-color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--toast); color: var(--bg-main); padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 20; max-width: calc(100% - 32px);
}
.toast.error { background: var(--danger); color: var(--on-accent); }

/* ---------- 設定・ログイン画面 ---------- */
.center-screen {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 100%; max-width: 420px;
}
.panel h1 { font-size: 20px; margin: 0 0 20px; }
.panel p { line-height: 1.7; color: var(--text-sub); }
.login label { display: block; font-size: 13px; color: var(--text-sub); margin: 14px 0 6px; }
.login input { width: 100%; }
.login-error { color: var(--danger) !important; min-height: 1.5em; margin: 12px 0 0; }
.login-note { font-size: 13px; margin: 8px 0 0; }

/* ---------- 全体の枠と左メニュー ---------- */
.shell { display: flex; height: 100vh; }
.sidebar {
  width: 228px; flex-shrink: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 10px 12px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 700; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--text-sub); }
.side-label { font-size: 11px; color: var(--text-faint); padding: 0 10px 8px; letter-spacing: .1em; }
.sidenav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: none; border: none; border-radius: 8px;
  padding: 10px 10px; text-align: left; color: var(--text);
}
.nav-item svg { color: var(--text-sub); }
.nav-item:hover { background: var(--card-hover); }
.nav-item.active { background: var(--accent-soft); font-weight: 700; }
.nav-item.active svg { color: var(--accent); }
.nav-item .grow { flex: 1; }
.nav-count { font-family: var(--mono); font-size: 12px; color: var(--text-sub); }
.nav-soon { font-size: 11px; color: var(--text-faint); }
.side-foot { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.side-foot .nav-item { padding: 8px 10px; font-size: 14px; color: var(--text-sub); }
.sync { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-sub); padding: 6px 10px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.sync.on .sync-dot { background: var(--done); }

.main { flex: 1; min-width: 0; overflow-y: auto; }
.load-error {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 16px 32px 0; padding: 12px 16px; border-radius: 8px;
  background: var(--danger-soft); color: var(--danger); font-size: 14px;
}
.load-error span { flex: 1; min-width: 200px; }
/* 下は右下のマーク（Netlify）に重ならないよう広めに空ける */
.view { padding: 28px 32px 80px; }

.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 700; margin: 0; letter-spacing: .04em; }
.page-date { font-family: var(--mono); color: var(--text-sub); font-size: 13px; }
.page-actions { margin-left: auto; display: flex; gap: 10px; }

/* ---------- ダッシュボード ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; text-align: left; display: block; width: 100%;
}
.stat:hover { background: var(--card-hover); }
.stat-num { font-family: var(--mono); font-size: 30px; line-height: 1.2; }
.stat-num.accent { color: var(--accent); }
.stat-num.danger { color: var(--danger); }
.stat-label { font-size: 13px; color: var(--text-sub); margin-top: 6px; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.dash-row { margin-bottom: 14px; }
/* カレンダーの段は、カレンダーを広く・占いを細く */
.dash-grid.dash-row { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr); }
#boxWeather .weather { gap: 8px; }
.dash-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.box { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.box-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.box-title { font-weight: 700; font-size: 14px; }
.box-sub { font-size: 12px; color: var(--text-sub); }
.box-link { margin-left: auto; font-size: 13px; }
.box-empty { color: var(--text-sub); font-size: 14px; padding: 14px 0 6px; }

.line { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-top: 1px solid var(--border); }
.line:first-of-type { border-top: none; }
.line-main { flex: 1; min-width: 0; }
.line-title { font-size: 15px; line-height: 1.4; }
.line-sub { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.line-right { font-family: var(--mono); font-size: 13px; color: var(--text-sub); white-space: nowrap; }
.line-right.danger { color: var(--danger); }
.line.clickable { cursor: pointer; border-radius: 6px; }
.line.clickable:hover { background: var(--card-hover); }
.mini-check {
  width: 18px; height: 18px; border-radius: 4px; padding: 0;
  border: 1.5px solid var(--border-strong); background: var(--field);
  display: flex; align-items: center; justify-content: center; color: transparent;
}
.mini-check:hover { border-color: var(--done); color: var(--done); }

.weather { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; padding-top: 8px; }
.wday { padding: 6px 0; border-radius: 6px; }
.wday.today { background: var(--accent-soft); }
.wday-date { font-size: 12px; color: var(--text-sub); }
.wday-date.sun { color: var(--danger); }
.wday-date.sat { color: var(--tag); }
.wday-icon { height: 30px; display: flex; align-items: center; justify-content: center; color: var(--text-sub); }
.wday-text { font-size: 11px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wday-temp { font-family: var(--mono); font-size: 12px; margin-top: 4px; }
.t-max { color: var(--danger); }
.t-min { color: var(--tag); }

.fortune { padding: 12px 2px; border-top: 1px solid var(--border); }
.box-head + .fortune { border-top: none; }
.fortune-head { display: flex; align-items: center; gap: 8px; }
.fortune-mark { font-size: 20px; color: var(--accent); width: 24px; text-align: center; }
.fortune-name { font-weight: 700; flex: 1; }
.fortune-rank { font-family: var(--mono); font-size: 14px; padding: 2px 10px; border-radius: 999px; background: var(--bg-main); }
.fortune-rank.good { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.fortune-msg { font-size: 14px; line-height: 1.6; margin: 6px 0 4px 32px; }
.fortune-lucky { font-size: 12px; color: var(--text-sub); margin-left: 32px; }
/* 星座ごとの色（config.js の FORTUNE_SIGNS の color） */
.fortune.colored .fortune-mark,
.fortune.colored .fortune-name { color: var(--sign-color); }
.fortune.colored .fortune-rank {
  background: var(--sign-color); color: #fff; font-weight: 700;
}
.fortune.colored { border-left: 4px solid var(--sign-color); padding-left: 10px; }
.box-head + .fortune.colored { margin-top: 4px; }
.fortune.colored + .fortune.colored { margin-top: 8px; }
/* ダークモードでは濃い色の文字が読みにくいので、名前はふつうの文字色にする */
:root[data-theme="dark"] .fortune.colored .fortune-name { color: var(--text); }

/* ---------- 現場一覧 ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
table.sites { width: 100%; border-collapse: collapse; font-size: 14px; }
.sites th, .sites td { padding: 12px 14px; text-align: left; border-top: 1px solid var(--border); white-space: nowrap; }
.sites th { border-top: none; font-weight: 400; font-size: 12px; color: var(--text-sub); }
.sites tbody tr { cursor: pointer; }
.sites tbody tr:hover { background: var(--card-hover); }
.sites .name { font-weight: 700; white-space: normal; min-width: 160px; }
.sites td.mono { color: var(--text-sub); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.st-着工前 { background: var(--st-before-bg); color: var(--st-before); }
.st-工事中 { background: var(--st-active-bg); color: var(--st-active); }
.st-完成 { background: var(--st-done-bg); color: var(--st-done); }
.map-link { color: var(--tag); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.map-link:hover { text-decoration: underline; }
.filter-row { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chip { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px; font-size: 13px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* 現場のカード */
.site-tools { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.site-search { flex: 0 1 280px; min-width: 180px; }
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.site-card {
  position: relative; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px 14px 22px; cursor: pointer; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
}
.site-card:hover { border-color: var(--border-strong); background: var(--card-hover); }
.site-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--st-before);
}
.site-card.s-工事中::before { background: var(--st-active); }
.site-card.s-完成::before { background: var(--text-faint); }
.site-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 2px; }
.site-name { flex: 1; font-weight: 700; font-size: 15px; line-height: 1.45; word-break: break-word; }
.site-tags { display: flex; gap: 4px; flex-shrink: 0; }
.tag-type {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-sub); white-space: nowrap;
}
.site-tags .badge { font-size: 11px; padding: 2px 8px; white-space: nowrap; }
.site-line { font-size: 13px; color: var(--text-sub); }
.site-line.mono { font-family: var(--mono); font-size: 12px; }
.site-progress { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.bar { flex: 1; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.pct { font-family: var(--mono); font-size: 14px; min-width: 42px; text-align: right; }
.site-empty { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 13px; margin: 12px 0 0; min-height: 1em; }
.form-error:empty { display: none; }

/* たく専用（お金のこと） */
.owner-lock { margin: 40px auto; }
.owner-lock label { display: block; font-size: 13px; color: var(--text-sub); margin: 14px 0 6px; }
.owner-lock input { width: 100%; }
.owner-lock-title { font-size: 18px; margin: 0 0 8px; }
.owner-box { margin-bottom: 14px; }
.owner-table-wrap { border: none; margin-top: 8px; }
table.owner-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.owner-table th, .owner-table td { padding: 10px 12px; border-top: 1px solid var(--border); white-space: nowrap; text-align: left; }
.owner-table th { border-top: none; font-weight: 400; font-size: 12px; color: var(--text-sub); }
.owner-table .num { text-align: right; font-family: var(--mono); }
.owner-table .name { white-space: normal; min-width: 150px; }
.owner-table .warn { color: var(--danger); }
.owner-table .strong { font-weight: 700; }
.owner-table tbody tr { cursor: pointer; }
.owner-table tbody tr:hover { background: var(--card-hover); }
.owner-table tbody tr.selected { background: var(--accent-soft); }
.owner-table tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); }
.owner-done { margin-left: 8px; font-size: 11px; }
.fin-row > div { flex: 0 0 150px; }
.fin-row > div.grow { flex: 1 1 200px; }
.fin-top { display: flex; align-items: center; gap: 10px; }
.fin-kind { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--bg-main); }
.fin-kind.k-請求 { background: var(--st-before-bg); color: var(--st-before); }
.fin-kind.k-入金 { background: var(--accent-soft); color: var(--accent); }
.fin-kind.k-支払 { background: var(--danger-soft); color: var(--danger); }
.fin-amount { font-family: var(--mono); font-size: 16px; font-weight: 700; }

/* 経費精算 */
.owner-tabs { margin: 0 0 14px; }
.exp-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.exp-nav { margin: 0; }
.exp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.exp-table td { vertical-align: middle; }
.exp-table .mono { font-family: var(--mono); }
.exp-table .exp-desc { white-space: normal; min-width: 160px; }
.exp-table tr.exp-carry td { background: var(--bg-main); color: var(--text-sub); cursor: default; }
.exp-card { margin-left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--st-before-bg); color: var(--st-before); }
.exp-thumb {
  width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 6px;
  background: var(--field); overflow: hidden; display: inline-flex; align-items: center; justify-content: center;
}
.exp-thumb img { width: 100%; height: 100%; object-fit: cover; }
.exp-pending { border-color: var(--border); }
.exp-pend-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.exp-pend-row .log-main { flex: 1; min-width: 160px; order: 0; flex-basis: auto; }
.exp-confirm { padding: 6px 12px; font-size: 13px; }
.warn-pill { background: var(--danger); color: #fff; }
.exp-photo { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.exp-preview { max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--border); }
.exp-fuel .field { width: 100%; }
.exp-opening summary { cursor: pointer; }
.exp-opening .todo-add { flex-wrap: wrap; }
.photo-modal { width: min(900px, calc(100% - 32px)); }
.photo-modal img { display: block; max-width: 100%; max-height: 75vh; margin: 0 auto; border-radius: 8px; }

/* チャット */
/* 右下に公開サービス（Netlify）のマークが出るので、送信ボタンが隠れないよう下を空ける */
.view.chat-view { display: flex; flex-direction: column; height: 100%; padding-bottom: 68px; }
.chat-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.chat-list {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px;
}
.chat-empty { text-align: center; padding: 40px 0; }
.chat-day { text-align: center; font-size: 12px; color: var(--text-faint); margin: 14px 0 8px; }
.chat-row { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; }
.chat-row.mine { justify-content: flex-end; }
.chat-bubble-wrap { max-width: min(560px, 78%); min-width: 0; }
.chat-name { font-size: 12px; color: var(--text-sub); margin: 0 0 3px 2px; }
.chat-line { display: flex; align-items: flex-end; gap: 6px; }
.chat-row.mine .chat-line { flex-direction: row-reverse; }
.chat-bubble {
  background: var(--bg-main); border-left: 3px solid var(--border-strong);
  border-radius: 10px; padding: 8px 12px; font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; min-width: 0;
}
.chat-row.mine .chat-bubble { background: var(--accent); color: var(--on-accent); border-left: none; }
.chat-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.chat-row:not(.mine) .chat-meta { align-items: flex-start; }
.chat-del { background: none; border: none; padding: 0; font-size: 11px; color: var(--text-faint); text-decoration: underline; }
.chat-del:hover { color: var(--danger); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.chat-input { flex: 1; min-width: 0; resize: none; line-height: 1.5; max-height: 160px; }
.chat-error { margin-top: 6px; }
.nav-count.unread { background: var(--danger); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 11px; }

/* 今日の TODO */
.todo-nav { margin: 12px 0 10px; }
.todo-add { display: flex; gap: 6px; margin: 6px 0 8px; }
.todo-add .field { flex: 1; min-width: 0; }
.todo-add-btn { padding: 8px 14px; }
.todo-count { font-size: 12px; color: var(--text-sub); margin: 4px 2px 2px; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-top: 1px solid var(--border); }
.todo-item:first-child { border-top: none; }
.todo-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.todo-body { flex: 1; min-width: 0; font-size: 15px; line-height: 1.5; word-break: break-word; cursor: pointer; }
.todo-item.done .todo-body { color: var(--text-faint); text-decoration: line-through; }
.todo-carry { font-size: 11px; color: var(--danger); white-space: nowrap; }
.todo-del { padding: 4px; color: var(--text-faint); }
.todo-del svg { width: 16px; height: 16px; }
.todo-subhead { font-size: 12px; color: var(--text-sub); margin: 14px 2px 2px; padding-top: 10px; border-top: 1px dashed var(--border); }
#list .todo-block { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }

/* 現場の詳しい画面 */
.back-link { margin: -8px 0 8px -8px; font-size: 14px; }
#view-site .page-head .site-tags { flex-shrink: 0; }
.site-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 14px; align-items: start; }
.info-list { display: grid; grid-template-columns: 9em minmax(0, 1fr); gap: 10px 12px; margin: 10px 0 4px; font-size: 14px; }
.info-list dt { color: var(--text-sub); }
.info-list dd { margin: 0; word-break: break-word; white-space: pre-wrap; }
.log-form { background: var(--bg-main); border-radius: 8px; padding: 12px 14px; margin: 10px 0 8px; }
.log-form label { display: block; font-size: 12px; color: var(--text-sub); margin: 8px 0 4px; }
.log-form .field { width: 100%; }
.log-form textarea { min-height: 72px; resize: vertical; line-height: 1.6; }
.log-form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.log-form-row > div:first-child { flex: 0 0 170px; }
.log-form-row .grow { flex: 1; min-width: 160px; }
.log-form-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.log-item { display: flex; gap: 14px; padding: 12px 4px; border-top: 1px solid var(--border); }
.log-item.editing { background: var(--accent-soft); border-radius: 6px; }
.log-date { font-family: var(--mono); font-size: 13px; color: var(--text-sub); width: 118px; flex-shrink: 0; padding-top: 2px; }
.log-main { flex: 1; min-width: 0; }
.log-content { font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.log-note { font-size: 13px; color: var(--text-sub); margin-top: 4px; white-space: pre-wrap; }
.log-by { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.log-acts { display: flex; gap: 4px; align-items: flex-start; flex-shrink: 0; }

/* ---------- 入力の小窓 ---------- */
dialog.modal {
  border: 1px solid var(--border); border-radius: 12px; padding: 0;
  background: var(--card); color: var(--text);
  width: min(560px, calc(100% - 32px));
  max-height: calc(100vh - 32px); overflow-y: auto;
}
dialog.modal::backdrop { background: rgba(10, 16, 12, .45); }
.modal-body { padding: 24px; }
.modal-title { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 12px; color: var(--text-sub); margin: 12px 0 5px; }
.form-grid .field { width: 100%; }
.form-grid textarea { min-height: 70px; resize: vertical; }
.contact-label { display: block; font-size: 12px; color: var(--text-sub); margin: 12px 0 5px; }
.contact-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; margin-bottom: 6px; }
.contact-line { display: flex; gap: 10px; flex-wrap: wrap; }
.contact-line + .contact-line { margin-top: 4px; }
.contact-who { color: var(--text-sub); }
.field-hint { font-size: 12px; color: var(--text-faint); margin: 5px 0 0; line-height: 1.6; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); }
.modal-foot .grow { flex: 1; }

.modal-note { font-size: 13px; color: var(--text-sub); line-height: 1.7; margin: 0 0 12px; }
.modal-hint { font-size: 12px; color: var(--text-faint); }
.quick-text { width: 100%; min-height: 110px; resize: vertical; line-height: 1.7; }

/* ---------- 仮入力 ---------- */
.quick-btn {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  margin: 0 4px 16px; padding: 8px 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text);
}
.quick-btn:hover { background: var(--card-hover); }
.inbox-item { padding: 12px 2px; border-top: 1px solid var(--border); }
.inbox-item:first-of-type { border-top: none; }
.inbox-body { font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.inbox-meta { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.inbox-time { font-family: var(--mono); font-size: 12px; color: var(--text-faint); margin-right: auto; }
.mini-btn {
  background: var(--field); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-size: 13px;
}
.mini-btn:hover { background: var(--card-hover); border-color: var(--border-strong); }
.mini-btn.go { color: var(--accent); border-color: var(--accent); }
.count-pill {
  font-family: var(--mono); font-size: 12px; color: var(--on-accent); background: var(--accent);
  border-radius: 999px; padding: 1px 8px;
}

/* ---------- カレンダー ---------- */
a.btn-outline { color: var(--text); text-decoration: none; }
.cal-modes { margin: 0; }
#calBody { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.cal-nav { display: flex; align-items: center; gap: 4px; margin: 4px 0 8px; }
.cal-nav .icon-btn { font-size: 20px; line-height: 1; padding: 4px 10px; }
.cal-today { padding: 5px 14px; border-radius: 999px; font-size: 13px; margin-right: 4px; }
.cal-title { font-size: 17px; font-weight: 700; margin-left: 6px; }
.cal-status { font-size: 13px; color: var(--text-sub); min-height: 0; }
.cal-status:not(:empty) { margin-bottom: 8px; }
.cal-error { color: var(--danger); }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--border); border-left: 1px solid var(--border);
}
.cal-wd {
  font-size: 12px; color: var(--text-sub); text-align: center; padding: 6px 0;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-side);
}
.cal-wd.sun, .cal-num.sun, .cal-list-date.sun { color: var(--danger); }
.cal-wd.sat, .cal-num.sat, .cal-list-date.sat { color: var(--tag); }
.cal-cell {
  min-height: 104px; padding: 4px 4px 6px; overflow: hidden; cursor: pointer;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.cal-grid.compact .cal-cell { min-height: 84px; }
.cal-grid.two-weeks .cal-cell { min-height: 132px; }
.cal-grid.week .cal-cell { min-height: 280px; }
.cal-cell:hover { background: var(--card-hover); }
.cal-cell.other { background: var(--bg-main); }
.cal-cell.other .cal-num { opacity: .5; }
.cal-num { font-family: var(--mono); font-size: 12px; text-align: center; margin-bottom: 2px; }
.cal-cell.today .cal-num {
  width: 24px; height: 24px; line-height: 24px; margin: 0 auto 2px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
}
.cal-ev {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  font-size: 12px; line-height: 1.5; white-space: nowrap; overflow: hidden;
}
.cal-ev.all-day {
  display: block; color: #fff; border-radius: 4px; padding: 0 6px;
  text-overflow: ellipsis; font-weight: 700;
}
.cal-ev-time { font-family: var(--mono); font-size: 11px; color: var(--text-sub); flex-shrink: 0; }
.cal-ev-title { overflow: hidden; text-overflow: ellipsis; }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.cal-more, .cal-none { font-size: 11px; color: var(--text-faint); padding-left: 4px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--text-sub); }
.cal-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.cal-list-day { display: flex; gap: 16px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.cal-list-day.today { background: var(--accent-soft); border-radius: 6px; }
.cal-list-date { width: 72px; flex-shrink: 0; font-family: var(--mono); font-size: 13px; padding-top: 2px; }
.cal-list-items { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cal-line { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.cal-line .cal-dot { margin-top: 7px; }
.cal-line-time { font-family: var(--mono); font-size: 13px; color: var(--text-sub); width: 40px; flex-shrink: 0; padding-top: 1px; }
.cal-line-main { flex: 1; min-width: 0; }
.cal-line-title { font-size: 15px; word-break: break-word; }
.cal-line-sub { font-size: 12px; color: var(--text-faint); }
#boxSchedule .cal-nav { margin-top: 0; }
.cal-week-date { display: none; font-family: var(--mono); font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.cal-week-date.sun { color: var(--danger); }
.cal-week-date.sat { color: var(--tag); }

/* ---------- 準備中 ---------- */
.soon { max-width: 520px; margin: 80px auto; text-align: center; color: var(--text-sub); line-height: 1.8; }
.soon h2 { color: var(--text); font-size: 20px; }

/* ---------- タスク画面 ---------- */
.view.tasks-view { padding: 0; height: 100%; }
.app { display: flex; height: 100%; }
.list-pane {
  width: 440px; min-width: 320px;
  background: var(--bg-main);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.tabs {
  background: var(--card);
  display: flex; align-items: flex-end; gap: 4px;
  padding: 0 16px; height: 44px;
  border-bottom: 1px solid var(--border);
}
.tab {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none;
  padding: 0 14px 10px; color: var(--text-sub);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--accent); font-weight: 700; border-bottom-color: var(--accent); }
.tab-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--tag); }
.toolbar {
  background: var(--card);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.list-scroll { flex: 1; overflow-y: auto; padding: 8px 16px 72px; }

.group-head { display: flex; align-items: center; gap: 10px; padding: 14px 4px 10px; font-weight: 700; }
.group-head .grow { flex: 1; }
.group-count { color: var(--text-faint); font-weight: 400; font-size: 13px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.avatar.small { width: 26px; height: 26px; font-size: 12px; }
.avatar.none { background: #b8b1a6; }
.avatar.done { background: var(--done); }

.card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin: 0 0 8px; cursor: pointer;
}
.card:hover { border-color: var(--border-strong); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.check {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--border-strong); background: var(--field);
  display: flex; align-items: center; justify-content: center;
  padding: 0; margin-top: 1px; color: transparent;
}
.check:hover { border-color: var(--done); color: var(--done); }
.check.on { background: var(--done); border-color: var(--done); color: var(--on-accent); }
.card-body { flex: 1; min-width: 0; }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-title { flex: 1; font-weight: 700; font-size: 16px; line-height: 1.4; word-break: break-word; }
.card-title.untitled { color: var(--text-faint); font-weight: 400; }
.card.is-done .card-title { color: var(--text-faint); text-decoration: line-through; font-weight: 400; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.prop-tag {
  background: var(--tag); color: #fff; border-radius: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 6px;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
:root[data-theme="dark"] .prop-tag { color: #151816; }
.pri {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; padding: 2px 8px; border-radius: 4px; font-size: 13px; font-weight: 700;
}
.pri-高 { background: var(--pri-high-bg); color: var(--pri-high); }
.pri-中 { background: var(--pri-mid-bg); color: var(--pri-mid); }
.pri-低 { background: var(--pri-low-bg); color: var(--pri-low); }
.date { display: inline-flex; align-items: center; gap: 4px; color: var(--text-sub); font-size: 14px; font-family: var(--mono); }
.date.overdue { color: var(--danger); }
.confirmed-mark { display: inline-flex; align-items: center; gap: 3px; color: var(--done); font-size: 12px; }

.add-link {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; background: none; border: none;
  color: var(--text-faint); padding: 8px 10px 4px;
}
.add-link:hover { color: var(--accent); }
.icon-plus { background: none; border: none; color: var(--text-faint); padding: 4px; border-radius: 6px; display: flex; }
.icon-plus:hover { color: var(--accent); background: var(--card-hover); }
.empty { color: var(--text-faint); text-align: center; padding: 12px 0; font-size: 14px; }

.detail-pane { flex: 1; overflow-y: auto; min-width: 0; background: var(--card); }
.detail { max-width: 900px; padding: 28px 32px 80px; }
.detail-top { display: flex; align-items: flex-start; gap: 12px; }
.title-input {
  flex: 1; min-width: 0; font-size: 24px; font-weight: 700;
  border: 1px solid transparent; border-radius: 6px;
  padding: 4px 6px; margin-left: -6px; background: transparent;
}
.title-input:hover { border-color: var(--border); }
.title-input:focus { outline: none; border-color: var(--accent); }
.icon-btn { background: none; border: none; color: var(--text-sub); padding: 8px; border-radius: 6px; display: flex; }
.icon-btn:hover { background: var(--card-hover); }
.row { display: flex; align-items: flex-start; padding: 10px 0; }
.row-label {
  width: 180px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  color: var(--text-sub); padding-top: 8px;
}
.row-value { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.field.date-field { font-size: 16px; font-family: var(--mono); }
.status-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--field); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 16px;
}
.status-btn:hover { background: var(--card-hover); }
.status-btn.on { background: var(--done-soft); border-color: var(--done); color: var(--done); }
.sub-note { color: var(--text-faint); font-size: 13px; width: 100%; }
.overdue-note { color: var(--danger); font-weight: 700; font-size: 14px; width: 100%; }
.pri-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.pri-group button { background: var(--field); border: none; padding: 8px 18px; border-right: 1px solid var(--border); }
.pri-group button:last-child { border-right: none; }
.pri-group button.on.p-高 { background: var(--pri-high-bg); color: var(--pri-high); font-weight: 700; }
.pri-group button.on.p-中 { background: var(--pri-mid-bg); color: var(--pri-mid); font-weight: 700; }
.pri-group button.on.p-低 { background: var(--pri-low-bg); color: var(--pri-low); font-weight: 700; }
.section-label { display: flex; align-items: center; gap: 10px; color: var(--text-sub); margin: 22px 0 10px; }
.memo-input {
  width: 100%; min-height: 160px; resize: vertical;
  border: 1px solid transparent; border-radius: 6px;
  padding: 8px; margin-left: -8px; background: transparent;
  line-height: 1.7; font-size: 16px;
}
.memo-input:hover { border-color: var(--border); }
.memo-input:focus { outline: none; border-color: var(--accent); background: var(--field); }
.detail-foot {
  border-top: 1px solid var(--border); margin-top: 28px; padding-top: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.placeholder {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text-faint);
}

/* ---------- 狭い画面 ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .dash-grid.dash-row { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .shell { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; padding: 10px 12px; border-right: none; border-bottom: 1px solid var(--border); }
  .brand { padding: 4px 4px 10px; }
  .quick-btn { margin: 0 0 10px; }
  .side-label { display: none; }
  .sidenav { flex-direction: row; overflow-x: auto; }
  .nav-item { white-space: nowrap; padding: 8px 10px; }
  .nav-soon { display: none; }
  .side-foot { flex-direction: row; flex-wrap: wrap; align-items: center; margin-top: 8px; }
  .main { overflow: visible; }
  .view { padding: 20px 16px 72px; }
  .page-actions { margin-left: 0; width: 100%; }
  .view.tasks-view { height: auto; }
  .app { flex-direction: column; height: auto; }
  .list-pane { width: 100%; min-width: 0; border-right: none; }
  .list-scroll { overflow: visible; }
  .detail-pane { border-top: 1px solid var(--border); }
  .detail { padding: 20px 16px 72px; }
  .row { flex-direction: column; }
  .row-label { width: auto; padding: 0 0 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .site-detail { grid-template-columns: 1fr; }
  .view.chat-view { height: auto; }
  .chat-list { flex: none; height: 60vh; }
  .chat-bubble-wrap { max-width: 85%; }
  .log-item { flex-wrap: wrap; gap: 6px 10px; }
  .log-date { width: auto; }
  .log-main { flex-basis: 100%; order: 3; }
  .log-acts { margin-left: auto; }
  .log-form-row > div:first-child { flex: 1 1 100%; }
  #calBody { padding: 10px 8px; }
  .cal-cell, .cal-grid.compact .cal-cell { min-height: 64px; padding: 2px 2px 4px; }
  .cal-grid.two-weeks .cal-cell { min-height: 90px; }
  .cal-grid.week { grid-template-columns: 1fr; }
  .cal-grid.week .cal-wd { display: none; }
  .cal-grid.week .cal-cell { min-height: 0; padding: 8px; }
  .cal-grid.week .cal-week-date { display: block; }
  .cal-grid.week .cal-ev { font-size: 13px; }
  .cal-grid.week .cal-ev-time { display: inline; }
  .cal-ev { font-size: 10px; }
  .cal-ev-time { display: none; }
  .cal-ev.all-day { padding: 0 3px; }
  .weather { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 8px; }
}
