/* ==========================================================================
   E-Diary — base: reset, type, controls
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--leather);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; text-wrap: balance; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.num { font-variant-numeric: tabular-nums; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* thin, quiet scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- icons ---------- */
.ic {
  width: 1.25em; height: 1.25em; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.25em;
}
.ic .fill { fill: currentColor; stroke: none; }
.ic text { font-family: var(--font-ui); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 14px;
  border: 1px solid var(--card-border); border-radius: 8px;
  background: var(--paper-3); color: var(--ink);
  font-weight: 550; font-size: 14px; line-height: 1.1;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
  transition: background-color .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--rule-strong); background: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--well); }
.btn.small { min-height: 28px; padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-3);
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--well); color: var(--ink); }
.icon-btn .ic { width: 22px; height: 22px; }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.sm .ic { width: 18px; height: 18px; }
.icon-btn.active { color: var(--accent); }

/* the round blue "+" used next to Add Task / Add Role / Add Goal */
.add-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  border: 3px solid var(--accent); background: var(--paper-3); color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform .12s, background-color .15s;
  flex: none;
}
.add-btn:hover { background: var(--accent); color: var(--accent-ink); }
.add-btn:active { transform: scale(.94); }
.add-btn .ic { width: 22px; height: 22px; stroke-width: 2.6; }

.link-btn {
  border: 0; background: none; padding: 0; color: var(--accent);
  font-weight: 500; cursor: pointer; text-align: left;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- form fields ---------- */
.field, select.field, textarea.field {
  width: 100%; min-height: 34px; padding: 6px 10px;
  border: 1px solid var(--card-border); border-radius: 8px;
  background: var(--paper-3); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
textarea.field { min-height: 80px; resize: vertical; line-height: 1.45; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--ink-3); }
select.field { padding-right: 28px; }
input[type="date"].field, input[type="time"].field { font-variant-numeric: tabular-nums; }
input[type="color"] { width: 40px; height: 32px; padding: 0 2px; border: 1px solid var(--card-border); border-radius: 8px; background: var(--paper-3); }

label.lbl, .lbl { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--ink-2); margin-bottom: 4px; }
.hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.hint a { color: var(--accent); }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; width: 44px; height: 26px; border-radius: 26px;
  background: var(--toggle-off); transition: background-color .18s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform .18s;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* segmented control */
.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--well); border: 1px solid var(--card-border); gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 550; color: var(--ink-2);
}
.seg button[aria-pressed="true"] { background: var(--paper-3); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 550;
  background: var(--well); color: var(--ink-2); border: 1px solid var(--card-border);
  white-space: nowrap;
}
.chip button { border: 0; background: none; padding: 0; color: inherit; display: inline-grid; place-items: center; }
.chip .ic { width: 14px; height: 14px; }

/* progress bar (blue fill on grey rail, as in the paper planner) */
.bar { position: relative; height: 12px; border-radius: 12px; background: var(--paper-2); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.12); }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 12px; background: linear-gradient(180deg, #4d9bff, #1f6fe0); min-width: 12px; }
.bar.done > i { background: linear-gradient(180deg, #56c166, #2e8b3b); }

/* coloured text from user-chosen category/role colours */
.tinted { color: var(--c, var(--ink)); }
@supports (color: color-mix(in srgb, red, white)) {
  .tinted { color: color-mix(in srgb, var(--c, var(--ink)), #fff var(--tint-mix)); }
}

/* empty states */
.empty {
  display: grid; place-items: center; gap: 10px; text-align: center;
  padding: 28px 16px; color: var(--ink-3); font-size: 14px;
}
.empty .ic { width: 44px; height: 44px; stroke-width: 1.4; opacity: .7; }

/* loading shimmer for first paint */
.loading-note { color: var(--topbar-ink-2); text-align: center; padding: 60px 16px; font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
