/* =====================================================
   AI Life Planner v3 — UDS-style design
   ===================================================== */

:root {
  --c-bg:        #F5F5F7;
  --c-surface:   #FFFFFF;
  --c-surface2:  #F2F2F4;
  --c-border:    #E5E5EA;
  --c-text:      #1C1C1E;
  --c-text2:     #6C6C70;
  --c-text3:     #AEAEB2;
  --c-accent:    #5856D6;
  --c-accent2:   #7A79E6;
  --c-green:     #34C759;
  --c-red:       #FF3B30;
  --c-orange:    #FF9500;
  --c-blue:      #007AFF;
  --c-purple:    #AF52DE;
  --c-teal:      #5AC8FA;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
  --shadow-modal:0 24px 64px rgba(0,0,0,.18);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --tr: all .18s cubic-bezier(.4,0,.2,1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --sidebar-w: 280px;
  --header-h: 64px;
}

[data-theme="dark"] {
  --c-bg:        #000000;
  --c-surface:   #1C1C1E;
  --c-surface2:  #2C2C2E;
  --c-border:    #38383A;
  --c-text:      #FFFFFF;
  --c-text2:     #AEAEB2;
  --c-text3:     #636366;
  --c-accent:    #7A79E6;
  --c-accent2:   #9D9CE8;
}

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

html, body {
  width: 100%; height: 100%;
  font-family: var(--font);
  font-size: 14px;
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background .2s, color .2s;
}

button { font-family: var(--font); cursor: pointer; border: none; }
input, textarea, select { font-family: var(--font); }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 4px; }

/* =====================================================
   LAYOUT
   ===================================================== */

.app-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* =====================================================
   SIDEBAR
   ===================================================== */

.sidebar {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: background .2s, border-color .2s;
}

.sidebar-top {
  padding: 20px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.brand-icon svg { width: 100%; height: 100%; }

.brand-text { flex: 1; min-width: 0; }

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -.3px;
}

.brand-sub {
  font-size: 11px;
  color: var(--c-text3);
  font-weight: 500;
}

.theme-toggle {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--c-surface2);
  color: var(--c-text2);
  display: flex; align-items: center; justify-content: center;
  transition: var(--tr);
  flex-shrink: 0;
}

.theme-toggle:hover { background: var(--c-border); color: var(--c-text); }
.theme-toggle svg { width: 15px; height: 15px; }

/* Search */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 14px; height: 14px;
  color: var(--c-text3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--c-surface2);
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  padding: 8px 28px 8px 32px;
  font-size: 13px;
  color: var(--c-text);
  outline: none;
  transition: var(--tr);
}

.search-input::placeholder { color: var(--c-text3); }
.search-input:focus { border-color: var(--c-accent); background: var(--c-surface); }

.search-clear {
  position: absolute; right: 8px;
  width: 18px; height: 18px;
  background: var(--c-text3);
  color: #fff;
  border-radius: 50%;
  font-size: 9px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--tr);
}

.search-clear:hover { background: var(--c-text2); }
.search-clear.hidden { display: none; }

/* Sidebar Nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.snav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text2);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--tr);
  position: relative;
  text-align: left;
  width: 100%;
}

.snav-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.snav-btn span { flex: 1; }

.snav-indicator {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c-accent);
  display: none;
}

.snav-btn:hover { background: var(--c-surface2); color: var(--c-text); }

.snav-btn.active {
  background: rgba(88, 86, 214, .1);
  color: var(--c-accent);
  font-weight: 600;
}

.snav-btn.active .snav-indicator { display: block; }

/* Sidebar Events */
.sidebar-events {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 0;
  border-top: 1px solid var(--c-border);
  margin-top: 16px;
}

.sidebar-events-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.events-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-card {
  background: var(--c-surface2);
  border-radius: var(--r-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--tr);
  position: relative;
  border: 1.5px solid transparent;
}

.event-card:hover {
  background: var(--c-border);
  border-color: var(--c-accent);
  transform: translateX(2px);
}

.event-cat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c-accent);
  flex-shrink: 0;
}

.event-card[data-cat="task"] .event-cat-dot { background: var(--c-green); }
.event-card[data-cat="call"] .event-cat-dot { background: var(--c-blue); }
.event-card[data-cat="personal"] .event-cat-dot { background: var(--c-orange); }
.event-card[data-cat="reminder"] .event-cat-dot { background: var(--c-red); }

.event-info { flex: 1; min-width: 0; }

.event-time {
  font-size: 10px;
  font-weight: 600;
  color: var(--c-accent);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 2px;
}

.event-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-meta {
  font-size: 11px;
  color: var(--c-text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.event-edit-btn {
  background: none;
  color: var(--c-text3);
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: 0;
  transition: var(--tr);
  flex-shrink: 0;
}

.event-card:hover .event-edit-btn { opacity: 1; color: var(--c-accent); }

.empty-state {
  color: var(--c-text3);
  font-size: 12px;
  font-style: italic;
  padding: 8px 0;
  text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--c-border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.footer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text2);
  font-size: 13px;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: var(--tr);
}

.footer-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.footer-btn:hover { background: var(--c-surface2); color: var(--c-text); }

.footer-menu-wrap { position: relative; }

.menu-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  width: 220px;
  overflow: hidden;
  z-index: 500;
  padding: 6px;
}

.menu-dropdown.show { display: flex; }

.menu-divider {
  height: 1px;
  background: var(--c-border);
  margin: 4px 6px;
}

.menu-dropdown button {
  padding: 10px 12px;
  background: transparent;
  color: var(--c-text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  border-radius: var(--r-sm);
  transition: var(--tr);
}

.menu-dropdown button:hover { background: var(--c-surface2); }

/* =====================================================
   MAIN AREA
   ===================================================== */

.main-area {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
  transition: background .2s;
}

.tab-pane {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.tab-pane.active { display: flex; }

/* Pane Header */
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
  flex-shrink: 0;
  transition: background .2s, border-color .2s;
}

.pane-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -.4px;
}

.pane-sub {
  font-size: 13px;
  color: var(--c-text2);
  margin-top: 2px;
}

/* AI Status */
.ai-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(52, 199, 89, .1);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-green);
}

.ai-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c-green);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .7; transform: scale(.85); }
}

.ai-status-pill.thinking {
  background: rgba(88, 86, 214, .1);
  color: var(--c-accent);
}
.ai-status-pill.thinking .ai-dot {
  background: var(--c-accent);
  animation: spin-dot .8s linear infinite;
}
@keyframes spin-dot {
  0% { transform: scale(.6); }
  50% { transform: scale(1.2); }
  100% { transform: scale(.6); }
}

/* =====================================================
   CHAT
   ===================================================== */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Welcome */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 0;
  gap: 8px;
  animation: fadeUp .3s ease;
}

.welcome-emoji {
  font-size: 32px;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--c-accent), var(--c-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chat-welcome h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -.4px;
}

.chat-welcome p {
  font-size: 14px;
  color: var(--c-text2);
}

.welcome-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 20px;
  width: 100%;
  max-width: 480px;
}

.waction {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px 12px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: 14px;
  cursor: pointer;
  transition: var(--tr);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.waction:hover {
  border-color: var(--c-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.waction:active { transform: translateY(0); }

.waction-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 2px;
}
.waction-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text1);
  line-height: 1.2;
}
.waction-desc {
  font-size: 10.5px;
  color: var(--c-text3);
  line-height: 1.2;
}

.waction-danger:hover {
  border-color: var(--c-red);
  background: rgba(255,59,48,0.04);
}
.waction-danger .waction-label { color: var(--c-text2); }
.waction-danger:hover .waction-label { color: var(--c-red); }


/* Messages */
.message {
  max-width: 68%;
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  animation: fadeUp .2s ease;
  box-shadow: var(--shadow-sm);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-msg {
  background: var(--c-surface);
  color: var(--c-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--c-border);
}

.user-msg {
  background: var(--c-accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.typing-msg {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: var(--c-text2);
  font-style: italic;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 5px; height: 5px;
  background: var(--c-text3);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* Input Bar */
.input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px 16px;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
  transition: background .2s, border-color .2s;
}

#messageInput {
  flex: 1;
  background: var(--c-surface2);
  border: 1.5px solid transparent;
  border-radius: 100px;
  padding: 11px 18px;
  font-size: 16px; /* 16px — iOS не зумит при фокусе */
  color: var(--c-text);
  outline: none;
  transition: var(--tr);
  min-width: 0;
}

#messageInput::placeholder { color: var(--c-text3); }
#messageInput:focus { border-color: var(--c-accent); background: var(--c-surface); box-shadow: 0 0 0 3px rgba(88,86,214,.08); }

.send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: var(--tr);
  flex-shrink: 0;
  background: var(--c-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(88,86,214,.3);
}

.send-btn svg { width: 15px; height: 15px; }
.send-btn:hover { background: var(--c-accent2); box-shadow: 0 4px 12px rgba(88,86,214,.4); transform: scale(1.04); }


/* =====================================================
   CALENDAR
   ===================================================== */

.pane-header .cal-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cal-arrow-btn {
  width: 32px; height: 32px;
  background: var(--c-surface2);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text2);
  transition: var(--tr);
}

.cal-arrow-btn svg { width: 16px; height: 16px; }
.cal-arrow-btn:hover { background: var(--c-border); color: var(--c-text); }

.today-btn {
  padding: 7px 14px;
  background: rgba(88,86,214,.1);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-accent);
  transition: var(--tr);
}

.today-btn:hover { background: rgba(88,86,214,.18); }

.calendar-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 8px;
}

.cal-weekdays span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 0;
}

.cal-weekdays span.wknd { color: var(--c-red); opacity: .7; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  align-content: start;
}

.cal-cell {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 8px;
  min-height: 80px;
  cursor: pointer;
  transition: var(--tr);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-cell.empty { background: transparent; border-color: transparent; cursor: default; }

.cal-cell:not(.empty):hover {
  border-color: var(--c-accent);
  box-shadow: var(--shadow-sm);
  transform: scale(1.01);
}

.cal-cell.has-events {
  background: rgba(88, 86, 214, .04);
  border-color: rgba(88, 86, 214, .2);
}

.cal-cell.has-events:hover {
  border-color: var(--c-accent);
  background: rgba(88, 86, 214, .08);
}

.cal-cell.is-today {
  border-color: var(--c-accent) !important;
  background: rgba(88, 86, 214, .06) !important;
}

.cal-cell.is-today .cal-day-num {
  background: var(--c-accent);
  color: #fff;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}

.cal-cell.is-wknd .cal-day-num { color: var(--c-red); }

.cal-day-num {
  font-size: 13px;
  font-weight: 600;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text);
}

.cal-chips {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.cal-chip {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(88,86,214,.12);
  color: var(--c-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cal-chip:nth-child(2) { background: rgba(175,82,222,.12); color: var(--c-purple); }
.cal-chip:nth-child(3) { background: rgba(0,122,255,.12); color: var(--c-blue); }

.cal-chip.cat-task { background: rgba(52,199,89,.12); color: var(--c-green); }
.cal-chip.cat-call { background: rgba(0,122,255,.12); color: var(--c-blue); }
.cal-chip.cat-personal { background: rgba(255,149,0,.12); color: var(--c-orange); }
.cal-chip.cat-reminder { background: rgba(255,59,48,.12); color: var(--c-red); }

.cal-more {
  font-size: 10px;
  color: var(--c-text3);
  padding: 1px 4px;
}

/* =====================================================
   NOTES
   ===================================================== */

.notes-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-content: start;
}

.note-card {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 16px;
  cursor: pointer;
  transition: var(--tr);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  min-height: 120px;
}

.note-card:hover {
  border-color: var(--c-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.note-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--c-text);
  flex: 1;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}

.note-date {
  font-size: 11px;
  color: var(--c-text3);
  font-weight: 500;
}

.empty-notes {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 0;
  color: var(--c-text3);
  gap: 8px;
}

.empty-notes-icon { font-size: 36px; margin-bottom: 8px; }
.empty-notes h3 { font-size: 16px; font-weight: 600; color: var(--c-text2); }
.empty-notes p { font-size: 13px; }

/* =====================================================
   STATS
   ===================================================== */

.stats-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--tr);
}

.stat-card:hover { border-color: var(--c-accent); box-shadow: var(--shadow-sm); }

.stat-icon {
  font-size: 22px;
  margin-bottom: 4px;
}

.stat-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -.5px;
}

.stat-lbl {
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text2);
}

.stats-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--c-border);
}

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

.upcoming-row {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--tr);
}

.upcoming-row:hover { border-color: var(--c-accent); transform: translateX(2px); }

.upcoming-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-accent);
  min-width: 80px;
}

.upcoming-name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--c-text);
}

/* =====================================================
   BUTTONS
   ===================================================== */

.add-btn {
  padding: 9px 18px;
  background: var(--c-accent);
  color: #fff;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  transition: var(--tr);
  box-shadow: 0 2px 8px rgba(88,86,214,.25);
}

.add-btn:hover { background: var(--c-accent2); box-shadow: 0 4px 14px rgba(88,86,214,.35); transform: translateY(-1px); }
.add-btn.full-w { width: 100%; text-align: center; border-radius: var(--r-sm); }

/* =====================================================
   MODALS
   ===================================================== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeOverlay .15s ease;
}

.overlay.hidden { display: none; }

@keyframes fadeOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-modal);
  animation: slideModal .2s cubic-bezier(.4,0,.2,1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-wide { max-width: 540px; }
.modal-sm { max-width: 420px; }

@keyframes slideModal {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-hdr {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.modal-ttl {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
}

.modal-x {
  width: 28px; height: 28px;
  background: var(--c-surface2);
  border-radius: 50%;
  font-size: 12px;
  color: var(--c-text2);
  display: flex; align-items: center; justify-content: center;
  transition: var(--tr);
}

.modal-x:hover { background: var(--c-red); color: #fff; }

.modal-list {
  padding: 12px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-empty {
  color: var(--c-text3);
  font-size: 13px;
  font-style: italic;
  padding: 12px 0;
}

.modal-event-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--c-surface2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--tr);
  border: 1.5px solid transparent;
}

.modal-event-row:hover {
  border-color: var(--c-accent);
  background: rgba(88,86,214,.04);
}

.modal-event-row.done { opacity: .45; }

.modal-ev-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-accent);
  min-width: 40px;
  flex-shrink: 0;
}

.modal-ev-info { flex: 1; min-width: 0; }

.modal-ev-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--c-text);
}

.modal-ev-person {
  font-size: 12px;
  color: var(--c-text2);
}

.modal-ev-meta {
  font-size: 12px;
  color: var(--c-text3);
  margin-top: 2px;
}

.modal-ftr {
  padding: 12px 20px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}

/* Edit Form */
.edit-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row.span2 { grid-column: span 2; }

.form-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-row input,
.form-row select {
  background: var(--c-surface2);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--c-text);
  font-size: 13.5px;
  outline: none;
  transition: var(--tr);
}

.form-row input:focus,
.form-row select:focus {
  border-color: var(--c-accent);
  background: var(--c-surface);
  box-shadow: 0 0 0 3px rgba(88,86,214,.08);
}

.form-row input::placeholder { color: var(--c-text3); }
input[type="date"], input[type="time"] { color-scheme: light; }
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="time"] { color-scheme: dark; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236C6C70' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-textarea {
  background: var(--c-surface2);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  color: var(--c-text);
  font-size: 13.5px;
  outline: none;
  resize: vertical;
  transition: var(--tr);
  line-height: 1.5;
}

.form-textarea:focus {
  border-color: var(--c-accent);
  background: var(--c-surface);
}

.form-textarea::placeholder { color: var(--c-text3); }

/* Category Chips */
.cat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-pill {
  padding: 6px 12px;
  background: var(--c-surface2);
  border: 1.5px solid var(--c-border);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text2);
  transition: var(--tr);
}

.cat-pill:hover { border-color: var(--c-accent); color: var(--c-accent); }

.cat-pill.active {
  background: rgba(88,86,214,.1);
  border-color: var(--c-accent);
  color: var(--c-accent);
  font-weight: 600;
}

/* AI Edit block */
.ai-edit-block {
  background: rgba(88,86,214,.06);
  border: 1.5px solid rgba(88,86,214,.15);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-edit-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-edit-lbl svg { width: 13px; height: 13px; }

.ai-edit-row {
  display: flex;
  gap: 8px;
}

.ai-edit-row input {
  flex: 1;
  background: var(--c-surface2);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--c-text);
  font-size: 13px;
  outline: none;
  transition: var(--tr);
  min-width: 0;
}

.ai-edit-row input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(88,86,214,.08);
}

.ai-edit-row input::placeholder { color: var(--c-text3); }

/* Edit Actions */
.edit-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--c-border);
  margin-top: 4px;
}

.act-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  transition: var(--tr);
}

.act-btn.primary {
  background: var(--c-accent);
  color: #fff;
}
.act-btn.primary:hover { background: var(--c-accent2); }
.act-btn.primary:disabled { opacity: .5; cursor: not-allowed; }

.act-btn.success {
  background: rgba(52,199,89,.1);
  border: 1.5px solid rgba(52,199,89,.3);
  color: var(--c-green);
}
.act-btn.success:hover { background: rgba(52,199,89,.18); }

.act-btn.danger {
  background: rgba(255,59,48,.08);
  border: 1.5px solid rgba(255,59,48,.2);
  color: var(--c-red);
}
.act-btn.danger:hover { background: rgba(255,59,48,.15); }
.act-btn.hidden { display: none; }

/* =====================================================
   BOTTOM NAV (mobile)
   ===================================================== */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  justify-content: space-around;
  align-items: center;
  height: calc(60px + env(safe-area-inset-bottom, 0px));
}

.bnav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 16px;
  background: transparent;
  color: var(--c-text3);
  font-size: 10px;
  font-weight: 500;
  transition: var(--tr);
  border-radius: var(--r-sm);
  min-width: 60px;
}

.bnav-btn svg { width: 20px; height: 20px; }
.bnav-btn:hover { color: var(--c-text2); }
.bnav-btn.active { color: var(--c-accent); }

/* =====================================================
   TOAST
   ===================================================== */

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--c-text);
  color: var(--c-bg);
  border-radius: 100px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--c-red);
  color: #fff;
}

/* =====================================================
   MOBILE RESPONSIVE
   ===================================================== */

/* =====================================================
   MOBILE RESPONSIVE — All devices
   ===================================================== */

/* Base: use dvh everywhere for correct mobile height */
.app-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }

  /* Layout: subtract bottom nav height + safe area */
  .app-layout {
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
    margin-bottom: 0;
  }

  /* Main area fills remaining space */
  .main-area {
    height: 100%;
    overflow: hidden;
  }

  /* Tab pane fills main area */
  .tab-pane {
    height: 100%;
    overflow: hidden;
  }

  .pane-header {
    padding: 12px 16px;
    flex-shrink: 0;
  }
  .pane-title { font-size: 17px; }
  .pane-sub { font-size: 12px; }

  /* Chat messages scroll area */
  .chat-messages {
    padding: 12px 14px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .chat-welcome { padding: 20px 0; }
  .chat-welcome h2 { font-size: 18px; }
  .message { max-width: 88%; font-size: 13.5px; }

  /* Input bar — always visible above bottom nav */
  .input-bar {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    position: relative;
    z-index: 10;
  }

  /* Widget actions bar — horizontal scroll on small screens */
  .widget-actions-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Notes */
  .notes-grid {
    padding: 12px 14px;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }

  /* Stats */
  .stats-body {
    padding: 12px 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }
  .stats-row { grid-template-columns: repeat(2, 1fr); }

  /* Calendar */
  .calendar-body {
    padding: 8px 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }
  .cal-cell { min-height: 52px; padding: 4px; }
  .cal-day-num { font-size: 11px; width: 20px; height: 20px; }
  .cal-chip { font-size: 9px; }

  /* Automations list */
  .auto-list {
    padding: 12px 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }

  /* Modals — bottom sheet style on mobile */
  .overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-bottom: none;
  }
  .modal-wide { max-width: 100%; }
  .modal-sm { max-width: 100%; }

  .edit-body {
    padding: 14px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-row.span2 { grid-column: span 1; }
  .edit-actions { flex-wrap: wrap; gap: 8px; }

  /* AI status pill — hide on very small screens */
  .ai-status-pill { font-size: 11px; padding: 4px 9px; }
}

/* Small phones: 375px and below (iPhone SE, older Androids) */
@media (max-width: 390px) {
  .pane-header { padding: 10px 12px; }
  .pane-title { font-size: 16px; }
  .chat-messages { padding: 10px 12px; }
  .input-bar { padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .notes-grid { grid-template-columns: 1fr; }
  .wab-btn { padding: 5px 7px; min-width: 48px; }
  .wab-icon { width: 30px; height: 30px; }
  .wab-icon svg { width: 15px; height: 15px; }
  .wab-label { font-size: 9px; }
  .ai-status-pill { display: none; }
  .message { font-size: 13px; }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .app-layout {
    height: calc(100vh - 50px);
    height: calc(100dvh - 50px);
  }
  .bottom-nav { padding: 4px 0 calc(4px + env(safe-area-inset-bottom, 0px)); }
  .pane-header { padding: 8px 16px; }
  .chat-welcome { padding: 10px 0; }
  .chat-welcome .welcome-logo { width: 40px; height: 40px; }
  .chat-welcome h2 { font-size: 16px; }
  .chat-welcome p { display: none; }
  .input-bar { padding: 7px 12px; }
}

/* Tablet: 769px - 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .pane-header { padding: 16px 20px; }
  .chat-messages { padding: 16px 20px; }
  .pane-title { font-size: 18px; }
}

/* Large desktop: 1400px+ */
@media (min-width: 1400px) {
  :root { --sidebar-w: 300px; }
  .chat-messages { padding: 28px 36px; }
  .pane-header { padding: 22px 36px; }
}


/* =====================================================
   NEW FEATURES v3.1
   ===================================================== */

/* Color swatches */
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.color-swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--tr);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--c-text); box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 4px currentColor; }

.color-none {
  background: var(--c-surface2) !important;
  color: var(--c-text3);
  font-size: 12px;
}

/* Repeat badge */
.repeat-badge {
  font-size: 10px;
  opacity: .7;
  vertical-align: middle;
}

/* Calendar weather */
.cal-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
}

.cal-weather {
  font-size: 10px;
  color: var(--c-text2);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Activity chart */
.activity-chart-wrap {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.activity-chart-wrap canvas {
  display: block;
  width: 100%;
}

/* Note card improvements */
.note-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.note-card-top .note-text { flex: 1; }

.note-pin-btn {
  background: none;
  font-size: 14px;
  padding: 0 2px;
  opacity: 0;
  transition: var(--tr);
  flex-shrink: 0;
  border-radius: 6px;
}

.note-card:hover .note-pin-btn { opacity: 1; }
.note-pin-btn.active { opacity: 1; }

.note-card.pinned {
  border-color: var(--c-orange);
  background: rgba(255, 149, 0, .04);
}

/* Event card color left border */
.event-card {
  border-left: 3px solid transparent;
  transition: var(--tr);
}

/* Stats section title spacing */
.stats-section-title {
  margin-bottom: 12px;
}

/* Mobile calendar weather */
@media (max-width: 768px) {
  .cal-weather { display: none; }
  .activity-chart-wrap { padding: 10px; }
}

/* =====================================================
   v5 — PWA, Automations, new UI
   ===================================================== */

/* PWA Banner */
.pwa-banner { position:fixed;top:0;left:0;right:0;background:var(--c-accent);color:#fff;z-index:9000;padding:10px 16px;box-shadow:0 2px 12px rgba(88,86,214,.4); }
.pwa-banner.hidden { display:none; }
.pwa-banner-content { display:flex;align-items:center;gap:12px;max-width:900px;margin:0 auto; }
.pwa-banner-icon { font-size:22px;flex-shrink:0; }
.pwa-banner-text { flex:1;min-width:0; }
.pwa-banner-title { font-size:14px;font-weight:700; }
.pwa-banner-sub { font-size:12px;opacity:.85; }
.pwa-install-btn { padding:7px 16px;background:#fff;color:var(--c-accent);border-radius:100px;font-size:13px;font-weight:700;flex-shrink:0;transition:var(--tr); }
.pwa-install-btn:hover { opacity:.9; }
.pwa-dismiss-btn { background:rgba(255,255,255,.2);color:#fff;width:28px;height:28px;border-radius:50%;font-size:12px;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:var(--tr); }
.pwa-dismiss-btn:hover { background:rgba(255,255,255,.35); }

/* iOS hint */
.ios-hint { position:fixed;bottom:80px;left:50%;transform:translateX(-50%);background:var(--c-text);color:var(--c-bg);border-radius:var(--r-lg);padding:16px 20px;z-index:8000;box-shadow:var(--shadow-lg);max-width:320px;width:calc(100% - 32px);text-align:center; }
.ios-hint.hidden { display:none; }
.ios-hint-title { font-size:15px;font-weight:700;margin-bottom:10px; }
.ios-hint-steps { font-size:13px;line-height:1.7;text-align:left;margin-bottom:12px; }
.ios-share-icon { font-size:16px; }
.ios-hint-close { padding:8px 20px;background:var(--c-accent);color:#fff;border-radius:100px;font-size:13px;font-weight:600;transition:var(--tr); }
.ios-hint-arrow { text-align:center;font-size:20px;margin-top:4px;color:var(--c-text); }

/* Automations tab */
.auto-list { flex:1;overflow-y:auto;padding:20px 28px;display:flex;flex-direction:column;gap:12px; }

.auto-card { background:var(--c-surface);border:1.5px solid var(--c-border);border-radius:var(--r-lg);padding:16px 18px;transition:var(--tr); }
.auto-card:hover { border-color:var(--c-accent);box-shadow:var(--shadow-sm); }
.auto-card-main { display:flex;align-items:center;gap:12px; }
.auto-card-info { flex:1;min-width:0; }
.auto-card-title { font-size:14px;font-weight:600;color:var(--c-text);margin-bottom:3px; }
.auto-card-meta { font-size:12px;color:var(--c-text2); }
.auto-card-last { font-size:11px;color:var(--c-text3);margin-top:2px; }
.auto-card-actions { display:flex;gap:6px;flex-shrink:0; }
.auto-toggle-btn,.auto-run-btn,.auto-edit-btn { width:32px;height:32px;border-radius:var(--r-sm);background:var(--c-surface2);color:var(--c-text2);font-size:14px;display:flex;align-items:center;justify-content:center;transition:var(--tr); }
.auto-toggle-btn:hover,.auto-run-btn:hover,.auto-edit-btn:hover { background:var(--c-border);color:var(--c-text); }
.auto-toggle-btn.enabled { background:rgba(52,199,89,.1);color:var(--c-green); }

.auto-empty { display:flex;flex-direction:column;align-items:center;text-align:center;padding:40px 20px;gap:8px;color:var(--c-text3); }
.auto-empty-icon { font-size:40px;margin-bottom:8px; }
.auto-empty h3 { font-size:16px;font-weight:600;color:var(--c-text2); }
.auto-empty p { font-size:13px; }
.auto-examples { display:flex;flex-direction:column;gap:8px;margin-top:16px;width:100%;max-width:320px; }
.auto-example { background:var(--c-surface);border:1.5px solid var(--c-border);border-radius:var(--r-md);padding:12px 16px;font-size:13px;font-weight:500;color:var(--c-text);cursor:pointer;transition:var(--tr); }
.auto-example:hover { border-color:var(--c-accent);color:var(--c-accent);transform:translateX(3px); }

/* Auto actions checkboxes */
.auto-actions-wrap { display:flex;flex-direction:column;gap:8px;padding:4px 0; }
.auto-action-check { display:flex;align-items:center;gap:8px;font-size:13px;color:var(--c-text);cursor:pointer; }
.auto-action-check input { width:16px;height:16px;accent-color:var(--c-accent);cursor:pointer; }

/* Color swatches */
.color-swatches { display:flex;flex-wrap:wrap;gap:6px;margin-top:2px; }
.color-swatch { width:26px;height:26px;border-radius:50%;border:2px solid transparent;cursor:pointer;transition:var(--tr);display:flex;align-items:center;justify-content:center;font-size:10px; }
.color-swatch:hover { transform:scale(1.15); }
.color-swatch.active { border-color:var(--c-text);box-shadow:0 0 0 2px var(--c-surface),0 0 0 4px var(--c-text); }
.color-none { background:var(--c-surface2)!important;color:var(--c-text3); }

/* Repeat badge */
.repeat-badge { font-size:10px;opacity:.7;vertical-align:middle; }

/* Calendar weather */
.cal-day-row { display:flex;align-items:center;justify-content:space-between;gap:2px; }
.cal-weather { font-size:10px;color:var(--c-text2);font-weight:500;white-space:nowrap; }

/* Activity chart */
.activity-chart-wrap { background:var(--c-surface);border:1.5px solid var(--c-border);border-radius:var(--r-lg);padding:16px;margin-bottom:16px; }
.activity-chart-wrap canvas { display:block;width:100%; }

/* Note card */
.note-card-top { display:flex;align-items:flex-start;gap:8px; }
.note-card-top .note-text { flex:1; }
.note-pin-btn { background:none;font-size:14px;padding:0 2px;opacity:0;transition:var(--tr);flex-shrink:0;border-radius:6px; }
.note-card:hover .note-pin-btn { opacity:1; }
.note-pin-btn.active { opacity:1; }
.note-card.pinned { border-color:var(--c-orange);background:rgba(255,149,0,.04); }

/* Event card */
.event-card { border-left:3px solid transparent; }

@media (max-width:768px) {
  .cal-weather { display:none; }
  .pwa-banner-sub { display:none; }
  .auto-list { padding:16px; }
}

/* modal event edit button */
.modal-ev-edit-btn {
  background: none;
  border: none;
  color: var(--c-text3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: var(--tr);
  flex-shrink: 0;
  opacity: 0;
}
.modal-event-row:hover .modal-ev-edit-btn { opacity: 1; color: var(--c-accent); }

/* ═══════════════════════════════════════
   LIVE WIDGET — погода + курс
═══════════════════════════════════════ */
.live-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--c-surface2);
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
  min-height: 44px;
  transition: var(--tr);
  position: relative;
}
.live-widget.hidden { display: none; }

.widget-weather {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
#wIcon { font-size: 18px; line-height: 1; }
#wTemp { font-weight: 700; font-size: 15px; color: var(--c-text1); }
.widget-city {
  color: var(--c-text2);
  font-size: 12px;
  max-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-desc {
  color: var(--c-text3);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.widget-divider {
  width: 1px;
  height: 20px;
  background: var(--c-border);
  flex-shrink: 0;
}

.widget-rates {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-size: 12px;
  color: var(--c-text2);
}
#wUsd { font-weight: 600; color: var(--c-text1); }
.widget-eur { color: var(--c-text3); }

.widget-refresh {
  background: none;
  border: none;
  color: var(--c-text3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--tr);
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}
.widget-refresh:hover { color: var(--c-accent); background: var(--c-hover); }
.widget-refresh.spinning { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* geo permission banner */
.geo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08));
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
  color: var(--c-text2);
}
.geo-banner.hidden { display: none; }
.geo-banner-text { flex: 1; }
.geo-banner-text strong { color: var(--c-text1); }
.geo-allow-btn {
  background: var(--c-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--tr);
}
.geo-allow-btn:hover { opacity: 0.88; }
.geo-dismiss-btn {
  background: none;
  border: none;
  color: var(--c-text3);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.geo-dismiss-btn:hover { color: var(--c-text1); }

/* ─── Widget Actions Bar ─── */
.widget-actions-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 8px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.widget-actions-bar::-webkit-scrollbar { display: none; }

.wab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: none;
  background: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  flex-shrink: 0;
  min-width: 60px;
}
.wab-btn:hover { background: var(--c-hover); }
.wab-btn:active { transform: scale(0.93); }

.wab-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wab-btn:hover .wab-icon {
  border-color: var(--c-accent);
  box-shadow: 0 2px 8px rgba(99,102,241,0.15);
}

.wab-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--c-text2);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.wab-btn:hover .wab-label { color: var(--c-text1); }

.wab-divider {
  width: 1px;
  height: 36px;
  background: var(--c-border);
  margin: 0 4px;
  flex-shrink: 0;
}

.wab-danger:hover .wab-icon {
  border-color: #EF4444;
  box-shadow: 0 2px 8px rgba(239,68,68,0.15);
}
.wab-danger:hover .wab-label { color: #EF4444; }

/* Mobile: немного компактнее */
@media (max-width: 480px) {
  .wab-btn { padding: 6px 8px; min-width: 52px; }
  .wab-icon { width: 32px; height: 32px; border-radius: 9px; }
  .wab-icon svg { width: 17px; height: 17px; }
  .wab-label { font-size: 9.5px; }
}



@media (max-width: 480px) {
  .widget-desc { display: none; }
  .widget-eur { display: none; }
  .live-widget { padding: 8px 12px; gap: 8px; }
}

/* ═══════════════════════════════════════
   REDESIGN PATCH — чистый виджет, SVG иконки
═══════════════════════════════════════ */

/* Виджет — без эмодзи */
.live-widget {
  padding: 9px 16px;
  gap: 12px;
  font-size: 12.5px;
  letter-spacing: 0.01em;
}
.w-weather-icon {
  display: flex;
  align-items: center;
  opacity: 0.85;
  flex-shrink: 0;
}
.w-weather-icon svg { display: block; }
.w-temp {
  font-weight: 700;
  font-size: 14px;
  color: var(--c-text1);
  letter-spacing: -0.01em;
}
.widget-city {
  color: var(--c-text3);
  font-size: 12px;
  font-weight: 500;
}
.w-rate {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text2);
  letter-spacing: 0.01em;
}
.w-rate-eur {
  color: var(--c-text3);
  font-weight: 500;
}
/* Скрыть старый wDesc если остался */
#wDesc { display: none !important; }

/* Welcome logo */
.welcome-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 4px;
  filter: drop-shadow(0 4px 16px rgba(99,102,241,0.25));
  animation: fadeUp 0.4s ease;
}
.welcome-logo svg { width: 100%; height: 100%; }

/* Убираем старый welcome-emoji если остался */
.welcome-emoji { display: none; }

.chat-welcome h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text1);
  margin: 0;
  letter-spacing: -0.02em;
}
.chat-welcome p {
  font-size: 14px;
  color: var(--c-text3);
  margin: 0;
  max-width: 320px;
}


/* SVG иконки категорий */
.cat-svg-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-right: 5px;
  opacity: 0.7;
  color: var(--c-accent);
  flex-shrink: 0;
}
.cat-svg-icon svg { display: block; }

.event-name {
  display: flex;
  align-items: center;
}

.stat-icon.cat-svg-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--c-surface2);
  border-radius: 8px;
  margin: 0 auto 6px;
  opacity: 0.9;
}

/* AI статус — чище */
.ai-status-pill {
  font-size: 11.5px;
  letter-spacing: 0.02em;
  padding: 5px 11px;
}

/* Меню — без эмодзи */
.menu-dropdown button {
  font-size: 13px;
}

/* Cat pills в форме — чище без эмодзи */
.cat-pill {
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 480px) {
  .w-rate-eur { display: none; }
  .welcome-logo { width: 52px; height: 52px; }
  .chat-welcome h2 { font-size: 18px; }
}

/* ═══════════════════════════════════════
   CHAT HEADER SETTINGS BUTTON
═══════════════════════════════════════ */
.chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Quick actions bar — always visible in chat header */
.quick-actions-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--c-border);
  background: var(--c-surface2);
  font-size: 16px;
  cursor: pointer;
  transition: var(--tr);
  flex-shrink: 0;
  line-height: 1;
}
.qa-btn:hover {
  background: var(--c-hover);
  border-color: var(--c-accent);
  transform: scale(1.08);
}
.qa-btn:active {
  transform: scale(0.96);
}

@media (max-width: 480px) {
  .quick-actions-bar { gap: 2px; }
  .qa-btn { width: 32px; height: 32px; font-size: 15px; border-radius: 8px; }
  .ai-status-pill { display: none; }
}

/* ═══════════════════════════════════════
   THEME TOGGLE PILL (sidebar)
═══════════════════════════════════════ */
.theme-toggle-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid var(--c-border);
  background: var(--c-surface2);
  cursor: pointer;
  transition: var(--tr);
  flex-shrink: 0;
  position: relative;
  height: 30px;
}
.theme-toggle-pill:hover { border-color: var(--c-accent); }

.ttp-sun, .ttp-moon {
  font-size: 13px;
  line-height: 1;
  transition: opacity 0.2s;
  z-index: 1;
  pointer-events: none;
}

.theme-toggle-pill:not(.is-dark) .ttp-moon { opacity: 0.35; }
.theme-toggle-pill.is-dark .ttp-sun { opacity: 0.35; }

.ttp-knob {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-accent);
  opacity: 0.15;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1), background 0.2s;
  pointer-events: none;
}
.ttp-knob.dark {
  transform: translateX(26px);
  background: #8B5CF6;
  opacity: 0.2;
}

.sidebar-footer .theme-toggle-pill {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
  gap: 8px;
}
.sidebar-footer .ttp-knob {
  width: 26px;
  height: 26px;
  top: 1px;
  left: 5px;
}
.sidebar-footer .ttp-knob.dark {
  transform: translateX(32px);
}
.sidebar-footer .ttp-sun, .sidebar-footer .ttp-moon { font-size: 15px; }

/* ═══════════════════════════════════════
   THEME ICON BUTTON (mobile chat header)
═══════════════════════════════════════ */
.theme-icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--c-border);
  background: var(--c-surface2);
  cursor: pointer;
  transition: var(--tr);
  flex-shrink: 0;
  font-size: 17px;
  line-height: 1;
  position: relative;
  overflow: hidden;
}
.theme-icon-btn:hover {
  border-color: var(--c-accent);
  background: var(--c-hover);
}
.theme-icon-btn:active { transform: scale(0.94); }

.theme-icon-sun,
.theme-icon-moon {
  position: absolute;
  transition: opacity 0.2s, transform 0.2s;
  line-height: 1;
}
/* light mode: show sun, hide moon */
.theme-icon-btn .theme-icon-sun { opacity: 1; transform: scale(1); }
.theme-icon-btn .theme-icon-moon { opacity: 0; transform: scale(0.6); }
/* dark mode */
[data-theme="dark"] .theme-icon-btn .theme-icon-sun { opacity: 0; transform: scale(0.6); }
[data-theme="dark"] .theme-icon-btn .theme-icon-moon { opacity: 1; transform: scale(1); }

@media (max-width: 768px) {
  .theme-icon-btn { display: flex; }
}


/* =====================================================
   NEXT EVENT BLOCK
   ===================================================== */
.next-event-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(99,102,241,0.08), rgba(139,92,246,0.06));
  border-bottom: 1px solid var(--c-border);
  position: relative;
  flex-shrink: 0;
}
.next-event-block.hidden { display: none; }

.neb-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-accent);
  white-space: nowrap;
  flex-shrink: 0;
}
.neb-content {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.neb-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-accent);
  background: rgba(99,102,241,0.1);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.neb-dismiss {
  background: none;
  border: none;
  color: var(--c-text3);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}
.neb-dismiss:hover { color: var(--c-text1); }

/* =====================================================
   QUICK TEMPLATES
   ===================================================== */
.quick-templates {
  margin-top: 20px;
  width: 100%;
  max-width: 400px;
}
.qt-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text3);
  margin-bottom: 10px;
  text-align: center;
}
.qt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.qt-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--tr);
  box-shadow: var(--shadow-sm);
}
.qt-btn:hover {
  border-color: var(--c-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.qt-btn:active { transform: translateY(0); }
.qt-icon { font-size: 20px; line-height: 1; }
.qt-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text2);
}
.qt-btn:hover .qt-name { color: var(--c-accent); }

@media (max-width: 390px) {
  .qt-grid { grid-template-columns: repeat(2, 1fr); }
  .qt-btn { padding: 10px 6px; }
  .qt-icon { font-size: 18px; }
}

/* =====================================================
   UNDO TOAST (кнопка отмены)
   ===================================================== */
.toast-undo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-undo-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.toast-undo-btn:hover { background: rgba(255,255,255,0.35); }


/* =====================================================
   SETTINGS MODAL
===================================================== */
.settings-modal { max-width: 460px; }
.settings-body { gap: 16px; display: flex; flex-direction: column; }
.settings-group { border: 1px solid var(--c-border); border-radius: 18px; padding: 14px; background: var(--c-surface2); }
.settings-group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text2); margin-bottom: 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.settings-row + .settings-row { border-top: 1px solid var(--c-border); }
.settings-row-title { font-weight: 600; color: var(--c-text1); }
.settings-row-sub { color: var(--c-text2); font-size: 13px; margin-top: 2px; }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.settings-actions.wrap .act-btn { flex: 1 1 140px; }
.settings-actions .act-btn { min-height: 40px; }
.settings-info-card { color: var(--c-text2); font-size: 13px; line-height: 1.5; }
.perm-badge { min-width: 44px; height: 28px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text2); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.perm-badge.granted, .perm-badge.default { background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.22); color: var(--c-accent); }
.perm-badge.denied { background: rgba(239,68,68,.10); border-color: rgba(239,68,68,.18); color: #DC2626; }
.perm-badge.prompt, .perm-badge.unknown { background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.18); color: #D97706; }
#settingsBtnMobile { display: none; }
#settingsBtnMobile svg { width: 18px; height: 18px; }
@media (max-width: 768px) {
  #settingsBtnMobile { display: inline-flex; }
  .settings-modal { max-width: 100%; border-radius: 22px; }
  .settings-group { padding: 12px; }
  .settings-actions { flex-direction: column; }
  .settings-actions .act-btn { width: 100%; }
}
