:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --text: #1d1d1b;
  --muted: #686862;
  --line: #dedbd2;
  --accent: #276a5c;
  --accent-strong: #164a41;
  --accent-soft: #e6f0ed;
  --gold: #b47722;
  --red: #a9423d;
  --blue: #3570a3;
  --shadow: 0 18px 45px rgba(31, 29, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar .toolbar {
  margin-left: auto;
}

h2,
h3,
p {
  margin-top: 0;
}

.toolbar,
.tabs,
.calendar-header,
.settings-subtabs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.primary-button,
.secondary-button,
.tab,
.retry-button,
.settings-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}

.icon-button {
  width: 42px;
  display: grid;
  place-items: center;
}

.primary-button,
.secondary-button,
.retry-button,
.tab,
.settings-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 800;
}

.secondary-button {
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
}

.auth-button.authenticated {
  border-color: #8eb9ad;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.auth-hidden {
  display: none !important;
}

.stop-processing-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid #d8aaa6;
  border-radius: 8px;
  background: var(--panel);
  color: var(--red);
  cursor: pointer;
  font-weight: 800;
}

.stop-processing-button[hidden] {
  display: none;
}

.stop-processing-button:hover:not(:disabled) {
  border-color: var(--red);
  background: #f8e7e4;
}

.retry-button {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.icon-button:hover,
.secondary-button:hover,
.tab:hover,
.retry-button:hover,
.settings-tab:hover {
  border-color: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.icon-button:active,
.primary-button:active,
.secondary-button:active,
.tab:active,
.retry-button:active,
.settings-tab:active {
  transform: translateY(1px);
}

.tabs {
  padding: 6px;
  width: fit-content;
  background: #ebe8df;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab {
  background: transparent;
  border-color: transparent;
  min-width: 110px;
}

.tab.active {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: 0 8px 20px rgba(31, 29, 24, 0.06);
}

.settings-subtabs {
  width: fit-content;
  margin-bottom: 18px;
  padding: 6px;
  background: #ebe8df;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-tab {
  min-width: 150px;
  background: transparent;
  border-color: transparent;
  font-weight: 800;
}

.settings-tab.active {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: 0 8px 20px rgba(31, 29, 24, 0.06);
}


.status-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

@media (min-width: 981px) {
  .status-strip:has(> .status-time) {
    grid-template-columns: repeat(5, minmax(68px, 0.55fr)) repeat(3, minmax(140px, 1.25fr));
  }
}

.background-jobs-panel {
  margin: -6px 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(31, 29, 24, 0.05);
}

.background-jobs-panel[hidden] {
  display: none;
}

.background-jobs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 850;
}

.background-jobs-header span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.background-jobs-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.background-jobs-header-actions .icon-button {
  width: 34px;
  min-height: 34px;
}

.background-jobs-list {
  display: grid;
  gap: 8px;
}

.background-job {
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf9f5;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.background-job.active {
  border-color: #ead6ae;
  background: #fff8e9;
}

.background-job:hover {
  border-color: var(--accent);
}

.background-job-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.background-job-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 850;
}

.background-job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.background-job-error {
  color: var(--red);
  font-size: 0.76rem;
  line-height: 1.35;
}

.filter-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin: -4px 0 18px;
}

.filter-field {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.filter-field select {
  min-width: 260px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 850;
  outline: 0;
}

.filter-field input[type="date"],
.filter-field input[type="text"] {
  min-width: 150px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 850;
  outline: 0;
}

.metric {
  min-height: 76px;
  padding: 13px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric .label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric .value {
  margin-top: 5px;
  font-size: 1.24rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.progress-metric .value {
  color: var(--accent-strong);
}

.progress-track {
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e4d9;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.mobile-pane-back,
.mobile-side-toggle {
  display: none;
}

.settings-panel-view {
  display: none;
}

.settings-panel-view.active {
  display: block;
}

.latest-layout {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.latest-sidebar {
  min-width: 0;
  display: grid;
  gap: 16px;
  align-content: start;
}

.latest-ad-block {
  min-width: 0;
  min-height: 90px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.video-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding-right: 4px;
}

.latest-list-more {
  min-height: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.video-card {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.video-card.active {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.thumbnail {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #ddd7cc;
  border-radius: 6px;
}

.video-card h3 {
  margin-bottom: 8px;
  font-size: 0.95rem;
  line-height: 1.35;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.summary-model-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-strong);
  font-weight: 800;
}

.summary-model-meta svg {
  width: 14px;
  height: 14px;
}

.summary-model-meta.unknown {
  color: var(--muted);
  font-weight: 750;
}

.stock-tag-row,
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stock-tag-row {
  margin-top: 9px;
}

.article-tags {
  margin-top: 12px;
}

.stock-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 190px;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid #c8d7ea;
  border-radius: 999px;
  background: #eef4fb;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 850;
  line-height: 1;
}

.stock-tag .ticker-name {
  min-width: 0;
  max-width: 112px;
  overflow: hidden;
  color: currentColor;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-tag.bullish {
  border-color: #35c86f;
  background: #ccffd8;
  color: #075f2d;
}

.stock-tag.bearish {
  border-color: #ff8a8a;
  background: #ffe1e1;
  color: #9a1f1f;
}

button.stock-tag {
  cursor: pointer;
}

button.stock-tag:hover {
  border-color: var(--blue);
  background: #e3eef9;
}

button.stock-tag.bullish:hover {
  border-color: #15934a;
  background: #b7ffc9;
}

button.stock-tag.bearish:hover {
  border-color: #c23a3a;
  background: #ffd1d1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
}

.status-pill.failed,
.status-pill.transcript_unavailable,
.status-pill.summary_failed,
.status-pill.failed_permanent {
  background: #f8e7e4;
  color: var(--red);
}

.status-pill.needs_summary,
.status-pill.summary_queued,
.status-pill.summarizing,
.status-pill.new,
.status-pill.discovered,
.status-pill.transcript_pending,
.status-pill.failed_retryable,
.status-pill.video_not_started {
  background: #fff1d8;
  color: var(--gold);
}

.status-pill.voided {
  background: #ece9df;
  color: var(--muted);
}

.status-pill.blocked {
  background: #e6e2e2;
  color: #8d1f1f;
}

.status-pill.members_only {
  background: #e7edf3;
  color: #314b63;
}

.article-panel {
  min-height: calc(100vh - 230px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.article-hero {
  display: grid;
  grid-template-columns: minmax(240px, 38%) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 16px;
}

.article-hero img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: #ddd7cc;
}

.article-title {
  margin-bottom: 10px;
  font-size: clamp(1.45rem, 2vw, 2.25rem);
  line-height: 1.15;
}

.article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.manual-model-control {
  display: inline-flex;
  align-items: center;
  min-width: min(100%, 300px);
}

.manual-model-control select {
  min-width: 210px;
  min-height: 42px;
  flex: 1 1 240px;
  padding: 0 34px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 750;
}

.manual-model-control select:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.danger-button {
  border-color: #e1c3bf;
  color: var(--red);
}

.danger-button:hover {
  border-color: var(--red);
  background: #f8e7e4;
}

.article-body {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  line-height: 1.72;
  font-size: 1rem;
}

.markdown-body {
  white-space: normal;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 24px 0 10px;
  color: var(--accent-strong);
  line-height: 1.28;
}

.markdown-body h2 {
  font-size: 1.45rem;
}

.markdown-body h3 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 1.18rem;
}

.markdown-body h4 {
  font-size: 1.05rem;
}

.markdown-body p {
  margin: 0 0 12px;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 16px;
  padding-left: 1.35rem;
}

.markdown-body li {
  margin: 6px 0;
  padding-left: 2px;
}

.markdown-body strong {
  font-weight: 850;
}

.markdown-body em {
  color: var(--muted);
  font-style: normal;
}

.markdown-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #f0eee6;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
}

.markdown-body hr {
  margin: 20px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.section-token {
  color: var(--accent-strong);
}

.sentiment-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 1px 8px;
  border-radius: 6px;
  font-weight: 900;
}

.sentiment-chip.bullish {
  background: #dff5e7;
  color: #0f5c34;
}

.sentiment-chip.bearish {
  background: #e6e2e2;
  color: #8d1f1f;
}

.timestamp {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #eef4fb;
  color: var(--blue);
  font-size: 0.86em;
  font-weight: 800;
  text-decoration: none;
}

a.timestamp {
  cursor: pointer;
}

a.timestamp:hover {
  border-color: var(--blue);
  background: #e3eef9;
}

.loading-icon {
  animation: spin 0.9s linear infinite;
}

.catalog-loading-state,
.catalog-load-error {
  min-height: 320px;
  padding: 48px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--muted);
}

.catalog-loading-state strong,
.catalog-load-error strong {
  color: var(--text);
  font-size: 1.05rem;
}

.catalog-loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.catalog-loading-dots {
  display: flex;
  gap: 5px;
  margin-top: 4px;
}

.catalog-loading-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: catalog-dot 1.2s ease-in-out infinite;
}

.catalog-loading-dots i:nth-child(2) { animation-delay: 0.15s; }
.catalog-loading-dots i:nth-child(3) { animation-delay: 0.3s; }

.catalog-loading-placeholder {
  padding: 42px;
  display: grid;
  gap: 16px;
}

.catalog-loading-placeholder span {
  height: 18px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent-soft), var(--panel), var(--accent-soft));
  background-size: 200% 100%;
  animation: catalog-shimmer 1.5s ease-in-out infinite;
}

.catalog-loading-placeholder span:first-child { width: 72%; height: 30px; }
.catalog-loading-placeholder span:nth-child(3) { width: 86%; }
.catalog-loading-placeholder span:last-child { width: 58%; }

.catalog-load-error .secondary-button { margin-top: 8px; }

@keyframes catalog-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

@keyframes catalog-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.tags-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tag-list-panel,
.tag-results-panel {
  min-height: calc(100vh - 230px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tag-list,
.tag-results-list {
  display: grid;
  gap: 10px;
}

.tag-list-item,
.tag-result {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf9f5;
  color: var(--text);
  cursor: pointer;
}

.tag-list-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  font-weight: 850;
}

.tag-list-item.active,
.tag-result:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tag-result {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  text-align: left;
}

.tag-result strong {
  display: block;
  margin: 7px 0 6px;
  line-height: 1.35;
}

.tag-snippet {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.sentiment-ranking-panel {
  position: relative;
  min-height: calc(100vh - 230px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sentiment-ranking-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.ranking-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.date-range-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.date-range-fields[hidden] {
  display: none;
}

.ranking-controls .filter-field select {
  min-width: 120px;
}

.sentiment-ranking-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(360px, 1fr);
  column-gap: clamp(72px, 7vw, 128px);
  row-gap: 16px;
  align-items: start;
}

.sentiment-connection-svg {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.sentiment-connection-svg path {
  fill: none;
  stroke: var(--connection-color, #8d8a82);
  stroke-width: 2;
  opacity: 0.92;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.ranking-column {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.ranking-column-heading {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.ranking-column-heading h3 {
  margin: 0;
  font-size: 1.08rem;
}

.ranking-column-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.ranking-column.bullish .ranking-column-heading h3 {
  color: #0f6f3d;
}

.ranking-column.bearish .ranking-column-heading h3 {
  color: #9a1f1f;
}

.ranking-list {
  display: grid;
  gap: 8px;
}

.ranking-row {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 28px max-content minmax(90px, 1fr) 42px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf9f5;
  color: var(--text);
  cursor: pointer;
}

.ranking-row:hover {
  border-color: var(--accent);
}

.ranking-index {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: right;
}

.ranking-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebe8df;
}

.ranking-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.ranking-row.bullish .ranking-bar span {
  background: #35c86f;
}

.ranking-row.bearish .ranking-bar span {
  background: #ff8a8a;
}

.ranking-row strong {
  font-size: 0.92rem;
  font-weight: 900;
  text-align: right;
}

.win-rate-panel {
  min-height: calc(100vh - 230px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.win-rate-toolbar,
.win-rate-controls,
.win-rate-content-heading,
.win-rate-column-heading {
  display: flex;
  align-items: center;
}

.win-rate-toolbar {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.win-rate-toolbar .section-heading {
  margin-bottom: 0;
}

.win-rate-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.win-rate-controls .filter-field select {
  min-width: 180px;
}

.win-rate-status {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid #b9d7cf;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.win-rate-status:empty {
  display: none;
}

.win-rate-status.warning {
  border-color: #e2c891;
  background: #fff7df;
  color: #725018;
}

.win-rate-status.failed {
  border-color: #e1b6b1;
  background: #fae9e6;
  color: var(--red);
}

.win-rate-method {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.win-rate-method strong {
  color: var(--text);
}

.win-rate-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.win-rate-metric {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 5px 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  background: #faf9f5;
}

.win-rate-metric.bullish {
  border-left-color: #25aa5a;
}

.win-rate-metric.bearish {
  border-left-color: #df5c61;
}

.win-rate-metric > span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.win-rate-metric > strong {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: center;
  color: var(--accent-strong);
  font-size: 1.45rem;
  font-weight: 900;
}

.win-rate-metric.bullish > strong {
  color: #0f7b42;
}

.win-rate-metric.bearish > strong {
  color: #a52c31;
}

.win-rate-metric small {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.win-rate-content-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.win-rate-content-heading h3,
.win-rate-content-heading p {
  margin: 0;
}

.win-rate-content-heading h3 {
  margin-bottom: 4px;
  font-size: 1.08rem;
}

.win-rate-content-heading p {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.win-rate-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
}

.win-rate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(28px, 4vw, 64px);
  align-items: start;
}

.win-rate-column {
  min-width: 0;
}

.win-rate-column-heading {
  min-height: 42px;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.win-rate-column-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.win-rate-column-heading span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.win-rate-column.bullish .win-rate-column-heading h3 {
  color: #0f6f3d;
}

.win-rate-column.bearish .win-rate-column-heading h3 {
  color: #9a1f1f;
}

.win-rate-list {
  display: grid;
  gap: 8px;
}

.win-rate-row {
  width: 100%;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #faf9f5;
  color: var(--text);
  text-align: left;
}

button.win-rate-row {
  cursor: pointer;
}

button.win-rate-row:hover {
  border-color: var(--accent);
  background: #f6faf8;
}

.channel-row-accuracy {
  display: grid;
  grid-template-columns: 28px minmax(150px, 0.95fr) minmax(80px, 1fr) 62px 18px;
}

.ticker-row-accuracy {
  display: grid;
  grid-template-columns: 28px minmax(160px, 0.95fr) minmax(80px, 1fr) 62px;
}

.win-rate-index {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-align: right;
}

.win-rate-row-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.win-rate-row-main strong {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
  font-size: 0.86rem;
}

.win-rate-row-main small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.win-rate-ticker-button {
  display: inline;
  padding: 0;
  border: 0;
  border-bottom: 1px dotted currentColor;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.win-rate-ticker-button:hover,
.win-rate-ticker-button:focus-visible {
  color: var(--accent);
  border-bottom-style: solid;
  outline: 0;
}

.win-rate-ticker-detail {
  margin: 0 0 20px;
  padding: 15px 14px;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--line);
  background: #f4f7f5;
}

.win-rate-ticker-detail.bullish {
  border-top-color: #25aa5a;
}

.win-rate-ticker-detail.bearish {
  border-top-color: #df5c61;
  background: #fbf6f5;
}

.win-rate-ticker-detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.win-rate-ticker-detail-heading h3,
.win-rate-ticker-detail-heading p {
  margin: 0;
}

.win-rate-ticker-detail-heading h3 {
  margin-bottom: 5px;
  font-size: 1.06rem;
}

.win-rate-ticker-detail-heading h3 span {
  color: var(--accent-strong);
}

.win-rate-ticker-detail-heading p {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.win-rate-mention-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.win-rate-mention {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.win-rate-mention:last-child {
  border-bottom: 0;
}

.win-rate-mention:hover {
  background: var(--accent-soft);
}

.win-rate-mention img {
  width: 112px;
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 5px;
  background: #ddd7cc;
  object-fit: cover;
}

.win-rate-mention-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.win-rate-mention-main > strong {
  overflow-wrap: anywhere;
  line-height: 1.35;
  font-size: 0.86rem;
}

.win-rate-mention-main > small {
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.73rem;
}

.win-rate-mention-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
}

.win-rate-outcome {
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 900;
}

.win-rate-outcome.win {
  background: #dff7e8;
  color: #087236;
}

.win-rate-outcome.loss {
  background: #fde3e3;
  color: #a51f29;
}

.win-rate-outcome.pending,
.win-rate-outcome.flat,
.win-rate-outcome.unresolved {
  background: #e9e7e0;
  color: #5f5c54;
}

.win-rate-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebe8df;
}

.win-rate-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.win-rate-column.bullish .win-rate-bar span,
.ticker-row-accuracy.bullish .win-rate-bar span {
  background: #35c86f;
}

.win-rate-column.bearish .win-rate-bar span,
.ticker-row-accuracy.bearish .win-rate-bar span {
  background: #ff7f84;
}

.win-rate-value {
  font-size: 0.86rem;
  font-weight: 900;
  text-align: right;
}

.win-rate-column-empty,
.win-rate-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.win-rate-column-empty {
  min-height: 58px;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 7px;
}

.win-rate-empty {
  min-height: 240px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.win-rate-empty svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.win-rate-empty span {
  font-size: 0.76rem;
}

.settings-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.settings-panel[hidden],
.settings-guest[hidden] {
  display: none;
}

.settings-guest {
  min-height: 360px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
}

.settings-guest > svg {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

.settings-guest h2 {
  margin: 0;
  font-size: 1.18rem;
}

.settings-feedback-link {
  min-height: 42px;
  text-decoration: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  align-items: start;
}

.settings-section {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.18rem;
}

.channel-settings-list {
  display: grid;
  gap: 10px;
}

.channel-settings-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 12px;
}

.global-settings-list {
  display: grid;
  gap: 10px;
  max-width: 620px;
}

.global-settings-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 850;
}

.global-settings-group-title svg {
  width: 17px;
  height: 17px;
}

.blocked-video-add {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.blocked-video-add .filter-field {
  flex: 1;
  min-width: min(420px, 100%);
}

.blocked-video-add .filter-field input[type="text"] {
  flex: 1;
  min-width: 180px;
}

.blocked-video-list {
  display: grid;
  gap: 10px;
}

.blocked-video-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) max-content;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf9f5;
}

.blocked-video-main {
  min-width: 0;
}

.blocked-video-main strong {
  display: block;
  margin-bottom: 7px;
  line-height: 1.35;
}

.global-setting-row {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(120px, 180px);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf9f5;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.global-setting-row.checkbox-field {
  grid-template-columns: 18px minmax(0, 1fr);
  color: var(--text) !important;
}

.ticker-name-setting-row {
  grid-template-columns: minmax(180px, 1fr) minmax(280px, 1.5fr);
  color: var(--text);
}

.ticker-name-scope-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.ticker-name-scope-list .checkbox-field {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  cursor: pointer;
}

.ticker-name-scope-list input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.cleanup-setting-row {
  grid-template-columns: minmax(0, 1fr) max-content;
}

.cleanup-setting-row strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.cleanup-setting-row span {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.global-setting-row input[type="number"] {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.global-setting-row > span:first-child small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.number-setting-control {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}

.number-setting-control > span {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: left;
}

.model-setting-row {
  grid-template-columns: minmax(180px, 1fr) minmax(280px, 1.5fr);
}

.model-select-control {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.backup-model-select-control {
  grid-template-columns: minmax(0, 1fr);
}

.model-select-control select,
.model-custom-input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.model-custom-input {
  grid-column: 1;
}

.model-select-control .icon-button {
  grid-column: 2;
  grid-row: 1;
}

.model-custom-input:not(:placeholder-shown) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.model-custom-input:focus {
  outline: 2px solid rgba(39, 106, 92, 0.18);
  border-color: var(--accent);
}

.model-list-message {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.model-list-message.error {
  color: var(--red);
}

.channel-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.6fr) minmax(220px, 1.2fr) minmax(115px, 0.45fr) minmax(170px, 0.7fr) minmax(135px, 0.55fr) minmax(135px, 0.55fr) 42px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf9f5;
}

.channel-row.is-paused {
  border-color: #bdbab1;
  background: #efeee9;
}

.channel-row.is-paused .channel-paused-field {
  color: #80591e !important;
  font-weight: 900;
}

.channel-row.is-win-rate-excluded .channel-win-rate-field {
  color: #9a1f1f !important;
  font-weight: 900;
}

.channel-row label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.checkbox-field {
  min-height: 40px;
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
}

.channel-row .checkbox-field input {
  width: 18px;
  min-height: 18px;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--accent);
}

.channel-row input,
.channel-row select,
.global-setting-row input[type="number"],
.prompt-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.channel-row input {
  min-height: 40px;
  padding: 0 10px;
}

.channel-row select {
  min-height: 40px;
  padding: 0 32px 0 10px;
}

.prompt-textarea {
  min-height: 520px;
  padding: 13px 14px;
  line-height: 1.58;
  resize: vertical;
}

.channel-row input:focus,
.channel-row select:focus,
.global-setting-row input[type="number"]:focus,
.prompt-textarea:focus {
  outline: 2px solid rgba(39, 106, 92, 0.18);
  border-color: var(--accent);
}

.channel-error {
  grid-column: 1 / -1;
  color: var(--red);
  font-size: 0.78rem;
  line-height: 1.4;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.settings-backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.data-backup-list {
  display: grid;
  gap: 10px;
  max-width: 860px;
}

.data-backup-row {
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf9f5;
}

.data-backup-main strong,
.data-backup-main span {
  display: block;
}

.data-backup-main strong {
  margin-bottom: 5px;
  color: var(--text);
  font-size: 0.92rem;
}

.data-backup-main span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.video-backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-message {
  flex: 1;
  min-height: 24px;
  color: var(--accent-strong);
  font-weight: 800;
  text-align: right;
}

.settings-message.error {
  color: var(--red);
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.login-dialog {
  width: min(420px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(31, 29, 24, 0.22);
}

.login-dialog::backdrop {
  background: rgba(29, 29, 27, 0.48);
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.login-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.login-dialog-header h2 {
  margin: 5px 0 0;
  font-size: 1.28rem;
}

.login-dialog-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 850;
}

.login-dialog-eyebrow svg {
  width: 15px;
  height: 15px;
}

.login-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.login-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.login-field input:focus {
  outline: 2px solid rgba(39, 106, 92, 0.18);
  border-color: var(--accent);
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.45;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.calendar-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  justify-content: stretch;
  margin: 8px 0 18px;
}

.calendar-month-controls {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 10px;
}

.calendar-history-check {
  grid-column: 3;
  justify-self: end;
}

.calendar-header h2 {
  min-width: 190px;
  margin: 0;
  text-align: center;
  font-size: 1.45rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  overflow: visible;
}

.weekday,
.day-cell {
  border-radius: 8px;
}

.weekday {
  padding: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
}

.day-cell {
  position: relative;
  min-height: 142px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: visible;
}

.day-cell.muted {
  background: rgba(255, 255, 255, 0.42);
  color: #aaa59b;
}

.day-cell.has-videos:hover,
.day-cell.has-videos:focus-within {
  z-index: 20;
  border-color: var(--accent);
}

.day-number {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 24px;
  margin-bottom: 7px;
  font-weight: 850;
}

.count-badge {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
}

.calendar-video {
  width: 100%;
  min-height: 32px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #f4f2eb;
  color: var(--text);
  text-align: left;
  font-size: 0.76rem;
  line-height: 1.25;
  cursor: pointer;
}

.calendar-video-thumbnail {
  width: 36px;
  height: 22px;
  display: block;
  border-radius: 4px;
  background: #ddd7cc;
  object-fit: cover;
}

.calendar-video-title {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.calendar-video:hover {
  border-color: var(--accent);
}

.calendar-more {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.calendar-day-tooltip {
  position: absolute;
  top: calc(100% - 4px);
  left: 8px;
  z-index: 30;
  width: min(360px, 82vw);
  max-height: 360px;
  display: none;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.day-cell:nth-child(7n) .calendar-day-tooltip,
.day-cell:nth-child(7n - 1) .calendar-day-tooltip {
  right: 8px;
  left: auto;
}

.day-cell.has-videos:hover .calendar-day-tooltip,
.day-cell.has-videos:focus-within .calendar-day-tooltip {
  display: block;
}

.calendar-tooltip-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 850;
}

.calendar-tooltip-list {
  display: grid;
  gap: 7px;
  max-height: 300px;
  overflow: auto;
}

.calendar-tooltip-video {
  width: 100%;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #faf9f5;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.calendar-tooltip-thumbnail {
  width: 84px;
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 5px;
  background: #ddd7cc;
  object-fit: cover;
}

.calendar-tooltip-video-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.calendar-tooltip-video:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.calendar-tooltip-video-title {
  line-height: 1.35;
  font-size: 0.82rem;
  font-weight: 850;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

@media (max-width: 980px) {
  .latest-layout,
  .article-hero,
  .settings-grid,
  .tags-layout,
  .sentiment-ranking-grid,
  .win-rate-grid {
    grid-template-columns: 1fr;
  }

  .video-list,
  .article-panel,
  .tag-list-panel,
  .tag-results-panel,
  .sentiment-ranking-panel,
  .win-rate-panel {
    max-height: none;
    min-height: auto;
  }

  .sentiment-ranking-toolbar,
  .win-rate-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .ranking-controls,
  .win-rate-controls {
    justify-content: flex-start;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day-cell {
    min-height: 120px;
  }

  .prompt-textarea {
    min-height: 420px;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 18px, 1440px);
    padding-top: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar .toolbar {
    margin-left: 0;
  }

  .topbar .tabs {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .settings-subtabs {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .toolbar,
  .tabs,
  .settings-subtabs,
  .filter-strip {
    width: 100%;
  }

  .filter-field,
  .filter-field select,
  .filter-field input[type="text"] {
    width: 100%;
  }

  .filter-field select,
  .filter-field input[type="text"] {
    min-width: 0;
  }

  .primary-button,
  .secondary-button,
  .stop-processing-button,
  .settings-tab {
    flex: 1;
  }

  .topbar .tab {
    flex: 0 0 110px;
  }

  .settings-subtabs .settings-tab {
    flex: 0 0 150px;
  }

  .manual-model-control {
    width: 100%;
    flex-wrap: wrap;
  }

  .manual-model-control select {
    width: 100%;
  }

  .ticker-name-setting-row {
    grid-template-columns: 1fr;
  }

  body:not(.admin-authenticated) .status-strip {
    display: none;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .latest-layout:not(.mobile-detail-open) .article-panel,
  .latest-layout.mobile-detail-open .latest-sidebar {
    display: none;
  }

  .latest-layout.mobile-detail-open .article-panel {
    display: block;
  }

  .latest-layout:not(.mobile-detail-open) .latest-sidebar {
    display: grid;
  }

  .latest-layout .article-panel {
    width: 100%;
  }

  .mobile-pane-back {
    display: inline-grid;
    flex: 0 0 auto;
  }

  .latest-mobile-back {
    margin-bottom: 10px;
  }

  .mobile-pane-heading {
    align-items: center;
    flex-direction: row;
    justify-content: flex-start;
  }

  .tags-layout:not(.mobile-results-open) .tag-results-panel,
  .tags-layout.mobile-results-open .tag-list-panel {
    display: none;
  }

  .tags-layout.mobile-results-open .tag-results-panel,
  .tags-layout:not(.mobile-results-open) .tag-list-panel {
    display: block;
  }

  .mobile-side-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 12px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ebe8df;
  }

  .mobile-side-toggle button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 850;
    cursor: pointer;
  }

  .mobile-side-toggle button.active {
    border-color: var(--line);
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 5px 14px rgba(31, 29, 24, 0.06);
  }

  .mobile-side-toggle button[data-sentiment-mobile-side="bullish"].active,
  .mobile-side-toggle button[data-win-rate-mobile-side="bullish"].active {
    color: #0f6f3d;
  }

  .mobile-side-toggle button[data-sentiment-mobile-side="bearish"].active,
  .mobile-side-toggle button[data-win-rate-mobile-side="bearish"].active {
    color: #9a1f1f;
  }

  .sentiment-ranking-grid.mobile-side-bullish .ranking-column.bearish,
  .sentiment-ranking-grid.mobile-side-bearish .ranking-column.bullish,
  .win-rate-grid.mobile-side-bullish .win-rate-column.bearish,
  .win-rate-grid.mobile-side-bearish .win-rate-column.bullish {
    display: none;
  }

  .sentiment-connection-svg {
    display: none;
  }

  .video-card {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .tag-result {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .blocked-video-row {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .blocked-video-row .unblock-video-button {
    grid-column: 1 / -1;
  }

  .calendar-grid {
    gap: 5px;
  }

  .weekday {
    padding: 6px 2px;
  }

  .day-cell {
    min-height: 96px;
    padding: 6px;
  }

  #calendarView {
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .calendar-header,
  .calendar-grid {
    min-width: 840px;
  }

  .calendar-video {
    min-height: 26px;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 4px;
    padding: 3px;
    font-size: 0.68rem;
  }

  .calendar-video-thumbnail {
    width: 28px;
    height: 18px;
  }

  .section-heading,
  .sentiment-ranking-toolbar,
  .win-rate-toolbar,
  .win-rate-content-heading,
  .settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .channel-settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-backup-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .data-backup-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .video-backup-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-message {
    text-align: left;
  }

  .ranking-controls,
  .ranking-controls .filter-field,
  .date-range-fields {
    width: 100%;
  }

  .ranking-controls .filter-field select,
  .filter-field input[type="date"] {
    min-width: 0;
  }

  .win-rate-controls,
  .win-rate-controls .filter-field,
  .win-rate-controls .secondary-button {
    width: 100%;
  }

  .win-rate-controls .filter-field select {
    min-width: 0;
    width: 100%;
  }

  .win-rate-metrics {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
    overflow-x: auto;
    padding-bottom: 5px;
    scroll-snap-type: x proximity;
  }

  .win-rate-metric {
    scroll-snap-align: start;
  }

  .channel-row-accuracy {
    grid-template-columns: 24px minmax(0, 1fr) 58px 18px;
  }

  .ticker-row-accuracy {
    grid-template-columns: 24px minmax(0, 1fr) 58px;
  }

  .channel-row-accuracy .win-rate-bar,
  .ticker-row-accuracy .win-rate-bar {
    grid-column: 2 / 4;
    grid-row: 2;
  }

  .channel-row-accuracy .win-rate-value,
  .ticker-row-accuracy .win-rate-value {
    grid-column: 3;
    grid-row: 1;
  }

  .channel-row-accuracy > svg {
    grid-column: 4;
    grid-row: 1;
  }

  .win-rate-ticker-detail {
    margin-right: -4px;
    margin-left: -4px;
    padding: 13px 10px;
  }

  .win-rate-ticker-detail-heading {
    align-items: flex-start;
  }

  .win-rate-mention {
    grid-template-columns: 86px minmax(0, 1fr) 16px;
    gap: 9px;
  }

  .win-rate-mention img {
    width: 86px;
  }

  .ranking-row {
    grid-template-columns: 28px max-content minmax(56px, 1fr) 36px;
  }

  .calendar-header {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .calendar-month-controls,
  .calendar-history-check {
    grid-column: 1;
  }

  .calendar-month-controls {
    justify-content: center;
  }

  .calendar-history-check {
    justify-self: stretch;
  }

  .channel-row {
    grid-template-columns: minmax(0, 1fr) 42px;
    grid-template-areas:
      "name name"
      "url url"
      "content remove"
      "direct direct"
      "paused paused"
      "winrate winrate"
      "error error";
  }

  .global-setting-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .model-list-message {
    grid-column: 1;
  }

  .global-setting-row.checkbox-field {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .channel-row .channel-name-field {
    grid-area: name;
  }

  .channel-row .channel-url-field {
    grid-area: url;
  }

  .channel-row .channel-content-field {
    grid-area: content;
  }

  .channel-row .channel-direct-url-field {
    grid-area: direct;
  }

  .channel-row .channel-paused-field {
    grid-area: paused;
  }

  .channel-row .channel-win-rate-field {
    grid-area: winrate;
  }

  .channel-row .remove-channel-button {
    grid-area: remove;
  }

  .channel-row .channel-error {
    grid-area: error;
  }

  .prompt-textarea {
    min-height: 360px;
  }
}
