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

:root {
  --bg-0: #0a0b14;
  --bg-1: #101223;
  --bg-2: #171a2e;
  --bg-3: #1f2340;
  --bg-elev: rgba(32, 37, 66, 0.55);
  --fg: #eef1fa;
  --fg-soft: #c9cfe3;
  --muted: #7a82a0;
  --muted-2: #5a6280;
  --border: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.12);

  --accent: #8b5cf6;
  --accent-2: #6366f1;
  --accent-3: #ec4899;
  --accent-glow: rgba(139, 92, 246, 0.5);
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;

  --grad-accent: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #3b82f6 100%);
  --grad-bg: radial-gradient(ellipse at top right, rgba(139, 92, 246, 0.10), transparent 60%),
             radial-gradient(ellipse at bottom left, rgba(236, 72, 153, 0.07), transparent 50%),
             linear-gradient(180deg, #0a0b14 0%, #101223 100%);

  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;

  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 10px 40px -10px var(--accent-glow);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --week-hour-height: 52px;
  --topbar-h: 60px;
  --toolbar-h: 96px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; font-weight: 400; letter-spacing: -0.01em;
  color: var(--fg); background: var(--grad-bg); background-attachment: fixed;
  min-height: 100dvh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: none; background: none; }
input, textarea { border: none; background: none; outline: none; }
a { color: var(--accent); text-decoration: none; }

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

/* === LOGIN === */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
  overflow: hidden; position: relative;
}
.login-body::before, .login-body::after {
  content: ''; position: absolute; width: 500px; height: 500px; border-radius: 50%;
  filter: blur(100px); opacity: 0.35; pointer-events: none;
}
.login-body::before { background: var(--accent); top: -150px; right: -100px; animation: float 12s ease-in-out infinite; }
.login-body::after  { background: var(--accent-3); bottom: -150px; left: -100px; animation: float 15s ease-in-out infinite reverse; }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(30px,-30px) scale(1.1); } }

.login-card {
  width: 100%; max-width: 400px; padding: 36px 28px 28px;
  background: rgba(23, 26, 46, 0.75); backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--border-2); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,0.1);
  text-align: center; position: relative; z-index: 1;
  animation: slideUp 0.5s var(--ease-spring) both;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(0.97); } to { opacity: 1; transform: none; } }
.login-card .logo {
  width: 64px; height: 64px; margin: 0 auto 14px;
  background: var(--grad-accent); border-radius: 18px;
  display: grid; place-items: center; box-shadow: var(--shadow-glow);
}
.login-card .logo svg { width: 32px; height: 32px; stroke: #fff; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.login-card .muted { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login-card input {
  width: 100%; padding: 14px 18px; border: 1px solid var(--border-2);
  border-radius: var(--radius); background: rgba(10, 11, 20, 0.5);
  text-align: center; font-size: 22px; font-weight: 600; letter-spacing: 12px;
  margin-bottom: 12px; transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.login-card input::placeholder { letter-spacing: 4px; font-weight: 400; color: var(--muted-2); }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15); }
.login-card button {
  width: 100%; padding: 14px; border-radius: var(--radius);
  background: var(--grad-accent); color: #fff; font-weight: 600; font-size: 15px;
  transition: transform 0.1s var(--ease); box-shadow: var(--shadow-glow);
}
.login-card button:active { transform: scale(0.98); }
.login-card .error {
  color: var(--danger); margin-top: 14px; font-size: 13px;
  padding: 8px 12px; background: rgba(239, 68, 68, 0.1); border-radius: var(--radius-sm);
}

/* === APP LAYOUT === */
.app {
  display: grid; grid-template-rows: auto 1fr; grid-template-columns: 1fr;
  min-height: 100dvh; padding-bottom: calc(env(safe-area-inset-bottom) + 72px);
  position: relative;
}
.chat-sidebar { display: none; flex-direction: column; }
.chat-sidebar.mobile-visible {
  display: flex !important;
  position: fixed; inset: 0; top: var(--topbar-h);
  bottom: calc(env(safe-area-inset-bottom) + 72px);
  background: var(--bg-0); z-index: 15;
  padding: 8px 12px 12px;
}
.chat-sidebar.mobile-visible .chat-messages { flex: 1; overflow-y: auto; padding: 8px 8px 100px; }
.chat-sidebar.mobile-visible .chat-input-wrap { display: block; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 10px;
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, rgba(10, 11, 20, 0.92) 60%, rgba(10, 11, 20, 0));
  backdrop-filter: blur(12px); min-height: var(--topbar-h);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .brand .logo-mini {
  width: 30px; height: 30px; border-radius: 9px; background: var(--grad-accent);
  display: grid; place-items: center;
}
.topbar .brand .logo-mini svg { width: 16px; height: 16px; stroke: #fff; }
.topbar .brand h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.topbar .actions { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--fg-soft); display: grid; place-items: center;
  transition: all 0.15s var(--ease);
}
.icon-btn.sm { width: 34px; height: 34px; border-radius: 9px; }
.icon-btn:hover { background: var(--bg-3); color: var(--fg); border-color: var(--border-2); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.main { padding: 8px 12px 20px; min-width: 0; overflow: hidden; }

/* === CAL TOOLBAR === */
.cal-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 10px 12px; align-items: center;
  padding: 6px 4px 14px;
}
.cal-nav {
  display: flex; align-items: center; gap: 8px;
  grid-column: 1 / -1;
}
.cal-title-wrap { flex: 1; text-align: center; min-width: 0; }
.cal-title {
  font-size: 18px; font-weight: 700; letter-spacing: -0.02em;
  text-transform: capitalize;
}
.cal-subtitle { font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 1px; text-transform: capitalize; }
.cal-view-toggle {
  display: flex; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px;
}
.cal-view-toggle button {
  padding: 6px 14px; border-radius: 7px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); transition: all 0.15s var(--ease);
}
.cal-view-toggle button.active { background: var(--bg-3); color: var(--fg); box-shadow: var(--shadow-1); }
.cal-today-btn {
  padding: 6px 14px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--fg-soft);
  transition: all 0.15s var(--ease);
}
.cal-today-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.cal-container { position: relative; }

/* === MONTH VIEW === */
.month-view {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  animation: fadeIn 0.25s var(--ease) both;
}
.month-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--bg-1); border-bottom: 1px solid var(--border);
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.month-dow > div { padding: 8px 6px; text-align: center; }
.month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(78px, 1fr);
}
.month-cell {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 6px 6px 4px; position: relative; cursor: pointer;
  min-height: 78px; display: flex; flex-direction: column; gap: 2px;
  transition: background 0.12s var(--ease);
  overflow: hidden;
}
.month-cell:nth-child(7n) { border-right: none; }
.month-cell.other-month { background: rgba(0, 0, 0, 0.2); color: var(--muted-2); }
.month-cell:hover { background: var(--bg-3); }
.month-cell.today .cell-date {
  background: var(--grad-accent); color: #fff;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; box-shadow: var(--shadow-glow);
}
.month-cell .cell-date {
  font-size: 13px; font-weight: 600; color: var(--fg);
  width: 24px; height: 24px; display: grid; place-items: center;
  flex-shrink: 0;
}
.month-cell.other-month .cell-date { color: var(--muted-2); }
.month-cell .cell-events { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.month-event-pill {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  padding: 2px 5px; border-radius: 4px;
  background: color-mix(in srgb, var(--cal-color) 18%, transparent);
  border-left: 2px solid var(--cal-color);
  font-size: 10.5px; color: var(--fg-soft); line-height: 1.25;
}
.month-event-pill .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 9.5px; flex-shrink: 0; }
.month-event-pill .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; font-weight: 500; }
.month-cell .more { font-size: 10px; color: var(--muted); margin-top: 1px; font-weight: 500; }
.month-cell .busy-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--busy-color, var(--accent)));
  opacity: var(--busy, 0); transition: opacity 0.2s var(--ease);
}

/* === WEEK VIEW === */
.week-view {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  animation: fadeIn 0.25s var(--ease) both;
  display: flex; flex-direction: column;
  max-height: calc(100dvh - var(--topbar-h) - var(--toolbar-h) - 92px);
  min-height: 400px;
}
.week-head {
  display: grid; grid-template-columns: 48px repeat(7, 1fr);
  border-bottom: 1px solid var(--border); background: var(--bg-1);
  position: sticky; top: 0; z-index: 3;
}
.week-head .wh-cell {
  padding: 8px 4px 10px; text-align: center; font-size: 10.5px;
  color: var(--muted); font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; border-right: 1px solid var(--border);
  cursor: pointer; transition: background 0.12s var(--ease);
}
.week-head .wh-cell:last-child { border-right: none; }
.week-head .wh-cell:hover { background: var(--bg-3); }
.week-head .wh-cell .dnum {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: 50%; font-size: 15px; margin-top: 3px; color: var(--fg);
  font-weight: 600; letter-spacing: normal; text-transform: none;
}
.week-head .wh-cell.is-today .dnum {
  background: var(--grad-accent); color: #fff; box-shadow: var(--shadow-glow);
}
.week-head .wh-cell.is-selected { background: var(--bg-3); }
.week-head .wh-cell .busy-ind {
  margin: 4px auto 0; height: 3px; border-radius: 2px; width: 60%;
  background: color-mix(in srgb, var(--busy-color, var(--accent)) var(--busy-pct, 0%), transparent);
  opacity: var(--busy-vis, 0);
}

.week-body {
  flex: 1; overflow-y: auto; display: grid;
  grid-template-columns: 48px repeat(7, 1fr); position: relative;
}
.hour-col {
  border-right: 1px solid var(--border);
  position: relative;
}
.hour-label {
  height: var(--week-hour-height); padding: 2px 6px 0 0;
  text-align: right; font-size: 10.5px; color: var(--muted);
  font-variant-numeric: tabular-nums; font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.day-col {
  position: relative; border-right: 1px solid var(--border);
}
.day-col:last-child { border-right: none; }
.day-col .hour-slot {
  height: var(--week-hour-height); border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.12s var(--ease);
}
.day-col .hour-slot:hover { background: rgba(139, 92, 246, 0.05); }

.day-col .all-day-band {
  position: sticky; top: 0; background: var(--bg-2); z-index: 2;
  min-height: 0; padding: 0; display: none;
}

.week-event {
  position: absolute; left: 2px; right: 2px; top: 0;
  background: color-mix(in srgb, var(--cal-color) 22%, var(--bg-2));
  border-left: 3px solid var(--cal-color);
  border-radius: 6px; padding: 3px 6px;
  font-size: 11.5px; line-height: 1.2;
  overflow: hidden; cursor: pointer;
  transition: all 0.15s var(--ease);
  display: flex; flex-direction: column; gap: 1px;
  color: var(--fg);
}
.week-event:hover {
  background: color-mix(in srgb, var(--cal-color) 35%, var(--bg-2));
  transform: translateX(1px);
  box-shadow: var(--shadow-1);
  z-index: 2;
}
.week-event .we-time { font-size: 10px; color: var(--muted); font-weight: 500; }
.week-event .we-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.now-line {
  position: absolute; left: 48px; right: 0; height: 0;
  border-top: 2px solid var(--accent-3); z-index: 4; pointer-events: none;
  box-shadow: 0 0 8px var(--accent-3);
}
.now-line::before {
  content: ''; position: absolute; left: -6px; top: -6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-3);
  box-shadow: 0 0 10px var(--accent-3);
}

.all-day-row {
  display: grid; grid-template-columns: 48px repeat(7, 1fr);
  border-bottom: 1px solid var(--border-2); background: var(--bg-1);
  min-height: 28px; max-height: 90px; overflow-y: auto;
}
.all-day-row .ad-label {
  padding: 6px 6px 0 0; text-align: right; font-size: 9.5px;
  color: var(--muted); font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; border-right: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end;
}
.all-day-row .ad-day {
  border-right: 1px solid var(--border); padding: 4px 3px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.all-day-row .ad-day:last-child { border-right: none; }
.all-day-pill {
  font-size: 10.5px; padding: 2px 5px; border-radius: 4px;
  background: color-mix(in srgb, var(--cal-color) 22%, transparent);
  border-left: 2px solid var(--cal-color);
  color: var(--fg-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500; cursor: pointer;
}

/* === DAY VIEW === */
.day-view {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  animation: fadeIn 0.25s var(--ease) both;
  display: flex; flex-direction: column;
  max-height: calc(100dvh - var(--topbar-h) - var(--toolbar-h) - 92px);
  min-height: 400px;
}
.day-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-1); display: flex; align-items: baseline; gap: 12px;
}
.day-head .d-num { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.day-head .d-num.today {
  background: var(--grad-accent); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.day-head .d-info { display: flex; flex-direction: column; }
.day-head .d-info strong { font-size: 15px; font-weight: 600; text-transform: capitalize; }
.day-head .d-info span { font-size: 12px; color: var(--muted); }
.day-head .d-stats {
  margin-left: auto; text-align: right; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column;
}
.day-head .d-stats b { font-size: 14px; color: var(--fg); font-weight: 700; }
.day-body {
  flex: 1; overflow-y: auto; display: grid;
  grid-template-columns: 52px 1fr; position: relative;
}
.day-body .hour-col { position: relative; }
.day-body .day-single { position: relative; }
.day-body .day-single .hour-slot {
  height: var(--week-hour-height); border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.day-body .day-single .hour-slot:hover { background: rgba(139, 92, 246, 0.05); }
.day-body .now-line { left: 52px; }

.day-all-day {
  padding: 8px 14px; background: var(--bg-1); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--muted);
  animation: fadeIn 0.4s var(--ease) both;
}
.empty-state svg { width: 56px; height: 56px; stroke: var(--muted-2); fill: none; stroke-width: 1.5; margin-bottom: 16px; }
.empty-state .title { font-size: 16px; font-weight: 600; color: var(--fg-soft); margin-bottom: 4px; }
.empty-state .sub { font-size: 13px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* === BOTTOM NAV === */
.bottom-nav {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  display: flex; gap: 4px; z-index: 30;
  background: rgba(23, 26, 46, 0.9); backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--border-2); border-radius: 100px;
  padding: 6px; box-shadow: var(--shadow-2);
}
.nav-btn {
  display: flex; align-items: center; gap: 8px; padding: 10px 18px;
  border-radius: 100px; color: var(--muted); font-weight: 600; font-size: 13px;
  transition: all 0.2s var(--ease); white-space: nowrap;
}
.nav-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.nav-btn.active { background: var(--grad-accent); color: #fff; box-shadow: var(--shadow-glow); }
.nav-btn:not(.active):hover { color: var(--fg); }

/* === CHAT === */
.chat-messages {
  display: flex; flex-direction: column; gap: 14px;
  padding: 4px 4px 20px;
}
.msg { max-width: 85%; line-height: 1.45; word-wrap: break-word; animation: msgIn 0.25s var(--ease) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg-row { display: flex; gap: 10px; align-items: flex-end; }
.msg-row.user { justify-content: flex-end; }
.msg-row.assistant .avatar {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  background: var(--grad-accent); display: grid; place-items: center; box-shadow: var(--shadow-1);
}
.msg-row.assistant .avatar svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; }
.bubble {
  padding: 10px 14px; border-radius: 18px; white-space: pre-wrap;
  font-size: 14.5px; letter-spacing: -0.005em;
}
.msg-row.user .bubble { background: var(--grad-accent); color: #fff; border-bottom-right-radius: 6px; box-shadow: var(--shadow-1); }
.msg-row.assistant .bubble { background: var(--bg-2); color: var(--fg); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.bubble code { background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.bubble strong { font-weight: 700; }

.tool-chip {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  margin-left: 42px; padding: 4px 10px; background: var(--bg-elev);
  border: 1px dashed var(--border-2); border-radius: 100px;
  font-size: 11px; font-weight: 500; color: var(--muted);
  animation: msgIn 0.25s var(--ease) both;
}
.tool-chip svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2; }

.typing-bubble { display: inline-flex; gap: 4px; padding: 4px 4px; }
.typing-bubble span { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: bounce 1.2s infinite; }
.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-intro { text-align: center; padding: 32px 16px; animation: fadeIn 0.4s var(--ease) both; }
.chat-intro .avatar-big {
  width: 56px; height: 56px; margin: 0 auto 14px;
  background: var(--grad-accent); border-radius: 16px;
  display: grid; place-items: center; box-shadow: var(--shadow-glow);
}
.chat-intro .avatar-big svg { width: 28px; height: 28px; stroke: #fff; fill: none; stroke-width: 2; }
.chat-intro h2 { font-size: 20px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.02em; }
.chat-intro p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.chat-suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 420px; margin: 0 auto; }
.chat-suggestions button {
  padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; color: var(--fg-soft);
  text-align: left; transition: all 0.15s var(--ease); cursor: pointer;
}
.chat-suggestions button:hover { background: var(--bg-3); border-color: var(--accent); color: var(--fg); }

.chat-input-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 78px);
  padding: 8px 12px; z-index: 26; display: none;
}
.chat-input-wrap > .chat-input-inner {
  max-width: 820px; margin: 0 auto;
  display: flex; gap: 8px; align-items: flex-end;
  background: rgba(23, 26, 46, 0.95); backdrop-filter: blur(20px);
  border: 1px solid var(--border-2); border-radius: 26px;
  padding: 6px 6px 6px 16px; box-shadow: var(--shadow-2);
  transition: border-color 0.2s var(--ease);
}
.chat-input-wrap > .chat-input-inner:focus-within { border-color: var(--accent); }
.chat-input-wrap textarea {
  flex: 1; resize: none; padding: 9px 0; max-height: 140px; min-height: 24px;
  line-height: 1.4; font-size: 15px;
}
.chat-input-wrap textarea::placeholder { color: var(--muted); }
.chat-input-wrap button {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--grad-accent); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
  transition: transform 0.1s var(--ease), opacity 0.2s var(--ease); box-shadow: var(--shadow-1);
}
.chat-input-wrap button svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2.5; }
.chat-input-wrap button:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-input-wrap button:not(:disabled):active { transform: scale(0.92); }

/* === FAB === */
.fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 82px);
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--grad-accent); color: #fff;
  box-shadow: var(--shadow-glow), var(--shadow-2); z-index: 28;
  display: grid; place-items: center;
  transition: transform 0.2s var(--ease-spring);
}
.fab svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2.5; }
.fab:active { transform: scale(0.92); }

/* === TOAST === */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 150px);
  transform: translateX(-50%);
  background: rgba(23, 26, 46, 0.95); backdrop-filter: blur(16px);
  border: 1px solid var(--border-2); padding: 11px 18px; border-radius: 100px;
  font-size: 13px; font-weight: 500; z-index: 50; box-shadow: var(--shadow-2);
  animation: toastIn 0.3s var(--ease-spring);
  display: flex; align-items: center; gap: 8px;
}
.toast svg { width: 14px; height: 14px; stroke-width: 2.5; }
.toast.ok svg { stroke: var(--ok); }
.toast.err svg { stroke: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px) scale(0.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* === MODAL === */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 5, 12, 0.7); backdrop-filter: blur(8px);
  display: grid; place-items: flex-end; padding: 0;
  animation: backdropIn 0.25s var(--ease);
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop.center { place-items: center; padding: 20px; }
.modal {
  background: var(--bg-1); border: 1px solid var(--border-2);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 6px 20px calc(env(safe-area-inset-bottom) + 20px);
  width: 100%; max-width: 520px; max-height: 90dvh; overflow-y: auto;
  animation: modalIn 0.35s var(--ease-spring);
}
@keyframes modalIn { from { transform: translateY(100%); } to { transform: none; } }
.modal-backdrop.center .modal { border-radius: var(--radius-xl); padding: 20px; }
.modal .grabber { width: 40px; height: 4px; background: var(--border-2); border-radius: 2px; margin: 8px auto 14px; }
.modal h2 { margin: 0 0 18px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.modal label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--muted); margin-bottom: 6px; margin-top: 14px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.modal label:first-of-type { margin-top: 0; }
.modal input[type="text"], .modal input[type="datetime-local"], .modal input[type="date"], .modal textarea, .modal select {
  width: 100%; padding: 11px 14px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--fg); font-size: 15px;
  transition: border-color 0.15s var(--ease);
}
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--accent); }
.modal textarea { resize: vertical; min-height: 70px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal .checkbox-row {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
}
.modal .checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.modal .checkbox-row label { margin: 0; text-transform: none; letter-spacing: normal; font-size: 14px; color: var(--fg); font-weight: 500; }
.modal .actions { display: flex; gap: 10px; margin-top: 22px; }
.modal .actions button {
  flex: 1; padding: 13px; border-radius: var(--radius); font-weight: 600; font-size: 14px;
  transition: all 0.15s var(--ease);
}
.modal .actions button:active { transform: scale(0.98); }
.modal .actions .primary { background: var(--grad-accent); color: #fff; box-shadow: var(--shadow-1); }
.modal .actions .secondary { background: var(--bg-3); color: var(--fg); border: 1px solid var(--border); }
.modal .actions .danger {
  background: transparent; color: var(--danger); border: 1px solid var(--danger); flex: 0 0 auto; padding: 13px 14px;
}
.modal .actions .danger:hover { background: rgba(239, 68, 68, 0.1); }

.settings-section { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-top: 14px; overflow: hidden; }
.settings-section h3 { margin: 0; padding: 12px 16px 8px; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.settings-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); transition: background 0.1s var(--ease); }
.settings-row:first-of-type { border-top: none; }
.settings-row.clickable { cursor: pointer; }
.settings-row.clickable:hover { background: var(--bg-3); }
.cal-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 10px color-mix(in srgb, var(--cal-color) 50%, transparent); }
.settings-row .name { flex: 1; font-size: 14px; font-weight: 500; }
.settings-row .badge { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 100px; letter-spacing: 0.04em; text-transform: uppercase; }
.settings-row .chev { color: var(--muted); }
.settings-row .chev svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; }
.settings-row button.small { background: var(--bg-3); border: 1px solid var(--border); color: var(--fg-soft); padding: 5px 10px; border-radius: 7px; font-size: 12px; font-weight: 500; }
.settings-row button.small:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Desktop */
@media (min-width: 960px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 440px;
    grid-template-rows: auto 1fr; padding-bottom: 0;
  }
  .topbar { grid-column: 1 / -1; padding-left: 28px; padding-right: 28px; }
  .main {
    grid-column: 1; grid-row: 2;
    padding: 12px 28px 40px;
    max-width: 1100px; margin: 0 auto; width: 100%;
  }
  .cal-toolbar {
    grid-template-columns: auto 1fr auto auto;
    grid-template-rows: auto;
  }
  .cal-nav { grid-column: 2; max-width: 340px; margin: 0 auto; width: 100%; }
  .cal-view-toggle { grid-column: 3; }
  .cal-today-btn { grid-column: 4; }

  .chat-sidebar {
    display: flex !important;
    grid-column: 2; grid-row: 2;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(16,18,35,0.5), rgba(16,18,35,0.8));
    position: sticky; top: var(--topbar-h);
    height: calc(100dvh - var(--topbar-h));
    max-height: calc(100dvh - var(--topbar-h));
    min-height: 0; overflow: hidden;
  }
  .chat-sidebar .chat-messages { flex: 1; overflow-y: auto; padding: 20px 20px 16px; min-height: 0; }
  .chat-sidebar .chat-input-wrap {
    display: block !important; position: static !important;
    padding: 10px 16px calc(env(safe-area-inset-bottom) + 14px);
    border-top: 1px solid var(--border); background: rgba(10,11,20,0.4);
  }
  .chat-sidebar .chat-input-wrap > .chat-input-inner { max-width: none; background: var(--bg-2); }
  .bottom-nav { display: none; }
  .fab { bottom: 24px; right: 468px; }

  .week-view, .day-view {
    max-height: calc(100dvh - var(--topbar-h) - 150px);
  }
  .month-grid { grid-auto-rows: minmax(100px, 1fr); }
  .month-cell { min-height: 100px; }
}
