:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #e0e2e8;
  --border-strong: #cbced7;
  --text: #1a1d29;
  --text-sub: #5c6474;
  --text-faint: #949aa8;
  --accent: #4f4fd0;
  --accent-2: #6d5cf0;
  --accent-hover: #3e3eb8;
  --accent-soft: #eeeefb;
  --accent-ring: rgba(79, 79, 208, 0.28);
  --danger: #d63b40;
  --danger-soft: #fbecec;
  --ok: #2c9c66;
  --radius-sm: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1017;
    --surface: #191b23;
    --surface-2: #20232d;
    --border: #262933;
    --border-strong: #3a3e4b;
    --text: #e9ebf1;
    --text-sub: #969db0;
    --text-faint: #656b7c;
    --accent: #8888f2;
    --accent-2: #a48bfa;
    --accent-hover: #9d9dff;
    --accent-soft: #1e2036;
    --accent-ring: rgba(136, 136, 242, 0.35);
    --danger: #f0595e;
    --danger-soft: #281a1c;
    --ok: #3ac986;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --- ヘッダー(下罫線で本文と区切る) --- */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border-strong);
}

.brand { display: flex; align-items: center; gap: 0.55rem; }
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.9rem;
  flex: none;
}
header h1 {
  font-size: 1rem;
  margin: 0;
  letter-spacing: 0.01em;
  font-weight: 700;
}

nav { display: flex; gap: 0.4rem; }
nav a {
  text-decoration: none;
  color: var(--text-sub);
  padding: 0.4rem 0.55rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

main { padding: 1.1rem 1.5rem 2.5rem; max-width: 1240px; margin: 0 auto; }

/* --- フィルタ(枠なし・下罫線で一覧と区切る) --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  align-items: flex-end;
  padding: 0 0 0.9rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-strong);
}
.filter-item { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-item.grow { flex: 1; min-width: 200px; }
.filter-item label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-faint);
}

input, select, button, textarea {
  font: inherit;
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.14s, box-shadow 0.14s;
}
input::placeholder { color: var(--text-faint); }
input:hover, select:hover { border-color: var(--accent); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

button {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  font-weight: 600;
  transition: background 0.14s, border-color 0.14s, color 0.14s, opacity 0.14s;
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--border-strong);
}
button.secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border-strong);
}
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }

#filter-clear {
  background: transparent;
  color: var(--text-sub);
  border-color: var(--border-strong);
}
#filter-clear:hover { background: var(--surface-2); color: var(--text); border-color: var(--accent); }

/* --- レポート一覧 + 本文(箱なし・縦罫線で左右を区切る) --- */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* 一覧: 枠・塗りなし。行を横罫線で区切る */
.report-list {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
}

.report-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0.7rem 0.6rem 0.7rem 0.8rem;
  font-weight: 400;
  transition: background 0.13s;
}
.report-item:first-child { padding-top: 0.2rem; }
.report-item:last-child { border-bottom: none; }
.report-item::before {
  content: "";
  position: absolute;
  left: -0.1rem; top: 0.15rem; bottom: 0.15rem;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.13s;
}
.report-item:hover { background: var(--surface-2); }
.report-item.selected::before { opacity: 1; }
.report-item.selected .report-item-title { color: var(--accent); }
.report-item-title { font-weight: 700; font-size: 0.92rem; line-height: 1.45; }
.report-item-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-sub);
}
.report-item-meta .dot { color: var(--text-faint); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.71rem;
  font-weight: 700;
  line-height: 1.6;
  background: var(--cat-soft, var(--accent-soft));
  color: var(--cat, var(--accent));
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* 本文: 枠・塗りなし。左の縦罫線で一覧と区切る */
.report-view {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-strong);
  border-radius: 0;
  padding: 0 0 0 1.5rem;
  min-height: 320px;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
}
.report-view > :first-child { margin-top: 0; }
.report-view h1 {
  font-size: 1.4rem;
  line-height: 1.35;
  margin: 0 0 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-strong);
}
.report-view h2 {
  font-size: 1.15rem;
  margin-top: 1.6rem;
  padding-left: 0.6rem;
  border-left: 3px solid var(--accent);
}
.report-view h3 { font-size: 1rem; margin-top: 1.2rem; }
.report-view a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.14s; }
.report-view a:hover { border-bottom-color: var(--accent); }
.report-view ul { padding-left: 1.2rem; }
.report-view li { margin: 0.3rem 0; }
.report-view blockquote {
  margin: 0.8rem 0;
  padding: 0.4rem 0.9rem;
  color: var(--text-sub);
  border-left: 3px solid var(--border-strong);
  font-size: 0.85rem;
}
.report-view code {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.08rem 0.32rem;
  font-size: 0.88em;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 240px;
  color: var(--text-faint);
  font-size: 0.9rem;
  text-align: center;
}
.placeholder .icon { font-size: 2rem; opacity: 0.5; }
.report-list .placeholder { min-height: 150px; }

/* --- スクロールバー --- */
.report-list::-webkit-scrollbar, .report-view::-webkit-scrollbar { width: 9px; }
.report-list::-webkit-scrollbar-thumb, .report-view::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
.report-list::-webkit-scrollbar-thumb:hover, .report-view::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: padding-box;
}

/* --- 設定画面(カードの箱をやめ、下罫線でセクションを区切る) --- */
.settings-main { max-width: 720px; }

.card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  padding: 1.3rem 0;
  margin: 0;
}
.card:first-child { padding-top: 0.4rem; }
.card:last-child { border-bottom: none; }
.card h2 {
  font-size: 1.02rem;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.hint { font-size: 0.8rem; color: var(--text-sub); margin: 0.2rem 0 0.85rem; }

.feed-row {
  display: grid;
  grid-template-columns: 1fr 200px auto;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-row { margin-bottom: 0.85rem; display: flex; flex-direction: column; gap: 0.3rem; }
.form-row label { font-size: 0.79rem; font-weight: 600; color: var(--text-sub); }
.form-row select, .form-row input { max-width: 340px; }
.form-row.inline { flex-direction: row; align-items: center; gap: 0.5rem; }
.form-row.inline input { flex: 1; max-width: 420px; }

.actions { display: flex; align-items: center; gap: 0.8rem; }
.status { font-size: 0.82rem; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.error { color: var(--danger); }

@media (max-width: 820px) {
  main { padding: 1rem 0.9rem 2rem; }
  header { padding: 0.55rem 0.9rem; }
  .layout { grid-template-columns: 1fr; gap: 1rem; }
  .report-list { max-height: none; padding-bottom: 0.9rem; border-bottom: 1px solid var(--border-strong); }
  .report-view {
    max-height: none;
    border-left: none;
    padding: 0;
  }
  .feed-row { grid-template-columns: 1fr; }
}
