/* My Rhythm by Primaro */

:root {
  --rose: #C66F80;
  --rose-light: #F4C7D0;
  --rose-soft: #FCEBF1;
  --green: #4A6644;
  --olive: #9FAA74;
  --olive-light: #D7DAB3;
  --cream: #ECE3D2;

  --serif: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 18px;
  --radius-sm: 10px;
}

:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #ECE3D2;
  --ink: #2d2723;
  --ink-2: #4f4641;
  --muted: #74685f;
  --glass: rgba(252, 248, 242, 0.84);
  --glass-strong: rgba(255, 252, 248, 0.94);
  --line: rgba(74, 102, 68, 0.18);
  --line-strong: rgba(74, 102, 68, 0.28);
  --field: rgba(255, 255, 255, 0.72);
  --field-line: rgba(74, 102, 68, 0.26);
  --accent: #b9606f;
  --accent-text: #a14d5d;
  --accent-soft: var(--rose-soft);
  --accent-2: var(--green);
  --on-accent: #fff;
  --shadow: 0 12px 34px rgba(70, 45, 35, 0.14);
  --overlay: linear-gradient(180deg, rgba(236, 227, 210, 0.30), rgba(236, 227, 210, 0.55));
  --danger: #a3303a;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161914;
  --ink: #f4ede3;
  --ink-2: #ddd2c6;
  --muted: #b3a79c;
  --glass: rgba(24, 27, 22, 0.82);
  --glass-strong: rgba(31, 34, 29, 0.95);
  --line: rgba(215, 218, 179, 0.15);
  --line-strong: rgba(215, 218, 179, 0.26);
  --field: rgba(255, 255, 255, 0.06);
  --field-line: rgba(215, 218, 179, 0.24);
  --accent: #C66F80;
  --accent-text: #efa9b7;
  --accent-soft: rgba(198, 111, 128, 0.22);
  --accent-2: #b4c08a;
  --on-accent: #fff;
  --shadow: 0 14px 38px rgba(0, 0, 0, 0.45);
  --overlay: linear-gradient(180deg, rgba(10, 12, 9, 0.55), rgba(10, 12, 9, 0.72));
  --danger: #ff8f97;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 var(--sans);
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(34px, 5vw, 50px); }
h2 { font-size: 28px; }
h3 { font-size: 21px; }
h4 { margin: 0; }
p { margin: 0; }
a { color: var(--accent-text); }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------- background ---------- */

#bg { position: fixed; inset: 0; z-index: -1; background: var(--bg); }
.bg-layer {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity .8s ease;
}
.bg-layer.on { opacity: 1; }
#bg::after { content: ''; position: absolute; inset: 0; background: var(--overlay); }

/* ---------- surfaces ---------- */

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { padding: 22px; margin-bottom: 18px; }
.panel > h2 { margin-bottom: 6px; }
.panel-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 14px; }
.panel-head.wrap { flex-wrap: wrap; }

.page-head {
  display: inline-block;
  max-width: 100%;
  margin: 6px 0 14px;
  padding: 14px 22px;
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
}
.page-head .lead { color: var(--ink-2); max-width: 720px; margin-top: 4px; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 12px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }
.loading { padding: 60px 0; text-align: center; color: var(--ink); font-family: var(--serif); font-size: 24px; }
.error-box { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 10px; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  margin: 10px 16px 14px;
  padding: 8px 12px 8px 18px;
}
.logo-link { text-decoration: none; color: inherit; flex-shrink: 0; }
.logo { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.logo-main { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 30px; color: var(--accent-text); letter-spacing: .01em; }
.logo-by { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--accent-2); font-weight: 600; }

.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 14px; border-radius: 999px; white-space: nowrap;
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px;
  transition: background .2s, color .2s;
}
.nav a:hover { background: var(--accent-soft); }
.nav a.active { background: var(--accent); color: var(--on-accent); }

.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.save-status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--field); border: 1px solid var(--line); white-space: nowrap;
}
.save-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }
.save-status.busy .dot { background: var(--olive); animation: pulse 1s infinite ease-in-out; }
.save-status.err { color: var(--danger); border-color: currentColor; }
.save-status.err .dot { background: var(--danger); }
.save-status .retry { border: 0; background: none; padding: 0 0 0 4px; color: inherit; text-decoration: underline; font-weight: 700; }
@keyframes pulse { 50% { opacity: .3; } }

.content { max-width: 1680px; margin: 0 auto; padding: 0 16px 64px; }

/* ---------- controls ---------- */

input, textarea, select {
  font: inherit; color: var(--ink);
  background: var(--field);
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; line-height: 1.5; }
select { width: auto; padding-right: 28px; }
select option { background: var(--bg); color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[type="date"] { width: auto; }
input[type="number"].year-input { width: 92px; }

input.inline, textarea.inline {
  background: transparent; border: 0; border-bottom: 1px solid transparent; border-radius: 0;
  padding: 3px 2px; flex: 1;
}
textarea.inline { resize: none; overflow: hidden; line-height: 1.35; min-height: 0; display: block; }
.inline:hover { border-bottom-color: var(--line); }
.inline:focus { outline: none; border-bottom-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; background: var(--field); text-decoration: none;
  transition: transform .15s, background .2s, border-color .2s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.wide { width: 100%; padding: 12px; }
.btn:disabled { opacity: .6; cursor: progress; }

.icon-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); background: var(--field);
  font-size: 17px; line-height: 1; text-decoration: none; color: var(--ink);
  transition: background .2s;
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 14px; }
.icon-btn.del { width: 24px; height: 24px; border: 0; background: transparent; color: var(--muted); font-size: 18px; opacity: 0; }
.icon-btn.del:hover, .icon-btn.del:focus-visible { color: var(--danger); background: var(--accent-soft); }
.item:hover .icon-btn.del, .entry:hover .icon-btn.del, .proc-row .icon-btn.del, .habit-name:hover .icon-btn.del,
.icon-btn.del:focus-visible { opacity: 1; }
@media (hover: none) { .icon-btn.del { opacity: .7; } }

.chip {
  padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-strong); background: var(--field);
}
.chip:hover { background: var(--accent-soft); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.sm { padding: 3px 9px; font-size: 12px; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--field); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--on-accent); }

.year-nav { display: inline-flex; align-items: center; gap: 10px; }
.year-label { font-family: var(--serif); font-size: 26px; min-width: 64px; text-align: center; }

/* checkbox */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; position: relative; flex-shrink: 0; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box {
  width: 19px; height: 19px; border-radius: 6px; flex-shrink: 0;
  border: 1.6px solid var(--accent-2); background: var(--field);
  display: grid; place-items: center; transition: background .15s;
}
.check .box::after { content: ''; width: 5px; height: 9px; border: solid transparent; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.check input:checked + .box { background: var(--accent-2); }
.check input:checked + .box::after { border-color: var(--bg); }
:root[data-theme="light"] .check input:checked + .box::after { border-color: #fff; }
.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.check-label { font-size: 14px; font-weight: 500; }

/* list items */
.item { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; min-height: 32px; }
.item .item-text { flex: 1; min-width: 0; overflow-wrap: break-word; padding-top: 3px; line-height: 1.35; }
.item > .check, .item > .icon-btn { margin-top: 3px; }
.item.add-row { align-items: center; }
.item.add-row > .icon-btn { margin-top: 0; }
.item.done .inline, .item.done .item-text { text-decoration: line-through; color: var(--muted); }
.add-row { opacity: .9; }
.add-btn { width: 22px; height: 22px; font-size: 15px; border-style: dashed; }
input.inline.add::placeholder { font-style: italic; }

/* field */
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.field-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ring + bar */
.ring-wrap { position: relative; flex-shrink: 0; display: grid; place-items: center; }
.ring { position: absolute; inset: 0; }
.ring-track { stroke: var(--line-strong); }
.ring-bar { stroke: var(--accent); transition: stroke-dashoffset .5s ease; }
.ring-text { font-weight: 700; font-size: 13px; }
.bar { height: 7px; border-radius: 9px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--olive), var(--accent)); border-radius: inherit; transition: width .5s; }

/* ---------- auth ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(430px, 100%); padding: 32px 28px; display: flex; flex-direction: column; }
.auth-card .logo { justify-content: center; margin-bottom: 6px; }
.auth-card .logo-main { font-size: 42px; }
.auth-sub { text-align: center; color: var(--ink-2); margin-bottom: 18px; }
.auth-card .seg { align-self: center; margin-bottom: 4px; }
.auth-card .btn { margin-top: 8px; }
.auth-note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 14px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1px; }
.theme-float { position: fixed; top: 16px; right: 16px; }

/* ---------- calendar ---------- */

.month-chips, .type-picker {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.type-picker .muted { font-size: 13px; margin-right: 4px; }

.cal-month { padding: 12px; overflow: hidden; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-weight: 700; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 4px 0 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-cell {
  min-height: 132px; padding: 8px 8px 6px;
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.cal-cell.weekend { background: color-mix(in srgb, var(--rose-soft) 55%, var(--glass-strong)); }
:root[data-theme="dark"] .cal-cell.weekend { background: color-mix(in srgb, var(--rose) 10%, var(--glass-strong)); }
.cal-cell.today { border: 2px solid var(--accent); }
.cal-cell.other { background: transparent; border-style: dashed; opacity: .55; }
.cal-num { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--serif); font-size: 22px; font-weight: 700; }
.cal-cell.today .cal-num { color: var(--accent-text); }
.cal-wd { font-family: var(--sans); font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; display: none; }
.entries { display: flex; flex-direction: column; gap: 1px; }
.entry { display: flex; align-items: flex-start; gap: 4px; font-size: 13px; border-radius: 6px; padding: 0 2px; }
.entry .inline { padding: 2px 0; font-size: 13px; }
.entry.done .inline { text-decoration: line-through; color: var(--muted); }
.entry .check { margin-top: 3px; }
.entry .icon-btn.del { margin-top: 1px; }
.entry .check .box { width: 15px; height: 15px; border-radius: 4px; }
.entry .check .box::after { width: 4px; height: 7px; }
.t-task { --t: var(--accent-2); }
.t-event { --t: var(--olive); }
.t-birthday { --t: var(--rose); }
.t-note { --t: var(--muted); }
.entry-type { border: 0; background: none; padding: 3px 0 0; width: 16px; font-size: 12px; flex-shrink: 0; color: var(--t); }
.entry.t-note .inline { font-style: italic; }
.entry.t-birthday .inline, .entry.t-event .inline { font-weight: 600; }
.cal-add { font-size: 13px; margin-top: auto; padding: 4px 2px !important; }
.cal-add::placeholder { opacity: .55; }
.type-picker .chip.on { background: var(--t); border-color: var(--t); color: #fff; }
.type-picker .chip.t-event.on, :root[data-theme="dark"] .type-picker .chip.t-task.on { color: #232a1f; }

.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.mini-month { padding: 14px; }
.mini-title { border: 0; background: none; font-family: var(--serif); font-size: 22px; font-weight: 700; padding: 0 0 8px; color: var(--accent-text); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.mini-wd { font-size: 11px; font-weight: 700; color: var(--muted); padding: 2px 0; }
.mini-day { position: relative; border: 0; background: none; font-size: 13px; padding: 5px 0 7px; border-radius: 8px; }
.mini-day:hover { background: var(--accent-soft); }
.mini-day.other { opacity: .35; }
.mini-day.today { outline: 1.5px solid var(--accent); font-weight: 700; }
.mini-day.has { font-weight: 700; }
.mini-day.in-week { background: var(--accent-soft); font-weight: 700; }
.dots { position: absolute; left: 0; right: 0; bottom: 1px; display: flex; justify-content: center; gap: 2px; }
.dots b { width: 4px; height: 4px; border-radius: 50%; background: var(--t); }

/* ---------- week planner ---------- */

.week-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; align-items: start; }
.week-side { padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.side-title { font-size: 30px; color: var(--accent-text); }
.week-side .field { margin: 10px 0 4px; }
.side-group { display: flex; flex-direction: column; gap: 4px; }
.date-row { display: flex; gap: 6px; align-items: center; }
.date-row input { flex: 1; width: 100%; }
.period { font-family: var(--serif); font-size: 21px; font-weight: 600; margin: 2px 0 6px; }
.side-group > .btn { align-self: flex-start; margin-bottom: 4px; }
.mini-cal { margin: 8px 0; padding: 10px; border-radius: 14px; background: var(--field); border: 1px solid var(--line); }
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 700; }
.side-block { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 10px; }
.side-block h3 { font-size: 22px; margin-bottom: 8px; }
.progress-row { display: flex; align-items: center; gap: 16px; }
.progress-row > div:last-child { flex: 1; }
.progress-row .ring-text { font-size: 18px; }
.big-num { font-family: var(--serif); font-size: 28px; font-weight: 700; line-height: 1; }

.habit-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.habits { width: 100%; border-collapse: collapse; font-size: 13px; }
.habits th, .habits td { padding: 4px 2px; text-align: center; }
.habits thead th { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.habits thead th small { display: block; font-size: 12px; color: var(--ink); }
.habits thead th.today, .habits td.today { color: var(--accent-text); background: var(--accent-soft); }
.habits tbody tr { border-top: 1px solid var(--line); }
.habits tbody th { text-align: left; font-weight: 500; }
.habits tfoot td, .habits tfoot th { font-weight: 700; font-size: 12px; color: var(--muted); padding-top: 8px; text-align: center; }
.habits tfoot th { text-align: left; }
.habit-name { display: flex; align-items: center; gap: 4px; min-width: 84px; }
.habits td { padding: 3px 1px; }
.habits .check .box { width: 16px; height: 16px; border-radius: 5px; }
.habits.wide .habit-name { min-width: 220px; }
.habits.wide td, .habits.wide th { padding: 7px 6px; }
.habit-count { font-size: 11px; color: var(--muted); font-weight: 700; flex-shrink: 0; }

.week-days {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(176px, 1fr);
  gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: start;
  scroll-snap-type: x proximity;
}
.day-col { padding: 14px 10px 12px; display: flex; flex-direction: column; gap: 10px; scroll-snap-align: start; min-width: 0; container-type: inline-size; }
.day-col.today { border: 2px solid var(--accent); }
.day-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title ring" "date ring"; align-items: center; column-gap: 8px; }
.day-head h3 { grid-area: title; font-size: 22px; overflow-wrap: anywhere; }
.day-head .day-date { grid-area: date; }
.day-head .ring-wrap { grid-area: ring; }
.day-col.today .day-head h3 { color: var(--accent-text); }
.day-date { font-size: 13px; color: var(--muted); font-weight: 600; }
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.counters > div { background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 5px 2px; text-align: center; }
.counters b { display: block; font-size: 17px; line-height: 1.2; }
.counters span { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
/* narrow day columns: name on its own line, counters as a compact list */
@container (max-width: 200px) {
  .day-head { grid-template-areas: "title title" "date ring"; }
  .day-head h3 { font-size: 20px; margin-bottom: 2px; }
  .counters { grid-template-columns: 1fr; gap: 0; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 3px 0; }
  .counters > div { display: flex; align-items: baseline; justify-content: space-between; background: none; border: 0; padding: 1px 9px; text-align: left; }
  .counters b { font-size: 15px; }
  .counters span { order: -1; letter-spacing: .04em; }
  .day-section .item { font-size: 13px; gap: 6px; }
}
.day-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 2px; }
.day-section .item { font-size: 14px; }
.day-events { display: flex; flex-direction: column; gap: 4px; }
.event-chip { font-size: 13px; padding: 4px 8px; border-radius: 8px; background: color-mix(in srgb, var(--t) 20%, transparent); border-left: 3px solid var(--t); overflow-wrap: anywhere; }
.day-note { font-size: 14px; min-height: 70px; }

/* ---------- care ---------- */

.care-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.care-col { padding: 14px 12px; min-width: 0; }
.care-col.today { border: 2px solid var(--accent); }
.care-col h3 { font-size: 20px; }
.care-col .day-date { margin-bottom: 8px; }
.care-col .item { font-size: 14px; }
.proc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.proc-row > input { flex: 1 1 220px; }
.proc-new { border-bottom: 0; }
.proc-new > input { border-bottom: 1px dashed var(--line-strong); }
.wd-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- food ---------- */

.profile { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 26px; }
.profile h3.sub { font-size: 20px; margin: 14px 0 8px; }
.profile-photos { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.photo-card {
  aspect-ratio: 4 / 3; border-radius: 6px; background-size: cover; background-position: center;
  border: 8px solid #fffaf4; box-shadow: var(--shadow); transform: rotate(2deg);
}
.photo-card:nth-child(2) { transform: rotate(-2.5deg); margin-left: 18px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.metrics.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
.metrics.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); }
.metric-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.metric-input { display: flex; align-items: baseline; gap: 6px; }
.metric-input input { border: 0; background: transparent; padding: 0; font-family: var(--serif); font-size: 26px; font-weight: 700; }
.metric-input input:focus { outline: none; }
.metric:focus-within { border-color: var(--accent); }
.unit { font-size: 13px; color: var(--muted); font-weight: 600; }

.date-pickers { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.plan-date { margin: 16px 0 12px; font-size: 26px; color: var(--accent-text); }
.meal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.meal-card { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--field); border: 1px solid var(--line); }
.meal-card:focus-within { border-color: var(--accent); }
.meal-title { font-family: var(--serif); font-size: 23px; font-weight: 700; color: var(--accent-2); }
.meal-card textarea { border: 0; background: transparent; padding: 0; min-height: 90px; resize: none; }
.meal-card textarea:focus { outline: none; }
.kbju { margin-top: 18px; }
.kbju h3 { margin-bottom: 10px; }

.month-list { display: flex; flex-direction: column; gap: 4px; }
.month-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) 320px; gap: 12px; align-items: center;
  text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--field);
}
button.month-row:hover { border-color: var(--accent); }
.month-row.head { background: transparent; border: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.month-row.today { border: 2px solid var(--accent); }
.month-row.empty { opacity: .72; }
.mr-date { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.mr-date b { font-family: var(--serif); font-size: 22px; color: var(--ink); }
.mr-meals { font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.mr-meals em { font-style: normal; font-weight: 700; color: var(--accent-2); }
.mr-kbju { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 13px; text-align: center; }

/* ---------- books ---------- */

.shelf {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  column-gap: 24px; row-gap: 30px; padding: 28px 26px 22px;
}
.book { position: relative; display: flex; flex-direction: column; padding-top: 30px; min-width: 0; }
.book-tab {
  position: absolute; top: 0; left: var(--tab-shift, 0); max-width: 76%;
  padding: 6px 12px 10px; border: 0; border-radius: 10px 10px 0 0;
  background: var(--book); color: var(--book-ink);
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, .12);
}
.book-cover {
  position: relative; z-index: 1;
  aspect-ratio: 2 / 3; width: 100%; padding: 0; overflow: hidden;
  border: 0; border-top: 5px solid var(--book); border-radius: 3px 10px 10px 3px;
  background: var(--book); color: var(--book-ink);
  box-shadow: 0 14px 22px -10px rgba(0, 0, 0, .55), 0 2px 4px rgba(0, 0, 0, .2);
  transition: transform .2s;
}
.book-cover:hover { transform: translateY(-4px); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 12px; z-index: 1;
  background: linear-gradient(90deg, rgba(0, 0, 0, .28), rgba(255, 255, 255, .18) 60%, transparent);
}
.cover-title { display: grid; place-items: center; height: 100%; padding: 14px 12px 14px 20px; font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.1; overflow-wrap: anywhere; }
/* wooden shelf plank under each cover; neighbouring planks join across the gap */
.book::after {
  content: ''; position: absolute; left: -13px; right: -13px; bottom: 32px;
  height: 12px; background: linear-gradient(#a37b57, #6e4f35); border-radius: 2px;
  box-shadow: 0 6px 10px rgba(0, 0, 0, .3);
}
.read-badge { position: absolute; z-index: 2; right: 6px; bottom: 8px; padding: 2px 8px; border-radius: 999px; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; }
.book.is-read .book-cover img { filter: saturate(.85); }
.book-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 44px; padding-top: 16px; }
.book-actions .check-label { font-size: 13px; }
.empty-state { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }

/* ---------- self-development folders ---------- */

.folders { margin-top: 6px; padding-right: 22px; overflow-x: clip; }
.folder-tabs { display: flex; padding: 0 0 0 18px; position: relative; z-index: 3; overflow-x: auto; scrollbar-width: none; }
.folder-tabs::-webkit-scrollbar { display: none; }
.folder-tab {
  position: relative; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 8px;
  margin-right: -12px; padding: 11px 26px 15px; border: 0;
  border-radius: 16px 16px 0 0;
  background: var(--tab); color: var(--tab-ink);
  font-family: var(--serif); font-size: 21px; font-weight: 700;
  box-shadow: 0 -3px 10px rgba(0, 0, 0, .12);
  transform: translateY(8px); transition: transform .2s;
}
.folder-tab:hover { transform: translateY(3px); }
.folder-tab.on { transform: translateY(1px); padding-bottom: 20px; }
.folder-tab small { font-family: var(--sans); font-size: 11px; font-weight: 700; background: rgba(255, 255, 255, .35); border-radius: 999px; padding: 1px 7px; }
.folder-wrap { position: relative; margin-top: -6px; }
.folder-layer {
  position: absolute; inset: 0; border-radius: 4px 22px 22px 22px;
  background: var(--tab);
  transform: translate(calc(var(--n) * 7px), calc(var(--n) * -7px)) rotate(calc(var(--n) * .35deg));
  box-shadow: var(--shadow);
}
.folder-body {
  position: relative; z-index: 2;
  min-height: 320px; padding: 24px 24px 30px;
  border-radius: 4px 22px 22px 22px;
  background: color-mix(in srgb, var(--folder) 16%, var(--glass-strong));
  border-top: 7px solid var(--folder);
  box-shadow: var(--shadow);
}
.folder-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-bottom: 22px; }
.folder-head .muted { flex: 1; }
.empty-note { color: var(--ink-2); }

.materials { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 30px 24px; padding-top: 12px; }
.material {
  position: relative; padding: 10px 10px 12px; border-radius: 4px;
  background: var(--glass-strong); border: 1px solid var(--line);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .14);
  transform: rotate(var(--tilt)); transition: transform .2s;
}
.material:hover { transform: rotate(0) translateY(-3px); }
.clip { position: absolute; top: -22px; left: 24px; z-index: 2; color: #9b9a96; transform: rotate(-10deg); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3)); }
:root[data-theme="dark"] .clip { color: #c7c4bd; }
.material-photo { display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0; overflow: hidden; background: var(--accent-soft); border-radius: 2px; }
.material-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-ph { display: grid; place-items: center; height: 100%; font-family: var(--serif); font-size: 64px; color: var(--accent-text); }
.material.done .material-photo img { filter: grayscale(.45); }
.material-body { padding: 10px 2px 0; }
.material-body h3 { font-size: 21px; overflow-wrap: anywhere; }
.material.done h3 { text-decoration: line-through; text-decoration-color: var(--accent); }
.notes { margin-top: 6px; font-size: 13px; color: var(--ink-2); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.material-actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.material-actions .check-label { font-size: 13px; }

/* ---------- wish list ---------- */

.wish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.wish { overflow: hidden; padding: 0; display: flex; flex-direction: column; }
.wish-photo { position: relative; display: block; aspect-ratio: 1; padding: 0; border: 0; overflow: hidden; background: var(--accent-soft); }
.wish-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.wish-photo:hover img { transform: scale(1.04); }
.ribbon { position: absolute; top: 18px; right: -36px; transform: rotate(45deg); background: var(--green); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 40px; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.wish-body { padding: 12px 14px 14px; }
.wish-body h3 { overflow-wrap: anywhere; }
.wish.done h3 { color: var(--muted); }

/* ---------- modal ---------- */

.overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(25, 18, 14, .5); animation: fade .15s; }
.modal { width: min(540px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 24px; background: var(--glass-strong); }
.modal h2 { margin-bottom: 4px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.img-field { display: flex; gap: 16px; align-items: flex-start; }
.img-preview {
  width: 120px; aspect-ratio: 3 / 4; flex-shrink: 0; border-radius: 10px;
  border: 1.5px dashed var(--line-strong); background: var(--field) center / cover no-repeat;
}
.img-preview.has { border-style: solid; }
.img-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.swatch-row { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); }
@keyframes fade { from { opacity: 0; } }

/* ---------- toast ---------- */

#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translate(-50%, 20px);
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s;
  max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }

/* ---------- responsive ---------- */

@media (max-width: 1280px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .nav { order: 3; flex-basis: 100%; }
  .top-actions { margin-left: auto; }
  .care-week { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: minmax(190px, 1fr); overflow-x: auto; padding-bottom: 6px; }
}

/* below 1800px the planner sidebar becomes a band above the days so all 7 columns stay readable */
@media (max-width: 1799px) {
  .week-layout { grid-template-columns: 1fr; }
  .week-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 8px 26px; align-items: start; }
  .week-side .side-block { border-top: 0; margin-top: 0; padding-top: 4px; }
}

@media (max-width: 1100px) {
  .month-row { grid-template-columns: 64px minmax(0, 1fr); }
  .month-row .mr-kbju { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .profile { grid-template-columns: 1fr; }
  .profile-photos { flex-direction: row; order: -1; padding: 0 0 4px; }
  .photo-card { flex: 1; }
  .photo-card:nth-child(2) { margin-left: 0; }
  .metrics.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meal-grid { grid-template-columns: 1fr; }

  .cal-head { display: none; }
  .cal-grid { grid-template-columns: 1fr; }
  .cal-cell { min-height: 0; }
  .cal-cell.other { display: none; }
  .cal-wd { display: inline; }
  .cal-num { font-size: 20px; }
}

@media (max-width: 720px) {
  .topbar { margin: 8px; top: 8px; padding: 8px 10px 8px 14px; gap: 8px; }
  .logo-main { font-size: 25px; }
  .logo-by { font-size: 10px; letter-spacing: .16em; }
  .save-status { padding: 5px 9px; font-size: 12px; }
  .content { padding: 0 10px 48px; }
  .panel { padding: 16px; }
  .page-head { padding: 12px 16px; }
  .week-side { display: flex; }
  .week-side .side-block { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 14px; }
  .week-days { grid-auto-columns: 84vw; scroll-snap-type: x mandatory; margin: 0 -10px; padding: 0 10px 8px; scroll-padding: 0 10px; }
  .care-week { grid-auto-columns: 78vw; scroll-snap-type: x mandatory; }
  .care-col { scroll-snap-align: start; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); column-gap: 18px; padding: 22px 16px; }
  .folder-tab { font-size: 17px; padding: 9px 18px 13px; }
  .folder-body { padding: 18px 14px 24px; }
  .materials { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 26px 14px; }
  .wish-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .img-field { flex-direction: column; }
  .modal { padding: 18px; }
}

@media (max-width: 420px) {
  .logo { flex-direction: column; gap: 0; }
  .logo-main { font-size: 23px; line-height: 1; }
  .logo-by { font-size: 9px; }
  .materials { grid-template-columns: 1fr 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
}

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