@import url('tokens.css');

/* Shared news-wall look (Top Stories pattern). Colours come from tokens.css. */
:root {
  --radius: 10px;
  --shadow: 0 1px 2px color-mix(in oklch, var(--ink) 8%, transparent);
  --shadow-hover: 0 10px 24px color-mix(in oklch, var(--ink) 12%, transparent);
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
[data-theme="dark"] {
  --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 12px 28px -4px rgba(0, 0, 0, 0.5);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--ui);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  padding-bottom: 40px;
  -webkit-font-smoothing: antialiased;
}
html.rv-in-frame,
html.rv-in-frame body {
  background: transparent !important;
}
html.rv-in-frame .ts-header {
  background: transparent !important;
}
.ts-header {
  position: sticky; top: 0; z-index: 40; background: var(--bg);
  border-bottom: 1px solid var(--line); padding: 16px 24px;
}
.ts-header-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.ts-title-group { display: flex; align-items: center; gap: 10px; }
.ts-title {
  font-family: var(--sans); font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em; color: var(--ink);
}
.ts-count-badge {
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2);
  padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line);
}
.ts-controls { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 640px; min-width: 240px; justify-content: flex-end; }
.ts-cat-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ts-cat-select {
  flex: 0 0 auto; min-width: 160px; max-width: 220px; height: 36px;
  padding: 0 28px 0 12px; border-radius: 9px; border: 1px solid var(--line);
  color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; outline: none;
  appearance: none; -webkit-appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.ts-cat-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.ts-search-box { position: relative; flex: 1; min-width: 160px; }
.ts-search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.ts-search-input {
  width: 100%; padding: 8px 12px 8px 36px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 13px; outline: none;
}
.ts-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.ts-refresh-btn, .ts-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.ts-refresh-btn svg {
  color: #ef4444;
  stroke: #ef4444;
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.15s ease;
}
.ts-refresh-btn:hover, .ts-btn:hover { border-color: var(--accent); color: var(--accent); }
.ts-refresh-btn:hover svg {
  color: #dc2626;
  stroke: #dc2626;
  transform: rotate(45deg);
}
.ts-container { max-width: none; margin: 0; padding: 18px 20px 28px; }
.ts-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .ts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) {
  .ts-container { padding: 12px; }
  .ts-grid { grid-template-columns: 1fr; gap: 14px; }
  .ts-header { padding: 12px 14px; }
  .ts-controls { max-width: none; }
}

/* Brief — horizontal list */
body.ts-layout-list .ts-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 920px;
  margin: 0;
  margin-right: auto;
}
body.ts-layout-list .ts-card {
  flex-direction: row;
  align-items: stretch;
  min-height: 88px;
}
body.ts-layout-list .ts-card:hover {
  transform: none;
  box-shadow: var(--shadow-hover);
}
body.ts-layout-list .ts-card-media {
  width: 108px;
  min-width: 108px;
  max-width: 108px;
  aspect-ratio: auto;
  height: auto;
  align-self: stretch;
}
body.ts-layout-list .ts-card-fallback { font-size: 22px; }
body.ts-layout-list .ts-card-body {
  padding: 12px 16px;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}
body.ts-layout-list .ts-card-title {
  font-size: 15px;
  -webkit-line-clamp: 2;
}
body.ts-layout-list .ts-card-desc {
  -webkit-line-clamp: 1;
}
body.ts-layout-list .ts-skel-card { height: 88px; }
@media (max-width: 520px) {
  body.ts-layout-list .ts-card-media {
    width: 84px;
    min-width: 84px;
    max-width: 84px;
  }
}

/* Starred / Read Later — image board */
body.ts-layout-board .ts-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}
body.ts-layout-board .ts-card-desc,
body.ts-layout-board .ts-card-footer { display: none; }
body.ts-layout-board .ts-card-body { padding: 10px 11px 12px; gap: 0; }
body.ts-layout-board .ts-card-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  -webkit-line-clamp: 3;
}
body.ts-layout-board .ts-card-media { aspect-ratio: 16 / 10; }
body.ts-layout-board .ts-skel-card { height: 180px; }
@media (max-width: 1400px) { body.ts-layout-board .ts-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 1100px) { body.ts-layout-board .ts-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 860px) { body.ts-layout-board .ts-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { body.ts-layout-board .ts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.ts-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease; cursor: pointer;
  position: relative;
}
.ts-card-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 15px;
  line-height: 22px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ts-card-remove:hover { background: #ef4444; }
.ts-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.ts-card-media { width: 100%; aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; position: relative; }
.ts-card-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ts-card-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: var(--paper-3) !important;
  color: var(--ink) !important; font-family: var(--sans); font-size: 28px; font-weight: 700;
}
.ts-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; flex: 1; gap: 6px; }
.ts-card-title {
  font-family: var(--sans); font-size: 16px; font-weight: 700; line-height: 1.28; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ts-card-desc {
  font-size: 13px; color: var(--ink-2); line-height: 1.45; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ts-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 4px; }
.ts-card-meta { font-size: 11px; color: var(--ink-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-card-actions { display: flex; align-items: center; gap: 4px; }
.ts-icon-action {
  background: none; border: 0; border-radius: 6px; font-size: 14px; padding: 2px 5px;
  color: var(--ink-3); cursor: pointer; line-height: 1; opacity: .55;
}
.ts-card:hover .ts-icon-action { opacity: 1; }
.ts-icon-action:hover { color: var(--accent); background: var(--accent-light); }
.ts-icon-action.is-active-star { color: #d97706; opacity: 1; }
.ts-icon-action.is-active-save { color: #2563eb; opacity: 1; }
.ts-skel-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); height: 320px; }
.ts-skel-anim {
  background: var(--surface-2);
  background-size: 200% 100%; animation: tsShimmer 1.5s infinite;
}
@keyframes tsShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
#ts-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; align-items: center; justify-content: center; padding: 20px; }
#ts-modal.is-open { display: flex; }
.ts-modal-content { background: var(--surface); border-radius: 16px; width: 720px; max-width: 100%; max-height: 90vh; overflow-y: auto; border: 1px solid var(--line); display: flex; flex-direction: column; }
.ts-modal-header { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; }
.ts-modal-close { background: none; border: none; font-size: 24px; color: var(--ink-3); cursor: pointer; }
.ts-modal-body { padding: 24px; }
.ts-modal-img { width: 100%; max-height: 360px; object-fit: cover; border-radius: 10px; margin-bottom: 20px; }
.ts-modal-title { font-family: var(--sans); font-size: 24px; font-weight: 700; line-height: 1.3; margin-bottom: 12px; }
.ts-modal-text { font-size: 15px; line-height: 1.7; color: var(--ink-2); margin-bottom: 24px; }
.ts-modal-footer { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 12px; background: var(--surface-2); }
.ts-publisher-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.ts-publisher-icon { width: 16px; height: 16px; border-radius: 3px; }
.ts-publisher-name { font-weight: 600; }
.ts-dot { opacity: .45; }
.ts-time { color: var(--ink-3); }
.ts-empty { text-align: center; padding: 60px 20px; color: var(--ink-3); grid-column: 1 / -1; }
.ts-empty h3 { font-size: 18px; color: var(--ink); margin-bottom: 6px; }
.ts-read-btn { font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; }
.ts-btn.is-active-star { border-color: #f59e0b; color: #f59e0b; }
.ts-btn.is-active-save { border-color: #3b82f6; color: #3b82f6; }
