:root { font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color-scheme: light dark; }
* { box-sizing: border-box; }
body { margin:0; min-height:100vh; background:Canvas; color:CanvasText; }
main { max-width:760px; margin:0 auto; padding:20px 16px 100px; }
h1 { font-size:1.4rem; margin:0 0 6px; }
.sub { opacity:.65; margin-bottom:14px; }
nav { display:flex; gap:8px; overflow-x:auto; padding:0 0 12px; scrollbar-width:none; }
nav a { white-space:nowrap; padding:8px 14px; font-size:.9rem; border-radius:999px; text-decoration:none; color:CanvasText; background:color-mix(in srgb, CanvasText 8%, Canvas); }
nav a.active { background:CanvasText; color:Canvas; }

/* Section Labels */
.section-label { margin:20px 0 8px; font-size:.78rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase; opacity:.58; display:flex; justify-content:space-between; align-items:center; }
.card { border:1px solid color-mix(in srgb, CanvasText 16%, transparent); border-radius:16px; padding:14px; margin-top:12px; }

/* Grids */
.grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.grid label, .field { display:flex; flex-direction:column; gap:6px; font-size:.82rem; font-weight:600; }
.grid label span, .field > span { opacity:.65; }
.full { grid-column:1 / -1; }

input[type=text], input[type=date], input[type=number], select, textarea { width:100%; font:inherit; font-weight:400; padding:11px 14px; border-radius:12px; border:1px solid color-mix(in srgb, CanvasText 20%, transparent); background:Canvas; color:CanvasText; }
textarea { min-height:120px; resize:vertical; border-radius:14px; }

/* Multi-Column Checklist Grid (3 to 5 columns on desktop, 2 to 3 on mobile) */
.checklist-columns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}
@media (min-width: 600px) {
  .checklist-columns {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 720px) {
  .checklist-columns {
    grid-template-columns: repeat(4, 1fr);
  }
}

.check-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, CanvasText 14%, transparent);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  background: color-mix(in srgb, CanvasText 2%, Canvas);
  transition: all 0.12s ease;
  font-size: 0.86rem;
  line-height: 1.25;
}
.check-card:hover {
  background: color-mix(in srgb, CanvasText 5%, Canvas);
}
.check-card.on {
  background: color-mix(in srgb, CanvasText 10%, Canvas);
  border-color: CanvasText;
  font-weight: 600;
}
.check-card input[type=checkbox] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: CanvasText;
  flex: 0 0 auto;
}

/* Collapsible Recent History Accordion & Table */
details.recent-panel {
  border: 1px solid color-mix(in srgb, CanvasText 14%, transparent);
  border-radius: 14px;
  padding: 10px 14px;
  margin-top: 10px;
  margin-bottom: 16px;
  background: color-mix(in srgb, CanvasText 2%, Canvas);
}
details.recent-panel summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.86rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.recent-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}
table.recent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}
table.recent-table th {
  padding: 6px 10px;
  border-bottom: 1px solid color-mix(in srgb, CanvasText 16%, transparent);
  opacity: 0.65;
  font-weight: 600;
  white-space: nowrap;
}
table.recent-table td {
  padding: 8px 10px;
  border-bottom: 1px solid color-mix(in srgb, CanvasText 8%, transparent);
  white-space: nowrap;
}
table.recent-table tr:last-child td {
  border-bottom: 0;
}
table.recent-table a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Preset buttons */
.shortcuts { display:flex; gap:8px; overflow-x:auto; padding:0 0 10px; scrollbar-width:none; }
.shortcuts button { white-space:nowrap; padding:6px 12px; font-size:.82rem; }

.row { display:flex; gap:10px; flex-wrap:wrap; margin-top:10px; }
button { font:inherit; border:0; border-radius:999px; padding:11px 16px; cursor:pointer; }
button.primary { background:CanvasText; color:Canvas; }
button.secondary { background:color-mix(in srgb, CanvasText 8%, Canvas); color:CanvasText; }
button:disabled { opacity:.45; cursor:not-allowed; }
.status { margin-top:14px; min-height:1.4em; }
.ok { color:#278b49; } .danger { color:#c33; }
.tiny { font-size:.82rem; opacity:.7; }
.sticky { position:fixed; left:0; right:0; bottom:0; padding:10px 16px calc(10px + env(safe-area-inset-bottom)); background:color-mix(in srgb, Canvas 92%, transparent); backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px); border-top:1px solid color-mix(in srgb, CanvasText 12%, transparent); z-index:100; }
.sticky-inner { max-width:760px; margin:0 auto; display:flex; gap:10px; }
.sticky button { flex:1; }

/* Calendar Widget */
.calendar-widget {
  margin-top: 10px;
}
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 8px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day-name {
  font-size: 0.72rem;
  text-align: center;
  opacity: 0.5;
  font-weight: 600;
  padding-bottom: 4px;
}
.cal-day {
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, CanvasText 10%, transparent);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  position: relative;
  background: color-mix(in srgb, CanvasText 2%, Canvas);
}
.cal-day.empty {
  border: 0;
  background: transparent;
}
.cal-day.today {
  border-color: CanvasText;
  font-weight: 700;
}
.cal-day.logged {
  background: color-mix(in srgb, CanvasText 12%, Canvas);
  border-color: color-mix(in srgb, CanvasText 30%, transparent);
  font-weight: 600;
}
.cal-badge {
  font-size: 0.62rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  background: CanvasText;
  color: Canvas;
  margin-top: 2px;
}

/* Metric Stats Card (Days Since Cut / Protected) */
.metric-hero {
  border: 1px solid color-mix(in srgb, CanvasText 16%, transparent);
  border-radius: 16px;
  padding: 14px 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: color-mix(in srgb, CanvasText 3%, Canvas);
}
.metric-hero .val {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}
.metric-hero .lbl {
  font-size: 0.8rem;
  opacity: 0.65;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Freshness Badges */
.badge-overdue {
  color: #ef4444;
  font-weight: 700;
  background: color-mix(in srgb, #ef4444 12%, transparent);
  padding: 3px 7px;
  border-radius: 6px;
  display: inline-block;
  font-size: 0.76rem;
}
.badge-ok {
  color: #10b981;
  font-weight: 600;
  background: color-mix(in srgb, #10b981 12%, transparent);
  padding: 3px 7px;
  border-radius: 6px;
  display: inline-block;
  font-size: 0.76rem;
}
