:root {
  --paper: #fbf8f1;
  --paper2: #f3eee2;
  --card: #fffdf8;
  --ink: #1b1814;
  --muted: #6b6458;
  --line: #d9d1c0;
  --red: #a8324a;
  --green: #3f7a3a;
  --radius: 6px;
  --display: "Fraunces", Georgia, serif;
  --body: "Work Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--body);
}
a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red); }
.muted { color: var(--muted); }

/* Rėmelis su ornamentais kampuose, kaip etiketėse */
.frame { position: relative; border: 2px solid var(--ink); outline: 1px solid var(--ink); outline-offset: 4px; }
.frame::before, .frame::after {
  content: "❦"; position: absolute; font-size: 22px; line-height: 1; background: var(--paper); padding: 0 6px;
}
.frame::before { top: -14px; left: 50%; transform: translateX(-50%); }
.frame::after { bottom: -14px; left: 50%; transform: translateX(-50%) rotate(180deg); }

/* ---------- Viršus ---------- */
.hero { padding: 18px clamp(16px, 4vw, 48px) 56px; }
.topnav { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; justify-content: flex-end; font-size: 14px; }
.topnav a { color: var(--muted); text-decoration: none; }
.topnav a:hover { color: var(--ink); }
.lock { background: none; border: 1px solid var(--ink); border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 16px; padding: 0; }
.lock:hover { background: var(--paper2); }
.hero-inner { max-width: 1100px; margin: 40px auto 0; text-align: center; }
.kicker { text-transform: uppercase; letter-spacing: .3em; font-size: 12px; color: var(--muted); margin: 0 0 18px; }
h1 { margin: 0; }
h1 .logo { display: block; width: min(520px, 86vw); height: auto; margin: 0 auto; }
.tagline { max-width: 640px; line-height: 1.6; font-size: 18px; color: var(--muted); margin: 24px auto; font-style: italic; font-family: var(--display); }
.stats { list-style: none; padding: 0; margin: 28px 0 20px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.stats li { border: 1px solid var(--ink); border-radius: 999px; padding: 7px 16px; color: var(--muted); font-size: 14px; background: var(--card); }
.stats b { color: var(--ink); font-family: var(--display); font-size: 18px; margin-right: 4px; }
.links { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }

/* ---------- Skyriai ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px); }
section { padding: 72px 0 8px; }
h2 {
  font-family: var(--display); font-size: clamp(30px, 5vw, 44px); margin: 0 0 6px; font-weight: 700;
  display: flex; align-items: center; gap: 14px;
}
h2::after { content: ""; flex: 1; height: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); padding-top: 3px; }
h2 .num { font-family: var(--body); font-size: 13px; color: var(--muted); letter-spacing: .15em; font-weight: 500; }
h3 { font-family: var(--display); }
.lead { color: var(--muted); margin: 0 0 28px; font-style: italic; }

/* ---------- Kortelės ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 28px; }
.card {
  position: relative; background: var(--card);
  border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.card h3 { font-size: 26px; margin: 4px 0 0; line-height: 1.1; }
.meta { color: var(--muted); font-size: 14px; margin: 0; }
.desc { margin: 6px 0 0; }
.brews { margin: 0; font-size: 13px; color: var(--muted); font-style: italic; }
.blinks { display: flex; gap: 14px; font-size: 14px; margin: auto 0 0; padding-top: 10px; }
.cap { border-radius: 50%; flex-shrink: 0; }

.card-label { position: relative; margin-bottom: 8px; }
.card-label img { display: block; width: 100%; height: auto; border: 1px solid var(--line); }
.card-label .stock { position: absolute; top: 10px; right: 10px; }
.mini-label { background: #fff; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; }

.stock {
  background: var(--ink); color: var(--paper); font-weight: 600; font-size: 13px;
  padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}
.stock.zero { background: var(--card); color: var(--muted); border: 1px dashed var(--muted); }

/* ---------- Tamsus kambariukas ---------- */
.cellar { margin-top: 64px; padding: 48px clamp(18px, 3vw, 36px) 36px; background: var(--card); }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.bottle {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 16px 10px; border: 1px solid var(--ink); border-radius: var(--radius);
  color: var(--ink); position: relative; text-decoration: none; background: var(--paper);
}
.bottle:hover { box-shadow: 3px 3px 0 var(--ink); color: var(--ink); }
.bottle .mini-label { width: 74px; height: 56px; }
.bname { font-size: 13px; line-height: 1.25; }
.bcount { position: absolute; top: 6px; right: 10px; font-family: var(--display); font-weight: 900; font-size: 20px; }
.log-wrap h3 { margin: 32px 0 8px; font-size: 20px; }
.log { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.plus { color: var(--green); }
.minus { color: var(--red); }

/* ---------- Archyvas ---------- */
.archive { border: 1.5px solid var(--ink); border-radius: var(--radius); background: var(--card); }
.archive summary { cursor: pointer; padding: 18px 22px; font-family: var(--display); font-size: 20px; list-style: none; }
.archive summary::-webkit-details-marker { display: none; }
.archive summary::before { content: "＋ "; }
.archive[open] summary::before { content: "－ "; }
.archive summary span { color: var(--muted); font-size: 16px; }
.rows { padding: 0 12px 12px; }
.arow { border-top: 1px solid var(--line); padding: 12px 10px; }
.arow-main { display: grid; grid-template-columns: 58px 1fr auto; gap: 6px 14px; align-items: center; }
.arow-main > div { display: flex; flex-direction: column; }
.arow-main .mini-label { width: 58px; height: 44px; }
.arow-main .meta, .arow-main .desc { font-size: 13px; margin: 0; }
.arow-main .desc { color: var(--muted); font-style: italic; }
.arow-main .blinks { grid-column: 2 / 4; padding: 0; font-size: 13px; }

/* ---------- Planai ---------- */
.plans { list-style: none; padding: 0; margin: 0 0 20px; }
.plans li { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.plans li > div { display: flex; flex-direction: column; flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink); margin-top: 8px; flex-shrink: 0; }
.plan-form { display: grid; grid-template-columns: 2fr 2fr 2fr auto; gap: 8px; }

/* ---------- Valdymas ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--ink); color: var(--paper); border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
button:hover { background: #3a332b; }
button.ghost { background: var(--card); color: var(--ink); }
button.ghost:hover { background: var(--paper2); }
button.small { padding: 4px 10px; }
input, select, textarea { background: #fff; border: 1px solid var(--muted); border-radius: var(--radius); padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; line-height: 1.5; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 10px; }

.admin-only { display: none !important; }
body.is-admin .admin-only { display: revert !important; }
body.is-admin .plan-form { display: grid !important; }

.admin-box { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--muted); display: flex; flex-direction: column; gap: 8px; }
.admin-box .btns, .admin-box .settings { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.admin-box .btns button { padding: 6px 10px; font-size: 13px; }
.admin-box .n, .admin-box .brews { width: 64px; }
.admin-box .settings { font-size: 13px; color: var(--muted); }
.admin-box .settings label { display: flex; align-items: center; gap: 6px; }
.admin-box .settings button { padding: 5px 10px; font-size: 13px; }

dialog {
  background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 24px; width: min(360px, 90vw); box-shadow: 6px 6px 0 var(--ink);
}
dialog::backdrop { background: rgba(27,24,20,.35); }
dialog h3 { margin: 0 0 14px; font-size: 24px; }
dialog input { width: 100%; }
.err { color: var(--red); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-weight: 600;
  transition: all .25s ease; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); }

footer { text-align: center; padding: 80px 20px 40px; color: var(--muted); font-size: 14px; }
footer p { margin: 4px 0; }

@media (max-width: 640px) {
  .topnav { justify-content: flex-start; }
  .plan-form { grid-template-columns: 1fr; }
  .arow-main { grid-template-columns: 58px 1fr; }
  .arow-main .stock { grid-column: 2; justify-self: start; }
  .arow-main .blinks { grid-column: 2; }
}

/* ---------- Grupės ir variantai ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.tab {
  background: var(--card); color: var(--ink); border: 1px solid var(--ink); border-radius: 999px;
  padding: 3px 11px; font-size: 13px; font-weight: 500;
}
.tab:hover { background: var(--paper2); }
.tab.on { background: var(--ink); color: var(--paper); }
.tab small { opacity: .7; margin-left: 2px; }

/* ========== Kompaktiškas išdėstymas ========== */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: 8px clamp(12px, 3vw, 32px); background: rgba(251,248,241,.95); backdrop-filter: blur(6px);
  border-bottom: 1.5px solid var(--ink);
}
.brand img { display: block; height: 44px; width: auto; }
.tabs-main { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.tabs-main button {
  background: none; color: var(--ink); border: 1px solid transparent; border-radius: 999px;
  padding: 6px 14px; font-weight: 500; font-size: 14px;
}
.tabs-main button:hover { border-color: var(--ink); background: none; }
.tabs-main button.on { background: var(--ink); color: var(--paper); }
.topbar .lock { flex-shrink: 0; }

.intro { max-width: 820px; margin: 20px auto 0; padding: 0 clamp(16px, 4vw, 48px); }
.intro p { margin: 0; color: var(--muted); font-family: var(--display); font-style: italic; font-size: 16px; line-height: 1.55; }
.intro p.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.linklike { background: none; border: 0; padding: 2px 0; color: var(--ink); text-decoration: underline; font-weight: 500; font-size: 14px; }
.linklike:hover { background: none; color: var(--red); }

main { max-width: 820px; }
.view-head { display: flex; align-items: baseline; gap: 12px; margin-top: 28px; }
.view-head h2 { margin: 0; flex: 1; }
.lead { margin: 4px 0 16px; }

.list { border-top: 1.5px solid var(--ink); }
.li {
  display: grid; grid-template-columns: 1fr minmax(0, 1fr) 52px 52px; gap: 10px; align-items: center;
  padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer;
}
body.is-admin .li { grid-template-columns: 1fr minmax(0, 1fr) 52px 52px 88px; }
.li:hover, .li:focus-visible { background: var(--card); outline: none; }
.li-head { cursor: default; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px 6px; }
.li-head:hover { background: none; }
.li-name { font-weight: 600; }
.li-name small { font-weight: 400; }
.li-meta { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-year { font-size: 14px; text-align: right; }
.li .stock { justify-self: end; padding: 2px 10px; min-width: 34px; text-align: center; }
.li .stock.zero { border: 0; background: none; }
.quick { display: flex; gap: 4px; justify-content: flex-end; }
.quick button { padding: 3px 10px; font-size: 13px; }
.empty { padding: 24px 6px; color: var(--muted); font-style: italic; }

.beer-dlg { width: min(560px, 94vw); max-height: 92vh; padding: 20px; position: relative; }
.beer-dlg .close { position: absolute; top: 10px; right: 10px; background: var(--card); color: var(--ink); border: 1px solid var(--ink); border-radius: 50%; width: 32px; height: 32px; padding: 0; z-index: 1; }
.dlg-label { display: block; width: 100%; height: auto; border: 1px solid var(--line); margin-bottom: 12px; }
.dlg-cap { margin-bottom: 8px; }
.beer-dlg h3 { margin: 4px 40px 6px 0; font-size: 28px; line-height: 1.1; }
.dlg-stock { margin: 8px 0 0; }

.log-wrap { margin-top: 32px; }
footer { padding: 48px 20px 32px; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .brand img { height: 36px; }
  .tabs-main { order: 3; width: 100%; margin: 0; overflow-x: auto; flex-wrap: nowrap; }
  .topbar .lock { margin-left: auto; }
  .li, body.is-admin .li { grid-template-columns: 1fr 40px 44px; }
  body.is-admin .li { grid-template-columns: 1fr 40px 44px 80px; }
  .li-meta { display: none; }
  .li-head span:nth-child(2) { display: none; }
}
.dlg-label { max-height: 58vh; object-fit: contain; background: #fff; }
