:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #707579);
  --line: var(--tg-theme-section-separator-color, rgba(128, 128, 128, .2));
  --accent: var(--tg-theme-button-color, #3390ec);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --tabs: 54px;
  color-scheme: light dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body { padding: env(safe-area-inset-top) 0 0; }

.top { padding: 16px 16px 8px; }

.title { font-size: 20px; font-weight: 650; }

.sub { color: var(--hint); font-size: 13px; margin-top: 2px; min-height: 17px; }

.search {
  width: 100%;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  outline: none;
}

.search:focus { border-color: var(--accent); }

.list {
  padding: 0 8px calc(var(--tabs) + 68px + env(safe-area-inset-bottom));
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}

.row:last-child { border-bottom: 0; }

.box {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  margin-top: 1px;
  border-radius: 7px;
  border: 1.5px solid var(--hint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  transition: background .15s ease, border-color .15s ease;
}

.row.done .box { background: var(--accent); border-color: var(--accent); }

.body { flex: 1 1 auto; min-width: 0; }

.lbl {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  transition: color .15s ease;
}

.row.done .lbl { text-decoration: line-through; color: var(--hint); }

.when { font-size: .8em; color: var(--hint); margin-top: 2px; }

.del {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--danger);
  font-size: 16px;
  opacity: .6;
  cursor: pointer;
}

.del:active { opacity: 1; background: var(--card); }

.note {
  position: relative;
  margin: 8px 0;
  padding: 12px 44px 12px 12px;
  border-radius: 12px;
  background: var(--card);
}

.note-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note-meta { margin-top: 6px; font-size: .78em; color: var(--hint); }

.note .del { position: absolute; top: 6px; right: 6px; }

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--hint);
}

.add {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabs) + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.field {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  outline: none;
}

.field:focus { border-color: var(--accent); }

.send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 20px;
  cursor: pointer;
}

.send:active { opacity: .8; }

.send[disabled] { opacity: .4; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabs) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 0;
  background: transparent;
  color: var(--hint);
  font: 11px/1 system-ui, sans-serif;
  cursor: pointer;
}

.tab span { font-size: 10px; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs) + 76px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
  max-width: 80vw;
  z-index: 5;
}
