:root {
  --bg: #eaf2fb;
  --panel: #f8fbff;
  --line: #c7d8ea;
  --ink: #172231;
  --muted: #607287;
  --accent: #b04d2f;
  --accent-2: #0b5b8c;
  --ok: #1f7a45;
  --warn: #8f5e00;
  --shadow: 0 12px 28px rgba(22, 50, 82, 0.10);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -12%, rgba(17, 95, 159, 0.18), transparent 42%),
    radial-gradient(circle at 92% 8%, rgba(11, 56, 97, 0.16), transparent 38%),
    radial-gradient(circle at 60% 115%, rgba(42, 131, 197, 0.10), transparent 45%),
    linear-gradient(180deg, #eef5fd 0%, #e3edf9 100%);
  min-height: 100%;
  font-family: "Georgia", "Times New Roman", serif;
}

a {
  color: inherit;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(248, 251, 255, 0.8);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-logo img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  object-position: left center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(11, 91, 140, 0.12);
}

.brand-word {
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0.08em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.topbar-nav {
  display: flex;
  gap: 12px;
}

.topbar-nav a {
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
}

.topbar-nav a:hover {
  background: rgba(0, 0, 0, 0.04);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-pill {
  color: var(--muted);
  font-size: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.muted-text {
  color: var(--muted);
  font-size: 14px;
}

.error-text {
  color: var(--accent);
  min-height: 1.4em;
  margin: 8px 0 0;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.stack-form input,
.stack-form button {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.stack-form button,
button {
  cursor: pointer;
}

button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 12px;
}

button:hover {
  background: #f8f6ef;
}

.ghost-btn {
  background: transparent;
}

.inline-btn {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  background: #fff;
}

.gate-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: min(460px, 100%);
  background: rgba(248, 251, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(18, 47, 81, 0.16);
  padding: 26px;
}

.gate-card h1 {
  margin: 8px 0 14px;
  font-size: 24px;
}

.gate-brand {
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.center-wrap {
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-panel {
  width: min(520px, 100%);
  padding: 20px;
}

.password-change-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 10px;
}

.password-change-box summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-2);
  user-select: none;
}

.change-password-form {
  margin-top: 10px;
}

.home-layout {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 18px;
  padding: 18px;
}

.calendar-panel, .source-panel {
  padding: 16px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-nav span {
  min-width: 90px;
  text-align: center;
  font-weight: 600;
}

.calendar-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-cell,
.calendar-weekday {
  min-height: 48px;
  border-radius: 10px;
}

.calendar-weekday {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  min-height: 28px;
}

.calendar-cell {
  border: 1px solid transparent;
  background: #f3f8ff;
  padding: 6px;
  text-align: left;
}

.calendar-cell.empty {
  background: transparent;
}

.calendar-cell.has-news {
  border-color: rgba(11, 91, 140, 0.3);
  background: linear-gradient(180deg, #fbfdff, #e8f2fd);
}

.calendar-cell .dot {
  margin-top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
}

.calendar-cell.today {
  box-shadow: inset 0 0 0 1px rgba(155, 44, 44, 0.3);
}

.source-cards {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.source-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.logo-badge {
  min-width: 90px;
  height: 52px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 8px;
  overflow: hidden;
}

.logo-badge img {
  display: block;
  max-width: 100%;
  max-height: 28px;
  width: auto;
  height: auto;
}

.wsj-logo {
  background: linear-gradient(180deg, #edf5ff, #dcecff);
  color: #0f3d62;
  border: 1px solid rgba(11, 91, 140, 0.18);
}

.bloomberg-logo {
  background: linear-gradient(180deg, #edf5ff, #dcecff);
  color: #0f3d62;
  border: 1px solid rgba(11, 91, 140, 0.18);
  font-size: 14px;
}

.cctv2-logo {
  background: linear-gradient(180deg, #fff5f5, #ffe0e0);
  color: #8b0000;
  border: 1px solid rgba(180, 30, 30, 0.2);
}

.others-logo {
  background: linear-gradient(180deg, #dceeff, #bdddf6);
  color: #123b5a;
}

/* CCTV2 home card group */
.cctv2-card-group {
  display: grid;
  gap: 0;
}
.cctv2-parent-card {
  border-radius: 12px;
}
.cctv2-card-group:has(.cctv2-sub-cards:not(.hidden)) .cctv2-parent-card {
  border-radius: 12px 12px 0 0;
  border-bottom: none;
}
.cctv2-arrow {
  font-size: 12px;
  opacity: 0.6;
  margin-left: 4px;
}
.cctv2-sub-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}
.cctv2-sub-cards.hidden {
  display: none;
}
.source-card-sub {
  border-radius: 0 !important;
  border: none !important;
  border-right: 1px solid var(--line) !important;
  border-bottom: 1px solid var(--line) !important;
  padding: 10px 14px;
  background: #fffafa;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.source-card-sub:nth-child(2n) {
  border-right: none !important;
}
.source-card-sub:nth-last-child(-n+2) {
  border-bottom: none !important;
}
.source-card-sub .source-name {
  font-size: 14px;
  font-weight: 600;
  color: #8b0000;
}

.source-name {
  font-weight: 700;
}

.source-note {
  color: var(--muted);
  font-size: 13px;
}

.import-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.import-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.import-btn:hover {
  background: var(--bg);
}

.import-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.editor-page {
  padding: 16px;
}

.editor-lock {
  padding: 20px;
}

.editor-main {
  padding: 14px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.editor-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.editor-toolbar select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}

.split-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  min-height: 70vh;
}

.editor-pane {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pane-title {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #eef5fd;
  font-size: 14px;
  color: var(--muted);
}

#md-input {
  flex: 1;
  width: 100%;
  border: 0;
  outline: none;
  padding: 12px;
  resize: none;
  background: #fff;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  line-height: 1.5;
}

.preview-pane {
  padding: 14px;
  overflow: auto;
}

.news-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 12px;
  min-height: calc(100vh - 64px);
}

.news-sidebar {
  width: 280px;
  min-width: 180px;
  max-width: 50vw;
  resize: horizontal;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 10px;
}

.sidebar-head {
  font-weight: 700;
  margin-bottom: 8px;
}

.sidebar-resize-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

.date-tree {
  display: grid;
  gap: 8px;
}

.ym-group {
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.ym-title {
  font-weight: 700;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: linear-gradient(180deg, #f4f8ff, #eef4ff);
  border-bottom: 1px solid rgba(11, 91, 140, 0.08);
}

.ym-title::-webkit-details-marker {
  display: none;
}

.ym-title::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  color: var(--accent-2);
  transition: transform 120ms ease;
}

.ym-group[open] .ym-title::before {
  transform: rotate(90deg);
}

.ym-days-wrap {
  padding: 8px;
}

.day-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.day-btn {
  min-width: 42px;
  padding: 6px 8px;
}

.day-btn.active {
  border-color: rgba(11, 91, 140, 0.4);
  background: #edf5fb;
}

.news-main {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.news-top {
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.source-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.source-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
}

.source-tab.active {
  border-color: rgba(11, 91, 140, 0.35);
  background: #edf5fb;
}

.source-tab.disabled {
  opacity: 0.45;
}

.mini-logo {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 20px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  overflow: hidden;
}

.mini-logo img {
  display: block;
  max-width: 36px;
  max-height: 12px;
  width: auto;
  height: auto;
}

.mini-logo.wsj { background: #edf5ff; color: #0f3d62; border: 1px solid rgba(11, 91, 140, 0.18); }
.mini-logo.bbg { background: #edf5ff; color: #0f3d62; border: 1px solid rgba(11, 91, 140, 0.18); }
.mini-logo.cctv2 { background: #fff5f5; color: #8b0000; border: 1px solid rgba(180, 30, 30, 0.2); }
.mini-logo.cctv2 img { max-width: 40px; max-height: 14px; }
.mini-logo.oth { background: #cbe5fb; color: #0d436f; }

/* CCTV2 tab group in news page */
.source-tab-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 4px 2px 8px;
  background: #fffafa;
}
.tab-group-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #8b0000;
  white-space: nowrap;
}
.source-tab-sub {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
}
.tab-group-subs {
  display: inline-flex;
  gap: 2px;
}

.news-title {
  margin-top: 10px;
  font-size: 24px;
  font-weight: 700;
}

.news-meta {
  margin-top: 4px;
  color: var(--muted);
}

.news-content-wrap {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.news-content {
  padding: 18px;
  line-height: 1.7;
}

.selection-fab {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e7a85f, #c7772d);
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(149, 84, 25, 0.28);
  z-index: 5;
}

.selection-fab:hover,
.selection-fab:focus-visible {
  background: linear-gradient(180deg, #efb56f, #cf7c2d);
  box-shadow: 0 10px 20px rgba(149, 84, 25, 0.32);
}

.selection-fab::before {
  content: "+";
  color: #fff8ef;
  font-size: 18px;
  line-height: 1;
  display: block;
}

.ann-marker {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  margin-left: 3px;
  vertical-align: middle;
  background:
    radial-gradient(circle at 35% 35%, #fff 10%, transparent 11%),
    linear-gradient(180deg, #c03737, #7f1d1d);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ann-marker.has-question {
  background:
    radial-gradient(circle at 35% 35%, #fff 10%, transparent 11%),
    linear-gradient(180deg, #b48600, #7a5c00);
}

.ann-marker.has-favorite:not(.has-question) {
  background:
    radial-gradient(circle at 35% 35%, #fff 10%, transparent 11%),
    linear-gradient(180deg, #2a83c5, #0b5b8c);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.4);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 30;
}

.modal-panel {
  width: min(900px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 30px 50px rgba(10, 10, 10, 0.25);
  padding: 14px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-head h3 {
  margin: 0;
}

.modal-meta-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-meta-grid > div {
  background: #f2f7fe;
  border: 1px solid #dce8f5;
  border-radius: 10px;
  padding: 10px;
}

.modal-meta-grid > div.wide {
  grid-column: 1 / -1;
}

.meta-key {
  display: inline-block;
  min-width: 72px;
  color: var(--muted);
}

.quote-box {
  margin: 6px 0 0;
  white-space: pre-wrap;
  font-family: inherit;
}

.name-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.name-input-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.anno-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.anno-compose {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.anno-compose textarea {
  min-height: 96px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  resize: vertical;
}

.compose-actions {
  display: flex;
  gap: 8px;
}

.anno-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.anno-item {
  border: 1px solid #e8dfcb;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.anno-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.anno-kind {
  font-weight: 700;
}

.anno-kind.favorite { color: #0b5b8c; }
.anno-kind.comment { color: var(--accent-2); }
.anno-kind.question { color: var(--warn); }

.anno-body {
  margin-top: 8px;
  white-space: pre-wrap;
}

.anno-footer {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.reply-list {
  margin-top: 8px;
  border-top: 1px dashed #e8dfcb;
  padding-top: 8px;
  display: grid;
  gap: 6px;
}

.reply-item {
  background: #f4f8fe;
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
}

.reply-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.reply-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reply-item-actions button {
  padding: 4px 8px;
  font-size: 12px;
}

.reply-compose {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.reply-compose textarea {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.reply-actions {
  display: flex;
  gap: 8px;
}

.empty-state {
  color: var(--muted);
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #f2f7fe;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  line-height: 1.3;
  margin: 1.1em 0 0.5em;
}

.markdown-body p, .markdown-body li {
  line-height: 1.7;
}

.markdown-body pre {
  background: #f2f7fe;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  overflow: auto;
}

.markdown-body code {
  background: #f2f7fe;
  padding: 0.08em 0.3em;
  border-radius: 4px;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
}

@media (max-width: 900px) {
  .topbar {
    gap: 10px;
    padding: 10px 12px;
  }

  .topbar-logo img {
    width: 42px;
    height: 42px;
  }

  .brand-word {
    font-size: 20px;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .home-layout {
    grid-template-columns: 1fr;
  }

  .split-editor {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .news-layout {
    grid-template-columns: 1fr;
  }

  .news-sidebar {
    width: 100%;
    max-width: none;
    resize: vertical;
    min-height: 140px;
  }

  .modal-meta-grid {
    grid-template-columns: 1fr;
  }
}
