/* ============================================================
   Werkstatt-Speicher — "Werkstatt-Hauptbuch"
   Warmes Papier · Tinte · Terrakotta. Display: Fraunces,
   Zahlen: JetBrains Mono, Text: Hanken Grotesk.
   ============================================================ */

:root {
  --paper:      #f3eee2;
  --paper-2:    #ece4d3;
  --card:       #faf6ec;
  --ink:        #211d18;
  --ink-soft:   #5b5347;
  --ink-faint:  #8c8270;
  --line:       #d7cdb8;
  --line-soft:  #e3dac8;
  --accent:     #c4502d;
  --accent-deep:#9c3a1d;
  --good:       #4f8a4a;
  --warn:       #b5331f;
  --radius:     14px;
  --shadow:     0 1px 0 #fffdf6, 0 18px 40px -28px rgba(40, 30, 15, .55);
  --maxw:       760px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, var(--paper-2) 0%, var(--paper) 55%) fixed;
  line-height: 1.55;
  padding: clamp(18px, 4vw, 56px) 18px 64px;
  overflow-x: hidden;
}

.num { font-family: "JetBrains Mono", ui-monospace, monospace; font-feature-settings: "tnum" 1; }

/* film-grain / paper texture overlay */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  opacity: .045; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Masthead ---------- */
.masthead {
  max-width: var(--maxw);
  margin: 0 auto clamp(22px, 4vw, 40px);
  text-align: center;
  animation: rise .7s cubic-bezier(.2,.8,.2,1) both;
}
.masthead__kicker {
  display: inline-flex; align-items: center; gap: .5em;
  font-size: .76rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600;
  padding: .35em .9em; border: 1px solid var(--line);
  border-radius: 100px; background: var(--card);
}
.masthead__kicker .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px rgba(196,80,45,.18);
}
.masthead__title {
  font-family: "Fraunces", serif;
  font-weight: 600; font-optical-sizing: auto;
  font-size: clamp(2.6rem, 9vw, 5rem);
  line-height: .92; letter-spacing: -.02em;
  margin: .34em 0 .12em; color: var(--ink);
}
.masthead__title em {
  font-style: italic; font-weight: 400; color: var(--accent);
}
.masthead__lede {
  max-width: 42ch; margin: .2em auto 0;
  color: var(--ink-soft); font-size: 1.05rem;
}

/* ---------- Sheet ---------- */
.sheet {
  max-width: var(--maxw); margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 38px);
  animation: rise .8s .08s cubic-bezier(.2,.8,.2,1) both;
}

/* ---------- Verdict: Summe + Empfehlung ---------- */
.verdict {
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(14px, 3vw, 26px);
  align-items: stretch; margin-bottom: clamp(18px, 3vw, 26px);
}
.verdict__label {
  display: block; font-size: .73rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; margin-bottom: .4em;
}
.verdict__sum { align-self: center; }
.verdict__big { font-family: "Fraunces", serif; line-height: .95; display: flex; align-items: baseline; gap: .2em; }
.verdict__big .num { font-size: clamp(2.4rem, 8vw, 3.7rem); font-weight: 600; letter-spacing: -.01em; }
.verdict__unit { font-size: clamp(1rem, 3vw, 1.3rem); color: var(--ink-soft); font-style: italic; }
.verdict__tb { color: var(--ink-faint); font-size: .9rem; margin-top: .45em; display: block; }

.verdict__rec {
  background: var(--ink); color: var(--paper); border-radius: 12px;
  padding: clamp(15px, 2.6vw, 22px); position: relative; overflow: hidden;
  box-shadow: 0 18px 38px -24px rgba(0,0,0,.75);
  transition: background .3s;
}
.verdict__rec .verdict__label { color: rgba(245,241,232,.55); }
.rec__line { display: flex; align-items: baseline; gap: .55em; flex-wrap: wrap; }
.rec__name { font-family: "Fraunces", serif; font-size: clamp(1.9rem, 5.5vw, 2.5rem); font-weight: 600; color: #fff; line-height: 1; }
.rec__size {
  font-family: "JetBrains Mono", monospace; font-size: .9rem; font-weight: 700; color: #fff;
  background: rgba(196,80,45,.9); padding: .22em .6em; border-radius: 100px;
}
.rec__price { font-family: "Fraunces", serif; font-size: clamp(1.5rem, 4.5vw, 2.1rem); font-weight: 600; margin-top: .3em; }
.rec__per { font-family: "Hanken Grotesk", sans-serif; font-size: .78rem; font-weight: 500; color: rgba(245,241,232,.6); }
.rec__sub { font-size: .82rem; color: rgba(245,241,232,.68); margin-top: .55em; line-height: 1.45; }
.verdict__rec.is-over { background: var(--warn); }
@media (max-width: 560px) { .verdict { grid-template-columns: 1fr; } .verdict__sum { align-self: start; } }

/* ---------- Gauge / partition bar ---------- */
.gauge { margin-bottom: clamp(8px, 2vw, 14px); }

/* the partition bar */
.bar {
  position: relative; height: 56px; border-radius: 10px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  overflow: hidden; display: flex;
  box-shadow: inset 0 2px 6px rgba(60,45,20,.12);
}
.bar__track { display: flex; height: 100%; width: 100%; }
.seg {
  height: 100%; min-width: 0;
  position: relative;
  border-right: 1px solid rgba(255,253,246,.45);
  transition: width .55s cubic-bezier(.4,1.2,.4,1), filter .2s, opacity .2s;
  cursor: default;
}
.seg:last-child { border-right: 0; }
.seg__label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: "JetBrains Mono", monospace; font-size: .7rem; font-weight: 700;
  color: rgba(255,255,255,.96); text-shadow: 0 1px 2px rgba(0,0,0,.35);
  white-space: nowrap; overflow: hidden; pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
.seg.show-label .seg__label { opacity: 1; }
.bar.dim .seg:not(.hot) { filter: saturate(.4) brightness(1.05); opacity: .5; }
.seg.hot { filter: brightness(1.06); }
/* free remainder = diagonal hatch */
.bar__rest {
  position: absolute; top: 0; right: 0; bottom: 0;
  background-image: repeating-linear-gradient(45deg,
    transparent 0 7px, rgba(140,130,112,.28) 7px 8px);
  border-left: 1px dashed var(--ink-faint);
  transition: width .55s cubic-bezier(.4,1.2,.4,1);
  pointer-events: none;
}
.bar.is-over { box-shadow: inset 0 0 0 2px var(--warn), inset 0 2px 6px rgba(60,45,20,.12); }
.bar__caption {
  font-size: .82rem; color: var(--ink-faint); margin: 10px 2px 0;
  display: flex; align-items: center; gap: .5em; flex-wrap: wrap;
}
.swatch { display: inline-block; width: 22px; height: 12px; border-radius: 3px; vertical-align: middle; }
.swatch--free {
  background-image: repeating-linear-gradient(45deg,
    transparent 0 4px, rgba(140,130,112,.5) 4px 5px);
  border: 1px dashed var(--ink-faint);
}
.swatch--sys { background: #3a352c; }

/* Festes Nextcloud-System-Band im Balken */
.seg--sys {
  background: #3a352c;
  background-image: repeating-linear-gradient(45deg,
    rgba(255,255,255,.07) 0 6px, transparent 6px 12px);
}
.seg--sys .seg__label { color: rgba(255,255,255,.9); }

/* ---------- Tiers: Box-Stufen ---------- */
.tiers { margin-top: clamp(22px, 4vw, 32px); }
.tiers__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  border-top: 1px solid var(--line-soft); padding-top: 22px; margin-bottom: 14px;
}
.tiers__head h2 { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
.tiers__hint { font-size: .84rem; color: var(--ink-faint); }
.tiergrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .tiergrid { grid-template-columns: repeat(2, 1fr); } }
.tier {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 14px 16px;
  background: var(--card); position: relative; transition: all .25s;
  animation: rise .5s both;
}
.tier__name { font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: .8rem; color: var(--ink-faint); letter-spacing: .05em; }
.tier__size { font-family: "Fraunces", serif; font-size: 1.55rem; font-weight: 600; line-height: 1; margin: .22em 0 .18em; }
.tier__price { font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: 1.02rem; }
.tier__price .u { color: var(--ink-faint); font-weight: 500; font-size: .72em; }
.tier__snap { font-size: .71rem; color: var(--ink-faint); margin-top: .55em; }
.tier.is-small { opacity: .42; }
.tier.is-big { opacity: .68; }
.tier.is-rec {
  border-color: var(--accent); background: #fffdf7;
  box-shadow: 0 14px 30px -18px var(--accent-deep); transform: translateY(-3px); opacity: 1;
}
.tier.is-rec::before {
  content: "✓ passt"; position: absolute; top: -10px; right: 10px;
  background: var(--accent); color: #fff;
  font-size: .67rem; font-weight: 700; padding: .2em .7em; border-radius: 100px; letter-spacing: .03em;
}
.tier.is-rec .tier__name { color: var(--accent); }

/* ---------- Ledger / rows ---------- */
.ledger__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  border-top: 1px solid var(--line-soft); padding-top: 22px; margin-bottom: 6px;
}
.ledger__head h2 {
  font-family: "Fraunces", serif; font-weight: 600; font-size: 1.5rem;
  margin: 0; letter-spacing: -.01em;
}
.ledger__hint { font-size: .84rem; color: var(--ink-faint); }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  border-bottom: 1px solid var(--line-soft);
  animation: rise .5s both;
}
.row__main {
  display: grid; grid-template-columns: 14px 1fr auto auto;
  align-items: center; gap: 14px;
  width: 100%; text-align: left; background: none; border: 0;
  font: inherit; color: inherit; cursor: pointer;
  padding: 14px 6px; border-radius: 8px;
  transition: background .18s;
}
.row__main:hover, .row__main:focus-visible { background: var(--paper); outline: none; }
.row__chip { width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.row__name { font-weight: 600; font-size: 1.04rem; }
.row__note { display: block; font-size: .82rem; color: var(--ink-faint); font-weight: 400; }
.row__gb {
  font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: 1.02rem;
  white-space: nowrap;
}
.row__gb .u { color: var(--ink-faint); font-weight: 500; font-size: .8em; margin-left: .15em; }
.row__gb.zero { color: var(--ink-faint); font-weight: 500; }
.row__edit {
  font-size: .8rem; color: var(--accent); font-weight: 600;
  opacity: .55; transition: opacity .18s; white-space: nowrap;
}
.row__main:hover .row__edit { opacity: 1; }
.row.is-open .row__main { background: var(--paper); }

/* ---------- Inline editor ---------- */
.editor {
  display: grid; gap: 16px;
  padding: 4px 6px 20px;
  animation: open .35s cubic-bezier(.2,.8,.2,1) both;
}
.editor__field { display: grid; gap: 8px; }
.editor__field label {
  font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600;
}
.editor__field label .opt { text-transform: none; letter-spacing: 0; color: var(--ink-faint); font-weight: 400; }
.stepper { display: flex; align-items: stretch; gap: 8px; max-width: 320px; }
.stepper .gbInput {
  flex: 1; min-width: 0; text-align: center;
  font-size: 1.4rem; font-weight: 700; color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: 10px; padding: .35em;
}
.stepper .gbInput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,80,45,.16); }
.step {
  font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: .9rem;
  background: var(--paper-2); border: 1.5px solid var(--line); color: var(--ink-soft);
  border-radius: 10px; padding: 0 .9em; cursor: pointer; transition: all .15s;
}
.step:hover { border-color: var(--accent); color: var(--accent); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button {
  font-family: "JetBrains Mono", monospace; font-size: .82rem;
  background: none; border: 1px solid var(--line); color: var(--ink-soft);
  border-radius: 100px; padding: .3em .8em; cursor: pointer; transition: all .15s;
}
.quick button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.noteInput {
  font: inherit; background: var(--card); border: 1.5px solid var(--line);
  border-radius: 10px; padding: .6em .8em; color: var(--ink);
}
.noteInput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,80,45,.16); }
.editor__actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn {
  font: inherit; font-weight: 600; border-radius: 100px; padding: .6em 1.4em;
  cursor: pointer; transition: all .15s; border: 1.5px solid transparent;
}
.btn--ghost { background: none; border-color: var(--line); color: var(--ink-soft); }
.btn--ghost:hover { border-color: var(--ink-soft); }
.btn--solid { background: var(--accent); color: #fff; box-shadow: 0 6px 16px -8px var(--accent-deep); }
.btn--solid:hover { background: var(--accent-deep); }
.btn:disabled { opacity: .5; cursor: progress; }

/* ---------- Colophon ---------- */
.colophon {
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line-soft);
  display: flex; gap: .6em; flex-wrap: wrap;
  font-size: .8rem; color: var(--ink-faint);
}
.colophon__sep { opacity: .5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 130%);
  background: var(--ink); color: var(--paper);
  font-size: .9rem; font-weight: 500; padding: .75em 1.3em; border-radius: 100px;
  box-shadow: 0 16px 36px -16px rgba(0,0,0,.6); z-index: 200;
  transition: transform .4s cubic-bezier(.2,.9,.2,1); max-width: 90vw;
}
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--warn); }

/* ---------- Loading skeleton ---------- */
[aria-busy="true"] .rows::after {
  content: "Lädt …"; display: block; padding: 30px 6px; color: var(--ink-faint);
  font-family: "JetBrains Mono", monospace; font-size: .85rem;
}

/* ---------- Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes open { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

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

@media (max-width: 480px) {
  .row__main { grid-template-columns: 12px 1fr auto; }
  .row__edit { display: none; }
  .gauge__big .gauge__of { font-size: .85rem; }
}
