:root {
  color-scheme: light dark;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1f6f54;
  --accent-text: #ffffff;
  --danger: #b91c1c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1210;
    --card: #161d1a;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: #26312c;
    --accent: #3fb68b;
    --accent-text: #06110c;
    --danger: #f87171;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

[hidden] {
  display: none !important;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 96px;
}

h1 {
  font-size: 24px;
  margin: 0;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}

button {
  font: inherit;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

button.small {
  padding: 6px 12px;
  font-size: 14px;
}

button.link {
  background: none;
  color: var(--muted);
  padding: 8px 4px;
}

input {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

/* ---- Shopping list ---- */

/* ---- Top navigation ---- */

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 8px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border-radius: 12px;
}

.tab {
  padding: 7px 14px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.tab.active {
  background: var(--accent);
  color: var(--accent-text);
}

.page-title {
  margin: 12px 0 2px;
}

.count {
  color: var(--muted);
  font-weight: 500;
  font-size: 18px;
}

.add {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 8px;
  padding: 10px 0;
  background: var(--bg);
}

.add input {
  flex: 1;
}

.items {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
}

.items:empty {
  display: none;
}

.items li {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  padding: 2px 4px;
  border-bottom: 1px solid var(--line);
}

.items li:last-child {
  border-bottom: 0;
}

.check {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  background: none;
  display: grid;
  place-items: center;
}

.check::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--muted);
}

.done .check::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--card);
}

.text {
  flex: 1;
  overflow-wrap: anywhere;
}

.done .text {
  color: var(--muted);
  text-decoration: line-through;
}

.del {
  flex: none;
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 8px 12px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 0;
  margin: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 4px 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: #111827;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 15px;
}

/* ---- Login ---- */

.login {
  max-width: 380px;
  padding-top: 12vh;
}

.login h1 {
  margin-bottom: 24px;
}

.login form {
  display: grid;
  gap: 12px;
}

.error {
  color: var(--danger);
  margin: 0;
}

.notice {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--accent);
}

.hint {
  color: var(--muted);
  font-size: 14px;
  margin-top: 28px;
}

/* ---- Today ---- */

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 4px 4px;
}

.date {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.weekday {
  margin-left: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
}

.place {
  margin-top: 2px;
  font-size: 14px;
  color: var(--muted);
}

.now {
  text-align: right;
}

.temp {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
}

.cond {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  color: var(--muted);
}

.card {
  margin: 12px 0;
  padding: 12px 16px;
  background: var(--card);
  border-radius: 14px;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--text);
}

.card h2 a {
  color: inherit;
  text-decoration: none;
}

.card .count {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.weather .line {
  margin: 4px 0;
}

.label {
  margin-right: 8px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
}

.agenda {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Two rows per event: time on the left; title with the calendar name below it. */
.agenda li {
  display: grid;
  grid-template-columns: 6.6em 1fr;
  grid-template-areas:
    "time title"
    "time src";
  column-gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.agenda li:first-child {
  border-top: 0;
}

.agenda .time {
  grid-area: time;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.agenda .title {
  grid-area: title;
  overflow-wrap: break-word;
}

.agenda .src {
  grid-area: src;
  font-size: 12px;
  color: var(--muted);
}

.empty.small {
  padding: 4px 0;
  text-align: left;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 0;
}

.chip {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 15px;
}

.chip.more {
  color: var(--muted);
}

.status {
  margin: 16px 4px;
  font-size: 13px;
  color: var(--muted);
}

.status p {
  margin: 2px 0;
}

.status .warn {
  color: var(--danger);
}

/* ---- Fridge screen preview ---- */

.sizes {
  margin: 8px 0 12px;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

a.chip {
  color: var(--text);
  text-decoration: none;
}

.kindle-frame {
  padding: 14px;
  background: #1f2328;
  border-radius: 18px;
}

.kindle-frame img {
  display: block;
  width: 100%;
  height: auto;
  background: #ffffff;
  border-radius: 2px;
}

.small-text {
  font-size: 14px;
  color: var(--muted);
}

.card p {
  margin: 6px 0;
}

code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ua {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
