:root {
  --bg: #f5f2ea;
  --surface: #fffdf7;
  --surface-2: #f0ece1;
  --ink: #22301f;
  --muted: #6a6f62;
  --line: #e0dacb;
  --accent: #3d6b38;
  --accent-ink: #ffffff;
  --accent-soft: #e2ecd9;
  --warn: #9c4a24;
  --warn-soft: #f5e3d8;
  --danger: #a33a2a;

  --t-beskar: #3d6b38;   --t-beskar-bg: #e2ecd9;
  --t-godsla: #855819;   --t-godsla-bg: #f3e6cf;
  --t-kalka: #4f5965;    --t-kalka-bg: #e3e7ec;
  --t-kompost: #6b4a32;  --t-kompost-bg: #ece1d6;
  --t-plantera: #74497f; --t-plantera-bg: #eee2f1;
  --t-skydd: #2c5a78;    --t-skydd-bg: #dce8f0;
  --t-skota: #575d4f;    --t-skota-bg: #e8e7df;
  --t-sa: #56661c;       --t-sa-bg: #ebf0d3;
  --t-skord: #983848;    --t-skord-bg: #f6e0e4;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(40, 40, 20, .06), 0 2px 10px rgba(40, 40, 20, .04);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141813;
    --surface: #1c211a;
    --surface-2: #252b22;
    --ink: #e6e9de;
    --muted: #9ca191;
    --line: #313a2d;
    --accent: #93c283;
    --accent-ink: #12200f;
    --accent-soft: #26361f;
    --warn: #e39a74;
    --warn-soft: #3a2519;
    --danger: #ec8f7e;

    --t-beskar: #a3cf93;   --t-beskar-bg: #25351f;
    --t-godsla: #e2b673;   --t-godsla-bg: #3a2d18;
    --t-kalka: #b8c2ce;    --t-kalka-bg: #2a3038;
    --t-kompost: #d6ae8e;  --t-kompost-bg: #36291e;
    --t-plantera: #d5a9df; --t-plantera-bg: #33243a;
    --t-skydd: #92c3e3;    --t-skydd-bg: #1c2e3b;
    --t-skota: #c3c7b9;    --t-skota-bg: #2b2e27;
    --t-sa: #c9d68f;       --t-sa-bg: #2d3318;
    --t-skord: #eba1ad;    --t-skord-bg: #3a1f25;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- header ---------- */
.site {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.site .wrap { padding-top: 18px; }
.brand { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand h1 { font-size: 28px; letter-spacing: -.01em; }
#today { color: var(--muted); font-size: 15px; }

.tabs { display: flex; gap: 4px; margin-top: 12px; overflow-x: auto; }
.tabs a {
  color: var(--muted);
  text-decoration: none;
  padding: 10px 12px 12px;
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  font-weight: 500;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

main.wrap { padding-top: 24px; padding-bottom: 80px; }

/* ---------- sektioner ---------- */
.section { margin-bottom: 32px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.section-head h2 { font-size: 22px; }
.section-sub { color: var(--muted); margin: -4px 0 12px; font-size: 15px; }
.count {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
}
.empty {
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.footnote { color: var(--muted); font-size: 14px; max-width: 60ch; }

.banner {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner .link { white-space: nowrap; }

/* ---------- uppgiftskort ---------- */
.cards { display: grid; gap: 12px; }
.task {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.task.due { border-left: 4px solid var(--accent); }
.task.missed { border-left: 4px solid var(--warn); }
.task-main { flex: 1; min-width: 0; }
.task-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.when { font-size: 14px; color: var(--muted); }
.task.missed .when { color: var(--warn); }
.task h3 { font-size: 19px; }
.where { color: var(--muted); font-size: 15px; margin-top: 2px; }
.sep { opacity: .6; }
.note { margin-top: 10px; font-size: 15px; max-width: 62ch; }
.last { margin-top: 10px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.done-btn { flex-shrink: 0; }

.cards.compact { gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cards.compact .task { border: 0; box-shadow: none; border-radius: 0; padding: 12px 16px; background: none; }
.cards.compact .task + .task { border-top: 1px solid var(--line); }
.cards.compact .task h3 { font-size: 17px; }
.cards.compact .task-meta { margin-bottom: 2px; }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}
.t-beskar   { color: var(--t-beskar);   background: var(--t-beskar-bg); }
.t-godsla   { color: var(--t-godsla);   background: var(--t-godsla-bg); }
.t-kalka    { color: var(--t-kalka);    background: var(--t-kalka-bg); }
.t-kompost  { color: var(--t-kompost);  background: var(--t-kompost-bg); }
.t-plantera { color: var(--t-plantera); background: var(--t-plantera-bg); }
.t-skydd    { color: var(--t-skydd);    background: var(--t-skydd-bg); }
.t-skota    { color: var(--t-skota);    background: var(--t-skota-bg); }
.t-sa       { color: var(--t-sa);       background: var(--t-sa-bg); }
.t-skord    { color: var(--t-skord);    background: var(--t-skord-bg); }

.done-list summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; }
.done-list summary::-webkit-details-marker { display: none; }
.done-list summary h2 { font-size: 18px; color: var(--muted); }
.done-list summary::after { content: "▸"; color: var(--muted); }
.done-list[open] summary::after { content: "▾"; }
.done-list ul { list-style: none; padding: 0; margin: 12px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.done-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; font-size: 15px; }
.done-list li + li { border-top: 1px solid var(--line); }

/* ---------- knappar ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  background: none;
}
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: var(--line); background: var(--surface); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-ghost { color: var(--danger); border-color: var(--line); }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: var(--danger); }
.icon-btn {
  background: none; border: 0; cursor: pointer;
  width: 36px; height: 36px; border-radius: 8px;
  font-size: 22px; line-height: 1; color: var(--muted);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 18px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- växter ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 5px 12px; font-size: 14px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.plants { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.plant {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.plant header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.plant h3 { font-size: 20px; }
.notes { font-size: 15px; }
.grows-here { font-size: 15px; background: var(--surface-2); border-radius: 8px; padding: 6px 10px; }
.badge { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.badge.lime { background: none; color: var(--muted); font-weight: 500; padding: 0; }
.ptasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 15px; }
.ptasks li { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.ptasks .tag { font-size: 11px; justify-self: start; }
.pt-when { font-size: 13px; }
.plant footer { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }

.pill { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.pill.now { background: var(--accent); color: var(--accent-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--accent-soft); color: var(--accent); }

.lime-box { margin: 8px 0 28px; }
.lime-box summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; }
.lime-box summary::-webkit-details-marker { display: none; }
.lime-box summary h2 { font-size: 18px; color: var(--muted); }
.lime-box summary::after { content: "▸"; color: var(--muted); }
.lime-box[open] summary::after { content: "▾"; }
.lime-box[open] summary { margin-bottom: 12px; }
.lime-box .lime-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.lime-box .lime-list li:first-child { border-top: 0; }
.lime-list { list-style: none; margin: 0; padding: 0; }
.lime-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 120px; gap: 12px; align-items: start;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.lime-next { text-align: right; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- kalender ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.cal-head h2 { font-size: 26px; min-width: 9ch; text-align: center; }
.cal-head .icon-btn { font-size: 28px; }
.cal-head .link { margin-left: auto; font-size: 15px; }

.mstrip {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px;
  margin-bottom: 28px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px;
}
.mstrip-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; border-radius: 8px; padding: 6px 0; cursor: pointer;
  font-size: 13px; color: var(--muted); min-width: 0;
}
.mstrip-btn:hover { background: var(--surface-2); }
.mstrip-btn.today { color: var(--ink); font-weight: 600; }
.mstrip-btn.cur { background: var(--accent-soft); color: var(--ink); }
.mstrip-bar {
  width: 60%; height: 34px; border-radius: 4px; background: var(--surface-2);
  position: relative; overflow: hidden;
}
.mstrip-bar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--n) * 10%); background: var(--accent); opacity: .75; border-radius: 4px;
}
.mstrip-n { font-size: 12px; min-height: 1em; font-variant-numeric: tabular-nums; }
.mstrip-btn { position: relative; }
.mstrip-btn.newyear::before {
  content: ""; position: absolute; left: -3px; top: 6px; bottom: 6px; border-left: 1.5px dashed var(--line);
}
.mstrip-year { position: absolute; top: -17px; left: 0; font-size: 11px; color: var(--muted); }
.mstrip { margin-top: 18px; }

.cal-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cal-list > li + li { border-top: 1px solid var(--line); }
.cal-list summary {
  display: grid; grid-template-columns: 104px minmax(0, 1fr) auto; gap: 10px; align-items: baseline;
  padding: 12px 16px; cursor: pointer; list-style: none;
}
.cal-list summary::-webkit-details-marker { display: none; }
.cal-list summary .tag { justify-self: start; }
.cal-main { min-width: 0; }
.cal-title { font-weight: 600; }
.cal-sub { display: block; font-size: 14px; }
.cal-when { font-size: 14px; text-align: right; white-space: nowrap; }
.cal-body { padding: 0 16px 14px 130px; display: grid; gap: 8px; justify-items: start; }
.cal-body p { font-size: 15px; max-width: 62ch; }
.pill.muted-pill { background: var(--surface-2); color: var(--muted); font-weight: 500; }

@media (max-width: 560px) {
  .tabs { gap: 0; margin-left: -6px; }
  .tabs a { padding: 10px 8px 12px; font-size: 15px; }
  .mstrip { gap: 2px; padding: 6px 4px; }
  .mstrip-btn { font-size: 11px; }
  .cal-list summary { grid-template-columns: minmax(0, 1fr) auto; }
  .cal-list summary .tag { grid-column: 1 / -1; }
  .cal-body { padding-left: 16px; }
}

/* ---------- logg ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.filters select, .filters input {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; min-width: 0;
}
.filters input { flex: 1; min-width: 160px; }
.log-month { margin-bottom: 28px; }
.log-month h2 { font-size: 18px; margin-bottom: 10px; }
.log { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.log li { display: flex; gap: 14px; padding: 12px 12px 12px 16px; align-items: flex-start; }
.log li + li { border-top: 1px solid var(--line); }
.log time {
  font-family: var(--serif); font-size: 22px; line-height: 1; text-align: center; width: 36px; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.log time span { display: block; font-family: var(--sans); font-size: 12px; color: var(--muted); margin-top: 3px; }
.log-body { flex: 1; min-width: 0; }
.log-body p { font-size: 15px; margin-top: 4px; white-space: pre-wrap; }
.log .tag { font-size: 11px; vertical-align: 1px; }

.data-box { margin-top: 40px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.data-box h2 { font-size: 18px; margin-bottom: 6px; }
.data-box p { font-size: 15px; color: var(--muted); max-width: 64ch; }
.data-box.nudge { background: var(--warn-soft); }
.data-box .row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- dialog ---------- */
dialog {
  border: 0; padding: 0; border-radius: 16px;
  background: var(--surface); color: var(--ink);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(20, 24, 18, .45); }
.dlg-form { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 18px 12px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 22px; }
.dlg-body { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.dlg-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.hint { font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 8px 12px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea, .ted input, .ted select, .ted textarea {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px 10px; width: 100%;
}
.field input.invalid { border-color: var(--danger); }
textarea { resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }

.ed-h { font-size: 18px; margin-top: 8px; }
.ted { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ted-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ted-row .ted-title { flex: 1 1 200px; font-weight: 600; }
.ted-row select { width: auto; }
.ted-periods { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ted-periods .lbl, .rep { font-size: 14px; }
.ted-periods .lbl { font-weight: 600; }
.period { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.period input { width: 58px !important; text-align: center; }
.period select { width: auto !important; }
.period .dash { padding: 0 4px; color: var(--muted); }
.inline { display: inline-flex; gap: 6px; align-items: center; }
.inline input { width: 68px !important; text-align: center; }
.ted-foot { display: flex; justify-content: flex-end; font-size: 14px; }

.tpl-search { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 9px 12px; width: 100%; }
.tpl-group { display: flex; flex-direction: column; gap: 10px; }
.tpl-group[hidden], .tpl[hidden] { display: none; }
.tpl-h { font-size: 16px; margin: 8px 0 0; color: var(--muted); }
.tpl-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tpl {
  text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px;
}
.tpl:hover { border-color: var(--accent); }
.tpl .muted { font-size: 13px; }
.tpl.blank { border-style: dashed; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 150%);
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 16px;
  display: flex; gap: 16px; align-items: center; transition: transform .2s ease;
  max-width: calc(100vw - 32px); z-index: 20; font-size: 15px;
  visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .2s ease; }
#toast .link { color: var(--bg); }

@media (max-width: 560px) {
  .brand h1 { font-size: 24px; }
  .task { flex-direction: column; gap: 12px; }
  .done-btn { align-self: stretch; }
  .plants { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .lime-list li { grid-template-columns: 1fr auto; }
  .lime-last { grid-column: 1 / -1; grid-row: 2; }
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 16px 16px 0 0; margin: auto 0 0; }
  .dlg-form { max-height: 100dvh; }
  .toolbar { align-items: stretch; }
}
