/* Themes: the user picks one in the user menu; dark is the default. To add
   a theme, copy a block below with a new [data-theme] id and add it to
   themes in i18n.go. */
:root {
  --radius: 12px;
  --side-w: 290px;
}
:root, [data-theme="dark"] {
  --bg: #121316;
  --panel: #1c1d22;
  --panel-2: #272830;
  --side: #17181c;
  --line: #2f3038;
  --text: #ecebe8;
  --muted: #9b9aa3;
  --accent: #ff8a4c;
  --accent-soft: #3b2418;
  --kw: #74b0f5;
  --kw-soft: #172a40;
  --error: #ff8787;
  --shadow: 0 1px 2px rgb(0 0 0 / .4);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --panel-2: #ebe9e3;
  --side: #fbfaf7;
  --line: #dedbd2;
  --text: #1d1c1a;
  --muted: #6d6a62;
  --accent: #d9480f;
  --accent-soft: #fde4d6;
  --kw: #1864ab;
  --kw-soft: #dbeafe;
  --error: #c92a2a;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 14px rgb(0 0 0 / .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap;
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--kw-soft); color: var(--kw); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
/* Looks like any button; only the star shows whether the feed is prioritized. */
.star-btn .star-icon::before { content: "☆"; color: var(--muted); }
.star-btn.on .star-icon::before { content: "★"; color: var(--accent); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 8px; background: none; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); }
.link-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout: sidebar + main */
.app { display: flex; min-height: 100vh; }
#sidebar {
  width: var(--side-w); flex: none;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--side); border-right: 1px solid var(--line);
}
main { flex: 1; min-width: 0; padding: 0 24px 48px; container-type: inline-size; }
@media (min-width: 900px) {
  .nav-hidden #sidebar { display: none; }
}
@media (max-width: 899px) {
  #sidebar {
    position: fixed; left: 0; z-index: 20; max-width: 85vw;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .nav-shown #sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 19; background: rgb(0 0 0 / .35); }
  main { padding: 0 16px 40px; }
}

/* Sidebar */
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 16px; }
.brand { display: flex; font-size: 19px; text-decoration: none; }

/* Logo, in the style of Mork Music */
.logo { display: inline-flex; align-items: center; gap: .45em; line-height: 1; white-space: nowrap; }
.logo img { width: 1.5em; height: 1.5em; flex: none; }
.wordmark { font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.wordmark b {
  font-weight: 800;
  background: linear-gradient(90deg, #ff922b, #d6336c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#sync.spinning svg { animation: spin 1s linear infinite; }
.side-nav { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.side-nav a { text-decoration: none; }
.count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-all, .cat-row, .cat li {
  display: flex; align-items: center; gap: 6px; border-radius: 8px; min-height: 34px;
}
.side-all { padding: 6px 10px; font-weight: 600; margin-bottom: 6px; }
.side-all:hover, .cat-row:hover, .cat li:hover { background: var(--panel-2); }
.side-all.active, .cat-row.active, .cat li.active { background: var(--accent-soft); }
.cat-row { padding-right: 10px; }
.cat-row > a { flex: 1; min-width: 0; font-weight: 600; padding: 6px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-toggle { width: 26px; height: 26px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; flex: none; }
.cat-toggle svg { width: 16px; height: 16px; transition: transform .15s; }
.cat-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.cat ul { list-style: none; margin: 0 0 4px; padding: 0 0 0 22px; }
.cat:has(.cat-toggle[aria-expanded="false"]) ul { display: none; }
.cat li { padding-right: 10px; font-size: 14px; }
.cat li a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 5px 8px; }
.feed-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star { color: var(--accent); font-size: 12px; }
.favicon { width: 16px; height: 16px; flex: none; border-radius: 3px; }
.side-empty { color: var(--muted); padding: 8px 10px; }
.side-nav .side-empty a { text-decoration: underline; }
.side-foot { display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.sync-error { color: var(--error); cursor: help; }

/* Toolbar */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; margin: 0 -4px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
}
/* Title and actions wrap; the menu button and user menu stay on the first row. */
.toolbar-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; min-height: 36px; }
.toolbar > .icon-btn, .user-btn { flex: none; }
.view-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1 1 220px; }
.view-title h1 { margin: 0; font-size: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-count { color: var(--muted); font-size: 14px; white-space: nowrap; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) {
  /* Menu button, title and user menu on one row, the actions on full rows below. */
  .toolbar { position: static; flex-wrap: wrap; align-items: center; }
  .toolbar-main { display: contents; }
  .view-title { order: 1; flex: 1 1 0; }
  .user-btn { order: 2; }
  .actions { order: 3; width: 100%; }
}

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; user-select: none; margin-right: 4px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 10px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / .3); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Article grid: 1 column on phones, 2 on medium screens, 3 on wide ones */
.grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@container (min-width: 620px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@container (min-width: 1020px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: opacity .2s;
}
.card.read { opacity: .55; }
.card.read:hover { opacity: .85; }
.card-media {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0;
  background: var(--panel-2); cursor: pointer; overflow: hidden;
}
.card-media > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.no-image .card-media > img { display: none; }
.open { cursor: pointer; }

/* Placeholder: shown when there is no picture (yet) */
.ph, .loading { position: absolute; inset: 0; display: none; }
.card-media:not(:has(> img)) .ph, .card.no-image .ph {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--panel-2), var(--accent-soft));
  color: var(--muted); font-weight: 600; padding: 16px; text-align: center;
}
.ph-icon { width: 40px; height: 40px; border-radius: 8px; }
.ph-name { font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.pending .card-media:not(:has(> img)) .ph { animation: shimmer 1.4s ease-in-out infinite; }
.card.pending .card-media:not(:has(> img)) .ph-name { visibility: hidden; }
.card.pending .card-media:not(:has(> img)) .loading {
  display: flex; align-items: flex-end; justify-content: center; gap: 8px; padding: 12px;
  font-size: 13px; color: var(--muted);
}
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 50% { opacity: .55; } }

.card-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.card-meta .feed { display: flex; align-items: center; gap: 6px; text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta .feed:hover { color: var(--text); }
.card-meta time { margin-left: auto; white-space: nowrap; flex: none; }
.card h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.card h2 a { text-decoration: none; }
.card h2 a:hover { text-decoration: underline; }
.ingress { margin: 0; color: var(--muted); font-size: 15px; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.card.pending .ingress:empty {
  height: 3.6em; border-radius: 6px;
  background: repeating-linear-gradient(var(--panel-2) 0 .9em, transparent .9em 1.4em);
  animation: shimmer 1.4s ease-in-out infinite;
}
/* Bottom row: the priority tag, and mark read/unread without opening on the right. */
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 2px; }
.read-btn {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  order: 1; margin: 0 -6px 0 auto; /* bottom right, after the tag */
  border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer;
}
.read-btn:hover { background: var(--panel-2); color: var(--text); }
.read-btn svg { width: 18px; height: 18px; }
.read-btn .eye-off, .card.read .read-btn .eye { display: none; }
.card.read .read-btn .eye-off { display: block; }
.tag { align-self: flex-start; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.tag.prio { background: var(--accent-soft); color: var(--accent); }
.tag.kw { background: var(--kw-soft); color: var(--kw); }

/* List layout: one article per row with a small picture */
.grid.list { grid-template-columns: 1fr; gap: 10px; max-width: 980px; }
.grid.list .card { flex-direction: row; align-items: stretch; }
.grid.list .card-media { width: 180px; flex: none; aspect-ratio: auto; min-height: 112px; }
.grid.list .card-body { padding: 10px 14px; gap: 4px; min-width: 0; }
.grid.list h2 { font-size: 16px; }
.grid.list .ingress { font-size: 14px; -webkit-line-clamp: 2; }
.grid.list .ph-icon { width: 28px; height: 28px; }
.grid.list .ph-name { display: none; }
.grid.list .card.pending .card-media:not(:has(> img)) .loading { align-items: center; font-size: 0; }
.grid.list .card-foot { padding-top: 0; }
.grid.list .read-btn { width: 26px; height: 26px; }
@container (max-width: 560px) {
  .grid.list .card-media { width: 96px; min-height: 0; }
  .grid.list .ingress { -webkit-line-clamp: 2; }
}

/* Compact: no ingresses, and smaller pictures in the list */
.grid.compact .ingress { display: none; }
.grid.compact .card-media { aspect-ratio: 2 / 1; }
.grid.list.compact { gap: 6px; }
.grid.list.compact .card-media { width: 120px; min-height: 68px; aspect-ratio: auto; }
/* Eye beside the title instead of on a row of its own, so rows stay low. */
.grid.list.compact .card-body {
  padding: 8px 12px; display: grid; align-content: center; column-gap: 6px; row-gap: 2px;
  grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "meta meta meta" "eye title tag";
}
.grid.list.compact .card-meta { grid-area: meta; }
.grid.list.compact h2 { grid-area: title; }
.grid.list.compact .card-foot { display: contents; }
.grid.list.compact .read-btn { grid-area: eye; width: 26px; height: 26px; margin: 0 0 0 -6px; }
.grid.list.compact .tag { grid-area: tag; }
@container (max-width: 560px) {
  .grid.list.compact .card-body { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "meta meta" "eye title" ". tag"; }
  .grid.list.compact .tag { justify-self: start; }
}
.grid.list.compact .ph-icon { width: 22px; height: 22px; }
@container (max-width: 560px) {
  .grid.list.compact .card-media { width: 80px; }
}

/* User menu, top right */
.user-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px 0 8px; max-width: 180px;
  font: inherit; font-size: 14px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; cursor: pointer;
}
.user-btn:hover { border-color: var(--muted); }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .user-name { display: none; } .user-btn { padding: 0 8px; } }
#user-menu {
  position: fixed; inset: 60px 16px auto auto; margin: 0; width: min(280px, 100vw - 32px);
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--text); box-shadow: 0 12px 40px rgb(0 0 0 / .3);
}
#user-menu h3 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.um-who { margin: 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.um-who b { color: var(--text); }
.choices { display: flex; flex-direction: column; gap: 2px; }
.choice {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px;
  font: inherit; font-size: 14px; text-align: left; color: var(--text); background: none; cursor: pointer;
}
.choice:hover { background: var(--panel-2); }
.choice[aria-checked="true"] { background: var(--accent-soft); font-weight: 600; }
.choice[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--accent); }
/* A swatch carries its own data-theme, so it shows that theme's colors. */
.swatch {
  width: 22px; height: 22px; border-radius: 50%; flex: none; border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--bg) 0 50%, var(--accent) 50% 100%);
}
.um-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.um-foot .btn { width: 100%; justify-content: center; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg-btn { display: grid; place-items: center; width: 36px; height: 34px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn svg { width: 18px; height: 18px; }
.seg-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

.more { display: flex; justify-content: center; padding: 24px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 80px 16px; }

/* Preview */
dialog {
  border: 0; padding: 0; color: var(--text); background: var(--panel);
  border-radius: var(--radius); box-shadow: 0 20px 60px rgb(0 0 0 / .35);
}
dialog::backdrop { background: rgb(0 0 0 / .5); }
#preview { width: min(1120px, 100vw - 32px); height: min(92vh, 100%); max-height: 92vh; }
#preview[open] { display: flex; flex-direction: column; }
@media (max-width: 640px) {
  #preview { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
}
.pv-bar, .pv-foot { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 20px; border-bottom: 1px solid var(--line); }
.pv-foot { justify-content: flex-end; border-bottom: 0; border-top: 1px solid var(--line); padding: 12px 20px; }
.pv-meta { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-nav { display: flex; gap: 2px; }
.pv-scroll { flex: 1; overflow-y: auto; }
.pv-body { max-width: 840px; margin: 0 auto; padding: 24px 20px 40px; }
.pv-body h1 { margin: 0 0 16px; font-size: 28px; line-height: 1.2; }
#pv-image { width: 100%; max-height: 520px; object-fit: cover; border-radius: 8px; margin-bottom: 16px; }
.pv-content { font-size: 17px; line-height: 1.6; overflow-wrap: anywhere; }
.pv-content img, .pv-content video { max-width: 100%; height: auto; border-radius: 6px; }
.pv-content figure { margin: 16px 0; }
.pv-content figcaption { font-size: 13px; color: var(--muted); }
.pv-content pre { overflow-x: auto; background: var(--panel-2); padding: 12px; border-radius: 6px; }
.pv-content a { color: var(--accent); }
.pv-content .lead { color: var(--muted); font-style: italic; }

/* Category settings */
#settings, #feed-settings { width: min(520px, 100vw - 32px); }
.settings { display: flex; flex-direction: column; gap: 8px; padding: 20px 24px; max-height: 88vh; overflow-y: auto; }
.settings h2 { margin: 0 0 8px; font-size: 20px; }
/* flex: none, or a long feed list squeezes the keywords box instead of the dialog scrolling. */
.settings textarea { flex: none; min-height: 9em; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); resize: vertical; }
.settings fieldset { flex: none; border: 0; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.settings legend { padding: 0; margin-bottom: 4px; }
.hint { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; }
/* Stays at the bottom of the dialog while a long feed list scrolls. */
.settings-foot {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px;
  position: sticky; bottom: -20px; margin-bottom: -20px; padding: 12px 0 20px;
  background: var(--panel); border-top: 1px solid var(--line);
}

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--error); color: #fff; }

/* Login */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login form { display: flex; flex-direction: column; gap: 10px; width: min(380px, 100%); background: var(--panel); padding: 28px; border-radius: var(--radius); box-shadow: var(--shadow); }
.login h1 { margin: 0 0 8px; font-size: 26px; }
.login input { font: inherit; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.login .btn { justify-content: center; margin-top: 6px; }
.error { color: var(--error); margin: 0; }
