:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #667085;
  --border: #d9dde3;
  --accent: #2b6cb0;
  --accent-soft: #e6f0fa;
  --danger: #c53030;
  --new: #d97706;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --surface: #1f2229;
    --text: #e6e8eb;
    --muted: #9aa3af;
    --border: #333843;
    --accent: #63a4e8;
    --accent-soft: #23374d;
    --danger: #f28b82;
    --new: #f5a524;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

a { color: var(--accent); }

/* iOS Safari は 16px 未満の入力欄にフォーカスすると画面を拡大し、横スクロールが発生する。
   viewport の maximum-scale で禁止するとピンチズームも効かなくなるため、フォームは常に 16px にする。 */
input, select, textarea { font-size: 16px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-title { margin: 0; font-size: 1.25rem; white-space: nowrap; flex-shrink: 0; }
.app-title a { color: var(--text); text-decoration: none; }
.header-search { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-family: inherit; }

main { max-width: 860px; margin: 0 auto; padding: 12px 16px 64px; }

.btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--accent-soft); }
.btn--small { padding: 3px 8px; font-size: 13px; }
.btn--icon { padding: 4px 10px; font-size: 18px; line-height: 1; }
.file-label { display: inline-block; }
.more-btn { display: block; margin: 16px auto 0; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: nowrap; margin-bottom: 8px; }
/* タブは常に 1 行に収め、はみ出す分は js/app.js の fitSourceTabs() でラベルを省略して調整する。
   設定モーダル内のタブ(mute / unmute / forceMute)は調整しないため、折り返す。 */
.tabs { display: flex; flex-wrap: nowrap; gap: 6px; flex: 1 1 auto; min-width: 0; margin: 4px 0 8px; overflow: hidden; }
#settings-tabs { flex-wrap: wrap; overflow: visible; }
.tab {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  flex: 0 0 auto;
  white-space: nowrap;
}
.tab--active { background: var(--accent); border-color: var(--accent); color: #fff; }

.list-status-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; }
.list-controls { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.status { margin: 0; color: var(--muted); font-size: 13px; }

.entry-list { display: flex; flex-direction: column; gap: 8px; }

.entry {
  position: relative;
  padding: 10px 40px 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.entry--read { opacity: 0.55; }
.entry-title { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.entry-title:hover { text-decoration: underline; }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 2px; color: var(--muted); font-size: 12px; }
.meta-link { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.meta-link:hover { color: var(--accent); text-decoration: underline; }
.entry-desc { display: block; margin: 4px 0 0; color: var(--muted); font-size: 13px; text-decoration: none; overflow-wrap: anywhere; }
a.entry-desc:hover { color: var(--text, inherit); }
a.bm-count { color: var(--danger); font-weight: 600; text-decoration: none; white-space: nowrap; }
a.bm-count:hover { text-decoration: underline; }
.badge-new { padding: 0 6px; border-radius: 4px; background: var(--new); color: #fff; font-size: 11px; font-weight: 700; }
.tag { padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
.btn--x { position: absolute; top: 6px; right: 6px; padding: 0 8px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* 右寄せで常に画面下に固定する(hateb-tycoon と同じ)。下のコンテンツを押せるよう、リンク以外は pointer-events: none。 */
.app-footer { position: fixed; left: 10px; right: 10px; bottom: 8px; text-align: right; font-size: 11px; line-height: 1.4; color: var(--muted); font-family: monospace; overflow-wrap: anywhere; pointer-events: none; }
.app-footer a { pointer-events: auto; }

.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.4); }
.modal[hidden] { display: none; }
.modal-panel { width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; overflow-x: hidden; padding: 16px 20px 20px; background: var(--surface); border-radius: 10px; box-sizing: border-box; }
.modal-panel * { box-sizing: border-box; min-width: 0; }
.modal-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.modal-section h3 { margin: 0 0 8px; font-size: 14px; }
.modal-section h4 { margin: 14px 0 6px; font-size: 13px; }
.modal-section .hint { margin: 0 0 12px; }
.modal-section .status:empty { display: none; }
.help-btn { margin-left: 6px; padding: 0 2px; border: none; border-bottom: 1px dashed var(--muted); border-radius: 0; background: none; color: var(--muted); font-size: 13px; line-height: 1.2; cursor: pointer; }
.help-btn[aria-expanded="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.import-target { margin: 0; font-size: 13px; color: var(--muted); }
a.btn { text-decoration: none; color: inherit; }
.gist-row { flex-wrap: nowrap; align-items: center; }
.gist-row .btn { flex: 0 0 auto; white-space: nowrap; }
.mute-settings #settings-tabs { margin-bottom: 10px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { margin: 0; font-size: 17px; }
.hint { color: var(--muted); font-size: 12px; }
.hint[hidden] { display: none; }
code { padding: 0 4px; background: var(--bg); border-radius: 4px; }

.rule-form, .gist-row, .import-export-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.rule-form input, .gist-row input, .rule-row input { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-family: inherit; }
.rule-form select, .rule-row select { padding: 5px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-family: inherit; }
.rule-list-details { margin: 8px 0; }
.rule-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 40vh; overflow-y: auto; }
.rule-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.rule-type { flex: none; width: 5.5em; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.rule-value { flex: 1; min-width: 0; overflow-wrap: anywhere; }
/* 取得元は件数が少ない。長いURLで行が高くなっても、内側スクロールで削除ボタンが隠れないようにする */
#source-list { max-height: none; overflow-y: visible; }
.export-text { width: 100%; height: 8em; margin: 4px 0; padding: 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-family: ui-monospace, monospace; line-height: 1.4; }

@media (max-width: 520px) {
  .app-title { font-size: 1.05rem; }
  .tab { padding: 3px 6px; font-size: 0.72rem; }
  .rule-type { width: 4.5em; }
}

.footer-warn { color: var(--danger); }
#scroll-sentinel { height: 1px; }

/* ブックマークページ */
.bm-header { margin: 12px 0; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.bm-title { font-size: 1.1rem; font-weight: bold; overflow-wrap: anywhere; }
.bm-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; color: var(--muted); font-size: 0.82rem; }
.bm-description { margin: 0 0 8px; padding: 6px 12px; border-left: 3px solid var(--border); color: var(--muted); font-size: 0.85rem; font-style: italic; line-height: 1.6; overflow-wrap: anywhere; }
.bm-description:empty { display: none; }

.comment-list { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; padding-left: 20px; font-size: 0.88rem; line-height: 1.6; overflow-wrap: anywhere; }
.comment-list li { padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.comment-list li:last-child { border-bottom: none; padding-bottom: 0; }
.comment-user { padding: 0; border: none; background: none; color: var(--text); font: inherit; font-weight: bold; cursor: pointer; }
.comment-user:hover { color: var(--accent); text-decoration: underline; }
.comment-date { color: var(--muted); }
/* 前回訪問後に付いたコメントは「NEW」バッジのみ。前回訪問時点で既にあったコメントはグレーアウト。 */
.comment-badge-new { display: inline-block; padding: 0 6px; margin-right: 2px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.68rem; font-weight: 700; vertical-align: 1px; }
.comment-list li.comment--read { opacity: 0.6; filter: grayscale(100%); }

.layout-toggle { display: flex; gap: 6px; flex-shrink: 0; }
.comment-list--rich { list-style: none; padding-left: 0; gap: 12px; }
.comment-list li.comment--rich { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; }
.comment-icon { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 4px; background: var(--surface); object-fit: cover; }
.comment-rich-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.comment-rich-line2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 0.8rem; }
.comment-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.comment-tag { padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 0.75rem; }

.offline-cache-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
.offline-cache-row input { width: 5em; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-family: inherit; }

/* ヘッダーのオフライン用キャッシュ(クイックボタン + 進捗のポップオーバー) */
.offline-cache-quick { position: relative; display: inline-flex; flex-shrink: 0; }
.offline-cache-popover { position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; width: max-content; max-width: min(260px, calc(100vw - 32px)); padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); }
.offline-cache-popover .status { margin: 0; }

/* ブックマークページ下部のボタン(前後の記事・一覧に戻る)。スマホの片手操作を想定した全幅ボタン */
.entry-nav-buttons { display: flex; gap: 8px; margin-top: 16px; }
.entry-nav-btn { flex: 1 1 50%; padding: 14px 8px; font-size: 1rem; text-align: center; }
.entry-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#entry-back-bottom { display: block; width: 100%; margin-top: 16px; padding: 14px 8px; font-size: 1rem; text-align: center; }
