/* kevnews - Google News circa 2012 styling */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fff;
  color: #222;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* Masthead */
#masthead {
  border-bottom: 1px solid #c9d7f1;
  background: #fff;
}
#masthead .bar {
  width: 80%;
  max-width: none;
  margin: 0 auto;
  padding: 14px 10px 12px;
  display: flex;
  align-items: center;
}
.gn-logo {
  font-size: 26px;
  font-weight: bold;
  letter-spacing: -1px;
  margin-right: 24px;
  font-family: Arial, sans-serif;
}
.g-blue   { color: #4285f4; }
.g-red    { color: #db4437; }
.g-yellow { color: #f4b400; }
.g-green  { color: #0f9d58; }

#search { display: flex; }
#search input {
  width: 420px;
  padding: 6px 8px;
  border: 1px solid #d9d9d9;
  border-right: 0;
  font-size: 14px;
  outline: none;
}
#search input:focus { border-color: #4285f4; }
#search button {
  padding: 6px 16px;
  border: 1px solid #3079ed;
  background: #4d90fe;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}
#search button:hover { background: #357ae8; }

/* Page grid */
#page {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 10px;
  display: grid;
  grid-template-columns: 150px 1fr 220px;
  gap: 20px;
}

/* Left nav */
#left-nav { font-size: 13px; }
.section-link {
  display: block;
  padding: 5px 8px;
  color: #1a0dab;
  border-left: 3px solid transparent;
}
.section-link:hover { background: #f1f5fd; text-decoration: none; }
.section-link.top {
  font-weight: bold;
  color: #dd4b39;
  border-left-color: #dd4b39;
  background: #fef7f6;
}
.section-link.muted { color: #777; }
.nav-sep { border-top: 1px solid #eee; margin: 8px 0; }

/* Main column */
.news-section {
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid #ebebeb;
}
.section-head {
  display: flex;
  align-items: baseline;
  border-bottom: 2px solid #dd4b39;
  padding-bottom: 3px;
  margin-bottom: 10px;
}
.section-head h2 {
  font-size: 16px;
  color: #dd4b39;
  margin: 0;
  font-weight: bold;
}
.section-count { margin-left: auto; color: #999; font-size: 11px; }

.lead-story { margin-bottom: 12px; }
.lead-title {
  font-size: 18px;
  color: #1a0dab;
  line-height: 1.25;
}
.lead-title:visited { color: #609; }
.lead-summary {
  margin: 6px 0 0;
  color: #444;
  font-size: 13px;
}

.byline, .rel-meta {
  color: #093;
  font-size: 11px;
  margin-top: 3px;
}
.byline .source, .rel-meta .source { color: #093; }
.byline .time, .rel-meta .time { color: #777; }
.dot { color: #999; margin: 0 4px; }

.related { list-style: none; margin: 6px 0 0; padding: 0; }
.related li {
  padding: 6px 0;
  border-top: 1px solid #f2f2f2;
}
.rel-title { color: #1a0dab; font-size: 13px; }
.rel-title:visited { color: #609; }

.more-row { margin-top: 8px; }
.more-row summary {
  color: #1a0dab;
  cursor: pointer;
  font-size: 12px;
  display: inline-block;
  padding: 4px 0;
}
.more-row summary:hover { text-decoration: underline; }
.see-more {
  display: inline-block;
  color: #1a0dab;
  font-size: 12px;
  padding: 4px 0;
  text-decoration: none;
}
.see-more:hover { text-decoration: underline; }

/* Single-topic detail page */
.topic-detail h1 { font-size: 22px; margin: 0; }
.topic-detail .section-head { display: flex; align-items: baseline; gap: 10px; }

/* Single-topic page runs ~2x wide: main column matches the width of both
   columns on the topics board, with no right rail. */
#page.topic-page-wide {
  max-width: 1180px;
  grid-template-columns: 150px 1fr;
}
.detail-list { list-style: none; margin: 14px 0 0; padding: 0; }
.detail-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}
.detail-thumb {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border: 1px solid #e5e5e5;
  border-radius: 3px;
  background: #fafafa;
}
.detail-thumb-link { flex: 0 0 auto; }
.detail-body { min-width: 0; }
.detail-title {
  color: #1a0dab;
  font-size: 15px;
  line-height: 1.3;
  display: block;
}
.detail-title:visited { color: #609; }
.detail-meta { color: #093; font-size: 12px; margin-top: 3px; }
.detail-meta .time { color: #777; }
.detail-summary { color: #444; font-size: 13px; margin: 5px 0 0; line-height: 1.4; }

/* Clustered stories (Google News 2012 "one story, many sources") */
.cluster-list { margin: 14px 0 0; }
.cluster {
  padding: 14px 0;
  border-bottom: 1px solid #eee;
}
.cluster.has-related {
  background: #fbfcfe;
  border-bottom: 1px solid #e6e9f0;
  padding: 14px 12px;
  margin: 0 -12px;
}
.cluster-lead { display: flex; gap: 12px; }
.detail-title.lead { font-size: 16px; font-weight: bold; }
.cluster-related {
  list-style: none;
  margin: 8px 0 0 132px;
  padding: 6px 0 0;
  border-top: 1px dotted #e0e0e0;
}
.cluster-related li { margin: 4px 0; font-size: 13px; line-height: 1.35; }
.cluster-related .rel-title { color: #1a0dab; }
.cluster-related .rel-title:visited { color: #609; }
.cluster-related .rel-src { color: #093; margin-left: 5px; }
.cluster-related .time { color: #777; margin-left: 4px; }
.cluster-related .dot { color: #bbb; margin-left: 4px; }
.cluster-sources {
  margin: 8px 0 0 132px;
  font-size: 12px;
  color: #777;
}
.src-chip {
  display: inline-block;
  color: #444;
  background: #eef1f6;
  border-radius: 2px;
  padding: 1px 6px;
  margin: 2px 4px 0 0;
}
.src-more { color: #999; margin-left: 2px; }

/* "+N more" under a cluster: reveals the remaining related article rows. */
.rel-more {
  background: none;
  border: none;
  padding: 2px 0;
  margin: 2px 0 0 132px;
  font: inherit;
  font-size: 12px;
  color: #1a0dab;
  cursor: pointer;
}
.rel-more:hover { text-decoration: underline; }
.topic-cluster .rel-more { margin-left: 42px; font-size: 12px; }

/* "Load more" pagination */
#load-more-wrap { text-align: center; margin: 18px 0 6px; }
#load-more {
  font-size: 13px;
  color: #1a0dab;
  background: #f8f8f8;
  border: 1px solid #ccc;
  border-radius: 2px;
  padding: 8px 22px;
  cursor: pointer;
}
#load-more:hover { background: #f1f1f1; border-color: #999; }
#load-more:disabled { color: #999; cursor: default; opacity: 0.7; }
.load-status { color: #777; font-size: 12px; margin: 8px 0 0; font-style: italic; }

.empty { color: #777; font-style: italic; }

.fetch-error {
  background: #fdecea;
  border: 1px solid #f5c6cb;
  color: #a33;
  padding: 8px 10px;
  font-size: 12px;
  margin: 0 0 10px;
}
.fetch-notice {
  background: #fef7e0;
  border: 1px solid #f5e2a3;
  color: #8a6d0b;
  padding: 6px 10px;
  font-size: 12px;
  margin: 0 0 10px;
}

/* Right rail */
#right-rail { font-size: 12px; }
.rail-box {
  border: 1px solid #e5e5e5;
  margin-bottom: 14px;
  background: #f9f9f9;
}
.rail-head {
  background: #f1f1f1;
  border-bottom: 1px solid #e5e5e5;
  padding: 5px 8px;
  font-weight: bold;
  color: #555;
}
.rail-body { padding: 8px; }
.muted { color: #999; }

/* Footer */
#footer {
  width: 80%;
  max-width: none;
  margin: 20px auto;
  padding: 12px 10px;
  border-top: 1px solid #ebebeb;
  color: #999;
  font-size: 11px;
  text-align: center;
}

/* ===================== Topics page ===================== */
.masthead-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.ghost-link { color: #1a0dab; font-size: 13px; }
#add-topic-btn {
  padding: 7px 14px;
  border: 1px solid #3079ed;
  background: #4d90fe;
  color: #fff;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  border-radius: 2px;
}
#add-topic-btn:hover { background: #357ae8; }

#topics-page { width: 80%; max-width: none; margin: 0 auto; padding: 16px 10px; }
.empty-hint {
  color: #777;
  background: #f9f9f9;
  border: 1px dashed #ddd;
  padding: 24px;
  text-align: center;
  font-size: 14px;
}

#topics-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 640px) { #topics-container { grid-template-columns: 1fr; } }
.topic-column { display: flex; flex-direction: column; gap: 20px; }

/* Topic section */
.topic-section {
  border: 1px solid #ebebeb;
  border-radius: 3px;
  overflow: hidden;
}
.topic-head {
  display: flex;
  align-items: center;
  background: #f7f7f7;
  border-bottom: 2px solid #dd4b39;
  padding: 8px 12px;
}
.topic-head h2 {
  margin: 0;
  font-size: 16px;
  color: #dd4b39;
  text-transform: capitalize;
}
.topic-controls { margin-left: auto; display: flex; gap: 6px; }
.topic-btn {
  width: 26px; height: 26px;
  border: 1px solid #ddd;
  background: #fff;
  color: #555;
  cursor: pointer;
  border-radius: 2px;
  font-size: 15px;
  line-height: 1;
}
.topic-btn:hover { background: #f1f1f1; }
.topic-btn.remove:hover { background: #fdecea; border-color: #f5c6cb; color: #a33; }
.topic-btn.minimize { font-size: 17px; }
.topic-btn.minimize:hover { background: #f1f1f1; }
/* Minimized card: header only, so the red underline reads as the card edge. */
.topic-section.collapsed .topic-head { border-bottom-width: 1px; }

/* Single list of results inside a topic card */
.topic-list {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
}

.topic-card {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #f2f2f2;
  align-items: flex-start;
}
.topic-card:first-child { border-top: 0; }
.topic-thumb {
  width: 32px; height: 32px;
  flex: 0 0 32px;
  border: 1px solid #eee;
  border-radius: 3px;
  background: #fafafa;
  object-fit: contain;
}
.topic-card-body { min-width: 0; }
.topic-card-title {
  color: #1a0dab;
  font-size: 13px;
  line-height: 1.3;
  display: block;
}
.topic-card-title:visited { color: #609; }
.topic-card-meta { color: #093; font-size: 11px; margin-top: 3px; }
.topic-card-meta .time { color: #777; }

/* Topic header links to the dedicated single-topic page */
.topic-title-link { color: #dd4b39; }
.topic-title-link:hover { text-decoration: underline; }
.topic-title-link:visited { color: #dd4b39; }

/* Board story clusters (grouped like the single-topic page, but compact) */
.topic-cluster {
  padding: 10px 0;
  border-top: 1px solid #f2f2f2;
}
.topic-cluster:first-child { border-top: 0; }
.topic-cluster.has-related {
  background: #fbfcfe;
  margin: 0 -12px;
  padding: 10px 12px;
  border-top: 1px solid #eef1f6;
}
.topic-cluster .cluster-lead { display: flex; gap: 10px; align-items: flex-start; }
.topic-cluster.has-related .topic-card-title { font-weight: bold; font-size: 14px; }
.topic-cluster .cluster-related {
  list-style: none;
  margin: 6px 0 0 42px;
  padding: 5px 0 0;
  border-top: 1px dotted #e2e2e2;
}
.topic-cluster .cluster-related li { margin: 3px 0; font-size: 12px; line-height: 1.3; }
.topic-cluster .cluster-related .rel-title { color: #1a0dab; }
.topic-cluster .cluster-related .rel-title:visited { color: #609; }
.topic-cluster .cluster-related .rel-src { color: #093; margin-left: 5px; }
.topic-cluster .cluster-sources {
  margin: 6px 0 0 42px;
  font-size: 11px;
  color: #888;
}
.topic-cluster .src-chip {
  display: inline-block;
  color: #444;
  background: #eef1f6;
  border-radius: 2px;
  padding: 1px 5px;
  margin: 2px 3px 0 0;
}
.topic-cluster .src-more {
  color: #4285f4;
  background: none;
  border: none;
  padding: 1px 4px;
  margin: 2px 3px 0 0;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.topic-cluster .src-more:hover { text-decoration: underline; }

/* "See more" as a button that reveals the next 10 clusters in place */
.see-more-btn {
  display: inline-block;
  margin: 4px 12px 12px;
  padding: 5px 12px;
  font-size: 13px;
  color: #1a0dab;
  background: #f8f8f8;
  border: 1px solid #ccc;
  border-radius: 2px;
  cursor: pointer;
}
.see-more-btn:hover { background: #f1f5fd; }

.topic-empty, .topic-loading { color: #999; font-style: italic; padding: 8px 0; }
.topic-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-style: normal;
}
.spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid #d9d9d9;
  border-top-color: #4285f4;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.topic-loading-text { color: #777; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Small inline spinner in a topic header during a background refresh */
.spinner-sm {
  width: 12px;
  height: 12px;
  border-width: 2px;
  margin-left: 8px;
}

/* A story that wasn't on the board last time the page was opened: small pill
 * plus a gentle fade-in so new items announce themselves without a jump. */
.new-badge {
  display: inline-block;
  margin-right: 5px;
  padding: 0 4px;
  border-radius: 2px;
  background: #dd4b39;
  color: #fff;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 0.5px;
  vertical-align: 1px;
}
.topic-cluster.is-new { animation: fade-in 0.5s ease-out; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff;
  width: 440px;
  max-width: 92vw;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.modal-head {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}
.modal-head h3 { margin: 0; font-size: 15px; color: #333; }
.modal-close {
  margin-left: auto;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: #999;
  cursor: pointer;
}
.modal-close:hover { color: #333; }
#add-topic-form { padding: 16px; }
#topic-input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #d9d9d9;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}
#topic-input:focus { border-color: #4285f4; }
.modal-actions { margin-top: 12px; text-align: right; }
.modal-actions button {
  padding: 8px 18px;
  border: 1px solid #3079ed;
  background: #4d90fe;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  border-radius: 2px;
}
.modal-actions button:hover { background: #357ae8; }
.modal-preview { padding: 0 16px 16px; }
.modal-loading { color: #777; font-size: 13px; }
.modal-error { color: #a33; font-size: 13px; }

/* --- Floating notes-chat panel ------------------------------------------- */
/* Pinned bottom-right. A pencil launcher expands into a tabbed note panel. */
#chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #dd4b39;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 1000;
}
#chat-launcher:hover { background: #c23321; }

#chat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 360px;
  height: 480px;
  max-height: 80vh;
  background: #fff;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}
#chat-panel.chat-collapsed { display: none; }

#chat-head {
  display: flex;
  align-items: stretch;
  background: #f7f7f7;
  border-bottom: 2px solid #dd4b39;
  min-height: 34px;
}
#chat-tabs {
  display: flex;
  align-items: stretch;
  flex: 1;
  overflow-x: auto;
  gap: 2px;
  padding: 4px 4px 0;
}
#chat-tabs::-webkit-scrollbar { height: 4px; }
.chat-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 130px;
  padding: 3px 6px;
  background: #ececec;
  border: 1px solid #ddd;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.chat-tab.active { background: #fff; font-weight: bold; }
.chat-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}
.chat-tab-x {
  border: none;
  background: transparent;
  color: #999;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}
.chat-tab-x:hover { color: #a33; }
.chat-history {
  align-self: center;
  margin-left: 4px;
  font-size: 11px;
  max-width: 90px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
}
#chat-new, #chat-min {
  border: none;
  background: transparent;
  color: #555;
  font-size: 18px;
  cursor: pointer;
  padding: 0 10px;
  line-height: 1;
}
#chat-new:hover, #chat-min:hover { background: #ececec; }

#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fafafa;
}
.chat-empty { color: #999; font-size: 13px; text-align: center; margin: auto; }
.chat-msg {
  max-width: 85%;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-user {
  align-self: flex-end;
  background: #dd4b39;
  color: #fff;
  border-bottom-right-radius: 3px;
}
.chat-assistant {
  align-self: flex-start;
  background: #eceff1;
  color: #222;
  border-bottom-left-radius: 3px;
}
.chat-typing { color: #888; letter-spacing: 2px; }

#chat-form {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid #eee;
  background: #fff;
}
#chat-input {
  flex: 1;
  resize: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 7px 8px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.35;
  max-height: 96px;
}
#chat-input:focus { outline: none; border-color: #dd4b39; }
#chat-send {
  border: none;
  background: #dd4b39;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
#chat-send:hover { background: #c23321; }

@media (max-width: 640px) {
  #chat-panel { width: auto; left: 12px; right: 12px; }
}

/* --- Chat: dragged-in link doc chips + dropzone -------------------------- */
#chat-panel.chat-dragover,
#chat-launcher.chat-dragover {
  outline: 2px dashed #dd4b39;
  outline-offset: -4px;
  background: #fff7f6;
}
.chat-msg-text { white-space: pre-wrap; word-wrap: break-word; }
.chat-doc {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 6px;
  padding: 7px 9px;
  background: #fff;
  border: 1px solid #e2e2e2;
  border-left: 3px solid #4a90d9;
  border-radius: 4px;
  max-width: 100%;
}
.chat-user .chat-doc { background: #fff; color: #222; }
.chat-doc-err { border-left-color: #d9534f; }
.chat-doc-icon { font-size: 14px; line-height: 1.4; flex-shrink: 0; }
.chat-doc-body { min-width: 0; }
.chat-doc-title {
  display: block;
  font-size: 12px;
  font-weight: bold;
  color: #1a5aa8;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 230px;
}
.chat-doc-title:hover { text-decoration: underline; }
.chat-doc-meta { font-size: 10.5px; color: #888; margin-top: 1px; }
.chat-doc-err .chat-doc-meta { color: #c0392b; }
