:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #667085;
  --line: #e2e5ea;
  --accent: #2c6bed;
  --accent-text: #ffffff;
  --danger: #c0362c;
  --ok: #1a7f4b;
  --off: #b9c0cb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --card: #1e232b;
    --text: #e8ebf0;
    --muted: #98a2b3;
    --line: #2f3641;
    --accent: #5b8cff;
    --accent-text: #0b1020;
    --danger: #ff7b6e;
    --ok: #4cc38a;
    --off: #4a5361;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
}
body.centered { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
h1 { font-size: 1.15rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 4px; }
h3 { font-size: 0.95rem; margin: 18px 0 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; max-width: 860px; margin: 0 auto;
}
main { max-width: 860px; margin: 0 auto; padding: 0 16px 48px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card.auth { width: 100%; max-width: 380px; display: grid; gap: 8px; }
.card.auth h1 { margin-bottom: 8px; }
.card.auth button { margin-top: 12px; }
#passkey-area { display: grid; gap: 8px; }
#passkey-area[hidden], [hidden] { display: none; }
.divider { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 10px 0 2px; }

label { font-size: 0.9rem; color: var(--muted); }
input[type=text], input[type=password], select {
  width: 100%; padding: 9px 10px; font: inherit; color: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
button {
  font: inherit; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  background: transparent; color: inherit; border: 1px solid var(--line);
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.link { border: 0; padding: 4px; color: var(--muted); text-decoration: underline; }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 0.9rem; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.dot.bad { background: var(--danger); }
.notice { background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; margin-top: 12px; }

/* スイッチ */
.switch { position: relative; display: inline-flex; flex: none; width: 46px; height: 26px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { flex: 1; border-radius: 13px; background: var(--off); transition: background 0.15s; pointer-events: none; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 通知ルール */
.rules { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 10px; }
.rule { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 10px; }
.rule.off { opacity: 0.6; }
.rule .path { font-weight: 600; word-break: break-all; }
.rule .options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 0.95rem; white-space: nowrap; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

button.small { padding: 4px 10px; font-size: 0.9rem; }
.section-title { margin-top: 8px; }
.section-title p { margin: 0; }
p.card.notice { margin: 0; }
.form { display: grid; gap: 6px; max-width: 460px; }
.form button { justify-self: start; margin-top: 6px; }
details { margin-top: 12px; font-size: 0.95rem; }
details summary { cursor: pointer; color: var(--muted); }
details p { margin: 8px 0; }
.link-text { word-break: break-all; user-select: all; background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 0.85rem; }

/* 履歴 */
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.list .sub { color: var(--muted); font-size: 0.85rem; word-break: break-all; }
.history pre { margin: 4px 0 0; white-space: pre-wrap; word-break: break-all; font: inherit; font-size: 0.9rem; }
.history li { display: block; }
.inline { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.inline select { flex: 1 1 220px; width: auto; }

/* フォルダー選択 */
dialog { width: min(560px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog .path { font-weight: 600; word-break: break-all; margin: 8px 0; }
.folders { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.folders li + li { border-top: 1px solid var(--line); }
.folders button { width: 100%; text-align: left; border: 0; border-radius: 0; padding: 10px 12px; word-break: break-all; }
.folders button:hover { background: var(--bg); }
.folders .empty { padding: 12px; color: var(--muted); }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 20px;
  font-size: 0.9rem; opacity: 0; transition: opacity 0.2s; pointer-events: none; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; }
#toast.bad { background: var(--danger); color: #fff; }
