:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --card: #ffffff;
  --ink: #20211f;
  --muted: #73766f;
  --line: #e7e7e1;
  --soft: #efefe9;
  --accent: #20211f;
  --danger: #b33a2f;
  --urgent-bg: #fff5ec;
  --urgent-line: #efd2b7;
  --shadow: 0 8px 28px rgba(27, 29, 25, 0.06);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }

.shell {
  width: min(760px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 70px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.brand { font-size: 27px; font-weight: 760; letter-spacing: -0.035em; }
.subtle { color: var(--muted); font-size: 13px; }

.top-actions, .nav-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn, .ghost-btn, .back-btn, .home-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  min-height: 42px;
  padding: 0 13px;
}
.icon-btn { min-width: 42px; padding: 0; }
.back-btn, .home-btn { display: inline-flex; align-items: center; gap: 7px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.capture { padding: 18px; margin-bottom: 20px; }
.capture-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.input-line { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.task-input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfbf8;
  color: var(--ink);
  border-radius: 14px;
  padding: 14px 15px;
  outline: none;
}
.task-input:focus { border-color: #bdbeb7; box-shadow: 0 0 0 3px rgba(32,33,31,.05); }
.mic-btn {
  width: 50px; height: 50px; border: 1px solid var(--line); border-radius: 14px;
  background: #fbfbf8; font-size: 20px;
}
.mic-btn.listening { border-color: #d7a274; background: #fff3e8; }

.capture-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.control-group { flex: 0 0 150px; min-width: 0; }
.schedule-select, .date-input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}
.schedule-select { width: 100%; }
.date-input { width: 155px; }
.schedule-select:focus, .date-input:focus { border-color: #bdbeb7; box-shadow: 0 0 0 3px rgba(32,33,31,.05); }
.urgent-toggle {
  min-height: 40px;
  border: 1px solid var(--urgent-line);
  border-radius: 12px;
  background: #fffaf6;
  color: #6b341d;
  padding: 0 12px;
  white-space: nowrap;
}
.urgent-toggle.active { background: #6b341d; border-color: #6b341d; color: white; }
.add-btn {
  margin-left: auto;
  border: none;
  min-height: 40px;
  border-radius: 12px;
  padding: 0 18px;
  background: var(--ink);
  color: white;
  font-weight: 700;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.section { margin: 23px 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-title { font-size: 17px; font-weight: 730; }
.section-count { color: var(--muted); font-size: 13px; }

.task-list { display: grid; gap: 8px; }
.completed-details { margin-top: 10px; }
.completed-details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.completed-details .task-list { margin-top: 8px; }
.compact-empty { padding: 14px 16px; }

.task-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 11px;
  min-height: 58px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 15px;
}
.task-row.urgent { background: var(--urgent-bg); border-color: var(--urgent-line); }
.check {
  width: 25px; height: 25px; border: 1.5px solid #b8bab3; border-radius: 8px;
  background: white; display: grid; place-items: center; padding: 0;
}
.check.done { background: var(--ink); color: white; border-color: var(--ink); }
.task-main { min-width: 0; }
.task-text { font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.task-row.completed .task-text { text-decoration: line-through; color: var(--muted); }
.task-meta { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 4px; font-size: 11px; color: var(--muted); }
.badge { border-radius: 999px; padding: 2px 7px; background: var(--soft); }
.badge.urgent { background: #f6dcc6; color: #6b341d; }
.more-btn { width: 34px; height: 34px; border: none; background: transparent; border-radius: 9px; font-size: 20px; color: var(--muted); }
.more-btn:hover { background: var(--soft); }

.empty {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed #d9dad4;
  border-radius: 14px;
  background: rgba(255,255,255,.45);
  font-size: 14px;
}

.calendar-card { padding: 16px; }
.calendar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.month-title { font-size: 17px; font-weight: 720; }
.month-nav { display: flex; gap: 6px; }
.month-nav button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: white; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekday { text-align: center; color: var(--muted); font-size: 10px; padding: 6px 0; }
.day-cell {
  position: relative;
  aspect-ratio: 1/1;
  min-height: 44px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  color: var(--ink);
}
.day-cell:hover { background: var(--soft); }
.day-cell.other { color: #b3b5af; }
.day-cell.today { border-color: #bfc0ba; background: white; }
.day-num { font-size: 13px; }
.day-count {
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  font-size: 9px; min-width: 17px; height: 17px; border-radius: 999px;
  display: grid; place-items: center; background: var(--ink); color: white; padding: 0 4px;
}

.total-button {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 16px 17px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  color: var(--ink); box-shadow: var(--shadow);
}
.total-button strong { font-size: 15px; }
.total-button span { color: var(--muted); }

.view-title { margin: 14px 0 20px; }
.view-title h1 { margin: 0 0 5px; font-size: 26px; letter-spacing: -0.03em; }
.filter-tabs { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; margin: 14px 0 18px; }
.filter-tab { white-space: nowrap; border: 1px solid var(--line); background: white; border-radius: 999px; padding: 9px 12px; }
.filter-tab.active { background: var(--ink); color: white; border-color: var(--ink); }

.auth-wrap { width: min(430px, calc(100% - 28px)); margin: 9vh auto 40px; }
.auth-card { padding: 24px; }
.auth-card h1 { margin: 0 0 7px; font-size: 28px; }
.auth-card p { color: var(--muted); margin: 0 0 20px; }
.field { margin: 12px 0; }
.field label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.field input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px; outline: none; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 68px; }
.password-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: none; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; padding: 8px; }
.password-toggle:hover { color: var(--ink); }
.auth-help { display: flex; justify-content: flex-end; margin-top: -4px; margin-bottom: 4px; font-size: 12px; }
.auth-success { min-height: 18px; margin-top: 10px; color: #287a4b; font-size: 13px; }
.primary-btn { width: 100%; border: none; border-radius: 12px; min-height: 46px; background: var(--ink); color: white; font-weight: 700; margin-top: 8px; }
.auth-switch { margin-top: 15px; text-align: center; font-size: 13px; color: var(--muted); }
.link-btn { border: none; background: none; text-decoration: underline; padding: 0; color: var(--ink); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(20,22,19,.28); display: grid; place-items: end center; padding: 18px; z-index: 20; }
.modal { width: min(560px, 100%); background: white; border-radius: 20px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.16); padding: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal h2 { margin: 0; font-size: 19px; }
.modal-close { width: 36px; height: 36px; border: 1px solid var(--line); background: white; border-radius: 10px; font-size: 22px; line-height: 1; }
.check-line { display: flex; align-items: center; gap: 9px; margin: 12px 0; }
.modal-actions { display: flex; gap: 8px; margin-top: 15px; }
.modal-actions .primary-btn { width: auto; flex: 1; margin: 0; }
.danger-btn { border: 1px solid #ebc8c4; color: var(--danger); background: #fffafa; border-radius: 12px; padding: 0 13px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  opacity: 0; pointer-events: none; background: #20211f; color: white; padding: 10px 14px;
  border-radius: 12px; font-size: 13px; transition: .2s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.demo-banner { background: #fff6da; border: 1px solid #eadca5; color: #5d5124; padding: 10px 12px; border-radius: 13px; margin-bottom: 14px; font-size: 12px; }
.error { color: #9c2f26; font-size: 12px; margin-top: 8px; }

@media (max-width: 560px) {
  .shell { width: min(100% - 18px, 760px); padding-top: 16px; }
  .brand { font-size: 24px; }
  .capture { padding: 14px; }
  .capture-controls { gap: 7px; }
  .control-group { flex: 1 1 135px; }
  .date-input { flex: 1 1 150px; width: auto; }
  .urgent-toggle { flex: 1 1 100px; }
  .add-btn { flex: 1 1 80px; margin-left: 0; }
  .nav-actions { gap: 6px; }
  .back-btn, .home-btn, .ghost-btn { min-height: 40px; padding: 0 10px; }
  .day-cell { min-height: 42px; }
  .calendar-card { padding: 11px; }
}

/* V1.2 additions */
.search-top { white-space: nowrap; }
.quiet-toggle {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfbf8;
  color: var(--muted);
  padding: 0 12px;
  white-space: nowrap;
}
.quiet-toggle.active { color: var(--ink); background: white; border-color: #c9cac4; }
.capture-note { margin-top: 10px; }
.note-textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfbf8;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  font: inherit;
  line-height: 1.4;
}
.note-textarea:focus { border-color: #bdbeb7; box-shadow: 0 0 0 3px rgba(32,33,31,.05); }
.task-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow: hidden;
}
.task-wrap.urgent { background: var(--urgent-bg); border-color: var(--urgent-line); }
.task-wrap .task-row { border: 0; border-radius: 0; background: transparent; }
.task-wrap.completed .task-text { text-decoration: line-through; color: var(--muted); }
.note-link {
  margin-top: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
}
.note-link.has-note { color: #4c554b; }
.note-link:hover { text-decoration: underline; }
.note-panel {
  border-top: 1px solid var(--line);
  padding: 10px 12px 12px 48px;
  background: rgba(255,255,255,.62);
}
.note-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 7px; }
.small-btn { min-height: 34px; padding: 0 11px; border-radius: 10px; }
.dark-btn { border: 0; background: var(--ink); color: white; }
.history-group { margin: 0 0 24px; }
.history-date { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 8px 2px; }
.search-title { margin-bottom: 12px; }
.search-card { padding: 15px; }
.search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfbf8;
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
  font: inherit;
}
.search-input:focus { border-color: #bdbeb7; box-shadow: 0 0 0 3px rgba(32,33,31,.05); }
.search-filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 11px; }
.search-filters label, .custom-range label { display: grid; gap: 5px; min-width: 0; }
.search-filters label span, .custom-range label span { font-size: 11px; color: var(--muted); }
.search-filters select, .custom-range input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  color: var(--ink);
  padding: 0 9px;
}
.custom-range { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 9px; }
.search-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 11px; color: var(--muted); font-size: 12px; }

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .quiet-toggle { flex: 1 1 92px; }
  .note-panel { padding-left: 12px; }
  .search-filters { grid-template-columns: 1fr; }
  .custom-range { grid-template-columns: 1fr; }
}
