:root {
  color-scheme: light;
  font-family: "Noto Sans Armenian", "Arial", sans-serif;
  color: #292b28;
  background: #f5f1e8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --ink: #292b28;
  --muted: #89877f;
  --paper: #fffefa;
  --line: #e9e5db;
  --green: #58765b;
  --red: #c65c4c;
}

* {
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 0, rgb(255 255 255 / 54%), transparent 58%),
    #f5f1e8;
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.notebook {
  width: min(100% - 40px, 680px);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 0 80px;
}

.topbar,
.brand,
.composer-footer,
.list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  justify-content: flex-start;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: var(--green);
  color: white;
  font-family: "Noto Sans Armenian", sans-serif;
  font-size: 18px;
}

.topbar-actions { display: flex; gap: 6px; }

.ghost-button {
  padding: 8px 13px;
  border: 1px solid #dcd7ca;
  border-radius: 8px;
  background: transparent;
  color: #55574e;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.intro {
  margin: 65px 0 27px;
}

.eyebrow {
  margin: 0 0 11px;
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.65px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(29px, 7vw, 39px);
  font-weight: 600;
  letter-spacing: -1.35px;
  line-height: 1.25;
}

.today {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.composer {
  padding: 16px;
  border: 1px solid #eeeadf;
  border-radius: 13px;
  background: var(--paper);
  box-shadow: 0 5px 18px rgb(52 47 34 / 4%);
}

.entry-types {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
}

.type-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #85837b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.type-button.is-selected {
  background: #f1f3ed;
  color: var(--green);
  font-weight: 600;
}

.type-button[data-type="task"].is-selected {
  background: #fbefec;
  color: var(--red);
}

#entry-text {
  display: block;
  width: 100%;
  min-height: 76px;
  padding: 8px 3px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
}

#entry-text::placeholder {
  color: #aaa79e;
}

.composer-footer {
  gap: 12px;
  padding-top: 11px;
  border-top: 1px solid #f0ede6;
}

.hint {
  color: #a09d94;
  font-size: 11px;
}

.add-button {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 150ms ease, transform 150ms ease;
}

.add-button:hover {
  background: #49674d;
}

.add-button:active {
  transform: scale(0.98);
}

.list-heading {
  margin: 36px 0 18px;
}

.list-heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.entry-count {
  color: #a09d94;
  font-size: 11px;
}

.day-group + .day-group {
  margin-top: 26px;
}

.day-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 11px;
  color: #7d7a71;
  font-size: 11px;
  font-weight: 600;
}

.day-title::after {
  height: 1px;
  flex: 1;
  background: #e6e1d6;
  content: "";
}

.day-entries {
  display: grid;
  gap: 8px;
}

.entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 52px;
  padding: 15px 13px;
  border: 1px solid #eeeadf;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 2px 8px rgb(52 47 34 / 2%);
}

.entry.is-task {
  border-left: 3px solid var(--red);
  padding-left: 11px;
}

.entry.is-complete {
  border-left-color: #9caa98;
}

.entry-text {
  flex: 1;
  margin: 0;
  color: #41423e;
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.is-task:not(.is-complete) .entry-text {
  color: #a8493e;
}

.is-complete .entry-text {
  color: #98978e;
  text-decoration: line-through;
  text-decoration-color: #c5c3bb;
}

.task-toggle {
  display: grid;
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  place-items: center;
  margin: 1px 0 0;
  padding: 0;
  border: 1.5px solid #d5a39b;
  border-radius: 50%;
  background: transparent;
  color: white;
  cursor: pointer;
}

.task-toggle span {
  font-size: 12px;
  line-height: 1;
}

.is-complete .task-toggle {
  border-color: #79917a;
  background: #79917a;
}

.delete-button {
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  margin: -2px -3px 0 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #aaa79e;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  opacity: 0;
  transition: opacity 120ms ease, background 120ms ease;
}

.entry:hover .delete-button,
.delete-button:focus-visible {
  opacity: 1;
}

.delete-button:hover {
  background: #f6efeb;
  color: var(--red);
}

.empty-state {
  padding: 35px 20px;
  border: 1px dashed #ded9cd;
  border-radius: 11px;
  color: #99968d;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
}

.notice {
  margin: -4px 0 16px;
  color: var(--red);
  font-size: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (max-width: 520px) {
  .notebook {
    width: min(100% - 30px, 680px);
    padding-top: 20px;
  }

  .composer {
    padding: 13px;
  }

  .delete-button {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- v2 ---- */
.sections {
  display: flex;
  gap: 6px;
  margin: 16px 0 12px;
  padding: 2px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.sections::-webkit-scrollbar { display: none; }

.section-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid #e3ded2;
  border-radius: 999px;
  background: var(--paper);
  color: #5d5e57;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.section-tab.is-active { background: var(--green); border-color: var(--green); color: #fff; }
.section-tab.add-section { border-style: dashed; color: var(--muted); background: transparent; }

.badge {
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  text-align: center;
}

.composer .composer-footer { gap: 8px; }
.composer .entry-types { margin: 0; }
.type-button { font-size: 13px; padding: 8px 10px; }
.add-button { font-size: 14px; padding: 10px 14px; }
#entry-text { font-size: 16px; min-height: 56px; } /* 16px stops iOS zoom on focus */
#entry-text.is-task { color: var(--red); }

.filters { display: flex; gap: 6px; margin: 20px 0 14px; }
.filter-button {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.filter-button.is-selected { background: #ebe7dc; color: var(--ink); }

.day-title { font-size: 13px; color: #6f6c63; }
.entry-text { font-size: 16px; cursor: text; }
.is-task:not(.is-complete) .entry-text { color: #c0392b; font-weight: 600; }
.is-task:not(.is-complete) { background: #fff6f4; border-color: #f2d6d0; border-left-color: var(--red); }
.task-toggle { width: 26px; height: 26px; flex-basis: 26px; border-width: 2px; border-color: var(--red); }
.task-toggle span { font-size: 15px; }
.is-complete .task-toggle { border-color: #4f9a5a; background: #4f9a5a; }
.delete-button { opacity: 1; color: #c9c6bd; }

dialog {
  width: min(100% - 32px, 380px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 20%);
}
dialog::backdrop { background: rgb(30 28 22 / 35%); }
.menu-body { display: grid; gap: 8px; padding: 18px; }
.menu-body h2 { margin: 0 0 2px; font-size: 17px; }
.menu-note { margin: 0 0 6px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.menu-body button {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 15px;
  text-align: left;
}
.menu-body button.danger { color: var(--red); }
.menu-body button.close { background: var(--ink); color: #fff; text-align: center; border: 0; }
.menu-body button[hidden] { display: none; }
.task-toggle[hidden] { display: none; }

/* ---- custom modal ---- */
#modal { width: min(100% - 32px, 420px); }
.modal-body { display: grid; gap: 12px; padding: 20px 18px 16px; }
.modal-body h2 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35; }
.modal-message { margin: 0; color: #5d5e57; font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.modal-message[hidden], .modal-field[hidden], .modal-actions button[hidden] { display: none; }
.modal-field {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid #e1dccf;
  border-radius: 10px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
}
.modal-field:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgb(88 118 91 / 15%); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal-actions button {
  min-width: 96px;
  padding: 11px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.modal-cancel { background: #efebe2; color: #4d4e48; }
.modal-ok { background: var(--green); color: #fff; }
.modal-ok.is-danger { background: var(--red); }
dialog[open] { animation: pop 140ms ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

img.brand-mark { display: block; padding: 0; background: none; border-radius: 9px; }

/* ---- login ---- */
[hidden] { display: none !important; }
.login {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  display: grid;
  gap: 8px;
  width: min(100%, 380px);
  padding: 28px 22px 22px;
  border: 1px solid #eeeadf;
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 10px 40px rgb(52 47 34 / 8%);
}
.login-logo { justify-self: center; border-radius: 14px; }
.login-card h1 { margin: 6px 0 0; text-align: center; font-size: 24px; letter-spacing: -0.5px; }
.login-sub { margin: 0 0 10px; color: var(--muted); text-align: center; font-size: 14px; line-height: 1.5; }
.login-card label { margin-top: 6px; color: #5d5e57; font-size: 13px; font-weight: 600; }
.login-card input {
  width: 100%;
  padding: 12px;
  border: 1.5px solid #e1dccf;
  border-radius: 10px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgb(88 118 91 / 15%); }
.password-row { position: relative; }
.password-row input { padding-right: 96px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: #f1eee6;
  color: #5d5e57;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.login-error {
  margin: 4px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: #fbefec;
  color: #a8493e;
  font-size: 14px;
  line-height: 1.45;
}
.login-submit {
  margin-top: 10px;
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
}
.login-submit:disabled { opacity: 0.6; cursor: wait; }

/* ---- sync status ---- */
.topbar-actions { align-items: center; }
.sync-dot {
  width: 10px;
  height: 10px;
  margin-right: 4px;
  border-radius: 50%;
  background: #4f9a5a;
  transition: background 200ms ease;
}
.sync-dot[data-state="pending"], .sync-dot[data-state="syncing"] { background: #d9a441; }
.sync-dot[data-state="syncing"] { animation: pulse 1s ease-in-out infinite; }
.sync-dot[data-state="offline"] { background: #a9a69c; }
.sync-dot[data-state="error"] { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.35; } }

.menu-account { display: grid; gap: 3px; margin: 0 0 6px; font-size: 13px; line-height: 1.45; }
.menu-account strong { font-size: 15px; }
.menu-account span { color: var(--muted); }
