/*
 * @us 1061 — Lygiai su paslėptu paveikslu ir rakteliais
 *          https://dev.azure.com/domesprojektai/KnyguValdovas/_workitems/edit/1061
 * @us 1062 — Perskaitytos knygos pridėjimas ir atsakymai raštu ar balsu
 *          https://dev.azure.com/domesprojektai/KnyguValdovas/_workitems/edit/1062
 * @us 1067 — Projekto sąranka, vietinis testavimas ir DevOps
 *          https://dev.azure.com/domesprojektai/KnyguValdovas/_workitems/edit/1067
 */
/* Knygų Valdovas — one stylesheet. Calm and readable: Lexend for text, Literata for titles. */

:root {
  --bg: #f5f4f0; --card: #fff; --ink: #1c2230; --muted: #5f687a; --faint: #8b93a3; --line: #e3e1da; --soft: #f0eee8;
  --pri: #2d4f8b; --pri-hover: #24427a; --pri-soft: #e8eef8;
  --accent: #a86b12; --accent-soft: #fbf1df;
  --ok: #2f7d4f; --ok-soft: #e6f2ea; --warn: #a65a0a; --warn-soft: #fdf0e1; --no: #b42318; --no-soft: #fbe9e7;
  --frame: #1c2230; --cell: #2a3346; --cell-2: #313b50;
  --r: 12px; --r-s: 8px;
  --shadow: 0 1px 2px rgba(28, 34, 48, .06), 0 1px 1px rgba(28, 34, 48, .04);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --serif: "Literata", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.5 "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: var(--pri); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.005em; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 17px; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── shell ───────── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + var(--sat)) 20px 10px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 600 19px/1 var(--serif); white-space: nowrap; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.who {
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; background: var(--card); color: var(--muted);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.who.demo { border-color: #e8c98e; background: var(--accent-soft); color: var(--accent); }
.who { max-width: 55vw; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 440px) { .brand span { display: none; } }
.tabs { margin-left: auto; display: flex; gap: 2px; }
.tabs a {
  display: flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px;
  padding: 8px 12px; border-radius: var(--r-s);
}
.tabs a:hover { background: var(--soft); color: var(--ink); }
.tabs a.on { color: var(--pri); background: var(--pri-soft); }
@media (max-width: 640px) {
  .top { padding: calc(8px + var(--sat)) 16px 8px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 30; justify-content: space-around;
          background: var(--card); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--sab)); }
  .tabs a { flex-direction: column; gap: 3px; font-size: 12px; padding: 6px 12px; }
  .tabs a .ico { width: 22px; height: 22px; }
  .view { padding-bottom: calc(84px + var(--sab)) !important; }
  .who { margin-left: auto; }
}
.view { max-width: 1040px; margin: 0 auto; padding: 24px 20px 48px; }
@media (max-width: 640px) { .view { padding: 16px 16px 40px; } }
.loading { padding: 48px; text-align: center; color: var(--muted); }

/* ───────── generic bits ───────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card.tight { padding: 14px 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 16px; min-height: 44px;
  background: var(--card); color: var(--ink); font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: var(--pri-hover); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.no { color: var(--no); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--pri); padding-left: 6px; padding-right: 6px; }
.btn.ghost:hover { background: var(--pri-soft); }
.btn.big { font-size: 17px; padding: 13px 22px; min-height: 52px; }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 14px; }
.btn.block { width: 100%; }

.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 500;
        background: var(--soft); color: var(--muted); white-space: nowrap; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip.plain::before { display: none; }
.chip.pri { background: var(--pri-soft); color: var(--pri); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.no { background: var(--no-soft); color: var(--no); }

label.f { display: block; font-weight: 500; font-size: 14px; margin: 14px 0 6px; }
.in, textarea.in, select.in {
  width: 100%; border: 1px solid #d4d1c8; border-radius: var(--r-s); padding: 10px 12px; background: #fff; min-height: 44px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.in:focus { border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft); }
.in.lg { font-size: 18px; }
textarea.in { min-height: 88px; resize: vertical; line-height: 1.5; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.err { color: var(--no); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.notice { border-radius: var(--r-s); padding: 12px 14px; background: var(--soft); color: var(--ink); margin: 12px 0 0; font-size: 15px; }
.notice.pri { background: var(--pri-soft); }
.notice.ok { background: var(--ok-soft); }
.notice.warn { background: var(--warn-soft); }
.notice.no { background: var(--no-soft); }

/* ───────── home: level header ───────── */
.level-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.level-num { flex: none; width: 64px; height: 64px; border-radius: 14px; display: grid; place-items: center; text-align: center;
             background: var(--pri); color: #fff; }
.level-num b { display: block; font: 600 28px/1 var(--serif); }
.level-num span { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.progress { height: 6px; border-radius: 999px; background: var(--soft); overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--pri); transition: width .6s; }
.level-path { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.level-path span { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 7px; display: grid; place-items: center;
                   font-size: 13px; font-weight: 500; background: var(--soft); color: var(--faint); }
.level-path span.done { background: var(--ok-soft); color: var(--ok); }
.level-path span.now { background: var(--pri); color: #fff; }

/* ───────── the picture ───────── */
.board { position: relative; display: grid; gap: 2px; padding: 2px; border-radius: var(--r); background: var(--frame);
         box-shadow: var(--shadow); overflow: hidden; user-select: none; }
.board.done { gap: 0; padding: 0; }
.piece { position: relative; overflow: hidden; border-radius: 3px; background: var(--cell); }
.board.done .piece { border-radius: 0; }
.piece img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; display: block; }
.piece.closed { cursor: pointer; background: linear-gradient(145deg, var(--cell-2), var(--cell)); }
.piece.closed:hover { background: linear-gradient(145deg, #3a4560, var(--cell-2)); }
.piece .n { position: absolute; left: 7px; top: 5px; font-size: 11px; font-weight: 500; color: rgba(255,255,255,.35); }
.piece .mark { position: absolute; right: 6px; top: 6px; color: #e6b65c; }
.piece .mark .ico { width: 16px; height: 16px; }
.piece.noimg { display: grid; place-items: center; background: #3b475f; color: rgba(255,255,255,.75); font-size: 12px; }
.piece.fresh { animation: kv-reveal 1.1s ease-out; z-index: 1; }
.piece.fresh::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px #f2c66d; animation: kv-ring 2.6s ease-out forwards; }
@keyframes kv-reveal { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes kv-ring { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* lists of books */
.blist { display: flex; flex-direction: column; }
.bitem { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.blist > .bitem:first-child { border-top: 0; }
a.bitem:hover .btitle { color: var(--pri); }
.bcards { display: flex; flex-direction: column; gap: 10px; }
.bcards .bitem { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.bthumb { flex: none; width: 44px; height: 60px; border-radius: 5px; background: var(--pri-soft); color: var(--pri); display: grid; place-items: center; overflow: hidden; }
.bthumb img { width: 100%; height: 100%; object-fit: cover; }
.btitle { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
.bmeta { font-size: 13px; color: var(--muted); }
.bitem .side { margin-left: auto; flex: none; display: flex; gap: 6px; align-items: center; }
.cellno { flex: none; min-width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; font-size: 13px; font-weight: 600;
          background: var(--accent-soft); color: var(--accent); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px; }
.stat b { display: block; font: 600 24px/1.1 var(--serif); }
.stat span { font-size: 13px; color: var(--muted); }

/* ───────── answering ───────── */
.qcard .qhead { display: flex; gap: 12px; align-items: flex-start; }
.qnum { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none;
        background: var(--pri-soft); color: var(--pri); font-weight: 600; font-size: 15px; }
.qcard.hard .qnum { background: var(--accent-soft); color: var(--accent); }
.qtext { font-size: 18px; font-weight: 500; line-height: 1.45; }
.rec { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.rec audio { height: 38px; max-width: 100%; }
.btn.mic { color: var(--no); border-color: #efc7c2; }
.btn.mic.on { background: var(--no); border-color: var(--no); color: #fff; animation: kv-rec 1.2s ease-in-out infinite; }
@keyframes kv-rec { 50% { opacity: .75; } }
.saved { font-size: 13px; color: var(--ok); }
.kidans { background: var(--soft); border-radius: var(--r-s); padding: 10px 12px; margin-top: 10px; white-space: pre-wrap; }
.expected { background: var(--pri-soft); color: #1f3a66; border-radius: var(--r-s); padding: 8px 12px; margin-top: 8px; font-size: 14px; }
.finish-box { text-align: center; padding: 28px 20px; }
.finish-box h2 { margin-bottom: 6px; }

/* ───────── admin ───────── */
.subnav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 9px 14px; text-decoration: none; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--ink); }
.subnav a.on { color: var(--pri); border-bottom-color: var(--pri); }
.subnav a.right { margin-left: auto; }
.warnbox { background: var(--warn-soft); color: #7a4100; border-radius: var(--r-s); padding: 10px 14px; margin-bottom: 12px; font-size: 15px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.tbl-wrap { overflow-x: auto; }
.lvl-thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-s); background: var(--soft); display: block; }
.pin-box { max-width: 340px; margin: 40px auto; text-align: center; }
.pin-box .in { text-align: center; font-size: 26px; letter-spacing: 8px; }
.upl { position: relative; overflow: hidden; }
.upl input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.bar { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--pri); width: 0; transition: width .2s; }
.cellpick { min-height: 34px; padding: 4px 8px; width: auto; font-size: 14px; }
.board.preview .piece .n { color: rgba(255,255,255,.9); text-shadow: 0 1px 2px rgba(0,0,0,.6); font-size: 12px; }
.board.preview .piece.req { box-shadow: inset 0 0 0 2px #f2c66d; }
.suggest { margin-top: 6px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.suggest:empty { display: none; }
.suggest button { text-align: left; border: 0; border-top: 1px solid var(--line); background: #fff; padding: 9px 12px; cursor: pointer; }
.suggest button:first-child { border-top: 0; }
.suggest button:hover { background: var(--soft); }

/* add a book */
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
@media (max-width: 420px) { .choice { grid-template-columns: 1fr; } }
.photo-pick { display: flex; align-items: center; gap: 12px; }
.photo-pick img { width: 54px; height: 72px; object-fit: cover; border-radius: 6px; }

/* ───────── overlays ───────── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; border-radius: var(--r-s); padding: 11px 16px; font-size: 15px; max-width: calc(100% - 32px);
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
@media (max-width: 640px) { .toast { bottom: calc(84px + var(--sab)); } }
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(28, 34, 48, .45); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .sheet-wrap { align-items: center; } }
.sheet { background: #fff; width: 100%; max-width: 540px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 24px 22px calc(22px + var(--sab)); }
@media (min-width: 640px) { .sheet { border-radius: 16px; } }
.celebrate { text-align: center; }
.celebrate img.full { border-radius: var(--r); width: 100%; margin: 6px 0 4px; }
.secret-video { width: 100%; border-radius: var(--r); background: #000; margin-top: 12px; }
.secret-text { font: 500 19px/1.45 var(--serif); background: var(--accent-soft); border-radius: var(--r); padding: 16px; margin-top: 12px; }

.fx { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.fx i { position: absolute; top: -20px; width: 8px; height: 12px; border-radius: 2px; animation: kv-fall linear forwards; }
@keyframes kv-fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); } }

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