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

:root {
  --bg: #0d0f14;
  --surface: #161921;
  --surface2: #1e2130;
  --border: #252836;
  --accent: #6c63ff;
  --accent-hover: #857dff;
  --text: #e2e4f0;
  --text-muted: #6b7280;
  --green: #4ade80;
  --red: #f87171;
  --yellow: #fbbf24;
  --sidebar-w: 210px;
  --radius: 10px;
}

body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.6; min-height: 100vh; }

/* LOGIN */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 44px 40px; width: 100%; max-width: 360px; text-align: center; }
.login-logo { font-size: 30px; font-weight: 800; color: var(--text); letter-spacing: -1px; margin-bottom: 6px; }
.login-logo span { color: var(--accent); }
.login-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 32px; }
.login-box input[type="password"] { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-size: 15px; color: var(--text); outline: none; margin-bottom: 10px; transition: border-color .15s; }
.login-box input[type="password"]:focus { border-color: var(--accent); }
.login-box button[type="submit"] { width: 100%; padding: 12px; font-size: 15px; }
.login-error { color: var(--red); font-size: 13px; margin-bottom: 10px; }

/* LAYOUT */
#app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 0; position: fixed; top: 0; left: 0; height: 100vh; z-index: 10; }
.sidebar-logo { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); padding: 0 20px 18px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.sidebar-logo span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 0 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; background: transparent; border: none; color: var(--text-muted); font-size: 14px; font-weight: 500; cursor: pointer; text-align: left; transition: all .15s; margin-bottom: 2px; }
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,.15); color: var(--accent); }
.sidebar-footer { padding: 14px 14px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.model-badge { font-size: 11px; color: var(--text-muted); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; text-align: center; word-break: break-all; }

/* CONTENT */
.content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px 60px; min-width: 0; }
.tab-pane { display: block; }
.tab-pane.hidden { display: none; }

/* PAGE HEADER */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* BUTTONS */
button { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s; white-space: nowrap; }
button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button:hover { background: var(--accent-hover); }
button:disabled { background: var(--surface2); color: var(--text-muted); cursor: not-allowed; }
.btn-logout { background: transparent; color: var(--text-muted); border: 1px solid var(--border); padding: 8px 12px; font-size: 13px; width: 100%; justify-content: center; }
.btn-logout:hover { background: var(--surface2); color: var(--text); }
.btn-read { background: transparent; color: var(--accent); border: 1px solid var(--accent); padding: 3px 9px; font-size: 11px; }
.btn-read:hover { background: var(--accent); color: #fff; }
.btn-translate { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); padding: 3px 9px; font-size: 11px; }
.btn-translate:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* SELECT */
.select-filter { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: 13px; outline: none; cursor: pointer; }
.select-filter:focus { border-color: var(--accent); }

/* SECTION LABEL */
.section-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); margin-bottom: 10px; }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card.loading { color: var(--text-muted); font-style: italic; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.card-preview { color: var(--text-muted); font-size: 13px; line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { margin-top: 14px; display: flex; justify-content: flex-end; }

/* FEED */
.feed-item { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 8px 12px; margin-bottom: 4px; transition: border-color .15s; }
.feed-item:hover { border-color: rgba(108,99,255,.4); }
.feed-item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.feed-item-title { font-weight: 600; font-size: 13px; line-height: 1.3; flex: 1; }
.feed-item-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.feed-cat { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; padding: 1px 6px; border-radius: 4px; flex-shrink: 0; }
.feed-cat.ai_news    { background: rgba(108,99,255,.15); color: var(--accent); }
.feed-cat.ai_tools   { background: rgba(74,222,128,.12); color: var(--green); }
.feed-cat.ai_content { background: rgba(251,191,36,.12);  color: var(--yellow); }
.feed-item-summary { font-size: 12px; color: var(--text-muted); line-height: 1.4; margin-bottom: 5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.feed-item-footer { display: flex; align-items: center; justify-content: space-between; }
.feed-source { font-size: 11px; color: var(--text-muted); }
.feed-actions { display: flex; gap: 5px; }

/* HISTORY */
.history-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; cursor: pointer; transition: border-color .15s; }
.history-item:hover { border-color: var(--accent); }
.history-item-title { font-weight: 600; font-size: 13px; }
.history-item-date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.history-item-arrow { color: var(--text-muted); font-size: 18px; flex-shrink: 0; }

/* PAGINATION */
.pagination { display: flex; gap: 6px; margin-top: 14px; }
.pagination button { background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 5px 11px; font-size: 12px; }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ARTICLE CARDS */
.article-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; transition: border-color .15s; }
.article-card:hover { border-color: rgba(108,99,255,.35); }
.article-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px; cursor: pointer; }
.article-card-left { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.article-card-title { font-weight: 600; font-size: 14px; line-height: 1.4; }
.article-card-meta { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.article-toggle-icon { color: var(--text-muted); font-size: 12px; flex-shrink: 0; margin-top: 4px; }
.article-card-body { padding: 0 18px 18px; border-top: 1px solid var(--border); }
.article-translation { padding-top: 16px; }
.article-translation h2 { font-size: 16px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.article-translation h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--accent); margin: 18px 0 8px; }
.article-translation p  { font-size: 13px; color: var(--text-muted); line-height: 1.75; margin-bottom: 10px; }
.article-translation ul { padding-left: 18px; margin-bottom: 12px; }
.article-translation li { font-size: 13px; color: var(--text-muted); line-height: 1.65; margin-bottom: 4px; }
.article-translation strong { color: var(--text); }
.article-translation a { color: var(--accent); font-size: 12px; text-decoration: none; }
.article-card-footer { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.badge-full { background: rgba(74,222,128,.12); color: var(--green); font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 4px; }
.badge-rss  { background: rgba(251,191,36,.12);  color: var(--yellow); font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 4px; }
.feed-item-processing { font-size: 12px; color: var(--text-muted); font-style: italic; margin-bottom: 8px; }

/* SOURCES */
.sources-group { margin-bottom: 24px; }
.sources-group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); margin-bottom: 8px; }
.source-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.source-name { font-weight: 600; font-size: 13px; }
.source-url { font-size: 11px; color: var(--text-muted); margin-top: 2px; word-break: break-all; }
.source-tag { font-size: 10px; background: rgba(108,99,255,.15); color: var(--accent); border-radius: 4px; padding: 2px 8px; white-space: nowrap; flex-shrink: 0; }

/* LOGS */
.logs-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.log-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.log-item:last-child { border-bottom: none; }
.log-level { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; flex-shrink: 0; margin-top: 2px; min-width: 44px; text-align: center; }
.log-level.info  { background: rgba(74,222,128,.12); color: var(--green); }
.log-level.error { background: rgba(248,113,113,.12); color: var(--red); }
.log-level.warn  { background: rgba(251,191,36,.12);  color: var(--yellow); }
.log-time { color: var(--text-muted); font-size: 11px; flex-shrink: 0; white-space: nowrap; margin-top: 3px; }
.log-msg  { color: var(--text); flex: 1; font-family: "SF Mono","Fira Code",monospace; font-size: 12px; }

/* NOTIFY */
.notify { padding: 11px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; margin-bottom: 18px; }
.notify.success { background: rgba(74,222,128,.10); color: var(--green);  border: 1px solid rgba(74,222,128,.2); }
.notify.error   { background: rgba(248,113,113,.10); color: var(--red);    border: 1px solid rgba(248,113,113,.2); }
.notify.info    { background: rgba(108,99,255,.10);  color: var(--accent); border: 1px solid rgba(108,99,255,.2); }
.hidden { display: none !important; }

/* MODAL */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.75); }
.modal-content { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; max-width: 740px; width: 100%; max-height: 82vh; overflow-y: auto; z-index: 201; }
.modal-close { position: absolute; top: 14px; right: 14px; background: transparent; color: var(--text-muted); border: none; font-size: 18px; padding: 4px 8px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); background: transparent; }

/* TRANSLATE PANEL (sliding right) */
.translate-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 299; }
.translate-panel { position: fixed; top: 0; right: 0; width: 480px; max-width: 95vw; height: 100vh; background: var(--surface); border-left: 1px solid var(--border); z-index: 300; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; }
.translate-panel:not(.hidden) { transform: translateX(0); }
.translate-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.translate-panel-title { font-weight: 700; font-size: 15px; }
.translate-body { flex: 1; overflow-y: auto; padding: 20px; }
.translate-placeholder { color: var(--text-muted); font-size: 13px; text-align: center; padding: 60px 20px; }
.translate-loading { color: var(--text-muted); font-size: 13px; text-align: center; padding: 40px 20px; }
.translate-content h2 { font-size: 18px; font-weight: 700; line-height: 1.4; margin-bottom: 6px; }
.translate-content .tr-source { font-size: 11px; color: var(--text-muted); margin-bottom: 20px; }
.translate-content h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--accent); margin: 20px 0 8px; }
.translate-content p  { font-size: 13px; color: var(--text-muted); line-height: 1.75; margin-bottom: 10px; }
.translate-content ul { padding-left: 18px; margin-bottom: 12px; }
.translate-content li { font-size: 13px; color: var(--text-muted); line-height: 1.65; margin-bottom: 4px; }
.translate-content strong { color: var(--text); }
.translate-content a { color: var(--accent); font-size: 12px; text-decoration: none; }
.translate-content a:hover { text-decoration: underline; }
.translate-orig-link { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.tr-fetch-badge { display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; padding: 3px 9px; border-radius: 4px; margin-bottom: 16px; }
.tr-fetch-badge.full { background: rgba(74,222,128,.12); color: var(--green); }
.tr-fetch-badge.rss  { background: rgba(251,191,36,.12); color: var(--yellow); }

/* DIGEST CONTENT */
.digest-content h2 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); margin: 22px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.digest-content strong { color: var(--text); font-weight: 600; }
.digest-content a { color: var(--accent); text-decoration: none; font-size: 12px; }
.digest-content a:hover { text-decoration: underline; }
.digest-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.digest-content p  { color: var(--text-muted); font-size: 13px; line-height: 1.75; margin: 5px 0; }

@keyframes spin { to { transform: rotate(360deg); } }
