:root {
  color-scheme: light;
  --page-background: #fff;
  --feed-background: #f6f6ef;
  --text: #1a1a1a;
  --muted-text: #626262;
  --story-divider: #d5d5cc;
  --field-background: #fff;
  --field-border: #77776d;
  --btc-price-color: #805000;
  --btc-glitch-color: #087e75;
  --btc-gain-color: #156837;
  --btc-loss-color: #a32424;
  --accent: #ff6600;
  --header-background: var(--accent);
  --header-text: #000;
  --theme-duration: 420ms;
  --theme-ease: cubic-bezier(.22, .75, .25, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-background: #11110f;
  --feed-background: #201f1b;
  --text: #efede7;
  --muted-text: #bab7ad;
  --story-divider: #4b4942;
  --field-background: #292823;
  --field-border: #888478;
  --btc-price-color: #ffd581;
  --btc-glitch-color: #1af0dc;
  --btc-gain-color: #64df91;
  --btc-loss-color: #ff8383;
  --accent: #ff8a45;
  --header-background: #35291f;
  --header-text: #ffd1ae;
}

body {
  margin: 8px 0;
  background: var(--page-background);
  color: var(--text);
  font: 13px/1.45 Verdana, Geneva, sans-serif;
}

body,
main,
.feed-header {
  transition: background-color var(--theme-duration) ease, color var(--theme-duration) ease,
    border-color var(--theme-duration) ease;
}

main {
  border-bottom: 2px solid var(--accent);
  background: var(--feed-background);
}

.btc-ticker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 2px 10px;
  padding: 2px 8px;
  color: var(--btc-price-color);
}

.btc-ticker img {
  display: block;
}

.btc-change:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btc-change[data-direction="up"] {
  color: var(--btc-gain-color);
}

.btc-change[data-direction="down"] {
  color: var(--btc-loss-color);
}

.btc-change-window,
.btc-pair,
#btc-price-status {
  color: var(--muted-text);
  font-size: 11px;
}

#btc-change-arrow:empty {
  display: none;
}

.btc-quote {
  position: relative;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#btc-price-actual {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

#btc-price {
  font-size: 16px;
}

.btc-price-glitch-digit {
  display: inline-block;
  clip-path: inset(-.2em 0);
}

.btc-price-glitch-face {
  position: relative;
  display: block;
  animation: btc-price-glitch 440ms step-end;
}

.btc-price-glitch-face::before,
.btc-price-glitch-face::after {
  content: attr(data-digit);
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--feed-background);
  color: var(--btc-glitch-color);
  opacity: 0;
}

.btc-price-glitch-face::before {
  text-shadow: -.09em 0 #52de42, -.18em 0 #ff00e1;
  animation: btc-glitch-upper 440ms step-end;
}

.btc-price-glitch-face::after {
  text-shadow: .09em 0 #ff00e1, .18em 0 #52de42;
  animation: btc-glitch-lower 440ms step-end;
}

@keyframes btc-price-glitch {
  0%, 26%, 80%, 100% { transform: scaleX(1); }
  10%, 58% { transform: scaleX(.94); }
  38% { transform: scaleX(1.08); }
}

@keyframes btc-glitch-upper {
  0%, 26%, 52%, 78%, 100% { opacity: 0; }
  8% { opacity: 1; clip-path: inset(12% 0 68%); transform: translateX(5%); }
  35% { opacity: 1; clip-path: inset(34% 0 48%); transform: translateX(7%); }
  62% { opacity: 1; clip-path: inset(5% 0 79%); transform: translateX(3%); }
}

@keyframes btc-glitch-lower {
  0%, 32%, 59%, 86%, 100% { opacity: 0; }
  15% { opacity: 1; clip-path: inset(56% 0 22%); transform: translateX(-5%); }
  42% { opacity: 1; clip-path: inset(76% 0 10%); transform: translateX(-7%); }
  68% { opacity: 1; clip-path: inset(44% 0 28%); transform: translateX(-3%); }
}

#btc-price-status:empty {
  position: absolute;
}

.feed-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 4px 8px;
  background: var(--header-background);
  color: var(--header-text);
}

.feed-header h1 {
  margin: 0;
  font-size: 14px;
}

.feed-profile {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: inherit;
  text-decoration: none;
}

.feed-profile:hover {
  text-decoration: underline;
}

.feed-profile:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

#theme-toggle {
  margin: 4px 6px 7px;
  padding: 2px;
  border: 1px solid #fffc;
  border-radius: 99px;
  background: linear-gradient(165deg, #fff 30%, #eef0f2 72%, #dfe3e8);
  box-shadow:
    inset 0 1px 1px #fff,
    0 2px 0 #a8afb9,
    0 5px 8px #17141055,
    0 9px 16px #17141030;
  cursor: pointer;
  transition: transform var(--theme-duration) var(--theme-ease), box-shadow var(--theme-duration) ease;
}

#theme-toggle:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 1px #fff,
    0 1px 0 #a8afb9,
    0 2px 4px #17141055;
}

.theme-sky {
  position: relative;
  display: block;
  width: 92px;
  height: 32px;
  overflow: hidden;
  isolation: isolate;
  border-radius: inherit;
  background: linear-gradient(115deg, #6cb7c4, #38869c);
  box-shadow: inset 0 1px 3px #163c4d66, 0 1px 1px #0003;
}

.theme-sky::before,
.theme-stars,
.theme-clouds {
  position: absolute;
  inset: 0;
  transition: opacity var(--theme-duration) ease, transform var(--theme-duration) var(--theme-ease);
}

.theme-sky::before {
  content: "";
  background: linear-gradient(120deg, #071322, #143149);
  opacity: 0;
}

.theme-clouds > span {
  position: absolute;
  width: 27px;
  height: 14px;
  background:
    radial-gradient(ellipse 46% 28% at 50% 72%, #e1f3f8 92%, transparent),
    radial-gradient(circle at 30% 62%, #edf9fb 21%, transparent 25%),
    radial-gradient(circle at 51% 42%, #fff 29%, transparent 33%),
    radial-gradient(circle at 71% 56%, #effaff 21%, transparent 25%);
}

.theme-clouds > span:nth-child(1) {
  top: 2px;
  left: 33px;
  opacity: .6;
}

.theme-clouds > span:nth-child(2) {
  bottom: 1px;
  left: 39px;
}

.theme-clouds > span:nth-child(3) {
  top: 7px;
  right: 4px;
  transform: scale(.7);
  opacity: .85;
}

.theme-stars {
  background:
    radial-gradient(circle at 14% 35%, #e9eff9 0.6px, transparent 1.2px),
    radial-gradient(circle at 24% 20%, #dbe9fa 0.5px, transparent 1.1px),
    radial-gradient(circle at 29% 56%, #c9dcf2 0.6px, transparent 1.2px),
    radial-gradient(circle at 39% 27%, #a5c4e3 0.5px, transparent 1.1px),
    radial-gradient(circle at 45% 68%, #b8d4eb 0.5px, transparent 1.1px),
    radial-gradient(circle at 53% 39%, #e9eff9 0.7px, transparent 1.3px),
    radial-gradient(circle at 59% 76%, #dbe9fa 0.5px, transparent 1.1px),
    radial-gradient(ellipse 38px 16px at 4% 116%, #17384f 96%, transparent);
  opacity: 0;
  transform: translateY(-6px);
}

.theme-orb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff44d, #ffc000);
  box-shadow: 0 0 7px #ffe200b3;
  transition: transform var(--theme-duration) var(--theme-ease), box-shadow var(--theme-duration) ease;
}

.theme-orb::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 30% 38%, #d8d6ca 2px, transparent 2.5px),
    radial-gradient(circle at 47% 23%, #d9d6cb 1.3px, transparent 1.8px),
    radial-gradient(circle at 70% 63%, #d8d6ca 3px, transparent 3.5px),
    radial-gradient(circle at 32% 72%, #dfdccf 1.5px, transparent 2px),
    linear-gradient(145deg, #fffbee, #e6e0ce);
  content: "";
  opacity: 0;
  transition: opacity var(--theme-duration) ease;
}

#theme-toggle[aria-pressed="true"] .theme-sky::before,
#theme-toggle[aria-pressed="true"] .theme-orb::after {
  opacity: 1;
}

#theme-toggle[aria-pressed="true"] .theme-clouds {
  opacity: 0;
  transform: translateY(9px);
}

#theme-toggle[aria-pressed="true"] .theme-stars {
  opacity: 1;
  transform: translateY(0);
}

#theme-toggle[aria-pressed="true"] .theme-orb {
  transform: translateX(60px);
  box-shadow: 0 0 8px #b9d5f0b3;
}

#theme-toggle:focus-visible {
  outline: 2px solid var(--header-text);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --theme-duration: 0ms;
  }

  .btc-price-glitch-face,
  .btc-price-glitch-face::before,
  .btc-price-glitch-face::after {
    animation: none;
  }
}

.story-filters:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--story-divider);
}

.story-filters label:not([hidden]) {
  display: grid;
  gap: 3px;
  font-size: 11px;
  color: var(--muted-text);
}

.story-search {
  flex: 1 1 200px;
  min-width: 0;
}

.story-range:not([hidden]) {
  display: contents;
}

.story-filters :is(input, select),
.story-pagination button {
  box-sizing: border-box;
  min-height: 32px;
  max-width: 100%;
  padding: 4px 7px;
  border: 1px solid var(--field-border);
  border-radius: 3px;
  background: var(--field-background);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.story-filters :is(input, select):focus-visible,
.story-pagination button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.story-results {
  margin: 0;
  color: var(--muted-text);
  font-size: 11px;
}

.story-results:not(:empty) {
  padding: 8px 8px 0;
}

.feed-tabs:not([hidden]) {
  display: flex;
  gap: 4px;
  padding: 0 8px;
  border-bottom: 1px solid var(--story-divider);
}

.feed-tabs button {
  min-height: 38px;
  padding: 8px 12px 6px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted-text);
  font: inherit;
  cursor: pointer;
}

.feed-tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: bold;
}

.todo-count {
  margin-left: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.feed-tabs button:focus-visible,
.story-actions button:focus-visible,
.todo-remove:focus-visible,
.todo-label input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#stories,
.story-measurement {
  margin: 0;
  padding: 10px 8px 12px;
  list-style-type: "";
  overflow-wrap: anywhere;
}

#stories {
  --story-row-spacing: 6px;
  --story-divider-width: 1px;
}

:is(#stories, .story-measurement) > li {
  position: relative;
  min-height: 28px;
  padding-right: 36px;
}

.story-subject {
  color: var(--accent);
  font-weight: 700;
}

.story-actions {
  position: absolute;
  top: 0;
  right: 0;
}

#stories > li:not([hidden]) ~ li:not([hidden]) .story-actions {
  top: var(--story-row-spacing);
}

.story-bookmark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  background: var(--feed-background);
  color: var(--muted-text);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.story-bookmark[aria-pressed="true"] svg {
  fill: currentColor;
}

#stories > li:hover .story-bookmark,
#stories > li:focus-within .story-bookmark,
.story-bookmark[aria-pressed="true"] {
  opacity: 1;
  pointer-events: auto;
}

.story-bookmark:hover,
.story-bookmark[aria-pressed="true"] {
  border-color: var(--story-divider);
  color: var(--text);
}

.todo-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 12px 8px 6px;
}

.todo-heading h2 {
  margin: 0;
  font-size: 13px;
}

.todo-heading p,
.todo-empty,
.todo-status {
  margin: 0;
  color: var(--muted-text);
  font-size: 11px;
}

.todo-empty,
.todo-status:not(:empty) {
  padding: 8px 8px 14px;
}

#todo-list {
  margin: 0;
  padding: 0 8px;
  list-style: none;
  overflow-wrap: anywhere;
}

.todo-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
}

.todo-row + .todo-row {
  border-top: 1px solid var(--story-divider);
}

.todo-content {
  flex: 1;
  min-width: 0;
}

.todo-label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
}

.todo-label input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.todo-row.is-complete .todo-text {
  color: var(--muted-text);
  text-decoration: line-through;
}

.todo-sources {
  margin: 3px 0 0 25px;
  font-size: 11px;
}

.todo-sources a {
  color: var(--muted-text);
  text-underline-offset: .14em;
}

.todo-remove {
  flex: none;
  min-height: 30px;
  padding: 4px 7px;
  border: 1px solid var(--story-divider);
  border-radius: 3px;
  background: var(--field-background);
  color: var(--muted-text);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.todo-remove:hover {
  color: var(--text);
  border-color: var(--field-border);
}

@media (hover: none), (pointer: coarse) {
  .story-bookmark {
    opacity: 1;
    pointer-events: auto;
  }
}

.story-measurement {
  position: fixed;
  top: 0;
  left: 0;
  box-sizing: border-box;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

#stories > li:not([hidden]) ~ li:not([hidden]) {
  margin-top: var(--story-row-spacing);
  padding-top: var(--story-row-spacing);
  border-top: var(--story-divider-width) solid var(--story-divider);
}

:is(#stories, .story-measurement) :is(time, a) {
  color: var(--muted-text);
  font-size: 11px;
  white-space: nowrap;
}

#stories a {
  white-space: nowrap;
  text-underline-offset: 0.14em;
}

.story-pagination:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  padding: 8px;
  border-top: 1px solid var(--story-divider);
  color: var(--muted-text);
  font-size: 11px;
}

.story-pagination button:enabled {
  cursor: pointer;
}

.story-pagination button:disabled {
  color: var(--muted-text);
  opacity: .6;
}

@media (max-width: 750px) {
  body {
    margin: 0;
  }
}
