:root {
  --paper: #f5efe4;
  --paper-2: #ece4d5;
  --ink: #2b2620;
  --ink-2: #625849;
  --line: #d9cfbd;
  --fikusas: #3d6b47;
  --fikusas-soft: #dfe8d8;
  --daiktai: #a24f2c;
  --daiktai-soft: #f1dccd;
  --gold: #a8730b;
  --gold-soft: #f6e5b8;
  --gold-ink: #5a3d00;
  --shadow: 0 6px 20px -8px rgb(60 40 20 / 0.28);
  --serif: "Iowan Old Style", "Charter", "Bitstream Charter", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --dock-h: 148px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1815;
    --paper-2: #24211c;
    --ink: #ebe3d5;
    --ink-2: #b3a894;
    --line: #3a352d;
    --fikusas: #93c08f;
    --fikusas-soft: #26332a;
    --daiktai: #e39a72;
    --daiktai-soft: #3a2a21;
    --gold: #f0c25a;
    --gold-soft: #3d3218;
    --gold-ink: #f6dc9c;
    --shadow: 0 6px 20px -8px rgb(0 0 0 / 0.6);
  }
}
body[data-series="fikusas"] { --accent: var(--fikusas); --accent-soft: var(--fikusas-soft); }
body[data-series="daiktai"] { --accent: var(--daiktai); --accent-soft: var(--daiktai-soft); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--paper); color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--accent-soft); color: var(--ink); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
svg { width: 22px; height: 22px; flex: none; }

/* ---------- viršus ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 6px) 8px 6px 16px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.series { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .3s; }
.series .mark { font-size: 20px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 0; }
.lang button { min-width: 44px; height: 44px; border: 0; background: none; border-radius: 999px; font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--ink-2); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; border-radius: 12px; cursor: pointer; color: var(--ink); }
.icon-btn:active { background: var(--paper-2); }

/* ---------- skaitymas ---------- */
main { outline: none; padding: 8px 22px calc(var(--dock-h) + env(safe-area-inset-bottom) + 28px); touch-action: pan-y; }
article { max-width: 34rem; margin: 0 auto; }
article.out-left { animation: outLeft .16s ease-in forwards; }
article.out-right { animation: outRight .16s ease-in forwards; }
article.in-right { animation: inRight .26s cubic-bezier(.16,1,.3,1); }
article.in-left { animation: inLeft .26s cubic-bezier(.16,1,.3,1); }
@keyframes outLeft { to { transform: translateX(-28px); opacity: 0; } }
@keyframes outRight { to { transform: translateX(28px); opacity: 0; } }
@keyframes inRight { from { transform: translateX(28px); opacity: 0; } }
@keyframes inLeft { from { transform: translateX(-28px); opacity: 0; } }

.pending { display: inline-block; margin: 14px 0 0; padding: 4px 10px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); font-size: 13px; }
h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.75rem, 7vw, 2.25rem); line-height: 1.15; letter-spacing: -0.01em;
  margin: 22px 0 22px; text-wrap: balance;
}
.text p {
  font-family: var(--serif); font-size: 1.25rem; line-height: 1.6;
  margin: 0 0 1em; text-wrap: pretty; hyphens: manual;
}
.end-mark { text-align: center; color: var(--line); letter-spacing: .4em; margin: 26px 0 10px; font-size: 18px; }

.comment { margin-top: 6px; }
.link-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--ink-2); font-size: 15px; cursor: pointer; }
.link-btn svg { width: 20px; height: 20px; }
.link-btn.has { color: var(--accent); }
#commentForm { margin-top: 6px; }
textarea, input {
  width: 100%; font: 16px/1.45 var(--sans); color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  caret-color: var(--accent);
}
textarea { resize: vertical; min-height: 96px; }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.row { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 8px; }
.saved { color: var(--accent); font-size: 14px; }
.small-btn { min-height: 44px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--ink); color: var(--paper); font-weight: 600; cursor: pointer; }

/* ---------- apatinė juosta ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.reactions, .dock-row { max-width: 34rem; margin: 0 auto; }
.reactions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.react {
  height: 52px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper);
  font-size: 26px; line-height: 1; cursor: pointer; transition: transform .15s, background .2s, border-color .2s;
}
.react:active { transform: scale(.94); }
.react[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.react.pop { animation: pop .35s cubic-bezier(.16,1,.3,1); }
@keyframes pop { 40% { transform: scale(1.18); } }

.dock-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.super {
  display: inline-flex; align-items: center; gap: 6px; height: 48px; padding: 0 14px 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer;
  font-weight: 650; font-size: 15px; color: var(--ink);
  transition: background .25s, border-color .25s, color .25s;
}
.super .star { font-size: 19px; filter: grayscale(.5); transition: filter .25s; }
.super .left { font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 700; }
.super[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-ink); box-shadow: 0 4px 14px -6px var(--gold); }
.super[aria-pressed="true"] .star { filter: none; }
.super.burst .star { animation: star .6s cubic-bezier(.16,1,.3,1); }
.super.empty { animation: shake .35s; }
@keyframes star { 0% { transform: scale(.6) rotate(-30deg); } 50% { transform: scale(1.5) rotate(12deg); } 100% { transform: none; } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.progress { flex: 1; text-align: center; color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.next {
  display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px 0 20px;
  border: 0; border-radius: 999px; background: var(--accent); color: var(--paper); font-weight: 650; font-size: 16px; cursor: pointer;
}
.next:active { transform: scale(.97); }

/* ---------- pranešimas ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 12px); z-index: 7;
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 26rem); padding: 10px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper); font-size: 15px; text-align: center; box-shadow: var(--shadow);
  transition: opacity .2s, transform .3s cubic-bezier(.16,1,.3,1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- meniu ---------- */
dialog { color: var(--ink); background: var(--paper); border: 0; padding: 0; }
dialog::backdrop { background: rgb(20 15 10 / .45); }
.sheet {
  width: 100%; max-width: 34rem; margin: auto auto 0; border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 24px); max-height: 88dvh; overflow: auto;
}
.sheet[open] { animation: up .3s cubic-bezier(.16,1,.3,1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { font-family: var(--serif); font-size: 1.4rem; margin: 0; }
.sheet h3 { font-size: 15px; margin: 24px 0 8px; color: var(--ink-2); font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 16px 0 0; }
legend, .field > span { font-size: 15px; color: var(--ink-2); font-weight: 600; margin-bottom: 8px; display: block; padding: 0; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--paper-2); border-radius: 14px; padding: 4px; }
.seg button { min-height: 44px; border: 0; border-radius: 10px; background: none; cursor: pointer; font-size: 15px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px -1px rgb(0 0 0 / .2); }
.field { display: block; margin-top: 22px; }
.field small { display: block; margin-top: 6px; color: var(--ink-2); font-size: 13px; }
.mine ul { list-style: none; margin: 0; padding: 0; }
.mine li { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.mine li:first-child { border-top: 0; }
.mine .go { flex: 1; text-align: left; min-height: 48px; border: 0; background: none; cursor: pointer; font-family: var(--serif); font-size: 17px; padding: 0; }
.mine .rm { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--ink-2); font-size: 14px; cursor: pointer; }
.mine .empty { color: var(--ink-2); font-size: 15px; padding: 6px 0; }

/* ---------- pirmas apsilankymas ---------- */
.intro { width: min(92vw, 26rem); border-radius: 22px; box-shadow: var(--shadow); }
.intro-body { padding: 28px 24px 24px; }
.intro-marks { font-size: 30px; margin: 0; letter-spacing: .2em; }
.intro h2 { font-family: var(--serif); font-size: 1.6rem; line-height: 1.2; margin: 12px 0 12px; }
.intro p { font-size: 17px; line-height: 1.55; color: var(--ink-2); margin: 0; }
.start { width: 100%; height: 52px; margin-top: 22px; border: 0; border-radius: 14px; background: var(--fikusas); color: var(--paper); font-size: 17px; font-weight: 650; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
