/* Benjamin — modern minimal planner */

/* === Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Neutral grayscale palette */
  --bg: #f7f7f7;
  --surface: #ffffff;
  --surface-hover: #fafafa;
  --surface-alt: #f2f2f2;
  --border: #e4e4e4;
  --border-light: #eeeeee;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --text-tertiary: #999999;

  /* Functional color — only where it aids scanning */
  --pri-a: #c33;
  --pri-b: #96780a;
  --pri-c: #999999;
  --status-done: #3a8a50;
  --sunday: #c33;

  /* Functional */
  --radius: 6px;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  font-feature-settings: 'cv01', 'cv02';
  overflow-x: hidden;
}

/* === Nav === */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 900;
}

nav .nav-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
}

nav .logo {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
  margin-right: 20px;
}

nav a {
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 14px 10px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}

nav a:hover { color: var(--text); }
nav a.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

nav .spacer { flex: 1; }

/* User avatar and dropdown */
.user-avatar-wrap {
  position: relative;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--sans);
}

.user-avatar:hover { opacity: 0.85; }

.user-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 140px;
  z-index: 910;
  overflow: hidden;
}

.user-menu.open { display: block; }

.user-menu-name {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

.user-menu a {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: none;
}

.user-menu a:hover {
  background: var(--surface-alt);
  color: var(--text);
}

/* === Layout === */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* === Planner Page (Today) === */

/* Left column wrapper */
.planner-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Right column wrapper */
.planner-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-self: start;
}

.planner-date {
  margin-bottom: 16px;
}

.planner-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.planner-date h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0;
}

.cal-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  display: none;  /* Only show on mobile */
}

.cal-toggle:hover { background: var(--surface-alt); }


.planner-date .date-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 400;
}


/* Briefing */
.planner-briefing {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.briefing-content {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* Mini calendar */
.mini-cal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 220px;
  flex-shrink: 0;
}

.mini-cal-month {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mini-cal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 16px;
  color: var(--text-tertiary);
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.1s;
}

.mini-cal-nav:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.mini-cal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.mini-cal-footer {
  text-align: center;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

.mini-cal-today-link {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-decoration: none;
}

.mini-cal-today-link:hover {
  color: var(--text);
}

.mini-cal-table th {
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 2px 0;
  text-align: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.mini-cal-table td {
  text-align: center;
  padding: 2px 0;
  color: var(--text-secondary);
  font-weight: 400;
}

.mini-cal-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  text-decoration: none;
  color: inherit;
  border-radius: 50%;
  transition: background 0.1s;
}

.mini-cal-day:hover {
  background: var(--surface-alt);
}

/* Saturday and Sunday columns */
.mini-cal-table td.is-saturday,
.mini-cal-table th.is-saturday {
  color: var(--text-tertiary);
}

.mini-cal-table td.is-sunday,
.mini-cal-table th.is-sunday {
  color: var(--sunday);
}

.mini-cal-table td.empty {
  color: transparent !important;
}

.mini-cal-table td.other-month {
  color: var(--border) !important;
}

.mini-cal-table td.is-today .mini-cal-day {
  font-weight: 700;
  color: var(--surface);
  background: var(--text);
}

.mini-cal-table td.is-today .mini-cal-day:hover {
  opacity: 0.8;
}

/* Two-column layout */
.planner-columns {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}

.planner-tasks {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.planner-schedule {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Section headers */
.section-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 14px;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-light);
}

.section-header-action {
  float: right;
}

/* === Task rows === */
.task-row {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  min-height: 40px;
  transition: background 0.1s;
}

.task-row:last-child { border-bottom: none; }

.task-row:hover {
  background: var(--surface-hover);
}

/* Priority label */
.task-priority {
  width: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-tertiary);
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.task-priority.pri-A { color: var(--pri-a); }
.task-priority.pri-B { color: var(--pri-b); }
.task-priority.pri-C { color: var(--pri-c); }

/* Status symbol */
.task-status-cell {
  width: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  transition: background 0.1s;
  border-radius: 4px;
  margin: 2px 0;
}

.task-status-cell:hover {
  background: var(--surface-alt);
}

.status-sym { font-weight: 500; }
.status-sym.pending { color: var(--text-tertiary); }
.status-sym.in_progress { color: var(--text-secondary); }
.status-sym.done { color: var(--status-done); }
.status-sym.deferred { color: var(--text-tertiary); }
.status-sym.cancelled { color: var(--text-tertiary); }

/* Task content */
.task-content {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px 10px 6px 4px;
  gap: 3px 8px;
  min-width: 0;
}

.task-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 400;
}

.task-text.is-done {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.task-text.is-deferred {
  color: var(--text-tertiary);
}

.task-text.is-cancelled {
  text-decoration: line-through;
  color: var(--text-tertiary);
  opacity: 0.5;
}

.task-detail {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.task-tag {
  font-size: 10px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-tertiary);
  letter-spacing: 0.1px;
  text-decoration: none;
  white-space: nowrap;
}

a.task-tag:hover {
  border-color: var(--text-tertiary);
  color: var(--text-secondary);
}

/* Action buttons */
/* Clickable rows for inline edit */
.task-row.editable { cursor: pointer; }
.schedule-slot.editable { cursor: pointer; }


/* === Milestones === */
.planner-milestones {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.milestone-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.milestone-row:last-child { border-bottom: none; }

.milestone-marker {
  color: var(--pri-a);
  font-size: 10px;
}

.milestone-title {
  font-weight: 500;
}

/* === Status Menu === */
.status-menu {
  display: none;
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 950;
  overflow: hidden;
  min-width: 150px;
}

.status-menu.open { display: block; }

.status-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--text);
  text-align: left;
}

.status-menu-item:hover {
  background: var(--surface-alt);
}

.status-menu-item .status-sym {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

/* === Schedule === */
.schedule-slot {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  min-height: 40px;
  padding: 0;
}

.schedule-slot:last-child { border-bottom: none; }

.slot-time {
  width: 52px;
  min-width: 52px;
  text-align: right;
  padding: 8px 10px 8px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.slot-time.all-day-label {
  font-size: 12px;
  color: var(--text-tertiary);
}

.slot-time.tz-converted {
  color: #8899aa;
}

.schedule-date-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-alt);
}

.slot-content {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px 10px 6px 4px;
  gap: 3px 8px;
  min-width: 0;
  font-size: 13px;
}

.slot-event-title {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  color: var(--text);
}

.slot-event-duration {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* === Notes section === */
.planner-notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 16px;
  overflow: hidden;
}

.planner-notes .notes-content {
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  min-height: 60px;
}

/* === Card === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
  color: var(--text-tertiary);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

/* === Projects === */
.project-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: var(--text);
}

.project-row:hover { background: var(--surface-alt); }

.project-row-name {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
  min-width: 0;
}

.project-row-dates {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.project-row-progress {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Milestones & Todos */
.milestone-item, .todo-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.milestone-item:last-child, .todo-item:last-child { border-bottom: none; }

.milestone-date, .todo-due {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Notes (markdown) */
.notes { font-size: 14px; line-height: 1.7; }
.notes h1 { font-size: 20px; margin: 16px 0 8px; font-weight: 700; letter-spacing: -0.3px; }
.notes > :first-child { margin-top: 0; }
.notes h2 { font-size: 17px; margin: 14px 0 6px; font-weight: 600; }
.notes h3 { font-size: 15px; margin: 12px 0 4px; font-weight: 600; }
.notes p { margin-bottom: 8px; }
.notes ul, .notes ol { margin-left: 20px; margin-bottom: 8px; }

/* === Search === */
.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-form input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.search-form input:focus {
  outline: none;
  border-color: var(--text-tertiary);
}

.search-results-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.search-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search-filters {
  display: flex;
  gap: 4px;
}

.search-filter-btn, .search-sort-btn {
  font-size: 12px;
  font-family: var(--sans);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.search-filter-btn.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.search-filter-btn:hover:not(.active), .search-sort-btn:hover {
  border-color: var(--text-tertiary);
}

.search-sort-btn {
  margin-left: auto;
}

.search-result-card {
  display: block;
  padding: 12px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}

.search-result-card:hover:not(.no-link) {
  border-color: var(--text-tertiary);
}

.search-result-card.no-link {
  cursor: default;
}

.search-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.search-result-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
}

.search-result-label {
  font-size: 14px;
  font-weight: 500;
}

.search-result-lines {
  padding-left: 2px;
}

.search-result-line {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-line-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  margin-right: 2px;
}

.search-result-more {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* === Chat History Log (daily page) === */
.chat-history-log { padding: 4px 14px; }
.chat-log-entry { margin-bottom: 12px; }
.chat-log-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.chat-log-content {
  font-size: 13px;
  line-height: 1.6;
  margin-top: 2px;
}
.chat-log-content p {
  margin: 0 0 0.5em 0;
}
.chat-log-content p:last-child {
  margin-bottom: 0;
}
.chat-log-content ul, .chat-log-content ol {
  margin: 0.25em 0;
  padding-left: 1.5em;
}
.chat-log-content code {
  background: var(--bg-secondary, #f0f0f0);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}

/* === Inline Add Forms === */
.add-form-inline {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-alt);
}

.add-form-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.add-form-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  height: 32px;
}

.add-form-input:focus { outline: none; border-color: var(--text-tertiary); }

.add-form-select,
.add-form-date,
.add-form-time,
.add-form-duration {
  padding: 6px 8px;
  font-size: 13px;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  height: 32px;
}

.add-form-select { width: 48px; }
.add-form-date { width: 150px; }
.add-form-time { width: 90px; }
.add-form-duration { width: 56px; }

.add-form-time:disabled,
.add-form-duration:disabled {
  opacity: 0.35;
  cursor: default;
}

.add-form-btn {
  padding: 4px 12px;
  font-size: 12px;
  height: 32px;
}

.add-form-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.add-form-check-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
}

.add-form-check-label input[type="checkbox"] {
  accent-color: var(--text);
}

/* === Project Detail === */
.todo-add-form {
  padding: 8px 14px;
  border-top: 1px solid var(--border-light);
}

.todo-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.todo-add-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.todo-add-input:focus { outline: none; border-color: var(--text-tertiary); }

.todo-add-select, .todo-add-date {
  padding: 6px 8px;
  font-size: 12px;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.todo-add-date { width: 130px; }

/* Notes editor */
.notes-view {
  padding: 14px 16px;
}

.notes-toggle-wrap {
  float: right;
}

.btn-sm {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--sans);
  padding: 2px 8px;
  border-radius: 3px;
  color: var(--text-secondary);
}

.btn-sm:hover { background: var(--surface-alt); color: var(--text); }

.notes-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
}

.notes-textarea {
  width: 100%;
  min-height: 200px;
  padding: 14px 16px;
  font-size: 13px;
  font-family: var(--sans);
  line-height: 1.65;
  border: none;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  outline: none;
}

.notes-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border-light);
}

.milestone-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.milestone-marker.done {
  color: var(--status-done);
}

/* === Settings === */
.settings-form {
  max-width: 560px;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.settings-fields {
  padding: 4px 0;
}

.settings-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  cursor: default;
}

.settings-label:last-child { border-bottom: none; }

.settings-label-text {
  color: var(--text);
  font-weight: 500;
}

.settings-label input,
.settings-label select {
  font-family: var(--sans);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  width: 200px;
}

.settings-label input:focus,
.settings-label select:focus {
  outline: none;
  border-color: var(--text-tertiary);
}

.settings-value {
  font-size: 13px;
  color: var(--text-secondary);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* Split actions: Delete left, Save+Cancel right */
.edit-actions-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.edit-actions-split .edit-actions-right {
  display: flex;
  gap: 8px;
}

.btn-danger {
  color: var(--text-tertiary);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--sans);
  padding: 6px 12px;
  border-radius: 6px;
}

.btn-danger:hover {
  color: #c00;
  border-color: #c00;
}

/* Schedule row actions (mirrors .task-actions for schedule-slot rows) */

/* === Login === */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.login-card {
  text-align: center;
  padding: 40px;
  max-width: 360px;
  width: 100%;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.login-card p {
  color: var(--text-tertiary);
  margin-bottom: 28px;
  font-size: 14px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.1s;
}

.btn:hover { background: var(--surface-alt); }

.btn-primary {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.btn-primary:hover { opacity: 0.85; }

/* === Empty state === */
.empty {
  text-align: center;
  padding: 32px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* === Flash === */
.flash {
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.flash-error { background: #fef5f5; border-color: #e5c5c5; color: #7a3030; }
.flash-success { background: #f5fef5; border-color: #c5e5c5; color: #307a30; }

/* === htmx === */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }

/* === Chat Widget === */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  border: none;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 1000;
}

.chat-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.chat-panel {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.chat-panel.open { display: flex; }

.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-title {
  font-size: 13px;
  font-weight: 600;
}

.chat-header-status {
  font-size: 11px;
  color: var(--text-tertiary);
}

.chat-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-tertiary);
  padding: 0;
  line-height: 1;
}

.chat-close:hover { color: var(--text); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 200px;
  max-height: 380px;
}

.chat-msg {
  font-size: 13px;
  line-height: 1.5;
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  word-wrap: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--text);
  color: var(--surface);
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface-alt);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-msg.tool-indicator {
  align-self: flex-start;
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 4px 0;
  background: none;
}

.chat-msg.error {
  align-self: center;
  font-size: 11px;
  color: #c33;
  padding: 4px 0;
  background: none;
}

/* Markdown inside chat messages */
.chat-msg code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}

.chat-msg ul {
  margin: 4px 0;
  padding-left: 18px;
}

.chat-msg li {
  margin: 2px 0;
}

.chat-msg strong {
  font-weight: 600;
}

.chat-typing {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 4px 16px 8px;
  display: none;
}

.chat-typing.active { display: block; }

.chat-input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 16px;  /* >= 16px prevents Safari auto-zoom on focus */
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: none;
  min-height: 44px;  /* iOS touch target minimum */
  max-height: 80px;
}

.chat-input:focus { border-color: var(--text-tertiary); }

.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.1s;
}

.chat-send:hover { opacity: 0.85; }
.chat-send:disabled { opacity: 0.3; cursor: default; }

/* === PWA Safe Areas === */
nav {
  padding-top: env(safe-area-inset-top, 0px);
}

/* JS adds .pwa-standalone to html when in standalone mode */
html.pwa-standalone nav {
  padding-top: max(env(safe-area-inset-top, 0px), 24px);
}

/* chat-header safe area handled in mobile section */

/* Chat safe area — only pad the input area for home indicator */
.chat-input-area {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
/* Keyboard open: safe-area not needed (keyboard covers home indicator) */
.chat-panel.keyboard-open .chat-input-area {
  padding-bottom: 12px;
}

/* PWA Standalone Mode — detected via JS (.pwa-standalone on html) */

/* === Responsive === */
@media (max-width: 700px) {
  .cal-toggle { display: block; }
  .mini-cal { min-width: unset; }
  .planner-columns { grid-template-columns: 1fr; }
  /* Flatten both columns into single flow with correct order */
  .planner-left, .planner-right { display: contents; }
  .mini-cal { order: 1; }
  .planner-briefing { order: 2; }
  .planner-tasks { order: 3; }
  .planner-schedule { order: 4; }
  .container { padding: 16px; overflow-x: hidden; }
  nav { padding: 0 12px; }
  nav .nav-inner { gap: 0; }
  nav .logo { margin-right: 8px; font-size: 14px; }
  nav a { padding: 14px 6px; font-size: 12px; }

  html.chat-open,
  body.chat-open {
    overflow: hidden;
    height: 100%;
    background: var(--surface);
  }
  body.chat-open .container,
  body.chat-open nav,
  body.chat-open .chat-fab {
    display: none;
  }
  .chat-panel {
    inset: 0;
    width: auto;
    max-height: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
    overscroll-behavior: none;
    /* iOS 26: force compositing layer to fix fixed positioning after keyboard */
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
  }
  .chat-header {
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  }
  .chat-messages {
    max-height: none;
    flex: 1;
  }
  .chat-fab { bottom: 16px; right: 16px; }
}

@media (max-width: 1024px) {
  .task-tag {
    max-width: 12ch;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
  }
}

/* Mobile + safe areas combined */
@media (max-width: 700px) {
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    .chat-fab {
      bottom: calc(16px + env(safe-area-inset-bottom));
    }
    /* chat-panel stays full-screen (top:0 bottom:0) on mobile */
    .chat-input-area {
      padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
  }
}

/* === Recurring Tasks === */
.recurring-columns {
  grid-template-columns: 1fr 320px;
}

/* recurring list uses same hover pattern as other pages */

.recurring-edit-inline {
  background: var(--surface-alt);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  padding: 12px 14px;
}

.recurring-edit-inline .settings-fields {
  gap: 8px;
}

.recurring-edit-inline .settings-actions {
  margin-top: 12px;
}

.recurring-gcal-note {
  padding: 12px 14px;
  font-size: 11px;
  color: var(--text-tertiary);
}

@media (max-width: 700px) {
  .recurring-columns { grid-template-columns: 1fr; }
}
