:root {
  --ink: #16202a;
  --muted: #6f7b85;
  --line: #dfe5e8;
  --paper: #f6f4ee;
  --card: #fffefa;
  --blue: #2476a9;
  --blue-deep: #185b83;
  --blue-pale: #e8f2f8;
  --sidebar: #112633;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 72% 0%, rgba(39, 126, 173, .08), transparent 28rem),
    var(--paper);
  font-family: "SF Pro Text", "PingFang SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 276px;
  padding: 32px 22px 24px;
  color: #eaf1f4;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), transparent 18%),
    var(--sidebar);
  display: flex;
  flex-direction: column;
  box-shadow: 12px 0 40px rgba(10, 29, 40, .08);
}

.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 8px 32px; }
.brand-mark {
  width: 43px; height: 43px; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.28); border-radius: 13px;
  color: white; background: linear-gradient(145deg, #3b96c7, #246a91);
  font-family: Georgia, serif; font-weight: 700; font-size: 22px;
  box-shadow: 0 7px 22px rgba(34, 123, 170, .22);
}
.brand-name { margin: 0; font-weight: 700; font-size: 17px; letter-spacing: .04em; }
.brand-note { margin: 3px 0 0; font-size: 11px; color: #8fa6b2; letter-spacing: .08em; }
.close-menu { display: none; margin-left: auto; border: 0; background: transparent; color: white; font-size: 28px; }

.nav-label { margin: 0 12px 10px; color: #718996; font-size: 11px; font-weight: 700; letter-spacing: .14em; }
.channel-nav { display: grid; gap: 5px; }
.channel {
  width: 100%; min-height: 48px; padding: 7px 10px; display: grid; grid-template-columns: 31px 1fr auto;
  align-items: center; gap: 9px; text-align: left; border: 0; border-radius: 10px;
  color: #aebfc7; background: transparent; font-size: 13px; transition: .18s ease;
}
.channel:hover { color: white; background: rgba(255,255,255,.055); }
.channel.active { color: white; background: rgba(70, 148, 188, .18); box-shadow: inset 2px 0 #55a6d1; }
.channel-icon { width: 29px; height: 29px; border-radius: 8px; display: grid; place-items: center; color: white; font-size: 11px; font-weight: 700; background: #315368; }
.channel-1 { background: #3b79b5; }.channel-2 { background: #695bad; }.channel-3 { background: #b66c3e; }.channel-4 { background: #3c8068; }
.channel-count { min-width: 25px; padding: 3px 7px; text-align: center; border-radius: 99px; color: #97adba; background: rgba(255,255,255,.07); font-size: 11px; }
.channel.active .channel-count { color: white; background: #2f83b1; }

.sidebar-card { margin-top: auto; padding: 14px 14px 13px; border: 1px solid rgba(255,255,255,.07); border-radius: 12px; background: rgba(255,255,255,.035); }
.sidebar-card p { display: inline; margin: 0 0 0 7px; font-size: 12px; color: #cbd8de; }
.sidebar-card > span:last-child { display: block; margin: 6px 0 0 16px; color: #708995; font-size: 10px; }
.pulse-dot, .tiny-live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #48bd81; box-shadow: 0 0 0 4px rgba(72,189,129,.11); }
.settings-button { margin-top: 12px; padding: 12px 14px; border: 0; border-radius: 10px; text-align: left; color: #9eb2bc; background: transparent; font-size: 12px; }
.settings-button:hover { background: rgba(255,255,255,.05); color: white; }

.content { width: calc(100% - 276px); margin-left: 276px; }
.topbar { height: 76px; padding: 0 48px; display: flex; align-items: center; gap: 20px; border-bottom: 1px solid rgba(99,116,126,.14); background: rgba(246,244,238,.82); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.search-wrap { width: min(520px, 60vw); display: flex; align-items: center; gap: 10px; padding: 0 13px; height: 40px; color: #82909a; border: 1px solid #d7dee1; border-radius: 10px; background: rgba(255,255,255,.7); }
.search-wrap input { flex: 1; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.search-wrap input::placeholder { color: #98a3aa; }
.search-wrap kbd { padding: 2px 6px; border: 1px solid #dce1e3; border-radius: 5px; color: #9aa5ab; background: white; font-size: 10px; }
.avatar { margin-left: auto; width: 36px; height: 36px; border: 1px solid #d5dcdf; border-radius: 50%; color: #205f83; background: #e8f3f8; font-weight: 700; }
.menu-button { display: none; border: 0; background: transparent; font-size: 22px; }

.feed-wrap { width: min(900px, calc(100% - 72px)); margin: 0 auto; padding: 56px 0 90px; }
.feed-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.eyebrow { margin: 0 0 10px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(34px, 4vw, 48px); line-height: 1; letter-spacing: -.02em; }
.subheading { margin: 14px 0 0; color: var(--muted); font-family: Georgia, "Songti SC", serif; font-size: 14px; }
.heading-actions { display: flex; gap: 9px; }
.filter-button, .read-button { height: 36px; padding: 0 13px; border: 1px solid #d6dde0; border-radius: 8px; color: #5e6c75; background: rgba(255,255,255,.64); font-size: 11px; }
.filter-button.active { color: var(--blue-deep); border-color: #9fc8dc; background: var(--blue-pale); }
.filter-dot { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; border: 1px solid currentColor; }
.filter-button.active .filter-dot { background: currentColor; }
.read-button { color: var(--blue-deep); }

.summary-row { margin: 34px 0 18px; padding: 17px 20px; display: grid; grid-template-columns: repeat(3, 120px) 1fr; align-items: center; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.summary-row div { display: flex; align-items: baseline; gap: 7px; }
.summary-row strong { font-family: Georgia, serif; font-size: 20px; }
.summary-row span { color: var(--muted); font-size: 10px; }
.summary-row p { margin: 0; justify-self: end; color: #5c776b; font-size: 10px; }
.summary-row .tiny-live { margin-right: 7px; width: 6px; height: 6px; }

.feed-list { display: grid; gap: 12px; }
.feed-card { position: relative; padding: 24px 26px 20px; overflow: hidden; border: 1px solid #dde2df; border-radius: 13px; background: rgba(255,254,250,.86); box-shadow: 0 7px 25px rgba(29,42,47,.035); transition: transform .2s ease, box-shadow .2s ease; }
.feed-card:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(29,42,47,.07); }
.feed-card.unread::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--blue); }
.card-meta { display: flex; align-items: center; gap: 10px; }
.source-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: white; font-size: 11px; font-weight: 700; }
.card-meta div { display: grid; gap: 2px; }
.card-meta strong { font-size: 12px; }
.card-meta span { color: #8a959b; font-size: 10px; }
.new-badge { margin-left: auto; padding: 3px 7px; border-radius: 5px; color: var(--blue) !important; background: var(--blue-pale); font-weight: 700; }
.feed-card h2 { margin: 19px 0 10px; font-family: Georgia, "Songti SC", serif; font-size: 19px; line-height: 1.45; font-weight: 700; }
.message-body { margin: 0; color: #5d6971; font-family: Georgia, "Songti SC", serif; font-size: 13px; line-height: 1.85; }
.card-footer { margin-top: 20px; padding-top: 15px; border-top: 1px solid #ebedeb; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tags span { padding: 4px 8px; border-radius: 5px; color: #68767e; background: #f0f1ed; font-size: 9px; }
.card-actions { display: flex; align-items: center; gap: 7px; }
.card-actions button { border: 0; color: #879299; background: transparent; font-size: 16px; }
.telegram-link { font-size: 10px !important; color: var(--blue) !important; }
.empty-state { padding: 80px 24px; text-align: center; border: 1px dashed #cfd7d9; border-radius: 13px; color: var(--muted); }
.empty-state > span { font-size: 30px; }.empty-state h2 { margin: 14px 0 5px; color: var(--ink); font-family: Georgia, serif; }.empty-state p { margin: 0; font-size: 12px; }
.menu-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-102%); transition: transform .24s ease; box-shadow: 16px 0 45px rgba(9,29,40,.24); }
  .sidebar.is-open { transform: translateX(0); }
  .close-menu, .menu-button { display: block; }
  .menu-backdrop { display: block; position: fixed; inset: 0; z-index: 25; border: 0; background: rgba(8,20,28,.35); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s ease; }
  .menu-backdrop.is-visible { opacity: 1; visibility: visible; pointer-events: auto; }
  .content { width: 100%; margin-left: 0; }
  .topbar { padding: 0 24px; }
  .feed-wrap { width: min(760px, calc(100% - 40px)); }
}

@media (max-width: 640px) {
  .topbar { height: 64px; padding: 0 15px; gap: 10px; }
  .search-wrap { width: 100%; }.search-wrap kbd { display: none; }.avatar { flex: 0 0 auto; }
  .feed-wrap { width: calc(100% - 28px); padding: 34px 0 60px; }
  .feed-heading { align-items: flex-start; flex-direction: column; gap: 22px; }
  .heading-actions { width: 100%; }.heading-actions button { flex: 1; }
  .summary-row { grid-template-columns: repeat(3, 1fr); padding: 14px 4px; }
  .summary-row div { align-items: center; flex-direction: column; gap: 2px; }
  .summary-row p { display: none; }
  .feed-card { padding: 20px 18px 17px; }
  .card-footer { align-items: flex-start; flex-direction: column; }
  .card-actions { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

a { color: inherit; text-decoration: none; }
.channel, .settings-button { text-decoration: none; }
.channel-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 2px 8px 0; }
.logout-form button { padding: 8px 6px; border: 0; color: #708995; background: transparent; font-size: 10px; }
.warn-dot { background: #d7a84e; box-shadow: 0 0 0 4px rgba(215,168,78,.11); }
.filter-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.bookmarked { color: #b75151 !important; }
.message-body { white-space: pre-line; overflow-wrap: anywhere; }
.onboarding-card { margin-bottom: 15px; padding: 27px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px; border: 1px solid #b8d5e3; border-radius: 13px; background: #edf6fa; }
.onboarding-number, .step-number { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: white; font-family: Georgia, serif; font-size: 12px; }
.onboarding-card h2 { margin: 4px 0 6px; font-family: Georgia, "Songti SC", serif; font-size: 18px; }
.onboarding-card p { margin: 0; color: var(--muted); font-size: 12px; }
.primary-button, .secondary-button { min-height: 40px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 9px; color: white; background: var(--blue); font-weight: 700; font-size: 12px; }
.primary-button:hover { background: var(--blue-deep); }
.secondary-button { color: var(--blue-deep); border: 1px solid #bdd3de; background: #eef6f9; }

/* Login */
.login-page { min-height: 100vh; background: var(--sidebar); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.08fr .92fr; }
.login-brand { position: relative; overflow: hidden; padding: 9vw; color: #eef4f7; background: radial-gradient(circle at 75% 30%, rgba(44,126,169,.22), transparent 26rem); display: flex; flex-direction: column; justify-content: center; }
.large-brand-mark { width: 61px; height: 61px; margin-bottom: 50px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.28); border-radius: 18px; color: white; background: linear-gradient(145deg, #3b96c7, #246a91); font: 700 31px Georgia, serif; }
.login-brand h1 { margin: 0; font-size: clamp(52px, 7vw, 88px); }
.login-brand > p:last-of-type { margin: 22px 0 0; color: #aebfc7; font: 16px/1.8 Georgia, "Songti SC", serif; }
.signal-lines { position: absolute; right: -10%; bottom: 20%; width: 62%; display: grid; gap: 34px; opacity: .34; transform: rotate(-7deg); }
.signal-lines span { height: 1px; background: linear-gradient(90deg, transparent, #58a4ca, transparent); }
.login-panel { padding: 30px; display: grid; place-items: center; background: var(--paper); }
.login-card { width: min(410px, 100%); padding: 46px; border: 1px solid #dbe1e2; border-radius: 18px; background: var(--card); box-shadow: 0 25px 70px rgba(5,24,35,.15); }
.login-card h2 { margin: 4px 0 7px; font: 700 26px/1.3 Georgia, "Songti SC", serif; }
.login-hint { margin: 0 0 30px; color: var(--muted); font-size: 12px; }
.stack-form { display: grid; gap: 10px; }
.stack-form label, .settings-form label span, .inline-form label span { color: #55636b; font-size: 11px; font-weight: 700; }
.stack-form input, .settings-form input, .inline-form input { width: 100%; height: 44px; padding: 0 13px; border: 1px solid #d3dbde; border-radius: 9px; outline: 0; color: var(--ink); background: white; }
.stack-form input:focus, .settings-form input:focus, .inline-form input:focus { border-color: #73aeca; box-shadow: 0 0 0 3px rgba(54,139,181,.1); }
.stack-form .primary-button { margin-top: 8px; }
.secure-note { margin: 20px 0 0; text-align: center; color: #89949a; font-size: 9px; }
.secure-note span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #4db983; }
.alert { margin: 0 0 22px; padding: 12px 14px; border-radius: 9px; font-size: 11px; line-height: 1.6; }
.alert-error { color: #894a4a; border: 1px solid #e8c7c7; background: #fff1f0; }
.alert-success { color: #356f58; border: 1px solid #b9dccc; background: #eef9f3; }

/* Settings */
.settings-page { min-height: 100vh; background: var(--paper); }
.settings-shell { min-height: 100vh; }
.settings-topbar { height: 68px; padding: 0 max(24px, calc((100vw - 980px) / 2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,254,250,.82); }
.back-link { color: var(--blue-deep); font-size: 12px; }
.compact-brand { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.compact-brand span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: white; background: var(--blue); font: 700 14px Georgia, serif; }
.settings-wrap { width: min(900px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 90px; }
.settings-heading { margin-bottom: 35px; }
.settings-heading h1 { font-size: 42px; }
.settings-heading > p:last-child { margin: 13px 0 0; color: var(--muted); font-size: 12px; }
.settings-card { margin-bottom: 16px; padding: 30px; border: 1px solid #dce2e1; border-radius: 15px; background: rgba(255,254,250,.88); box-shadow: 0 8px 25px rgba(22,36,42,.035); }
.settings-card-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.settings-card-heading h2 { margin: 0 0 4px; font: 700 19px Georgia, "Songti SC", serif; }
.settings-card-heading p { margin: 0; color: var(--muted); font-size: 10px; }
.status-pill { margin-left: auto; padding: 6px 10px; border-radius: 99px; color: #84642d; background: #f6edd8; font-size: 9px; font-weight: 700; }
.status-pill.connected { color: #347152; background: #e8f5ee; }
.settings-form { padding-top: 23px; border-top: 1px solid #e9ecea; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.settings-form label, .inline-form label { display: grid; gap: 7px; }
.settings-form .full-width { grid-column: 1 / -1; }
.settings-form .primary-button { justify-self: start; }
.verification-grid { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.inline-form { padding: 18px; display: grid; gap: 12px; border: 1px solid #e3e7e6; border-radius: 11px; background: #f8f8f4; }
.connected-message { padding: 22px; display: flex; align-items: flex-start; gap: 13px; border: 1px solid #c8ded2; border-radius: 11px; background: #eff8f3; }
.connected-message strong { font-size: 13px; }.connected-message p { margin: 5px 0 0; color: #638071; font-size: 11px; }
.disconnect-form { margin-top: 13px; text-align: right; }
.text-danger-button { border: 0; color: #a25555; background: transparent; font-size: 10px; }
.picker-list { display: grid; gap: 7px; max-height: 480px; overflow: auto; margin-bottom: 20px; }
.picker-row { min-height: 60px; padding: 10px 13px; display: grid; grid-template-columns: auto 36px 1fr auto; align-items: center; gap: 12px; border: 1px solid #e1e5e4; border-radius: 10px; background: #fff; cursor: pointer; }
.picker-row:has(input:checked) { border-color: #9fc8dc; background: #f0f7fa; }
.picker-row input { width: 16px; height: 16px; accent-color: var(--blue); }
.picker-name { display: grid; gap: 3px; }.picker-name strong { font-size: 12px; }.picker-name small, .picker-count { color: #889399; font-size: 9px; }
.empty-picker { padding: 35px; text-align: center; border: 1px dashed #ccd5d6; border-radius: 11px; color: var(--muted); font-size: 11px; }
.privacy-note { padding: 20px 25px; color: #6f7a80; border-left: 3px solid #9dbdca; background: #eef2f1; font-size: 10px; line-height: 1.8; }
.privacy-note strong { color: var(--ink); }.privacy-note p { margin: 4px 0 0; }

.avatar-color-0 { background: #3b79b5 !important; }.avatar-color-1 { background: #695bad !important; }.avatar-color-2 { background: #b66c3e !important; }.avatar-color-3 { background: #3c8068 !important; }.avatar-color-4 { background: #9b5d74 !important; }

@media (max-width: 720px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 32vh; padding: 45px 30px; }
  .large-brand-mark { width: 46px; height: 46px; margin-bottom: 25px; font-size: 22px; }
  .login-brand h1 { font-size: 46px; }.login-brand > p:last-of-type { margin-top: 12px; font-size: 13px; }
  .login-panel { padding: 22px; align-items: start; }.login-card { padding: 30px 25px; }
  .onboarding-card { grid-template-columns: auto 1fr; }.onboarding-card .primary-button { grid-column: 1 / -1; }
  .settings-wrap { padding-top: 35px; }.settings-heading h1 { font-size: 34px; }
  .settings-card { padding: 22px 18px; }.two-column, .verification-grid { grid-template-columns: 1fr; }
  .settings-card-heading { align-items: flex-start; }.status-pill { align-self: center; }
  .picker-row { grid-template-columns: auto 34px 1fr; }.picker-count { display: none; }
}
