:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f7f7f5;
  --line: #e4e2dd;
  --text: #1f1f1d;
  --muted: #6f6d68;
  --accent: #1b6b5a;
  --accent-soft: #e6f1ee;
  --warn: #9a5b12;
  --warn-soft: #fbf0df;
  --danger: #b3453a;
  --chip: #eeece7;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  overscroll-behavior-y: none;
}
h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: .02em; }
.muted { color: var(--muted); }
.note { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.note.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; word-break: break-all; }
.pad { height: 96px; }

/* ---------- レイアウト ---------- */
.view { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.view[hidden] { display: none; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px 0; }

.appbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel);
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.appbar h1 { flex: 1; }
.iconbtn {
  font: inherit; font-size: 13px; background: none; border: 1px solid var(--line);
  border-radius: 7px; padding: 4px 10px; color: var(--accent); cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.iconbtn.danger { color: var(--danger); }

.boot { padding: 40px 16px; color: var(--muted); }

/* ---------- ログイン ---------- */
.login { margin: auto; padding: 24px 20px; max-width: 420px; width: 100%; }
.login h1 { font-size: 20px; margin-bottom: 8px; }
.login form { margin-top: 18px; display: grid; gap: 10px; }
.login b { word-break: break-all; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- 入力共通 ---------- */
input[type=text], input[type=email], input[type=url], input[type=date], input[type=search],
select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%;
}
textarea { line-height: 1.7; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 13px center, right 8px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
button { font: inherit; cursor: pointer; }
button.primary {
  background: var(--accent); color: #fff; border: none; border-radius: 9px;
  padding: 13px 16px; font-size: 16px; font-weight: 700; width: 100%;
}
button.primary:disabled { background: #bcc7c3; }
button.ghost {
  background: #fff; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 14px; font-size: 14px;
}
button.danger-btn {
  background: #fff; color: var(--danger); border: 1px solid #e7c4bf;
  border-radius: 8px; padding: 9px 14px; font-size: 14px; width: 100%;
}
button.link {
  background: none; border: none; color: var(--accent); font-size: 12.5px;
  padding: 2px 4px; text-decoration: underline;
}

/* ---------- ステータス行 ---------- */
.status {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 12px; font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--line); background: #fff;
}
.status .sep { color: var(--line); }
.status.warnstate { background: var(--warn-soft); color: var(--warn); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.dot.off { background: #b9b6ae; }

/* ---------- 絞り込み ---------- */
.filters {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; margin-bottom: 12px;
}
.filters .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters .row + .row { margin-top: 8px; }
.filters select { flex: 1 1 46%; min-width: 130px; width: auto; font-size: 14px; padding: 7px 24px 7px 9px; }
label.inline { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
label.inline input { width: auto; }
.tagbar { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.tag {
  font-size: 12.5px; padding: 4px 10px; border-radius: 20px;
  background: var(--chip); border: 1px solid transparent; color: #45433e; user-select: none;
}
.tag.on { background: var(--accent); color: #fff; }
.tag .n { opacity: .6; font-size: 11px; margin-left: 3px; }

/* ---------- カード ---------- */
.count { font-size: 12px; color: var(--muted); margin: 0 0 8px 2px; }
.card {
  border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 8px; padding: 11px 13px; margin-bottom: 10px; background: #fff;
}
.card.plain { border-left-width: 1px; }
.card.tapable { cursor: pointer; }
.card.cand { border-left-color: var(--warn); }
.card.imp5 { border-left-color: var(--danger); }
.card.imp4 { border-left-color: var(--accent); }
.chead { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.title { font-weight: 700; font-size: 15px; }
.badge {
  font-size: 11px; padding: 1px 7px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.w { background: var(--warn-soft); color: var(--warn); }
.badge.g { background: var(--chip); color: #55534e; }
.badge.q { background: #fdecea; color: #8a2b20; }
.stars { color: #c8952a; letter-spacing: 1px; font-size: 12px; }
.stars i { color: #dcd9d2; font-style: normal; }
.body { margin: 7px 0 0; white-space: pre-wrap; font-size: 14.5px; }
.meta { margin-top: 8px; font-size: 12.5px; color: var(--muted); display: grid; gap: 2px; }
.meta i { font-style: normal; color: #9a978f; margin-right: 5px; }
.next { margin-top: 7px; font-size: 13px; background: var(--accent-soft); color: #14493e; border-radius: 6px; padding: 6px 9px; }
.ctags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.ctag { font-size: 11.5px; background: var(--chip); border-radius: 20px; padding: 2px 8px; color: #55534e; }
.empty { color: var(--muted); text-align: center; padding: 32px 10px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13.5px; }

/* ---------- FAB / 下部バー ---------- */
.fab {
  position: absolute; right: 16px; bottom: calc(20px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 28px; line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
}
.bottombar {
  border-top: 1px solid var(--line); background: var(--panel);
  padding: 10px 12px calc(10px + var(--safe-b));
}

/* ---------- 編集フォーム ---------- */
.fld { display: block; margin-bottom: 12px; }
.lbl { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.lbl em { font-style: normal; color: var(--danger); margin-left: 6px; font-size: 11px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
summary { cursor: pointer; font-size: 14px; color: var(--accent); padding: 6px 0 10px; user-select: none; }
.stars-input { display: flex; gap: 4px; }
.stars-input button {
  background: none; border: none; font-size: 30px; line-height: 1; padding: 0 2px; color: #dcd9d2;
}
.stars-input button.on { color: #c8952a; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.chip {
  font-size: 13px; background: var(--accent-soft); color: var(--accent);
  border-radius: 20px; padding: 3px 6px 3px 11px; display: inline-flex; align-items: center; gap: 4px;
}
.chip button { background: none; border: none; color: var(--accent); font-size: 15px; line-height: 1; padding: 0 4px; }
.suggest { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.suggest button {
  font-size: 12.5px; background: var(--chip); border: none; border-radius: 20px;
  padding: 4px 10px; color: #45433e;
}

/* ---------- バナー / トースト ---------- */
#banners { position: fixed; top: 0; left: 0; right: 0; z-index: 50; }
.banner {
  padding: calc(9px + env(safe-area-inset-top, 0px)) 12px 9px;
  font-size: 13px; display: flex; gap: 10px; align-items: center;
}
.banner.info { background: var(--accent); color: #fff; }
.banner.alert { background: #fdecea; color: #8a2b20; border-bottom: 1px solid #f3c7c1; }
.banner button {
  background: rgba(255,255,255,.22); border: 1px solid rgba(255,255,255,.5);
  color: inherit; border-radius: 6px; padding: 3px 10px; font-size: 12.5px; white-space: nowrap;
}
.banner.alert button { background: #fff; border-color: #e7c4bf; }
.banner span { flex: 1; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + var(--safe-b)); z-index: 60;
  background: #2f2e2b; color: #fff; font-size: 13px;
  padding: 9px 16px; border-radius: 20px; max-width: 88%;
  box-shadow: 0 3px 12px rgba(0,0,0,.25);
}
.toast[hidden] { display: none; }

@media (min-width: 720px) {
  .scroll { padding: 14px 20px 0; max-width: 780px; width: 100%; margin: 0 auto; }
  .appbar, .status, .bottombar { padding-left: 20px; padding-right: 20px; }
  button.primary { max-width: 320px; margin: 0 auto; display: block; }
}
