/* ----- Claude-styled daily planner ----- */

:root {
  /* Surfaces */
  --bg: #F5F4EE;          /* page bg, like claude.ai cream */
  --surface: #FAF9F5;     /* cards / composer */
  --surface-2: #EFEDE4;   /* progress track, hover */
  --hairline: #E6E3D8;    /* dividers */

  /* Ink */
  --ink: #1F1E1B;
  --ink-2: #4A4742;
  --ink-3: #87837A;

  /* Brand */
  --accent: #C96442;      /* claude orange/coral */
  --accent-2: #B25535;
  --accent-soft: #F5E4DC;

  --danger: #B23B3B;

  /* Type */
  --serif: "Tiempos Headline", "Tiempos Text", "STSong", "Noto Serif SC",
           ui-serif, Georgia, "Times New Roman", serif;
  --sans:  "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
           "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(31, 30, 27, 0.04);
  --shadow-md: 0 4px 16px rgba(31, 30, 27, 0.06);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
input { font: inherit; color: inherit; }

/* ----- Layout ----- */

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 20px 140px;
}

/* ----- Wordmark ----- */

.wordmark {
  margin: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  padding: 4px 0 0;
  font-weight: 500;
}

/* ----- Header ----- */

.header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 16px 0 8px;
}

.header-center {
  position: relative;
  text-align: center;
  display: block;
  background: none;
  border: 0;
  padding: 6px 4px;
  border-radius: var(--r-md);
  cursor: pointer;
}
.header-center:active { background: var(--surface-2); }

/* Invisible native date input overlaid on the header so a tap anywhere
   on the date label opens the system date picker. */
.date-input-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  font-size: 16px; /* prevent iOS auto-zoom on focus */
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  color: transparent;
}
.date-input-hidden::-webkit-calendar-picker-indicator { opacity: 0; }
.date-input-hidden::-webkit-date-and-time-value { opacity: 0; }

.date-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}

.date-sub {
  margin: 4px 0 0;
  color: var(--ink-3);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-btn:hover { background: var(--surface-2); color: var(--ink); }
.nav-btn:active { background: var(--hairline); }

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

.progress {
  margin: 12px 0 18px;
}
.progress-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.progress-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.progress-text {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}
.link-btn {
  font-size: 13px;
  color: var(--accent);
  padding: 4px 6px;
  border-radius: var(--r-sm);
}
.link-btn:active { background: var(--accent-soft); }

/* ----- List ----- */

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, transform 0.15s, opacity 0.2s;
  -webkit-user-select: none;
  user-select: none;
}
.task:active { transform: scale(0.995); }

.task.done {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.task.done .task-text { color: var(--ink-3); }
.task.done .task-time { color: var(--ink-3); background: transparent; border-color: transparent; }

.check {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-3);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.check svg { width: 14px; height: 14px; display: block; }
.task.done .check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.task-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: text;
}

.task-text {
  font-size: 16px;
  color: var(--ink);
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.task-edit {
  font-size: 16px;
  color: var(--ink);
  line-height: 1.45;
  width: 100%;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  font-family: inherit;
}

.task-time {
  align-self: flex-start;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
  background: var(--accent-soft);
  border: 1px solid transparent;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 2px;
}

.delete {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  margin: -4px -6px -4px 0;
  border-radius: 50%;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.delete:hover { opacity: 1; color: var(--danger); background: var(--surface-2); }
.delete:active { background: var(--hairline); }
.delete svg { width: 16px; height: 16px; }

/* ----- Empty ----- */

.empty {
  text-align: center;
  padding: 60px 20px 20px;
  color: var(--ink-3);
}
.empty-title {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--ink-2);
  margin: 0 0 6px;
  font-weight: 500;
}
.empty-sub { margin: 0; font-size: 14px; }

/* ----- Status toast ----- */

.status {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 30;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.status.show { opacity: 0.94; }
.status.error { background: var(--danger); }

/* ----- Composer (sticky bottom) ----- */

/* ---- Composer (Claude-style card) ---- */

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 75%, rgba(245, 244, 238, 0));
  z-index: 20;
}
.composer::before {
  content: "";
  position: absolute;
  inset: auto 0 100% 0;
  height: 16px;
  background: linear-gradient(to top, var(--bg), rgba(245, 244, 238, 0));
  pointer-events: none;
}

.composer-card {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 6px 8px 8px 14px;
  box-shadow: 0 6px 20px rgba(31, 30, 27, 0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(31, 30, 27, 0.06),
              0 0 0 3px rgba(201, 100, 66, 0.12);
}

.text-input {
  display: block;
  width: 100%;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  color: var(--ink);
  padding: 0;
}
.text-input::placeholder { color: var(--ink-3); }

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

/* Time chip — wraps a native <input type=time> styled to look subtle */
.time-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.time-chip:active { background: var(--hairline); }
.time-chip.user-set {
  background: var(--accent-soft);
  color: var(--accent-2);
}
.time-chip-icon { flex: 0 0 14px; opacity: 0.75; }

.time-input {
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 0;
  margin: 0;
  min-width: 56px;
  width: 56px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.time-input::-webkit-calendar-picker-indicator { display: none; opacity: 0; }
/* Force the native value-display to fill the input and align left, otherwise
   webkit on some Android browsers leaves invisible right padding that clips
   the last digit. */
.time-input::-webkit-date-and-time-value {
  width: 100%;
  text-align: left;
  padding: 0;
  margin: 0;
}
.time-input::-webkit-inner-spin-button,
.time-input::-webkit-clear-button { display: none; }

/* Send button — dark, like Claude's */
.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  flex: 0 0 36px;
}
.send-btn:hover { background: #000; }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled {
  background: var(--ink-3);
  opacity: 0.4;
  cursor: not-allowed;
}

/* ----- Auth overlay (password gate) ----- */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(31, 30, 27, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
/* Without this, the `hidden` attribute can't beat our `display: flex`
   (equal specificity, later rule wins), so the modal would never close. */
.auth-overlay[hidden] { display: none; }

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 24px;
  padding: 28px 22px 22px;
  box-shadow: 0 16px 48px rgba(31, 30, 27, 0.18);
  text-align: center;
}

.auth-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.auth-sub {
  font-size: 13px;
  color: var(--ink-3);
  margin: 0 0 20px;
}

.auth-input {
  display: block;
  width: 100%;
  height: 48px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: #fff;
  padding: 0 18px;
  font-size: 16px;
  text-align: center;
  letter-spacing: 0.05em;
  outline: 0;
  margin: 0 0 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-variant-numeric: tabular-nums;
}
.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.15);
}

.auth-submit {
  display: block;
  width: 100%;
  height: 48px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.auth-submit:hover { background: #000; }
.auth-submit:active { transform: scale(0.99); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-error {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
}

/* ----- Flatpickr (Claude-themed colour overrides only) -----
   Intentionally don't touch widths/heights/padding — flatpickr lays out the
   date and (separately) the time-only popup at carefully tuned sizes; our
   own dimension overrides earlier broke the time popup. Just recolour. */

.flatpickr-calendar {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 48px rgba(31, 30, 27, 0.14);
  font-family: var(--sans);
  color: var(--ink);
}
.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after,
.flatpickr-calendar.arrowBottom::before,
.flatpickr-calendar.arrowBottom::after { display: none; }

.flatpickr-months .flatpickr-month { color: var(--ink); }
.flatpickr-current-month .cur-month,
.flatpickr-current-month .cur-year,
.flatpickr-current-month input.cur-year { color: var(--ink); font-weight: 500; }
.flatpickr-current-month .numInputWrapper:hover { background: var(--surface-2); }

.flatpickr-prev-month svg,
.flatpickr-next-month svg { fill: var(--ink-2); }
.flatpickr-prev-month:hover svg,
.flatpickr-next-month:hover svg { fill: var(--accent); }

.flatpickr-weekday { color: var(--ink-3) !important; font-weight: 400; background: transparent; }

.flatpickr-day { color: var(--ink); border-radius: var(--r-sm); }
.flatpickr-day:hover,
.flatpickr-day:focus {
  background: var(--surface-2);
  border-color: var(--surface-2);
  color: var(--ink);
}
.flatpickr-day.today {
  border-color: var(--accent);
  color: var(--accent-2);
  font-weight: 500;
}
.flatpickr-day.today:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-2);
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus,
.flatpickr-day.selected.today {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay { color: var(--ink-3); opacity: 0.55; }

/* Time picker — colour only, no dimension changes */
.flatpickr-time input {
  color: var(--ink);
  background: transparent;
  font-variant-numeric: tabular-nums;
}
.flatpickr-time input:focus { background: var(--accent-soft); color: var(--accent-2); }
.flatpickr-time .numInputWrapper:hover { background: var(--surface-2); }
.flatpickr-time .flatpickr-time-separator,
.flatpickr-time .flatpickr-am-pm { color: var(--ink-2); }
.flatpickr-time .arrowUp::after { border-bottom-color: var(--ink-3); }
.flatpickr-time .arrowDown::after { border-top-color: var(--ink-3); }

/* ----- Wider screens ----- */

@media (min-width: 720px) {
  .app { padding: calc(var(--safe-top) + 32px) 24px 160px; }
  .date-title { font-size: 36px; }
  .composer {
    left: 50%;
    transform: translateX(-50%);
    max-width: 640px;
    padding-left: 24px;
    padding-right: 24px;
  }
}
