/* Same "pen and paper" palette as the desktop app's default Paper theme. */
:root {
  --paper: #f4ecd8;
  --paper-light: #fdf6e8;
  --paper-edge: #c9b896;
  --ink: #3a2f22;
  --ink-soft: #6b5c46;
  --accent: #96433a;
  --accent-soft: #b98a83;
  --body-font: Georgia, "Noto Serif", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body-font);
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ---------- Setup / login ---------- */

.centered-card {
  margin: auto;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.centered-card h1 { margin-bottom: 4px; }

.centered-card input {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  background: var(--paper-light);
  color: var(--ink);
}

.centered-card button {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px;
  font-size: 15px;
  border: none;
  border-radius: 20px;
  background: var(--accent);
  color: var(--paper-light);
  font-weight: bold;
}

.centered-card button.secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--paper-edge);
  font-weight: normal;
}

.error { color: var(--accent); font-size: 13px; min-height: 18px; }
.hint { color: var(--ink-soft); font-size: 13px; }

/* ---------- Shell ---------- */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--paper-edge);
}
#level-badge { font-weight: bold; }
#theme-select {
  margin-left: auto;
  margin-right: 10px;
  max-width: 40vw;
  padding: 4px 6px;
  font-size: 12px;
  font-family: var(--body-font);
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  background: var(--paper-light);
  color: var(--ink);
}
#logout-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--ink-soft);
}

#view {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.pane { max-width: 480px; margin: 0 auto; }

.section-heading {
  font-size: 15px;
  color: var(--ink-soft);
  margin: 4px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--paper-edge);
}

#tabbar {
  display: flex;
  border-top: 1px solid var(--paper-edge);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper-light);
}
#tabbar button {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 10px 2px;
  font-size: 11px;
  color: var(--ink-soft);
}
#tabbar button.active { color: var(--accent); font-weight: bold; }

/* ---------- Notes ---------- */

.notes-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.notes-toolbar button {
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--body-font);
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  background: var(--paper-light);
  color: var(--ink);
}
.notes-toolbar button:active { background: var(--accent-soft); color: var(--paper-light); }

.notes-editor {
  width: 100%;
  min-height: 55vh;
  padding: 12px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  background: var(--paper-light);
  color: var(--ink);
  overflow-y: auto;
}
.notes-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--ink-soft);
}
.notes-editor ul, .notes-editor ol { padding-left: 24px; margin: 6px 0; }

/* ---------- Checklist ---------- */

.task-list { list-style: none; padding: 0; margin: 0 0 16px; }
.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  border-bottom: 1px solid var(--paper-edge);
  flex-wrap: wrap;
}
.task-item label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.task-item input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; }
.task-item.done span { color: var(--ink-soft); text-decoration: line-through; }
.task-item em { font-style: normal; color: var(--ink-soft); font-size: 12px; }
.remove-btn { background: none; border: none; color: var(--ink-soft); font-size: 16px; flex-shrink: 0; }
.push-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.push-row .hint { margin: 0; }
.notes-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.notes-page-tab, .notes-page-add {
  background: var(--paper-light); color: var(--ink); border: 1px solid var(--paper-edge);
  border-radius: 14px; padding: 4px 12px; font: inherit; font-size: 14px;
}
.notes-page-tab.active { background: var(--accent); border-color: var(--accent); color: var(--paper-light); }
.notes-page-add { color: var(--ink-soft); border-style: dashed; }
.reminder-edit { flex-basis: 100%; display: flex; align-items: center; gap: 6px; padding: 8px 0 0 28px; }
.reminder-edit[hidden] { display: none; }
.reminder-edit input[type="time"], .reminder-edit select { font: inherit; padding: 4px; }
.reminder-edit input[type="number"] { font: inherit; padding: 4px; width: 4em; }
.reminder-edit [hidden] { display: none; }
.task-item.due-overdue > label span { color: #d9453b; font-weight: bold; }
.task-item.due-today > label span { font-weight: bold; }
.task-details { flex-basis: 100%; display: flex; flex-direction: column; gap: 6px; padding: 8px 0 0 28px; }
.task-details[hidden] { display: none; }
.task-details .due-row { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 14px; }
.task-details input, .task-details textarea { font: inherit; padding: 4px; }
.task-details textarea { width: 100%; box-sizing: border-box; resize: vertical; }
.subtask-list { list-style: none; padding: 0; margin: 0; }
.subtask { display: flex; align-items: center; justify-content: space-between; padding: 2px 0; }
.subtask label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.subtask.done span { color: var(--ink-soft); text-decoration: line-through; }
.subtask-add { display: flex; gap: 6px; }
.subtask-add input { flex: 1; min-width: 0; }
.rename-btn { background: none; border: none; color: var(--ink-soft); font-size: 15px; flex-shrink: 0; padding: 0 6px; }
.reorder-col { display: flex; flex-direction: column; margin-right: 6px; flex-shrink: 0; }
.reorder-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
}
.reorder-btn:disabled { opacity: 0.25; }

.add-row { display: flex; gap: 6px; }
.add-row input[type="text"] {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  background: var(--paper-light);
  font-size: 15px;
}
.add-row select {
  padding: 10px;
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  background: var(--paper-light);
}
.add-row button {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--paper-light);
  font-weight: bold;
}

/* ---------- Pomodoro ---------- */

.pomodoro-pane { text-align: center; }
.phase-label { font-size: 14px; color: var(--ink-soft); margin-bottom: 8px; }
.timer-ring {
  width: 220px;
  height: 220px;
  margin: 12px auto;
  border-radius: 50%;
  border: 10px solid var(--paper-edge);
  display: flex;
  align-items: center;
  justify-content: center;
}
#timer-text { font-size: 40px; font-weight: bold; }
.timer-controls { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
.timer-controls button {
  padding: 12px 28px;
  border: none;
  border-radius: 20px;
  background: var(--accent);
  color: var(--paper-light);
  font-weight: bold;
  font-size: 15px;
}
.timer-controls button.secondary {
  background: transparent;
  border: 1px solid var(--paper-edge);
  color: var(--ink-soft);
}

.settings-details { text-align: left; margin-top: 12px; }
.settings-details label { display: flex; justify-content: space-between; margin: 8px 0; font-size: 14px; }
.settings-details label.check-label { justify-content: flex-start; gap: 8px; align-items: center; }
.settings-details input { width: 70px; padding: 4px; }
.settings-details input[type="checkbox"] { width: auto; }
.settings-details button {
  margin-top: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--paper-light);
}

/* ---------- Progress ---------- */

.card {
  border: 1px dashed var(--paper-edge);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--paper-light);
}
.card h2 { margin: 0 0 8px; font-size: 16px; color: var(--accent); }
.xp-bar {
  height: 18px;
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  background: var(--paper);
  overflow: hidden;
}
.xp-bar-fill { height: 100%; background: var(--accent); }
.quest-list { list-style: none; padding: 0; margin: 8px 0 0; }
.quest-list li { padding: 6px 0; font-size: 14px; }
.quest-list li.done { color: var(--accent); font-weight: bold; }

/* ---------- Focus history ---------- */

.history-chart { display: flex; align-items: flex-end; gap: 3px; height: 118px; }
.history-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; }
.history-bar { width: 70%; background: var(--accent); border-radius: 3px 3px 0 0; }
.history-val { font-size: 9px; color: var(--ink-soft); height: 12px; }
.history-day { font-size: 10px; color: var(--ink-soft); margin-top: 3px; border-top: 1px solid var(--paper-edge); width: 100%; text-align: center; padding-top: 2px; }
.history-day.today { color: var(--accent); font-weight: bold; }

/* ---------- Shared tab ---------- */

.stack { display: flex; flex-direction: column; gap: 8px; }
.stack input {
  padding: 10px;
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  background: var(--paper);
  font-size: 15px;
}
.stack button {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--paper-light);
  font-weight: bold;
}
.shared-actions { margin-top: 12px; }
.shared-schedule { flex-wrap: wrap; margin-top: 8px; }
.shared-schedule select, .shared-schedule input {
  padding: 8px;
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  background: var(--paper-light);
  font-size: 14px;
  min-width: 0;
}
.shared-schedule input[type="number"] { width: 72px; }
.shared-schedule [hidden] { display: none; }
.add-row button.secondary-btn {
  flex: 1;
  background: none;
  border: 1px solid var(--paper-edge);
  color: var(--ink-soft);
  font-weight: normal;
}

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 76px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper-light);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 50;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Calendar ---------- */

.cal-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cal-nav strong { flex: 1; text-align: center; font-size: 17px; }
.cal-nav button {
  background: var(--paper-light); color: var(--ink); border: 1px solid var(--paper-edge);
  border-radius: 6px; padding: 6px 12px; font-family: var(--body-font); font-size: 15px;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-bottom: 8px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--ink-soft); padding: 2px 0; }
.cal-cell {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 46px; padding: 4px 0; border-radius: 6px;
  border: 1px solid var(--paper-edge); background: var(--paper-light); color: var(--ink);
  font-family: var(--body-font); font-size: 14px;
}
.cal-cell.other { opacity: 0.45; }
.cal-cell.today { border: 2px solid var(--accent); }
.cal-cell.selected { background: var(--accent-soft); color: var(--paper-light); }
.cal-dots { display: flex; gap: 2px; align-items: center; min-height: 8px; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--paper-edge); }
.cal-dot.event { background: var(--accent); }
.cal-dot.shared { background: var(--ink-soft); }
.cal-dot.done { opacity: 0.4; }
.cal-more { font-style: normal; font-size: 10px; line-height: 8px; }
.cal-entry { flex-direction: column; align-items: stretch; }
.cal-entry-head {
  display: flex; gap: 8px; align-items: center; width: 100%; text-align: left;
  background: none; border: none; padding: 4px 0; color: var(--ink); font-family: var(--body-font); font-size: 15px;
}
.cal-entry-head span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cal-entry.done .cal-entry-head span { color: var(--ink-soft); text-decoration: line-through; }
.cal-details { padding: 4px 0 8px 24px; font-size: 14px; }
.cal-details p { margin: 4px 0 8px; overflow-wrap: anywhere; }
.cal-files { list-style: none; padding: 0; margin: 8px 0; }
.cal-files li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.cal-files a { flex: 1; min-width: 0; color: var(--accent); display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.cal-files em { font-style: normal; font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.cal-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--paper-edge); flex-shrink: 0; }
.cal-attach {
  display: inline-block; padding: 8px 12px; border-radius: 6px; cursor: pointer;
  border: 1px dashed var(--paper-edge); color: var(--ink-soft);
}
.cal-add { margin: 8px 0 12px; }
.cal-add button { flex: 1; }
.cal-check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.stack textarea {
  font-family: var(--body-font); font-size: 15px; padding: 8px; border-radius: 6px;
  border: 1px solid var(--paper-edge); background: var(--paper-light); color: var(--ink);
}
.stack .add-row input[type="date"], .stack .add-row input[type="time"] { flex: 1; min-width: 0; }
