/* ============================================================
   Forbrug — apothecary paper aesthetic
   ============================================================ */
:root {
  --paper: #f7f1e3;
  --paper-deep: #efe6d0;
  --ink: #221e18;
  --ink-soft: #6d6354;
  --line: #d8cdb4;
  --accent: #d9482b;        /* tomato */
  --accent-deep: #b03317;
  --green: #3e6b4f;
  --gold: #c9962e;
  --blue: #3d5a80;
  --card-bg: #fffdf6;
  --radius: 14px;
  --shadow: 0 2px 0 var(--line), 0 14px 30px -18px rgba(60, 48, 28, 0.35);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Karla", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, #fdf8ec 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(120, 100, 60, 0.045) 31px 32px);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.55;
}

/* grain overlay */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.5;
  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='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============ HERO ============ */
.hero {
  max-width: 1060px;
  margin: 0 auto;
  padding: 64px 24px 30px;
  text-align: center;
  border-bottom: 3px double var(--line);
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.hero-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.hero-eyebrow::before,
.hero-eyebrow::after {
  content: "·";
  margin: 0 10px;
  color: var(--ink-soft);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.hero-title em {
  font-style: italic;
  font-weight: 600;
  color: var(--accent);
}

.hero-sub {
  max-width: 480px;
  margin: 18px auto 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* ============ LAYOUT ============ */
.layout {
  max-width: 1060px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 36px;
  align-items: start;
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.45rem;
  margin-bottom: 18px;
}

/* ============ FORM ============ */
.form-panel {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 24px 28px;
  position: sticky;
  top: 24px;
  animation: rise 0.7s 0.12s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.presets { margin-bottom: 20px; }

.presets-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  transform: translateY(-1px);
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.label-soft {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-soft);
}

.field input,
.field select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 72, 43, 0.15);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-narrow { min-width: 0; }

.freq-combo {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.freq-combo select { width: auto; }

.form-error {
  color: var(--accent-deep);
  font-size: 13.5px;
  font-weight: 700;
  margin: 4px 0 10px;
}

.btn-primary {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 13px 18px;
  margin-top: 6px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
}

.btn-primary:hover { background: var(--accent-deep); }
.btn-primary:active { transform: scale(0.985); }

.btn-arrow { transition: transform 0.18s ease; }
.btn-primary:hover .btn-arrow { transform: translateX(4px); }

.btn-ghost {
  width: 100%;
  margin-top: 8px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px;
  background: none;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--ink-soft);
  cursor: pointer;
}

.btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); }

/* ============ RESULTS ============ */
.results { animation: rise 0.7s 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.results-count {
  font-size: 13px;
  color: var(--ink-soft);
  font-style: italic;
}

.empty-state {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  color: var(--ink-soft);
}

.empty-tube {
  display: inline-flex;
  align-items: center;
  margin-bottom: 18px;
  opacity: 0.75;
}

.empty-tube-cap {
  width: 14px;
  height: 26px;
  background: var(--line);
  border-radius: 4px 0 0 4px;
}

.empty-tube-body {
  width: 170px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 0 22px 22px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* ---- cards ---- */
.cards {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 22px;
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.15;
}

.card-emoji { margin-right: 8px; }

.card-actions { display: flex; gap: 6px; flex-shrink: 0; }

.icon-btn {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 5px 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover { border-color: var(--ink); color: var(--ink); }
.icon-btn.danger:hover { border-color: var(--accent-deep); color: var(--accent-deep); }

.card-meta {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

/* ---- tube visual ---- */
.tube {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}

.tube-cap {
  width: 12px;
  height: 22px;
  background: var(--ink);
  border-radius: 4px 0 0 4px;
  flex-shrink: 0;
}

.tube-body {
  flex: 1;
  height: 38px;
  border: 2px solid var(--ink);
  border-radius: 0 19px 19px 0;
  overflow: hidden;
  position: relative;
  background:
    repeating-linear-gradient(135deg, transparent 0 8px, rgba(34, 30, 24, 0.05) 8px 16px),
    var(--paper-deep);
}

.tube-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(180deg, var(--fill-color, var(--accent)) 0%, var(--fill-color-deep, var(--accent-deep)) 100%);
  transition: width 0.9s cubic-bezier(0.25, 0.9, 0.3, 1);
}

.tube-fill::after {
  content: "";
  position: absolute;
  inset: 4px auto 60% 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.tube-pct {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}

/* ---- stats ---- */
.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.2;
}

.stat-value small {
  font-family: var(--font-body);
  font-size: 0.7em;
  font-weight: 500;
  color: var(--ink-soft);
}

.stat-value.urgent { color: var(--accent-deep); }

.card-note {
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-soft);
  font-style: italic;
}

.badge-empty {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--accent-deep);
  padding: 3px 9px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ---- timeline ---- */
.timeline-panel {
  margin-top: 30px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px 26px;
}

.timeline-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  margin-bottom: 18px;
}

.timeline { display: flex; flex-direction: column; gap: 12px; }

.tl-row {
  display: grid;
  grid-template-columns: 130px 1fr 92px;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
}

.tl-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-track {
  height: 8px;
  background: var(--paper-deep);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.tl-bar {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: var(--fill-color, var(--accent));
  transition: width 0.9s cubic-bezier(0.25, 0.9, 0.3, 1);
}

.tl-date {
  text-align: right;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ============ FOOTER ============ */
.footer {
  text-align: center;
  padding: 26px 24px 44px;
  font-size: 12.5px;
  color: var(--ink-soft);
  border-top: 3px double var(--line);
}

/* ============ ANIMATION ============ */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* ============ RESPONSIVE ============ */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .card-stats { grid-template-columns: 1fr 1fr; }
  .tl-row { grid-template-columns: 90px 1fr 80px; }
}
