:root {
  --bg: #fbfaf7; --fg: #1f1f1f; --muted: #6b6b6b; --line: #e6e3dc;
  --card: #ffffff; --accent: #2b6cb0; --danger: #b42318;
  --fs: 19px;
}
:root[data-theme="dark"] {
  --bg: #121212; --fg: #d8d8d8; --muted: #8d8d8d; --line: #262626;
  --card: #1b1b1b; --accent: #7fb2ee; --danger: #f08b82;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #121212; --fg: #d8d8d8; --muted: #8d8d8d; --line: #262626;
    --card: #1b1b1b; --accent: #7fb2ee; --danger: #f08b82;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); }
button, input {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .9rem;
}
button { cursor: pointer; }
button.danger { color: var(--danger); }
.error { color: var(--danger); margin: 0; }

.narrow { max-width: 22rem; margin: 20vh auto 0; padding: 0 1.25rem; }
.stack { display: grid; gap: .75rem; }
.switch { margin-top: 1.25rem; text-align: center; }

.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center;
  justify-content: space-between; gap: .5rem; flex-wrap: wrap; padding: .6rem 1rem;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.actions { display: flex; gap: .4rem; }
.actions form { margin: 0; }
.actions button { padding: .35rem .7rem; }
.tabs { display: flex; gap: 1rem; }
.tabs a { color: var(--muted); text-decoration: none; padding: .3rem 0; }
.tabs a.active { color: var(--fg); font-weight: 600; border-bottom: 2px solid var(--accent); }
.tabs small { color: var(--muted); font-weight: 400; }
.back { font-size: 1.4rem; text-decoration: none; }

.list { max-width: 44rem; margin: 0 auto; padding: .75rem 1rem 3rem; }
.card {
  margin-bottom: .6rem; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px;
}
.card-link { display: block; padding: .9rem 1rem .5rem; color: inherit; text-decoration: none; }
.card h2 { margin: 0 0 .25rem; font-size: 1.05rem; line-height: 1.3; }
.meta { margin: 0; color: var(--muted); font-size: .85rem; }
.excerpt {
  margin: .4rem 0 0; color: var(--muted); font-size: .9rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.empty { color: var(--muted); text-align: center; margin-top: 4rem; }

.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 10; }
#progress-bar { height: 100%; width: 0; background: var(--accent); }

.article { max-width: 40rem; margin: 0 auto; padding: 1.5rem 1.1rem 5rem; }
:root[data-font="serif"] .article { font-family: Charter, "Iowan Old Style", Georgia, serif; }
:root[data-font="sans"] .article { font-family: system-ui, -apple-system, sans-serif; }
.article h1 { font-size: 1.8em; line-height: 1.2; margin: 0 0 .4rem; }
.article .meta { margin-bottom: 1.8rem; }
.content { font-size: var(--fs); line-height: 1.65; overflow-wrap: break-word; }
.content h2, .content h3 { line-height: 1.25; margin-top: 2em; }
.content img, .content video { max-width: 100%; height: auto; border-radius: 6px; }
.content blockquote { margin: 1.2em 0; padding-left: 1em; border-left: 3px solid var(--line); color: var(--muted); }
.content pre { overflow-x: auto; background: var(--card); border: 1px solid var(--line); padding: .8em; border-radius: 8px; font-size: .85em; }
.content code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: .08em .3em; }
.content pre code { background: none; border: 0; padding: 0; font-size: 1em; }
.content table { display: block; overflow-x: auto; border-collapse: collapse; }
.content td, .content th { border: 1px solid var(--line); padding: .3em .6em; }
.item-actions { display: flex; gap: .5rem; margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); font-family: system-ui, sans-serif; }
.item-actions form { margin: 0; }

.settings {
  position: fixed; top: 3.2rem; right: .75rem; z-index: 20; width: 16rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .75rem; box-shadow: 0 8px 24px rgba(0,0,0,.18); display: grid; gap: .6rem;
}
.settings[hidden] { display: none; }
.settings .row { display: flex; align-items: center; gap: .4rem; }
.settings .row span { width: 3.2rem; color: var(--muted); font-size: .85rem; }
.settings .row button { padding: .3rem .6rem; flex: 1; }
.brand { margin: 0 0 .25rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; }
.add { display: flex; gap: .5rem; margin-bottom: .9rem; }
.add input { flex: 1; min-width: 0; }
.add.busy button { opacity: .6; pointer-events: none; }
.iconbtn { display: inline-block; padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: inherit; text-decoration: none; }
.list .error { margin: 0 0 .9rem; }
.page { max-width: 40rem; margin: 0 auto; padding: 1.5rem 1.1rem 4rem; }
.page h1 { font-size: 1.4rem; }
.page h2 { font-size: 1.05rem; margin-top: 2rem; }
.page code, .tokenbox { word-break: break-all; }
.tokenbox { display: block; padding: .7rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; }
.bookmarklet { display: inline-block; padding: .5rem 1rem; border: 1px dashed var(--accent); border-radius: 8px; text-decoration: none; }

.card-actions { display: flex; gap: .4rem; padding: 0 .75rem .7rem; }
.card-actions form { margin: 0; }
.card-actions button { padding: .4rem .8rem; min-height: 40px; font-size: .85rem; background: transparent; color: var(--muted); }
.card-actions button.danger { color: var(--danger); }
button, .iconbtn, .tabs a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) {
  .actions button, .iconbtn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .tabs a { padding: .6rem 0; }
  input { min-height: 46px; font-size: 16px; }
  .item-actions button { min-height: 44px; }
}
.page ol { padding-left: 1.2rem; }
.page li { margin-bottom: .5rem; }
.add.upload input[type=file] { padding: .4rem .6rem; font-size: .85rem; color: var(--muted); }

.content a[href^="http"]:not([href*="slowscroll.app"])::after { content: "\2197"; font-size: .75em; margin-left: .15em; opacity: .6; }
.linksheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-width: 40rem; margin: 0 auto;
  padding: 1rem 1.1rem calc(1rem + env(safe-area-inset-bottom)); background: var(--card);
  border: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px rgba(0,0,0,.18);
  font-family: system-ui, sans-serif;
}
.linksheet[hidden] { display: none; }
.linksheet-host { margin: 0 0 .75rem; font-weight: 600; word-break: break-all; }
.linksheet-msg { margin: 0 0 .75rem; }
.linksheet-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.linksheet-actions button, .linksheet-actions .iconbtn { min-height: 44px; display: inline-flex; align-items: center; }

.feedbar { display: flex; gap: .5rem; margin-bottom: .9rem; align-items: center; }
.feedbar form { margin: 0; }
.feedrow { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.feedrow form { margin: 0; }
.feedrow div { min-width: 0; word-break: break-all; }
.muted { color: var(--muted); }

.excerpt mark, .snippet mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 2px; }
.card .tags { margin: .25rem 0 0; color: var(--accent); }
.tagbox { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 2.5rem; font-family: system-ui, sans-serif; align-items: center; }
.tagchip { display: inline-flex; margin: 0; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.tagchip a { padding: .25rem .2rem .25rem .7rem; text-decoration: none; }
.tagchip button { border: 0; background: none; padding: .25rem .6rem .25rem .3rem; color: var(--muted); }
.tagadd { display: flex; gap: .3rem; margin: 0; }
.tagadd input { padding: .3rem .6rem; width: 8rem; }
.tagadd button { padding: .3rem .7rem; }
.item-actions { margin-top: 1.5rem; padding-top: 1rem; }
.content mark.hl { background: color-mix(in srgb, #f2c744 45%, transparent); color: inherit; border-radius: 2px; cursor: pointer; }
.hlbar { z-index: 31; }
.hlquote { position: relative; padding-right: 2.5rem; }
.hlquote form { position: absolute; top: .2rem; right: 0; margin: 0; }
.hlquote button { border: 0; background: none; color: var(--muted); font-size: 1.2rem; }
