:root {
  --navy: #16324f;
  --navy-dark: #10253c;
  --blue: #2f6db3;
  --blue-soft: #e8f1f9;
  --ink: #1d2733;
  --muted: #68788a;
  --line: #dde5ec;
  --bg: #f5f8fb;
  --card: #ffffff;
  --amber: #b7791f;
  --amber-bg: #fdf3e0;
  --red: #c0392b;
  --green: #2e9e6b;
  --radius: 14px;
  --nav-height: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; }
h1, h2, h3 { line-height: 1.35; }

/* ---------- 共通ボタン ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 18px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger-ghost { background: transparent; border-color: #ecc9c4; color: var(--red); }
.btn-block { display: block; width: 100%; margin-top: 10px; }
.btn-sm { min-height: 38px; padding: 6px 14px; font-size: 0.9rem; }

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="date"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 6px; font-weight: 400; }
.error-text { color: var(--red); min-height: 1.2em; font-size: 0.9rem; }
.empty-text { color: var(--muted); text-align: center; padding: 24px 0; }

/* ---------- 未設定の案内 ---------- */
.setup-notice {
  background: var(--amber-bg);
  color: var(--amber);
  padding: 12px 16px;
  font-size: 0.92rem;
  text-align: center;
}

/* ---------- ログイン ---------- */
.view { min-height: 100dvh; }
.login-card {
  max-width: 420px;
  margin: 0 auto;
  padding: 56px 24px 24px;
  text-align: center;
}
.login-icon { width: 84px; height: 84px; border-radius: 20px; }
.login-card h1 { font-size: 1.6rem; margin: 16px 0 4px; color: var(--navy); }
.login-sub { color: var(--muted); margin: 0 0 28px; }
.login-card form { text-align: left; }

/* ---------- ヘッダー ---------- */
.app-header {
  background: linear-gradient(180deg, var(--navy), var(--navy-dark));
  color: #fff;
  padding: 14px 16px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header-inner { display: flex; align-items: center; gap: 12px; max-width: 1100px; margin: 0 auto; }
.header-icon { width: 40px; height: 40px; border-radius: 10px; }
.header-titles { flex: 1; min-width: 0; }
.header-titles h1 { font-size: 1.15rem; margin: 0; }
.header-user { margin: 0; font-size: 0.78rem; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .btn-primary { background: #fff; color: var(--navy); border-color: #fff; white-space: nowrap; }

.count-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 1100px;
  margin: 14px auto 0;
}
.count-card {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  color: #fff;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 58px;
}
.count-num { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.count-label { font-size: 0.72rem; opacity: 0.9; }
.count-waiting { background: var(--amber-bg); border-color: #f0d9a8; color: #7c5510; }
.waiting-alert {
  max-width: 1100px;
  margin: 10px auto 0;
  background: var(--amber-bg);
  color: #7c5510;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------- メイン ---------- */
.app-main { max-width: 1100px; margin: 0 auto; padding: 16px 14px calc(var(--nav-height) + 28px); }
.page-title { font-size: 1.2rem; color: var(--navy); margin: 6px 0 14px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.search-input { flex: 1 1 180px; width: auto; }
.filter-select { flex: 0 1 auto; width: auto; min-width: 140px; }
.archive-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; font-size: 0.88rem; }
.archive-toggle input { width: 18px; height: 18px; }

/* ---------- 最近の動き ---------- */
.recent-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.recent-title { font-size: 0.95rem; margin: 0 0 6px; color: var(--navy); }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
  display: flex;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
  cursor: pointer;
}
.activity-list li:last-child { border-bottom: none; }
.activity-list.compact li { padding: 6px 2px; font-size: 0.88rem; }
.activity-icon { flex: 0 0 auto; }
.activity-body { flex: 1; min-width: 0; }
.activity-time { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }

/* ---------- カンバン ---------- */
.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 290px);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
  scroll-snap-type: x proximity;
}
.kanban-col {
  background: #edf2f7;
  border-radius: var(--radius);
  padding: 10px;
  scroll-snap-align: start;
  align-self: start;
  max-height: calc(100dvh - 340px);
  overflow-y: auto;
}
.kanban-col-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 0.92rem; color: var(--navy);
  padding: 2px 4px 10px;
}
.kanban-col-head .col-count {
  background: var(--navy); color: #fff; border-radius: 999px;
  font-size: 0.75rem; padding: 1px 9px;
}
.kanban-col.col-waiting { background: #faf0da; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(22, 50, 79, 0.05);
}
.card:hover { border-color: var(--blue); }
.card-title { font-weight: 700; margin: 0 0 6px; font-size: 0.98rem; }
.card-body-preview {
  color: var(--muted); font-size: 0.85rem; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.78rem; color: var(--muted); }

/* ---------- チップ ---------- */
.chip {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: 2px 10px;
  font-size: 0.75rem; font-weight: 600;
  background: var(--blue-soft); color: var(--navy);
}
.chip-priority-high { background: #fdeceb; color: var(--red); }
.chip-priority-medium { background: #fdf3e0; color: #8a5f0e; }
.chip-priority-low { background: #e9f5ef; color: #1f7a4d; }
.chip-due { background: #fdeceb; color: var(--red); }
.chip-due.future { background: var(--blue-soft); color: var(--navy); }
.chip-comments { background: #eef1f4; color: var(--muted); }
.chip-unsynced { background: #fdf3e0; color: #8a5f0e; }

/* ---------- リスト ---------- */
.request-list { list-style: none; margin: 0; padding: 0; }
.request-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex; gap: 12px; align-items: flex-start;
}
.request-list li:hover { border-color: var(--blue); }
.list-status { font-size: 1.25rem; flex: 0 0 auto; padding-top: 2px; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 700; margin: 0 0 4px; }
.list-sub { color: var(--muted); font-size: 0.82rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- 詳細・スレッド ---------- */
.detail-page { padding-bottom: 8px; }
.detail-head { margin-top: 12px; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.detail-head h2 { margin: 0 0 4px; font-size: 1.35rem; color: var(--navy); }
.detail-meta { color: var(--muted); font-size: 0.85rem; margin: 0; }
.detail-body {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; white-space: pre-wrap; word-break: break-word;
}
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 14px 0 20px; }
.status-label { margin: 0; flex: 1 1 180px; }
.status-label select { margin-top: 6px; }
.thread-title { font-size: 1.05rem; color: var(--navy); margin: 22px 0 10px; }
.thread { list-style: none; margin: 0; padding: 0; }
.thread li { display: flex; gap: 10px; margin-bottom: 12px; }
.thread .avatar {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: #fff;
}
.thread .avatar.user { background: var(--blue); }
.thread .avatar.gorou { background: var(--navy); }
.thread .bubble {
  flex: 1; min-width: 0;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px; padding: 10px 14px;
}
.thread li.from-gorou .bubble { background: var(--blue-soft); }
.bubble-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
.bubble-author { font-weight: 700; font-size: 0.88rem; }
.bubble-time { color: var(--muted); font-size: 0.76rem; }
.bubble-body { white-space: pre-wrap; word-break: break-word; font-size: 0.95rem; }
.comment-form {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-top: 6px;
}
.comment-note { color: var(--muted); font-size: 0.8rem; margin: 8px 0 0; }

/* ---------- モーダル ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16, 37, 60, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-card {
  background: #fff; width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; padding: 20px;
  max-height: 92dvh; overflow-y: auto;
}
.modal-card h2 { margin: 0 0 14px; font-size: 1.2rem; color: var(--navy); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

/* ---------- 設定 ---------- */
.settings-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.settings-row { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.settings-note { color: var(--muted); font-size: 0.9rem; background: var(--bg); border-radius: 10px; padding: 10px 12px; }

/* ---------- 下部ナビ ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.nav-btn {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 0.72rem; color: var(--muted); min-height: 52px;
}
.nav-btn .nav-icon { font-size: 1.25rem; line-height: 1; }
.nav-btn.active { color: var(--navy); font-weight: 700; }
.nav-add .nav-icon {
  background: var(--navy); color: #fff; border-radius: 50%;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}

@media (min-width: 760px) {
  .kanban { grid-auto-columns: minmax(260px, 1fr); }
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; }
}
