/* sorae Source Radar - 独自スタイル */

:root {
  --bg-0: #0a0e1a;
  --bg-1: #111827;
  --bg-2: #1a2236;
  --bg-3: #232d46;
  --fg-0: #e6edf7;
  --fg-1: #a8b3c7;
  --fg-2: #6b7489;
  --accent: #4f8cff;
  --accent-2: #7b5cff;
  --star: #f5c042;
  --border: #2a3452;
  --danger: #ff5e7a;
  --ok: #48d597;
}

body.theme-light {
  --bg-0: #f5f7fb;
  --bg-1: #ffffff;
  --bg-2: #f0f3f9;
  --bg-3: #e4e9f2;
  --fg-0: #1a2236;
  --fg-1: #3d4a63;
  --fg-2: #6b7489;
  --accent: #2563eb;
  --accent-2: #6d28d9;
  --border: #d7dde8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ========== Header ========== */
.app-header {
  background: linear-gradient(90deg, var(--bg-1), var(--bg-2));
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex; align-items: center; gap: 14px;
  height: 56px; flex-shrink: 0;
}
.app-logo { font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }
.app-logo .logo-accent { color: var(--accent); }
.header-btn {
  background: var(--bg-3); color: var(--fg-0);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.header-btn:hover { background: var(--accent); border-color: var(--accent); }
.header-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.header-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== 3カラムレイアウト ========== */
.app-main {
  display: grid;
  grid-template-columns: 280px 420px 1fr;
  height: calc(100vh - 56px);
}
body.layout-cards .app-main { grid-template-columns: 280px 1fr; }
body.layout-cards .preview-pane { display: none; }
body.layout-cards .list-pane { overflow-y: auto; }

body.layout-timeline .app-main { grid-template-columns: 280px 1fr; }
body.layout-timeline .preview-pane { display: none; }

.sidebar, .list-pane, .preview-pane {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  height: 100%;
}
.preview-pane { border-right: none; background: var(--bg-0); }

/* ========== Sidebar ========== */
.sidebar { padding: 14px 10px; }
.sidebar h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-2); margin: 14px 8px 6px 8px;
}
.filter-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  color: var(--fg-1); font-size: 13px;
  transition: background 0.1s;
}
.filter-item:hover { background: var(--bg-2); color: var(--fg-0); }
.filter-item.active { background: var(--accent); color: #fff; }
.filter-item .count {
  margin-left: auto; font-size: 11px; color: var(--fg-2);
  background: var(--bg-3); padding: 1px 7px; border-radius: 10px;
}
.filter-item.active .count { background: rgba(255,255,255,0.25); color: #fff; }
.filter-item .flag { font-size: 15px; }

.source-group { margin-bottom: 4px; }
.source-group-title {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; cursor: pointer; user-select: none;
  color: var(--fg-1); font-size: 12px; font-weight: 600;
}
.source-group-title:hover { color: var(--fg-0); }
.source-group-title .chevron { font-size: 10px; transition: transform 0.15s; }
.source-group.collapsed .chevron { transform: rotate(-90deg); }
.source-group.collapsed .source-list { display: none; }
.source-list { padding-left: 8px; }

.source-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; font-size: 12px; border-radius: 4px;
  cursor: pointer; color: var(--fg-1);
}
.source-item:hover { background: var(--bg-2); color: var(--fg-0); }
.source-item.active { background: var(--bg-3); color: var(--fg-0); }
.source-item .source-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-item .status-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--fg-2); flex-shrink: 0;
}
.source-item .status-dot.ok { background: var(--ok); }
.source-item .status-dot.error { background: var(--danger); }
.source-item .status-dot.link-only { background: var(--accent-2); }
.source-refetch-btn {
  background: transparent; border: none; color: var(--fg-2);
  cursor: pointer; font-size: 10px; padding: 2px 4px;
  opacity: 0; transition: opacity 0.15s;
}
.source-item:hover .source-refetch-btn { opacity: 1; }
.source-refetch-btn:hover { color: var(--accent); }

/* ソース絞り込み検索ボックス */
.source-search {
  width: 100%; margin: 2px 0 8px 0;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 9px; color: var(--fg-0);
  font-size: 12px;
}
.source-search:focus { outline: none; border-color: var(--accent); }
.source-search::placeholder { color: var(--fg-2); }

/* ソースグループの未読バッジ */
.group-unread {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 8px; margin-left: 4px;
  min-width: 16px; text-align: center;
}
/* ソース行のカウント表示（既読=薄色、未読=強調） */
.src-count {
  font-size: 10px; color: var(--fg-2);
  padding: 0 5px; border-radius: 8px;
  flex-shrink: 0;
}
.src-count.unread {
  color: #fff; background: var(--accent); font-weight: 600;
}

/* ステータスドット凡例 */
.status-legend {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 4px 8px 8px 8px; padding: 6px 8px;
  background: var(--bg-2); border-radius: 6px;
  font-size: 10px; color: var(--fg-2);
}
.status-legend span { display: inline-flex; align-items: center; gap: 3px; }
.status-legend .status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-legend .status-dot.ok { background: var(--ok); }
.status-legend .status-dot.error { background: var(--danger); }
.status-legend .status-dot.link-only { background: var(--accent-2); }
.status-legend .status-dot.neutral { background: var(--fg-2); }

/* ========== List pane ========== */
.list-toolbar {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--bg-1); position: sticky; top: 0; z-index: 5;
}
.search-box {
  flex: 1; min-width: 120px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; color: var(--fg-0);
  font-size: 13px;
}
.toolbar-btn {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--fg-1); padding: 5px 10px; border-radius: 6px;
  cursor: pointer; font-size: 12px;
}
.toolbar-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.toolbar-btn:hover { color: var(--fg-0); }

/* 記事リスト（Reader風） */
.article-row {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; position: relative;
  transition: background 0.1s;
}
.article-row:hover { background: var(--bg-2); }
.article-row.selected { background: var(--bg-3); }
.article-row.unread { border-left: 3px solid var(--accent); padding-left: 13px; }
.article-row.read { opacity: 0.65; }
.article-row .row-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--fg-2); margin-bottom: 4px;
}
.article-row .row-meta .flag { font-size: 13px; }
.article-row .row-title {
  font-weight: 600; font-size: 14px; color: var(--fg-0);
  line-height: 1.4; margin-bottom: 4px;
}
.article-row .row-desc {
  font-size: 12px; color: var(--fg-1);
  line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-row .row-actions {
  position: absolute; right: 10px; top: 10px;
  display: flex; gap: 4px;
}
.row-action-btn {
  background: transparent; border: none; color: var(--fg-2);
  cursor: pointer; font-size: 14px; padding: 3px 5px;
}
.row-action-btn:hover { color: var(--fg-0); }
.row-action-btn.starred { color: var(--star); }
.row-action-btn.processed { color: var(--ok); }

/* Card layout */
body.layout-cards .article-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px; padding: 14px;
}
body.layout-cards .article-row {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-1); padding: 14px;
}
body.layout-cards .article-row.unread { border-left: 3px solid var(--accent); }
body.layout-cards .article-thumb {
  width: 100%; aspect-ratio: 16/9; object-fit: cover;
  border-radius: 6px; margin-bottom: 10px; background: var(--bg-2);
}
body.layout-cards .article-row .row-desc { -webkit-line-clamp: 3; }
.article-thumb { display: none; }

/* Timeline layout */
body.layout-timeline .article-list {
  max-width: 820px; margin: 0 auto; padding: 20px;
  position: relative;
}
body.layout-timeline .article-list::before {
  content: ""; position: absolute; left: 130px; top: 20px; bottom: 20px;
  width: 2px; background: var(--border);
}
body.layout-timeline .article-row {
  padding-left: 160px; position: relative; border-bottom: none;
  margin-bottom: 10px; background: var(--bg-1); border-radius: 8px;
  border: 1px solid var(--border);
}
body.layout-timeline .article-row::before {
  content: ""; position: absolute; left: 125px; top: 20px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-0);
}
body.layout-timeline .timeline-date {
  position: absolute; left: 16px; top: 16px; width: 100px;
  font-size: 11px; color: var(--fg-2); text-align: right;
}

/* ========== Preview pane ========== */
.preview-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--fg-2); font-size: 14px;
}
.preview-content { padding: 24px 28px; max-width: 820px; }
.preview-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--fg-2); margin-bottom: 10px;
  flex-wrap: wrap;
}
.preview-meta .badge {
  background: var(--bg-2); padding: 2px 8px; border-radius: 10px;
  font-size: 11px;
}
.preview-title {
  font-size: 22px; font-weight: 700; line-height: 1.4;
  margin: 4px 0 16px; color: var(--fg-0);
}
.preview-actions {
  display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
.preview-body {
  font-size: 14px; line-height: 1.75; color: var(--fg-1);
  margin-bottom: 20px;
}
.preview-body img { max-width: 100%; border-radius: 8px; margin: 10px 0; }
.preview-section {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; margin-bottom: 14px;
}
.preview-section h4 {
  margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
  color: var(--fg-2); letter-spacing: 0.06em;
}
.memo-input {
  width: 100%; min-height: 90px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px; color: var(--fg-0); font-family: inherit; font-size: 13px;
  resize: vertical;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-3); color: var(--fg-0); padding: 3px 10px;
  border-radius: 12px; font-size: 12px; margin: 2px;
}
.tag-chip .remove { cursor: pointer; color: var(--fg-2); }
.tag-chip .remove:hover { color: var(--danger); }
.tag-input {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; color: var(--fg-0);
  font-size: 12px; width: 150px;
}

.translate-links { display: flex; gap: 6px; flex-wrap: wrap; }
.translate-links a {
  background: var(--bg-3); color: var(--fg-1); text-decoration: none;
  padding: 4px 10px; border-radius: 6px; font-size: 12px;
  display: inline-flex; align-items: center; gap: 4px;
}
.translate-links a:hover { background: var(--accent); color: #fff; }

/* 強化版 翻訳セクション */
.translate-block { display: flex; flex-direction: column; gap: 10px; }
.translate-row { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.translate-label {
  font-size: 11px; color: var(--fg-2); min-width: 64px; padding-top: 5px;
  flex-shrink: 0;
}
.translate-note {
  font-size: 11px; color: var(--fg-2); background: var(--bg-2);
  padding: 6px 10px; border-radius: 6px; line-height: 1.5;
}
.translate-note i { color: var(--accent); margin-right: 4px; }

/* ========== Toast & Progress ========== */
.fetch-progress {
  position: fixed; bottom: 16px; right: 16px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; font-size: 12px;
  color: var(--fg-1); box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  display: none; z-index: 100; min-width: 260px;
}
.fetch-progress.visible { display: block; }
.fetch-progress-bar {
  height: 3px; background: var(--bg-3); border-radius: 2px;
  margin-top: 6px; overflow: hidden;
}
.fetch-progress-bar-inner {
  height: 100%; background: var(--accent); transition: width 0.2s;
}

.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: var(--bg-2); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 8px; font-size: 13px;
  z-index: 1000; opacity: 0; transition: opacity 0.2s;
}
.toast.visible { opacity: 1; }

/* ========== Modal ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; z-index: 200;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; max-width: 640px; width: 92%;
  max-height: 80vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-2); }

/* ========== Responsive ========== */
@media (max-width: 1200px) {
  .app-main { grid-template-columns: 240px 360px 1fr; }
}
@media (max-width: 900px) {
  .app-main { grid-template-columns: 1fr; }
  .sidebar, .preview-pane { display: none; }
  body.mobile-show-sidebar .sidebar { display: block; position: fixed; inset: 56px 0 0 0; z-index: 20; }
}
