/* Januite — dark theme, warm gold accent (#f0c978). 30/70 split layout. */

:root {
  --bg: #15171a;
  --bg-elevated: #1c1f24;
  --bg-soft: #22262c;
  --border: #2d3138;
  --text: #e6e8eb;
  --text-muted: #8a8f98;
  --text-dim: #5f6470;
  --accent: #f0c978;
  --accent-soft: rgba(240, 201, 120, 0.12);
  --unread: #6cb6ff;
  --danger: #e57373;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

[hidden] { display: none !important; }

/* --- login --- */
.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}
.login-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.login-sub { color: var(--text-muted); font-size: 14px; }
.login-card button[type="submit"] {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 600;
  padding: 10px 16px;
  margin-top: 4px;
}
.login-card button[type="submit"]:hover { filter: brightness(1.05); }
.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 1em;
}

/* --- app layout --- */
.app {
  display: grid;
  grid-template-columns: 30% 70%;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  border-radius: 8px;
}
.brand-name { font-weight: 600; letter-spacing: -0.01em; }
.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.head-actions { display: flex; gap: 6px; }

/* --- filters --- */
.filters {
  display: flex;
  gap: 6px;
  padding: 10px 12px 6px;
}
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px solid transparent;
}
.filter-btn:hover { background: var(--bg-soft); color: var(--text); }
.filter-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(240, 201, 120, 0.3);
}
.filter-btn .count {
  font-size: 11px;
  background: var(--bg-soft);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 999px;
}
.filter-btn.active .count {
  background: var(--accent);
  color: #1a1a1a;
}

/* --- search --- */
.search {
  padding: 6px 12px 10px;
}
.search input { font-size: 13px; }

/* --- article list --- */
.article-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0 8px 16px;
  scrollbar-width: thin;
}
.article-list::-webkit-scrollbar { width: 8px; }
.article-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.article-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: start;
  margin-bottom: 4px;
  position: relative;
}
.article-item:hover { background: var(--bg-soft); }
.article-item.active { background: var(--bg-soft); }
.article-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--unread);
  margin-top: 8px;
  visibility: hidden;
}
.article-item.is-unread .unread-dot { visibility: visible; }

.article-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
  align-items: center;
}
.article-source { color: var(--accent); font-weight: 500; }
.article-time::before { content: "·"; margin-right: 6px; }

.article-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.article-item.is-read .article-title { color: var(--text-muted); font-weight: 400; }

.article-summary {
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.star-btn {
  align-self: start;
  padding: 4px;
  font-size: 16px;
  color: var(--text-dim);
  border-radius: 6px;
  margin-top: 2px;
}
.star-btn:hover { color: var(--accent); }
.star-btn.is-starred { color: var(--accent); }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}
.load-more {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
.load-more:hover { color: var(--accent); border-color: var(--accent); }
.logout-btn {
  padding: 8px 14px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 13px;
}
.logout-btn:hover { color: var(--danger); border-color: var(--danger); }

/* --- content --- */
.content {
  position: relative;
  overflow-y: auto;
  padding: 0;
  min-width: 0;
}
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.content-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 14px;
}

.article-detail {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 32px 96px;
}
.article-detail h1.article-title-detail {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}
.article-detail .meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.article-detail .meta-row .source { color: var(--accent); font-weight: 500; }
.article-detail .meta-row a { color: var(--text-muted); text-decoration: none; }
.article-detail .meta-row a:hover { color: var(--accent); }
.article-detail .meta-row .star-toggle {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
}
.article-detail .meta-row .star-toggle.is-starred { color: var(--accent); border-color: var(--accent); }

/* article content typography */
.article-body { font-size: 16px; line-height: 1.7; color: var(--text); }
.article-body p { margin: 0 0 18px; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4 {
  line-height: 1.3;
  margin: 28px 0 14px;
  letter-spacing: -0.01em;
}
.article-body h1 { font-size: 24px; }
.article-body h2 { font-size: 20px; }
.article-body h3 { font-size: 17px; }
.article-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}
.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 16px;
  color: var(--text-muted);
  margin: 18px 0;
  font-style: italic;
}
.article-body ul, .article-body ol { margin: 0 0 18px; padding-left: 24px; }
.article-body li { margin-bottom: 6px; }
.article-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  margin: 18px 0;
}
.article-body code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--bg-soft);
  padding: 2px 5px;
  border-radius: 4px;
}
.article-body pre code { background: none; padding: 0; }
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
}
.article-body th, .article-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.article-body th { background: var(--bg-soft); }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* --- AI status banner (article detail) --- */
.ai-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  line-height: 1.4;
}
.ai-banner-done {
  color: var(--accent);
  border-color: rgba(240, 201, 120, 0.35);
  background: var(--accent-soft);
}
.ai-banner-pending { color: var(--text-muted); }
.ai-banner-text { flex: 1; min-width: 0; }
.ai-banner-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: inherit;
  opacity: 0.55;
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
}
.ai-banner-close:hover { opacity: 1; }

/* --- modal --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 24px;
}
.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin-bottom: 16px; font-size: 18px; }
.modal-card form { display: flex; flex-direction: column; gap: 12px; }
.modal-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.form-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.api-config-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.api-config-fields[hidden] { display: none; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal-actions button {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.modal-actions button[type="button"] {
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.modal-actions button[type="submit"] {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 600;
}

/* --- manage feeds modal --- */
.manage-card { max-width: 560px; padding: 20px 20px 16px; }
.manage-card h2 { margin-bottom: 12px; font-size: 18px; }
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
  margin: 0 -4px 8px;
  padding: 0 4px;
  scrollbar-width: thin;
}
.feed-list::-webkit-scrollbar { width: 8px; }
.feed-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.feed-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  align-items: center;
}
.feed-row.is-busy { opacity: 0.55; }

.feed-info { min-width: 0; }
.feed-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.feed-name-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}
.feed-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.feed-url {
  color: var(--text-muted);
  text-decoration: none;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-url:hover { color: var(--accent); }
.feed-interval::before { content: "⏱ "; opacity: 0.7; }
.feed-unread { color: var(--unread); }

.tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.tag.kind-rss { color: var(--accent); border-color: rgba(240, 201, 120, 0.35); }
.tag.kind-web { color: var(--unread); border-color: rgba(108, 182, 255, 0.35); }
.tag.kind-api { color: #b08cff; border-color: rgba(176, 140, 255, 0.35); }
.tag.status-ok { color: #7ee0a0; border-color: rgba(126, 224, 160, 0.35); }
.tag.status-error { color: var(--danger); border-color: rgba(229, 115, 115, 0.4); }
.tag.status-paused { color: var(--text-dim); }

.feed-actions { display: flex; gap: 4px; }
.feed-action {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
}
.feed-action:hover { color: var(--accent); border-color: var(--accent); }
.feed-action.delete:hover { color: var(--danger); border-color: var(--danger); }

.feed-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* --- mobile --- */
.back-btn {
  display: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
}
.back-btn:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    position: relative;
  }
  .sidebar {
    position: absolute;
    inset: 0;
    z-index: 10;
    transition: transform 0.2s ease;
  }
  .content {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: var(--bg);
    transform: translateX(100%);
    transition: transform 0.2s ease;
  }
  .app.show-detail .sidebar { transform: translateX(-30%); }
  .app.show-detail .content { transform: translateX(0); }
  .back-btn { display: inline-block; }
  .article-detail { padding: 20px 18px 64px; }
  .article-detail h1.article-title-detail { font-size: 22px; }
  .article-body { font-size: 15px; }
}
