/* ===== HatebuView スタイル ===== */

:root {
  --accent: #00a4de;
  --accent-dark: #0080b0;
  --bg: #f4f6f8;
  --bg-card: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.92);
  --text: #1a2733;
  --text-sub: #66788a;
  --border: #dde4ea;
  --shadow: 0 1px 3px rgba(20, 40, 60, 0.08);
  --shadow-hover: 0 4px 14px rgba(20, 40, 60, 0.14);
  --badge-low: #8aa2b5;
  --badge-mid: #00a4de;
  --badge-high: #f0831e;
  --badge-hot: #eb4d55;
  --radius: 10px;
}

[data-theme="dark"] {
  --bg: #12181f;
  --bg-card: #1c242e;
  --bg-header: rgba(18, 24, 31, 0.92);
  --text: #e4ebf2;
  --text-sub: #8ba0b5;
  --border: #2c3844;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.5);
  --badge-low: #5b7285;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ===== ヘッダー ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px 6px;
  max-width: 1400px;
  margin: 0 auto;
}

.logo {
  font-size: 19px;
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.logo span { color: var(--accent); }

.search-box { flex: 1; max-width: 420px; }
.search-box input {
  width: 100%;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.search-box input:focus { border-color: var(--accent); }

.header-actions { display: flex; gap: 4px; margin-left: auto; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 17px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  line-height: 1;
}
.icon-btn:hover { background: var(--border); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn:disabled:hover { background: none; }
#sort-select:disabled { opacity: 0.4; }

/* ===== カテゴリタブ ===== */
.tabs {
  display: flex;
  gap: 2px;
  padding: 2px 18px 0;
  max-width: 1400px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  padding: 7px 13px;
  font-size: 13.5px;
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s;
  font-family: inherit;
}
.tabs button:hover { color: var(--text); }
.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tabs button .badge-count {
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  border-radius: 9px;
  padding: 1px 6px;
  margin-left: 4px;
}

/* ===== サブバー ===== */
.sub-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 18px 8px;
  max-width: 1400px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.mode-toggle button {
  background: var(--bg-card);
  border: none;
  padding: 5px 14px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-sub);
  font-family: inherit;
}
.mode-toggle button.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.mode-toggle button:disabled { opacity: 0.45; cursor: default; }

#archive-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}

.morning-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-sub);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.morning-btn:hover { border-color: var(--accent); color: var(--accent); }
.morning-btn.active {
  background: #f0831e;
  border-color: #f0831e;
  color: #fff;
  font-weight: 600;
}

.filters { display: flex; align-items: center; gap: 14px; }

.filter-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
}
.filter-label input[type="range"] { width: 110px; accent-color: var(--accent); }

#sort-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}

.status { margin-left: auto; font-size: 11.5px; color: var(--text-sub); }

/* ===== メイン ===== */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 18px 60px;
}

/* ===== 横断ビュー（なれのはてぶ風） ===== */
.entries.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr));
  gap: 14px;
  align-items: start;
}

.dash-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 6px;
  font-size: 14.5px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}
.dash-more {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
  padding: 2px 4px;
}
.dash-more:hover { text-decoration: underline; }

.entry.dash-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  background: none;
  border-left: 2px solid transparent;
}
.entry.dash-row:last-child { border-bottom: none; }
.entry.dash-row:hover { transform: none; box-shadow: none; background: color-mix(in srgb, var(--accent) 5%, transparent); }
.entry.dash-row.selected { border-color: var(--border); border-left-color: var(--accent); }
.entry.dash-row .users-badge { min-width: 44px; text-align: center; font-size: 11px; padding: 2px 7px; }

.dash-text { flex: 1; min-width: 0; }
.dash-text a {
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  display: block;
}
.dash-text a:hover { color: var(--accent); }
.entry.dash-row.read .dash-text a { color: var(--text-sub); }
.dash-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--text-sub);
  margin-top: 2px;
  overflow: hidden;
  white-space: nowrap;
}
.dash-meta .favicon { border-radius: 2px; }
.dash-empty { color: var(--text-sub); font-size: 12px; padding: 12px 0; text-align: center; }

/* 急上昇マーク */
.rising-mark { margin-right: 3px; }
.rising-rate { color: #eb4d55; font-weight: 700; }
.rising-tag {
  background: color-mix(in srgb, #eb4d55 14%, transparent);
  color: #eb4d55;
  border-radius: 9px;
  padding: 0 7px;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.dash-section.dash-rising { border: 1.5px solid #eb4d55; }
.dash-section.dash-rising .dash-head { border-bottom-color: #eb4d55; }

/* ブックマークしたユーザー表示 */
.by-user {
  display: inline-block;
  font-size: 10.5px;
  color: var(--accent-dark);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 9px;
  padding: 1px 8px;
  margin-top: 3px;
}
[data-theme="dark"] .by-user { color: #6cc8e8; }

/* 要約パネル */
.summary-panel {
  margin: 10px 14px 0;
  padding: 16px 18px;
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 10px;
  max-height: 62vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.summary-panel[hidden] { display: none; }
.summary-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  margin-bottom: 10px;
}
[data-theme="dark"] .summary-head { color: #6cc8e8; }
.summary-mock-note {
  font-weight: 400;
  color: var(--text-sub);
  margin-left: 6px;
  font-size: 10.5px;
}
.summary-text {
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}
.summary-text a { color: var(--accent); }
.summary-prompt {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: all;
}

/* コメント検索 */
.comment-search-wrap { padding: 8px 18px 0; }
.comment-search-wrap input {
  width: 100%;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  font-family: inherit;
}
.comment-search-wrap input:focus { border-color: var(--accent); }

/* トレンドタグ */
.trend-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.trend-tags:empty { display: none; }
.trend-label { font-size: 12px; color: var(--text-sub); }
.trend-tag {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 14px;
  padding: 3px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.trend-tag:hover { border-color: var(--accent); color: var(--accent); }
.trend-tag b { margin-left: 4px; color: var(--accent); font-size: 10.5px; }

/* カード表示 */
.entries.card-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

/* リスト表示 */
.entries.list-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto;
}

.entry {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.15s, transform 0.15s, opacity 0.2s;
  position: relative;
  border: 2px solid transparent;
}
.entry:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.entry.selected { border-color: var(--accent); }
.entry.read.dim-read { opacity: 0.55; }

.entry-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-sub);
}
.entry-top .favicon { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.entry-top .domain {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-top .date { margin-left: auto; white-space: nowrap; }

.entry-main { display: flex; gap: 12px; flex: 1; }
.entry-text { flex: 1; min-width: 0; }

.entry-title {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.45;
}
.entry-title a { color: var(--text); text-decoration: none; }
.entry-title a:hover { color: var(--accent); }
.entry.read .entry-title a { color: var(--text-sub); }

.entry-desc {
  font-size: 12px;
  color: var(--text-sub);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-thumb {
  width: 100px;
  height: 72px;
  object-fit: cover;
  border-radius: 7px;
  flex-shrink: 0;
  background: var(--border);
}
.hide-thumbs .entry-thumb { display: none; }

.entry-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}

.users-badge {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border-radius: 12px;
  padding: 2px 10px;
  background: var(--badge-low);
  cursor: pointer;
  white-space: nowrap;
  border: none;
  font-family: inherit;
  transition: filter 0.15s;
}
.users-badge:hover { filter: brightness(1.12); }
.users-badge.mid { background: var(--badge-mid); }
.users-badge.high { background: var(--badge-high); }
.users-badge.hot { background: var(--badge-hot); }

.entry-tags { display: flex; gap: 4px; overflow: hidden; flex: 1; }
.entry-tag {
  font-size: 10.5px;
  color: var(--accent-dark);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 1px 8px;
  border-radius: 9px;
  white-space: nowrap;
  cursor: pointer;
}
[data-theme="dark"] .entry-tag { color: #6cc8e8; }

.entry-actions { display: flex; gap: 2px; }
.entry-actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 3px 5px;
  border-radius: 6px;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.entry-actions button:hover { opacity: 1; background: var(--border); }
.entry-actions button.on { opacity: 1; }

/* リスト表示時の調整 */
.list-view .entry { flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; }
.list-view .entry-top { display: none; }
.list-view .entry-main { align-items: center; }
.list-view .entry-thumb { width: 72px; height: 48px; }
.list-view .entry-desc { display: none; }
.list-view .entry-bottom { margin: 0; flex-shrink: 0; flex-wrap: nowrap; }
.list-view .entry-tags { display: none; }
.list-view .entry-title { margin: 0; font-size: 13.5px; }
.list-view .list-domain {
  font-size: 11px;
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.card-view .list-domain { display: none; }

/* スケルトンローディング */
.entry.skeleton { pointer-events: none; min-height: 120px; justify-content: center; }
.sk-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 25%, color-mix(in srgb, var(--border) 40%, var(--bg-card)) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.3s infinite;
  margin: 5px 0;
}
.sk-w30 { width: 30%; }
.sk-w40 { width: 40%; }
.sk-w70 { width: 70%; }
.sk-w90 { width: 90%; }
@keyframes sk-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.load-more-wrap {
  grid-column: 1 / -1;
  text-align: center;
  padding: 10px 0;
}
.load-more-wrap .text-btn { padding: 9px 40px; font-size: 13.5px; }

.empty-message {
  text-align: center;
  color: var(--text-sub);
  padding: 60px 0;
  font-size: 14px;
}

/* ===== モーダル ===== */
.modal-backdrop[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 30, 0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--bg-card);
  border-radius: 14px;
  width: min(820px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border);
}
.modal-title-wrap { flex: 1; min-width: 0; }
.modal-header h2 { margin: 0 0 6px; font-size: 15.5px; line-height: 1.4; }
.modal-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; flex-wrap: wrap; }
.modal-meta a { color: var(--accent); text-decoration: none; }
.mini-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-sub);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.modal-meta a:hover { text-decoration: underline; }

.modal-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 18px 0;
  border-bottom: 1px solid var(--border);
}
.modal-tabs button {
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--text-sub);
  cursor: pointer;
  font-family: inherit;
}
.modal-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.modal-body { overflow-y: auto; padding: 14px 18px 20px; }

.comment {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
.comment img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
}
.comment-body { flex: 1; min-width: 0; }
.comment-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-sub);
  flex-wrap: wrap;
}
.comment-head .user { font-weight: 700; color: var(--text); }
.comment-head .user a { color: inherit; text-decoration: none; }
.comment-text { font-size: 13px; margin: 3px 0 0; word-break: break-word; }
.star-count { color: #e8a013; font-weight: 700; font-size: 11px; }
.comment-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.comment-tags span {
  font-size: 10px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent-dark);
  border-radius: 8px;
  padding: 0 7px;
}
[data-theme="dark"] .comment-tags span { color: #6cc8e8; }

.related-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
}
.related-item:last-child { border-bottom: none; }
.related-item:hover .related-title { color: var(--accent); }
.related-item .users-badge { flex-shrink: 0; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; }
.tag-cloud .tag-item {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 14px;
  padding: 3px 12px;
  font-size: 12.5px;
  color: var(--accent-dark);
}
[data-theme="dark"] .tag-cloud .tag-item { color: #6cc8e8; }
.tag-cloud .tag-item b { margin-left: 5px; }

.loading {
  text-align: center;
  color: var(--text-sub);
  padding: 30px;
}

/* ===== 設定 ===== */
.modal.settings section { margin-bottom: 18px; }
.modal.settings h3 { font-size: 13px; margin: 0 0 6px; }
.modal.settings textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
  font-size: 12.5px;
  font-family: inherit;
  resize: vertical;
}
.check { display: block; font-size: 13px; margin: 5px 0; cursor: pointer; }
.check input { accent-color: var(--accent); margin-right: 6px; }
.btn-row { display: flex; gap: 10px; }
.text-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
}
.text-btn:hover { border-color: var(--accent); color: var(--accent); }

.kbd-table { font-size: 12.5px; border-collapse: collapse; }
.kbd-table td { padding: 3px 14px 3px 0; color: var(--text-sub); }
.kbd-table td:first-child { color: var(--text); }
kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: inherit;
}

/* ===== 閲覧統計 ===== */
.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  font-size: 12.5px;
}
.stat-name {
  width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.stat-bar {
  flex: 1;
  height: 12px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
}
.stat-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}
.stat-num { width: 36px; text-align: right; color: var(--text-sub); flex-shrink: 0; }

.heat-grid {
  display: grid;
  grid-template-columns: 28px repeat(6, 1fr);
  gap: 3px;
  max-width: 420px;
}
.heat-label { font-size: 10.5px; color: var(--text-sub); text-align: center; align-self: center; }
.heat-cell {
  aspect-ratio: 2.2;
  background: var(--accent);
  border-radius: 3px;
}

/* ===== レスポンシブ ===== */
@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; gap: 8px; padding: 8px 12px 4px; }
  .search-box { order: 3; max-width: none; flex-basis: 100%; }
  .entries.card-view { grid-template-columns: 1fr; }
  .sub-bar { gap: 10px; }
  .status { display: none; }

  /* ---- タップ領域の確保 ----
     指で押す前提だと20px前後のボタンは誤タップしやすい。
     見た目を大きく変えずに、余白と最小高さで押しやすくする */
  .users-badge { min-height: 32px; padding: 6px 12px; display: inline-flex; align-items: center; }
  .dash-more { min-height: 32px; padding: 6px 10px; }
  .trend-tag { min-height: 32px; padding: 6px 12px; }
  .icon-btn { min-height: 36px; min-width: 36px; }
  .entry-actions button { min-height: 34px; min-width: 34px; font-size: 16px; }
  .tabs button { min-height: 38px; }
  .mode-toggle button, .morning-btn { min-height: 34px; }
  .dash-text a { padding: 2px 0; }
  /* 行間が詰まりすぎないよう、押し間違い防止の余白も足す */
  .entry.dash-row { padding: 10px 2px; gap: 12px; }
}
