/* ═══ Variables ═══ */
:root {
  --bg: #ffffff;
  --bg-sidebar: #f8f9fb;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --primary: #3b82f6;
  --primary-light: #eff6ff;
  --danger: #ef4444;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.12);
  --transition: 0.15s ease;
  --sidebar-width: 280px;
  --header-height: 56px;

  --color-NORMAL: #3b82f6;
  --color-BIRTHDAY: #ec4899;
  --color-WEDDINGDAY: #e11d48;
  --color-COUNTDOWN: #f97316;
  --color-HOUSEWORK: #22c55e;
  --color-MEALPLAN: #8b5cf6;
}

/* ═══ Reset ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text); background: var(--bg);
  display: flex; height: 100vh; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ═══ Auth Page ═══ */
.auth-page {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f8f9fb 50%, #e0e7ff 100%);
  z-index: 200;
}
.auth-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.12);
  width: 400px; max-width: 92vw;
  padding: 40px 36px 32px;
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-logo { font-size: 48px; display: block; margin-bottom: 8px; }
.auth-header h1 { font-size: 24px; font-weight: 700; color: var(--text); }
.auth-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-top: 8px; }
.auth-error {
  padding: 10px 14px; background: #fef2f2; color: var(--danger);
  border-radius: var(--radius); font-size: 13px; margin-bottom: 8px; text-align: center;
}
.auth-switch { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-secondary); }
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 500; margin-left: 4px; }
.auth-switch a:hover { text-decoration: underline; }

/* ═══ App Page ═══ */
.app-page { display: flex; width: 100%; height: 100vh; }
.app-page.hidden { display: none !important; }

/* ═══ Sidebar ═══ */
#sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px;
  height: 100vh; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 700; padding: 8px 4px 16px;
  color: var(--text);
}
.brand-icon { font-size: 24px; }

/* User Area */
.user-area {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.user-avatar { font-size: 18px; }
.user-name { font-weight: 500; color: var(--text); }
.auth-buttons {
  display: flex; gap: 6px; margin-bottom: 12px;
}
.auth-buttons .btn { flex: 1; }

/* Auth Modal */
.auth-modal { width: 380px; }
.auth-error {
  padding: 8px 12px; background: #fef2f2; color: var(--danger);
  border-radius: var(--radius); font-size: 13px; margin-bottom: 4px;
}
.auth-switch { font-size: 13px; color: var(--text-secondary); }

/* Mini Calendar */
.mini-cal { margin-bottom: 12px; }
.mini-cal-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600; margin-bottom: 6px;
  color: var(--text-secondary);
}
.mini-cal-header button {
  background: none; border: none; cursor: pointer;
  padding: 2px 6px; color: var(--text-muted); font-size: 12px;
  border-radius: 4px;
}
.mini-cal-header button:hover { background: var(--border); color: var(--text); }
.mini-cal-weekdays, .mini-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; gap: 1px;
}
.mini-cal-weekdays { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.mini-cal-weekdays span { padding: 2px 0; }
.mini-cal-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 12px; border-radius: 50%; cursor: pointer; color: var(--text);
  position: relative;
}
.mini-cal-cell:hover { background: var(--primary-light); }
.mini-cal-cell.today { background: var(--primary); color: #fff; font-weight: 600; }
.mini-cal-cell.selected { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.mini-cal-cell.other-month { color: var(--text-muted); }
.mini-cal-cell.has-event::after {
  content: ""; position: absolute; bottom: 2px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--primary);
}
.mini-cal-cell.selected.has-event::after,
.mini-cal-cell.today.has-event::after { background: #fff; }

/* Sidebar Events */
.sidebar-events { flex: 1; overflow-y: auto; }
.sidebar-events-header {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  padding: 8px 0; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.sidebar-events-list { display: flex; flex-direction: column; gap: 6px; }
.sidebar-event-item {
  padding: 8px 10px; border-radius: var(--radius);
  cursor: pointer; font-size: 13px;
  border-left: 3px solid var(--primary);
  background: #fff; transition: var(--transition);
}
.sidebar-event-item:hover { box-shadow: var(--shadow); }
.sidebar-event-item .se-title { font-weight: 500; }
.sidebar-event-item .se-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sidebar-empty { font-size: 13px; color: var(--text-muted); text-align: center; padding: 20px 0; }

/* ═══ Main ═══ */
#main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; height: 100vh;
}

/* Header */
.main-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 20px; height: var(--header-height);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; }
#header-title { font-size: 18px; font-weight: 600; min-width: 120px; text-align: center; }

/* Search */
.search-box {
  position: relative; display: flex; align-items: center;
}
.search-box input {
  width: 180px; padding: 6px 10px 6px 32px; border: 1px solid var(--border);
  border-radius: 20px; font-size: 13px; outline: none; transition: var(--transition);
}
.search-box input:focus { border-color: var(--primary); width: 220px; }
.search-icon { position: absolute; left: 10px; font-size: 13px; pointer-events: none; }
.search-dropdown {
  position: absolute; top: 48px; right: 20px;
  width: 320px; max-height: 360px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 50;
}

/* View Switcher */
.view-switcher {
  display: flex; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.btn-view {
  padding: 6px 14px; border: none; background: transparent;
  font-size: 13px; cursor: pointer; color: var(--text-secondary);
  transition: var(--transition);
}
.btn-view:hover { background: var(--bg-sidebar); }
.btn-view.active { background: var(--primary); color: #fff; }

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border: none; border-radius: var(--radius);
  font-size: 13px; cursor: pointer; font-weight: 500;
  transition: var(--transition); gap: 4px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-sidebar); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-danger-text { background: none; color: var(--danger); }
.btn-danger-text:hover { background: #fef2f2; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  background: transparent; color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg-sidebar); color: var(--text); }
.btn-full { width: 100%; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-close {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--text-muted); padding: 4px;
  border-radius: 4px;
}
.btn-close:hover { background: var(--bg-sidebar); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ═══ Calendar Views ═══ */
#calendar-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 0 12px 16px; }
.view { display: none; }
.view.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* --- Month View --- */
.month-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 12px; font-weight: 600;
  color: var(--text-muted); padding: 8px 0 4px;
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr; gap: 1px; flex: 1; min-height: 0;
}
.month-cell {
  min-height: 110px; padding: 4px 6px;
  border: 1px solid var(--border); cursor: pointer;
  transition: var(--transition); overflow: hidden;
  display: flex; flex-direction: column;
}
.month-cell:hover { background: #fafbfc; }
.month-cell.today { background: var(--primary-light); }
.month-cell.other-month { background: #f9fafb; color: var(--text-muted); }
.month-cell.selected { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.month-cell-num {
  font-size: 12px; font-weight: 500; margin-bottom: 2px;
  color: var(--text-secondary);
}
.month-cell.today .month-cell-num {
  background: var(--primary); color: #fff; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
}
.month-cell.other-month .month-cell-num { color: var(--text-muted); }
.month-event {
  font-size: 11px; padding: 2px 5px; margin-bottom: 1px;
  border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; color: #fff; transition: var(--transition);
}
.month-event:hover { opacity: 0.85; transform: translateX(2px); }
.month-event.continued { opacity: 0.5; border-radius: 0 3px 3px 0; }
.month-event-start { border-radius: 3px 0 0 3px; }
.month-more {
  font-size: 11px; color: var(--primary); cursor: pointer; margin-top: 1px;
}
.month-more:hover { text-decoration: underline; }

/* --- Week View --- */
.week-header {
  display: grid; grid-template-columns: 60px repeat(7, 1fr);
  text-align: center; font-size: 12px; padding: 4px 0;
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.week-header .wh-day {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 0; cursor: pointer; border-radius: var(--radius);
}
.week-header .wh-day:hover { background: var(--bg-sidebar); }
.week-header .wh-day.today .wh-num {
  background: var(--primary); color: #fff; width: 26px; height: 26px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.wh-day-name { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.wh-num { font-size: 15px; font-weight: 500; }
.week-body {
  display: grid; grid-template-columns: 60px repeat(7, 1fr);
  overflow-y: auto; position: relative; flex: 1; min-height: 0;
}
/* Allday row — separate from scrollable body, same column alignment */
.week-allday-row {
  display: grid; grid-template-columns: 60px repeat(7, 1fr);
  border-bottom: 1px solid var(--border); padding: 2px 0 6px;
  flex-shrink: 0;
}
.week-time-col {
  display: flex; flex-direction: column;
}
.week-time-label {
  height: 48px; font-size: 11px; color: var(--text-muted);
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding-right: 8px; line-height: 1;
  transform: translateY(-6px);
}
.week-day-col {
  border-left: 1px solid var(--border); position: relative;
  min-height: 1152px;
}
.week-day-col:last-child { border-right: 1px solid var(--border); }
.week-hour-line {
  position: absolute; left: 0; right: 0; border-top: 1px solid #f3f4f6;
}
.week-event {
  position: absolute; left: 2px; right: 2px;
  padding: 3px 6px; border-radius: 3px; font-size: 11px;
  color: #fff; cursor: pointer; overflow: hidden;
  transition: var(--transition);
}
.week-event:hover { opacity: 0.85; z-index: 2; }
.week-allday {
  display: grid; grid-template-columns: 60px repeat(7, 1fr);
  border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-bottom: 4px;
}
.week-allday-label { font-size: 11px; color: var(--text-muted); text-align: right; padding-right: 8px; }
.week-allday-col { padding: 2px; }
.week-allday-event {
  font-size: 11px; padding: 2px 6px; border-radius: 3px;
  color: #fff; margin-bottom: 1px; cursor: pointer;
}

/* --- Day View --- */
.day-header {
  text-align: center; padding: 12px 0; font-size: 18px; font-weight: 600;
}
.day-body { display: flex; flex: 1; min-height: 0; overflow-y: auto; }
.day-time-col {
  width: 60px; flex-shrink: 0; display: flex; flex-direction: column;
}
.day-time-label {
  height: 60px; font-size: 12px; color: var(--text-muted);
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding-right: 8px;
}
.day-event-col {
  flex: 1; position: relative; min-height: 1440px;
  border-left: 1px solid var(--border);
}
.day-hour-line {
  position: absolute; left: 0; right: 0; border-top: 1px solid #f3f4f6; height: 0;
}
.day-event {
  position: absolute; left: 8px; right: 8px; padding: 6px 10px;
  border-radius: 6px; color: #fff; font-size: 13px; cursor: pointer;
  overflow: hidden; transition: var(--transition);
}
.day-event:hover { opacity: 0.9; transform: scaleX(1.01); }
.day-event-time { font-size: 11px; opacity: 0.85; }
.day-event-title { font-weight: 500; }
.day-allday-section { padding: 8px 8px 8px 68px; border-bottom: 1px solid var(--border); }
.day-allday-event {
  display: inline-block; padding: 4px 10px; border-radius: 4px;
  color: #fff; font-size: 12px; margin: 2px 4px 2px 0; cursor: pointer;
}

/* ═══ AI Floating Button ═══ */
.ai-fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; border: none; cursor: pointer;
  font-size: 26px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(102,126,234,0.45);
  z-index: 60; transition: transform 0.2s, box-shadow 0.2s;
}
.ai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(102,126,234,0.6);
}
.ai-fab:active { transform: scale(0.95); }
.ai-fab-icon { line-height: 1; }

/* ═══ AI Chat Panel ═══ */
.ai-panel {
  position: fixed; bottom: 0; left: 0; right: 0;
  width: 100%; height: 65vh;
  background: #fff; border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 40px rgba(0,0,0,0.15);
  z-index: 70; display: flex; flex-direction: column;
  animation: ai-slide-up 0.3s ease;
  border: 1px solid var(--border);
  border-bottom: none;
}
@keyframes ai-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.ai-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-panel-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px;
}
.ai-panel-brand span:first-child { font-size: 22px; }
.ai-panel-subtitle {
  text-align: center; font-size: 12px; color: var(--text-muted);
  padding: 4px 24px 0; line-height: 1.5;
}
.ai-badge {
  font-size: 10px; background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; padding: 2px 6px; border-radius: 8px;
}
.ai-panel-actions { display: flex; align-items: center; gap: 6px; }

/* ═══ AI Chat ═══ */
.ai-panel-logo { font-size: 22px; margin-right: 6px; }
.ai-panel-header strong { font-size: 15px; }
.ai-panel-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.ai-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ai-load-more { text-align: center; padding: 6px 0 2px; }
.ai-load-more button { font-size: 12px; }
.ai-loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 0; color: #667eea; font-size: 12px; }
.ai-loading-spin { display: inline-block; width: 14px; height: 14px; border: 2px solid #e2e8f0; border-top-color: #667eea; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-pull-hint { text-align: center; padding: 14px 0; color: #9ca3af; font-size: 12px; user-select: none; }
.ai-msg { display: flex; gap: 6px; }
.ai-msg-user { max-width: 70%;  align-self: flex-end; flex-direction: row-reverse; }
.ai-msg-user .ai-msg-bubble { background: var(--primary); color: #fff; border-radius: 16px 4px 16px 16px; padding: 8px 12px; font-size: 14px; line-height: 1.5; display: inline-block; }
.ai-msg-assistant { max-width: 70%;  align-self: flex-start; }
.ai-msg-assistant .ai-msg-bubble { background: #f3f4f6; color: var(--text); border-radius: 4px 16px 16px 16px; padding: 8px 12px; font-size: 14px; line-height: 1.5; }
.ai-msg-bubble p { margin: 2px 0; }
.ai-msg-bubble strong { font-weight: 600; }

/* typing dots */
.ai-msg-typing .ai-msg-bubble { display: flex; gap: 4px; align-items: center; padding: 12px 14px; }
.ai-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #9ca3af; animation: dot-bounce 0.5s infinite alternate; }
.ai-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce { from { transform: translateY(0); opacity: 0.4; } to { transform: translateY(-5px); opacity: 1; } }

/* failed */
.ai-msg-failed .ai-msg-bubble { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; border-radius: 20px; padding: 8px 16px; font-size: 13px; cursor: pointer; text-align: center; }
.ai-msg-failed .ai-msg-bubble::before { content: "🔄 "; }

/* ── Markdown ── */
.ai-md { word-break: break-word; }
.ai-md p { margin: 0 0 6px; }
.ai-md p:last-child { margin-bottom: 0; }
.ai-md strong { font-weight: 700; }
.ai-md em { font-style: italic; }
.ai-md code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-size: 13px; font-family: ui-monospace,SFMono-Regular,Menlo,monospace; }
.ai-md pre { background: #1e293b; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 12px; line-height: 1.6; margin: 8px 0; }
.ai-md pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.ai-md ul,.ai-md ol { padding-left: 20px; margin: 4px 0 8px; }
.ai-md li { margin-bottom: 2px; }
.ai-md blockquote { border-left: 3px solid #667eea; margin: 8px 0; padding: 4px 12px; color: #475569; background: rgba(102,126,234,.06); border-radius: 0 6px 6px 0; }
.ai-md table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px; }
.ai-md th,.ai-md td { border: 1px solid #e2e8f0; padding: 6px 10px; text-align: left; }
.ai-md th { background: #f1f5f9; font-weight: 600; }
.ai-md img { max-width: 100%; border-radius: 8px; margin: 6px 0; cursor: pointer; }
.ai-md h1,.ai-md h2,.ai-md h3,.ai-md h4 { margin: 10px 0 4px; font-weight: 700; }
.ai-md h1 { font-size: 1.3em; } .ai-md h2 { font-size: 1.15em; } .ai-md h3 { font-size: 1.05em; }
.ai-md hr { border: none; border-top: 1px solid #e2e8f0; margin: 10px 0; }
.ai-md a { color: #3b82f6; text-decoration: none; }
.ai-md a:hover { text-decoration: underline; }

/* ── Tool Card ── */
.ai-msg-tool { max-width: 85%; align-self: flex-start; }
.ai-tool-card { display: flex; align-items: center; gap: 6px; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 10px; padding: 6px 12px; font-size: 12px; color: #0369a1; margin-bottom: 4px; }
.ai-tool-dot { width: 8px; height: 8px; border-radius: 50%; background: #0ea5e9; animation: tool-pulse 1.2s infinite; flex-shrink: 0; }
@keyframes tool-pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.ai-tool-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Input area */
.ai-input-area { padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.ai-text-row { display: flex; gap: 6px; align-items: center; }
.ai-input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 20px; font-size: 13px; outline: none; resize: none; max-height: 100px; font-family: inherit; }
.ai-input:focus { border-color: #667eea; }
.ai-panel-actions .active { background: #667eea; color: #fff; border-color: #667eea; }

/* ═══ Modal ═══ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 440px; max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal-footer .btn-danger { margin-right: auto; }
.input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; outline: none;
  transition: var(--transition); font-family: inherit;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.textarea { resize: vertical; min-height: 48px; }
.form-row {
  display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.form-row label { width: 50px; flex-shrink: 0; color: var(--text-secondary); }
.form-row .input { flex: 1; }
.checkbox-label {
  display: flex; align-items: center; gap: 6px; font-size: 14px;
  cursor: pointer; user-select: none;
}
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.type-picker { display: flex; gap: 4px; flex-wrap: wrap; }
.type-dot {
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  background: #f3f4f6;
}
.type-dot:hover { transform: scale(1.15); background: #e5e7eb; }
.type-dot.active { border-color: var(--text); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--text); }
/* Colored left border indicator on active type-dot */
.type-dot.active::before {
  content: ""; position: absolute; left: -1px; top: 2px; bottom: 2px;
  width: 3px; border-radius: 2px;
}

/* ═══ Event Detail Panel ═══ */
.detail-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center; z-index: 80;
}
.detail-panel {
  background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-lg); width: 400px; max-width: 90vw;
  overflow: hidden;
}
.detail-header {
  display: flex; justify-content: space-between; align-items: center;
}
.detail-header-left { display: flex; align-items: center; gap: 8px; }
.detail-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.detail-title { font-size: 16px; margin: 0; }
.detail-time, .detail-repeat, .detail-desc {
  padding: 6px 20px; font-size: 13px; color: var(--text-secondary);
}
.detail-time::before { content: "🕐 "; }
.detail-repeat::before { content: "🔁 "; }
.detail-repeat:empty { display: none; }
.detail-desc { color: var(--text); white-space: pre-wrap; }
.detail-desc:empty { display: none; }

.detail-recurrence-options {
  padding: 10px 20px; display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--border); margin-top: 8px;
}
.detail-recurrence-label { font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.detail-recurrence-options .input { flex: 1; }

.detail-actions {
  display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border);
}
.detail-actions .btn { flex: 1; }

/* Delete dialog */
.delete-dialog {
  box-shadow: var(--shadow-lg); width: 360px; max-width: 90vw; padding: 20px;
}
.delete-dialog h4 { margin-bottom: 12px; font-size: 16px; }
.delete-recurrence-options {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.delete-recurrence-options label { font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.delete-recurrence-options .input { flex: 1; }
.delete-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ═══ Search Results ═══ */
.search-item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.search-item .si-title { font-size: 13px; font-weight: 500; }
.search-item .si-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ═══ Utilities ═══ */
.hidden { display: none !important; }

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
  #sidebar { display: none; }
  :root { --sidebar-width: 0; }
}
.ai-confirm-card{background:#fff3e0;border:1px solid #ff9800;border-radius:12px;padding:12px 16px;display:flex;align-items:center;gap:10px;max-width:420px;margin:8px 0}
.ai-confirm-icon{font-size:20px}
.ai-confirm-text{flex:1;color:#e65100;font-size:14px}
.ai-confirm-btns{display:flex;gap:8px}
.ai-confirm-yes,.ai-confirm-no{padding:6px 16px;border-radius:8px;border:none;cursor:pointer;font-size:14px}
.ai-confirm-yes{background:#4caf50;color:#fff}
.ai-confirm-no{background:#f44336;color:#fff}
.ai-confirm-yes:disabled{opacity:0.5}
.ai-confirm-body{flex:1;min-width:0}
.ai-confirm-item{padding:4px 0;font-size:13px;border-bottom:1px solid #ffe0b2}
.ai-confirm-item:last-child{border-bottom:none}
.ai-msg-badge{display:inline-block;padding:2px 8px;border-radius:4px;font-size:11px;margin-right:6px;vertical-align:middle}
.ai-badge-create{background:#e8f5e9;color:#2e7d32}
.ai-badge-update{background:#fff3e0;color:#e65100}
.ai-badge-delete{background:#ffebee;color:#c62828}
/* 系统回执条(确认执行/执行失败):紧凑居中,区别于用户气泡 */
.ai-msg-sys { align-self: center; max-width: 100%; }
.ai-sys-chip { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; line-height: 1.6; }
.ai-sys-ok { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.ai-sys-fail { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
