:root {
  --bg: #0f1218;
  --bg-2: #161a22;
  --card: #1a1f29;
  --line: #2a303c;
  --text: #e9ecf2;
  --text-2: #a7afbd;
  --text-3: #7c8595;
  --accent: #6d97ff;
  --accent-2: #ffb36b;
  --good: #4fd1a5;
  --chip: #232a36;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Noto Sans CJK JP", sans-serif;
  font-size: 16px; line-height: 1.8; -webkit-text-size-adjust: 100%;
  padding-bottom: calc(72px + var(--safe-b));
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(15, 18, 24, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 800; font-size: 19px; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--accent-2); position: relative; overflow: hidden; }
.brand-mark::after { content: ""; position: absolute; left: -2px; right: -2px; bottom: -2px; height: 9px; background: var(--accent-2); }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); color: var(--text); font-size: 18px; }
.progress { position: fixed; top: 0; left: 0; height: 3px; background: var(--accent); z-index: 11; width: 0; }

main { max-width: 720px; margin: 0 auto; padding: 16px; outline: none; }

/* ---------- home ---------- */
.hero h1 { font-size: 30px; margin: 8px 0 4px; letter-spacing: .02em; }
.hero p { color: var(--text-2); margin: 0 0 16px; font-size: 15px; }
.hero .tagline { color: var(--accent-2); font-weight: 700; font-style: italic; margin: -2px 0 8px; letter-spacing: .02em; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 700; cursor: pointer; text-align: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b1020; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.counts { color: var(--text-3); font-size: 14px; margin: 6px 2px 14px; }
.search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); margin-bottom: 12px; }
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-label { flex: none; font-size: 12px; color: var(--text-3); align-self: center; min-width: 4.5em; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--chip); color: var(--text-2);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #0b1020; font-weight: 700; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar select { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 5px 8px; font-size: 14px; max-width: 46%; }
.toolbar .spacer { flex: 1; }
.clear-link { font-size: 13px; color: var(--text-3); background: none; border: 0; cursor: pointer; }

.group-title { font-size: 14px; color: var(--text-2); margin: 22px 2px 8px; display: flex; gap: 8px; align-items: baseline; }
.group-title b { color: var(--text); font-size: 16px; }
.cards { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); display: block; position: relative; }
.card .thumb { display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; background: var(--bg-2); }
.card .body { padding: 12px 14px 14px; }
.card .date { color: var(--text-3); font-size: 13px; }
.card h3 { margin: 2px 0 6px; font-size: 17px; line-height: 1.5; }
.card .sum { color: var(--text-2); font-size: 14px; margin: 0 0 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.badge { display: inline-block; background: var(--accent); color: #0b1020; font-size: 11px; font-weight: 800; padding: 0 8px; border-radius: 999px; margin-right: 6px; line-height: 1.7; vertical-align: 1px; }
.badge.req { background: var(--accent-2); }
.star-mark { color: var(--accent-2); }
.tags { display: block; line-height: 1; margin: 0 0 4px; }
.tags .tag { display: inline-block; margin: 0 4px 6px 0; }
.tag { white-space: nowrap; line-height: 1.6; font-size: 12px; border-radius: 999px; padding: 2px 10px; background: var(--chip); color: var(--text-2); border: 1px solid var(--line); }
.tag.field { color: var(--good); border-color: #2a4b42; }
.empty { text-align: center; color: var(--text-3); padding: 40px 0; }

/* ---------- article ---------- */
.a-meta { color: var(--text-3); font-size: 14px; }
.a-title { font-size: 25px; line-height: 1.45; margin: 6px 0 8px; }
.a-title-en { color: var(--text-2); font-style: italic; font-size: 15px; line-height: 1.6; margin: 0 0 12px; }
.a-infographic { width: 100%; border-radius: var(--radius); margin: 14px 0; display: block; }
.paper-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; color: var(--text-2); display: grid; grid-template-columns: 5.5em 1fr; gap: 4px 10px; }
.paper-box dt { color: var(--text-3); }
.paper-box dd { margin: 0; }
.article h2 { font-size: 21px; margin: 34px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.article h3 { font-size: 17px; margin: 22px 0 8px; }
.article p { margin: 0 0 14px; }
.article ul, .article ol { padding-left: 1.3em; margin: 0 0 14px; }
.article li { margin: 4px 0; }
.article strong { color: #fff; }
.article blockquote { margin: 0 0 12px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--bg-2); border-radius: 0 10px 10px 0; color: var(--text-2); font-size: 15px; }
.article blockquote p { margin: 0; }
.article img { width: 100%; border-radius: 10px; background: #fff; margin: 6px 0 8px; }
.article small { display: block; color: var(--text-3); font-size: 12px; margin: -4px 0 18px; }
.article .keypoints { background: #1b2540; border: 1px solid #34467a; border-radius: var(--radius); padding: 4px 16px 6px; margin: 18px 0; }
.article .keypoints h2 { border: 0; font-size: 16px; color: var(--accent); margin: 10px 0 4px; }
.table-wrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; }
.article table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.6; }
.article th, .article td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.article th { background: var(--bg-2); color: var(--text-2); white-space: nowrap; }
.article tr:last-child td { border-bottom: 0; }
.hub { display: inline-block; font-size: 13px; border-radius: 999px; padding: 1px 10px; margin: 2px 4px 2px 0; background: var(--chip); color: var(--text-2); border: 1px solid var(--line); cursor: pointer; }
.xref { font-weight: 700; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 26px 0; }
.panel h2 { margin: 0 0 10px !important; border: 0 !important; font-size: 18px !important; padding: 0 !important; }
.panel .hint { color: var(--text-3); font-size: 13px; margin: 6px 0 0; }
textarea { width: 100%; min-height: 120px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; line-height: 1.7; resize: vertical; }
.memo-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; color: var(--text-3); font-size: 13px; }
.other { padding: 10px 0; border-top: 1px solid var(--line); }
.other:first-of-type { border-top: 0; }
.other a { font-weight: 700; line-height: 1.5; display: block; }
.other .m { color: var(--text-3); font-size: 13px; margin: 2px 0 6px; }
.finish { background: linear-gradient(135deg, #1d2a4d, #2a2140); border: 1px solid #3c4a7a; border-radius: var(--radius); padding: 18px 16px; text-align: center; margin: 26px 0 12px; }
.finish h2 { border: 0 !important; margin: 0 0 12px !important; padding: 0 !important; font-size: 19px !important; }
.finish .next { color: var(--text-2); font-size: 14px; margin-top: 8px; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.prevnext a { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--text); font-size: 14px; line-height: 1.5; }
.prevnext a span { display: block; color: var(--text-3); font-size: 12px; }
.prevnext a.right { text-align: right; }
.disclaimer { color: var(--text-3); font-size: 12px; text-align: center; margin: 20px 0; }

/* ---------- bottom bar ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(15, 18, 24, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
}
.bottombar button, .bottombar a {
  background: none; border: 0; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 0;
  font-size: 11px; cursor: pointer; padding: 4px 0; line-height: 1.4;
}
.bottombar .ic { font-size: 19px; line-height: 1.2; }
.bottombar .on { color: var(--accent-2); }
.bottombar .primary { color: var(--accent); font-weight: 700; }

/* ---------- forms ---------- */
.form h1 { font-size: 24px; margin: 8px 0 6px; }
.form .lead { color: var(--text-2); font-size: 14px; margin: 0 0 18px; }
.field { margin-bottom: 18px; }
.field label, .field .label { display: block; font-weight: 700; margin-bottom: 6px; }
.field .help { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.field input[type=text], .field input[type=number], .field input[type=time], .field select {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2);
}
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days .d { text-align: center; font-size: 13px; color: var(--text-2); }
.days input, .days select { width: 100%; padding: 8px 2px; text-align: center; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); font-size: 14px; }
.days select { font-size: 11px; padding: 8px 0; }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 22px; height: 22px; }
.req-list { display: flex; flex-direction: column; gap: 8px; }
.req { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.req .btn { white-space: nowrap; }
.req .st { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--chip); white-space: nowrap; }
.req .st.pending { color: var(--accent-2); }
.req .st.done { color: var(--good); }
.notice { background: #2b2316; border: 1px solid #5a4422; color: #f3d3a6; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 0 0 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: #e9ecf2; color: #0f1218; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 20; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.filter-toggle { background: none; border: 1px solid var(--line); color: var(--text-2); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.filter-toggle.on { color: var(--accent); border-color: var(--accent); }
