@font-face {
  font-family: 'Lexend';
  src: url('fonts/lexend-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0E1116;
  --surface: #161B22;
  --surface-line: #232A33;
  --line: #2A323D;
  --text: #ECEFF3;
  --muted: #A9B1BC;
  --soft: #C9D0D9;
  --track: #252D38;
  --parish: #8CB4E6;
  --addiction: #9FCB8F;
  --on-accent: #0E1116;
  --error: #FF9B9B;
  --radius: 16px;
  font-family: 'Lexend', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 18px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
h2 { font-size: 1.1rem; font-weight: 700; margin: 0; }
p { margin: 0; }

.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); }
.error { color: var(--error); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }

input[type="password"], input[type="text"], input[type="date"],
input[type="time"], input[type="number"] {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.primary, .secondary, .danger {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 700;
}
.primary { border: 0; background: var(--text); color: var(--bg); min-height: 56px; }
.secondary { border: 2px solid var(--line); background: transparent; }
.danger { border: 0; background: var(--error); color: var(--bg); }
.primary:disabled, .secondary:disabled, .danger:disabled { opacity: 0.5; cursor: not-allowed; }

.link {
  min-height: 48px;
  padding: 12px 4px;
  border: 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:disabled { opacity: 0.5; cursor: not-allowed; }
.danger-text { color: var(--error); }

.banner {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600;
  text-align: center;
}

#login .stack { margin-top: 32px; }

/* Main screen: one column with even spacing */
#app { display: flex; flex-direction: column; gap: 16px; }

.month-nav {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 10px;
  text-align: center;
}
#month-title { font-size: 25px; font-weight: 700; }
#today-line { font-size: 15px; color: var(--muted); }
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.summary { display: grid; gap: 16px; }

.area-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--surface-line);
  border-radius: 20px;
  background: var(--surface);
}
.area-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.area-card .area-name { font-size: 20px; }
.area-parish .area-name, .item-area.area-parish { color: var(--parish); }
.area-addiction .area-name, .item-area.area-addiction { color: var(--addiction); }
.area-balance { font-size: 15px; color: var(--muted); white-space: nowrap; }
.area-balance strong { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

.week { display: flex; flex-direction: column; gap: 4px; }
.week .label { font-size: 15px; color: var(--muted); }
.week .big { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.big .of { font-size: 18px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.week-status { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 16px; color: var(--soft); }
.area-parish .week-status.done { color: var(--parish); }
.area-addiction .week-status.done { color: var(--addiction); }
.week-status svg { flex: none; }
.week-note { font-size: 15px; color: var(--muted); }

.bar { background: var(--track); }
.bar .fill { height: 100%; }
.area-parish .fill { background: var(--parish); }
.area-addiction .fill { background: var(--addiction); }
.bar-week { height: 16px; margin-top: 6px; border-radius: 8px; overflow: hidden; }
.bar-week .fill { border-radius: 8px; }
.bar-month { position: relative; height: 10px; border-radius: 5px; }
.bar-month .fill { border-radius: 5px; }
.due {
  position: absolute;
  top: -5px;
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: var(--text);
}

.month { display: flex; flex-direction: column; gap: 6px; }
.month-head { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; color: var(--muted); }
.month-status { font-size: 15px; color: var(--soft); }

.add-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 62px;
  font-size: 20px;
}
.ghost {
  width: 100%;
  min-height: 50px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
}
.ghost:disabled { opacity: 0.5; cursor: not-allowed; }

/* Figures table, still used by the print view */
.figures {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 16px;
  margin: 6px 0 0;
}
.figures dt { color: var(--muted); }
.figures dd {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.list-title { margin: 8px 0 -8px; font-size: 17px; font-weight: 500; color: var(--muted); }
.items { display: flex; flex-direction: column; gap: 8px; list-style: none; margin: 0; padding: 0; }
.item {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 14px 16px;
  border: 1px solid var(--surface-line);
  border-radius: 16px;
  background: var(--surface);
  text-align: left;
}
.item-line {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 10px;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}
.item-date { color: var(--soft); }
.item-area { font-weight: 500; }
.item-dur { font-weight: 700; }
.item-note { display: block; margin-top: 2px; padding-left: 96px; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 18px;
  font-size: 16px;
  color: var(--muted);
}
.footer a, .footer .link { display: inline-block; min-height: 48px; padding: 12px 0; color: var(--text); }
.version { width: 100%; font-size: 14px; }

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 20px 16px max(20px, env(safe-area-inset-bottom));
  border: 1px solid var(--surface-line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / 0.6); }

@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: sheet-in 0.2s ease-out; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
}

.choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}
.choice legend { margin-bottom: 6px; padding: 0; color: var(--muted); }
.choice-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}
.choice-btn input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.choice-btn:has(input:checked) { border-color: var(--text); background: var(--text); color: var(--bg); }
.choice-btn.area-parish:has(input:checked) { border-color: var(--parish); background: var(--parish); color: var(--on-accent); }
.choice-btn.area-addiction:has(input:checked) { border-color: var(--addiction); background: var(--addiction); color: var(--on-accent); }
.choice-btn:has(input:focus-visible) { outline: 3px solid var(--text); outline-offset: 2px; }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button {
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pair label { display: grid; gap: 4px; color: var(--muted); }
.pair input { color: var(--text); }

.confirm { padding: 12px; border: 2px solid var(--error); border-radius: var(--radius); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}
