@import './variables.css';

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════ */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow: hidden;
  transition: width 200ms ease;
  position: relative;
  z-index: 100;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

/* New button */
.new-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 16px;
  padding: 14px 24px;
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px rgba(60,64,67,.15);
  transition: box-shadow 200ms ease, background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.new-btn:hover {
  box-shadow: 0 2px 6px rgba(60,64,67,.3), 0 6px 16px rgba(60,64,67,.2);
}
.new-btn .new-icon { color: var(--blue); flex-shrink: 0; }
.sidebar.collapsed .new-btn {
  padding: 14px;
  border-radius: 50%;
  margin: 12px auto;
  width: 48px;
  justify-content: center;
}
.sidebar.collapsed .new-btn-label { display: none; }
.sidebar.collapsed .new-btn-arrow { display: none; }

/* New dropdown */
.new-dropdown {
  position: fixed;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 200px;
  z-index: 500;
  padding: 8px 0;
  animation: menuIn 100ms ease;
}
@keyframes menuIn { from { opacity:0; transform:scale(.97) translateY(-4px); } to { opacity:1; transform:scale(1) translateY(0); } }

.new-dropdown-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background var(--transition);
}
.new-dropdown-item:hover { background: var(--hover); }
.new-dropdown-item svg { color: var(--text-light); }
.new-dropdown-divider { height: 1px; background: var(--border); margin: 6px 0; }

/* Sidebar nav sections */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 0; scrollbar-width: none; }
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-meta);
  padding: 12px 16px 4px;
  text-transform: none;
  letter-spacing: 0;
}
.sidebar.collapsed .sidebar-section-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px 8px 16px;
  margin: 1px 8px 1px 0;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active {
  background: var(--active-bg);
  color: var(--active-text);
  font-weight: 600;
}
.nav-item.active svg { color: var(--active-text); }
.nav-item svg { flex-shrink: 0; color: var(--text-light); }
.nav-item-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-meta);
  background: var(--hover);
  border-radius: 8px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}
.sidebar.collapsed .nav-item { justify-content: center; margin: 1px auto; width: 48px; padding: 12px; border-radius: 50%; }
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-item-count { display: none; }

.sidebar-divider { height: 1px; background: var(--border); margin: 8px 16px; }
.sidebar.collapsed .sidebar-divider { margin: 8px; }

/* Storage bar */
.sidebar-storage {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar.collapsed .sidebar-storage { display: none; }
.storage-label { font-size: 12px; color: var(--text-light); margin-bottom: 6px; }
.storage-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.storage-fill { height: 100%; background: var(--blue); border-radius: 2px; transition: width 400ms ease; }
.storage-text { font-size: 11px; color: var(--text-meta); }
.storage-manage {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--blue);
  cursor: pointer;
  text-decoration: none;
}
.storage-manage:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════
   MAIN WRAPPER
═══════════════════════════════════════════ */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ═══════════════════════════════════════════
   TOP BAR
═══════════════════════════════════════════ */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 0 8px;
  background: var(--bg);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition);
}
.topbar-logo:hover { background: var(--hover); }
.topbar-logo-text {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-light);
  white-space: nowrap;
}
.topbar-logo-text span { color: var(--text); }

.topbar-center { flex: 1; display: flex; justify-content: center; max-width: 640px; margin: 0 auto; }

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  padding: 10px 20px;
  transition: all 200ms ease;
}
.search-box:focus-within {
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  border-color: transparent;
}
.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  outline: none;
}
.search-box input::placeholder { color: var(--text-light); }
.search-box .search-icon { color: var(--text-light); flex-shrink: 0; }
.search-box .search-clear {
  color: var(--text-light); cursor: pointer; flex-shrink: 0; opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.search-box:focus-within .search-clear { opacity: 1; pointer-events: all; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 8px;
}

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-light);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
  position: relative;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.active { background: var(--active-bg); color: var(--active-text); }

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

.profile-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: var(--font);
}

/* ═══════════════════════════════════════════
   CONTENT LAYOUT
═══════════════════════════════════════════ */
.content-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 32px;
}

/* ═══════════════════════════════════════════
   RIGHT PANEL
═══════════════════════════════════════════ */
.right-panel {
  width: var(--right-panel-width);
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  flex-shrink: 0;
  transition: width 200ms ease;
}
.right-panel.expanded { width: 320px; }

.panel-app-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 10px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
  transition: background var(--transition);
  text-align: center;
}
.panel-app-btn:hover { background: var(--hover); }
.panel-app-btn span { font-size: 11px; color: var(--text-light); }
.panel-app-btn.active { background: var(--active-bg); }
.panel-app-btn.active span { color: var(--active-text); }

/* ═══════════════════════════════════════════
   HOME VIEW
═══════════════════════════════════════════ */
.home-section { margin-bottom: 32px; }
.home-section-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 12px;
}

.suggested-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.recent-list { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════════
   ITEM CARDS
═══════════════════════════════════════════ */
.view-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.view-list { display: flex; flex-direction: column; }

.item-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow 150ms ease, border-color 150ms ease, transform 150ms ease;
  position: relative;
  overflow: hidden;
  user-select: none;
}
.item-card:hover {
  box-shadow: var(--shadow);
  border-color: transparent;
  transform: translateY(-1px);
}
.item-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-light);
}

/* Grid card */
.item-card.grid-card {
  display: flex;
  flex-direction: column;
}
.item-thumb {
  height: 116px;
  background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.item-thumb.thumb-doc   { background: linear-gradient(160deg, #E8F0FE 0%, #C5D8FC 100%); }
.item-thumb.thumb-sheet { background: linear-gradient(160deg, #E6F4EA 0%, #B7DFC0 100%); }
.item-thumb.thumb-task  { background: linear-gradient(160deg, #FCE8E6 0%, #F5C2BE 100%); }
.item-thumb.thumb-event { background: linear-gradient(160deg, #FEF7E0 0%, #FAE196 100%); }
.item-thumb.thumb-file  { background: linear-gradient(160deg, #F3E8FD 0%, #DDB9F9 100%); }

.item-body-grid {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: none;
}
.item-type-icon { flex-shrink: 0; }
.item-info-col { flex: 1; min-width: 0; }
.item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-meta { font-size: 11px; color: var(--text-meta); margin-top: 1px; }

/* List card */
.item-card.list-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  box-shadow: none;
}
.item-card.list-card:hover { transform: none; box-shadow: none; background: var(--hover); border-color: transparent; }
.item-card.list-card .item-meta-row {
  display: flex; gap: 24px; align-items: center;
  font-size: 12px; color: var(--text-meta); margin-left: auto;
  white-space: nowrap; flex-shrink: 0;
}

/* Checkbox */
.item-checkbox {
  position: absolute; top: 8px; left: 8px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  border: 2px solid rgba(0,0,0,.2);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition), border-color var(--transition);
  z-index: 2;
}
.item-checkbox:hover,
.item-card:hover .item-checkbox,
.item-card.selected .item-checkbox { opacity: 1; }
.item-card.selected .item-checkbox { background: var(--blue); border-color: var(--blue); }

/* Three-dot menu */
.item-more {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
  z-index: 2;
  color: var(--text-light);
}
.item-more:hover { background: var(--hover); color: var(--text); }
.item-card:hover .item-more { opacity: 1; }
[data-theme="dark"] .item-more { background: rgba(38,38,39,.9); }

/* List row three-dot */
.list-actions {
  display: flex; align-items: center; gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.item-card.list-card:hover .list-actions { opacity: 1; }

/* ═══════════════════════════════════════════
   CONTENT TOPBAR (inside content area)
═══════════════════════════════════════════ */
.content-topbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}
.content-topbar-title {
  font-size: 16px; font-weight: 500; flex: 1;
}
.view-btns { display: flex; gap: 2px; }
.view-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: none; background: transparent;
  cursor: pointer; color: var(--text-light);
  transition: background var(--transition), color var(--transition);
}
.view-btn:hover { background: var(--hover); color: var(--text); }
.view-btn.active { color: var(--active-text); }

/* Sort/filter chip */
.filter-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 16px;
  border: 1px solid var(--border);
  background: transparent;
  font-family: var(--font); font-size: 13px; color: var(--text);
  cursor: pointer; transition: background var(--transition);
}
.filter-chip:hover { background: var(--hover); }

/* ═══════════════════════════════════════════
   CONTEXT MENU
═══════════════════════════════════════════ */
.ctx-menu {
  position: fixed;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 196px;
  z-index: 1000;
  padding: 8px 0;
  animation: menuIn 80ms ease;
}
.ctx-item {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 20px;
  font-size: 14px;
  cursor: pointer; color: var(--text);
  transition: background var(--transition);
}
.ctx-item:hover { background: var(--hover); }
.ctx-item svg { color: var(--text-light); flex-shrink: 0; }
.ctx-item.danger { color: #D93025; }
.ctx-item.danger svg { color: #D93025; }
.ctx-divider { height: 1px; background: var(--border); margin: 6px 0; }

/* ═══════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 20px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-family: var(--font);
  font-size: 14px; font-weight: 500;
  transition: background var(--transition), box-shadow var(--transition);
}
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-ghost { background: transparent; color: var(--blue); }
.btn-ghost:hover { background: var(--active-bg); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--hover); border-color: var(--text-light); }
.btn-danger { background: #D93025; color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }

/* ═══════════════════════════════════════════
   FORMS
═══════════════════════════════════════════ */
.input, .textarea, .select {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px;
  outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(31,127,230,.12);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-light); }

/* ═══════════════════════════════════════════
   MODALS
═══════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(32,33,36,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity 150ms ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px 32px 28px;
  width: 100%; max-width: 520px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
  transform: scale(.96) translateY(8px);
  transition: transform 150ms ease;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ═══════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 64px 24px; gap: 12px; text-align: center;
  color: var(--text-light);
}
.empty-state svg { opacity: .3; }
.empty-title { font-size: 15px; font-weight: 500; color: var(--text); }
.empty-sub { font-size: 13px; }

.loading { display: flex; align-items: center; gap: 10px; padding: 48px; color: var(--text-light); justify-content: center; }

/* ═══════════════════════════════════════════
   BADGES
═══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge-blue   { background: var(--blue-light); color: var(--blue); }
.badge-green  { background: #E6F4EA; color: #137333; }
.badge-yellow { background: #FEF7E0; color: #B06000; }
.badge-red    { background: #FCE8E6; color: #C5221F; }
.badge-gray   { background: var(--bg-secondary); color: var(--text-light); }
[data-theme="dark"] .badge-green  { background: #1E3A2A; color: #81C995; }
[data-theme="dark"] .badge-yellow { background: #3A2E00; color: #FDD663; }
[data-theme="dark"] .badge-red    { background: #3A1208; color: #F28B82; }

/* ═══════════════════════════════════════════
   EDITOR
═══════════════════════════════════════════ */
.editor-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 6px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg); flex-wrap: wrap; position: sticky; top: 0; z-index: 5;
}
.tool-btn {
  display: flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 4px;
  border-radius: var(--radius-sm); border: none;
  background: transparent; cursor: pointer;
  color: var(--text-light); font-weight: 600; font-size: 13px; font-family: var(--font);
  transition: background var(--transition), color var(--transition);
}
.tool-btn:hover { background: var(--hover); color: var(--text); }
.tool-btn.active { background: var(--active-bg); color: var(--active-text); }
.tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }

.editor-page {
  max-width: 816px;
  margin: 0 auto;
  padding: 48px 72px;
  background: var(--card-bg);
  min-height: calc(100vh - 180px);
  box-shadow: var(--shadow-xs);
}
.editor-body {
  outline: none; font-size: 15px; line-height: 1.75; color: var(--text);
  caret-color: var(--blue);
}
.editor-body h1 { font-size: 24px; font-weight: 700; margin: 20px 0 8px; }
.editor-body h2 { font-size: 20px; font-weight: 600; margin: 16px 0 6px; }
.editor-body h3 { font-size: 16px; font-weight: 600; margin: 14px 0 4px; }
.editor-body ul, .editor-body ol { padding-left: 28px; margin: 6px 0; }
.editor-body ::selection { background: var(--blue-light); }

/* ═══════════════════════════════════════════
   SPREADSHEET
═══════════════════════════════════════════ */
.formula-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg); flex-shrink: 0;
}
.formula-bar-addr {
  min-width: 56px; text-align: center; font-size: 13px;
  color: var(--text); border-right: 1px solid var(--border);
  padding-right: 8px; font-family: monospace;
}
.formula-bar-fx { font-size: 13px; color: var(--text-meta); font-style: italic; }
.formula-bar input {
  flex: 1; border: none; outline: none; font-family: monospace;
  font-size: 13px; background: transparent; color: var(--text);
}
.sheet-wrap { flex: 1; overflow: auto; }
.sheet-table { border-collapse: collapse; font-size: 13px; }
.sheet-col-head {
  background: var(--bg-secondary); color: var(--text-light);
  padding: 5px 8px; min-width: 96px; border: 1px solid var(--border);
  font-weight: 500; text-align: center; position: sticky; top: 0; z-index: 2;
  font-size: 12px;
}
.sheet-row-num {
  background: var(--bg-secondary); color: var(--text-meta);
  padding: 4px 8px; text-align: center; border: 1px solid var(--border);
  position: sticky; left: 0; z-index: 1; min-width: 44px;
  font-size: 11px;
}
.sheet-cell { border: 1px solid var(--border); padding: 0; min-width: 96px; }
.sheet-cell input {
  border: none; outline: none; padding: 4px 6px; width: 100%;
  background: transparent; color: var(--text);
  font-family: var(--font); font-size: 13px;
}
.sheet-cell:focus-within { box-shadow: inset 0 0 0 2px var(--blue); z-index: 3; position: relative; }

/* ═══════════════════════════════════════════
   CALENDAR
═══════════════════════════════════════════ */
.cal-wrap { display: flex; flex-direction: column; flex: 1; }
.cal-header { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.cal-month { font-size: 20px; font-weight: 400; color: var(--text); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-day-head { background: var(--bg); padding: 8px; text-align: center; font-size: 11px; font-weight: 600; color: var(--text-meta); border-bottom: 1px solid var(--border); }
.cal-day { background: var(--card-bg); padding: 6px 8px; min-height: 96px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--transition); }
.cal-day:hover { background: var(--hover); }
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.today .day-num { background: var(--blue); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.cal-day.other-month { background: var(--bg-secondary); }
.cal-day.other-month .day-num { color: var(--text-meta); }
.day-num { font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.cal-event { font-size: 11px; padding: 2px 6px; border-radius: 3px; background: var(--blue-light); color: var(--active-text); margin-top: 2px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event:hover { background: var(--blue); color: #fff; }

/* ═══════════════════════════════════════════
   TASKS
═══════════════════════════════════════════ */
.task-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; transition: background var(--transition);
}
.task-row:hover { background: var(--hover); }
.task-check {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2px solid var(--border); border-radius: 50%;
  cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.task-check:hover { border-color: var(--blue); }
.task-check.done { background: var(--blue); border-color: var(--blue); }
.task-title { font-size: 14px; }
.task-title.done { text-decoration: line-through; color: var(--text-light); }

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #323232; color: #fff; padding: 10px 20px;
  border-radius: 6px; font-size: 13px; z-index: 999;
  animation: toastIn 150ms ease; pointer-events: none;
}
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(8px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 1280px) {
  .right-panel { display: none; }
}
@media (max-width: 1024px) {
  .sidebar { width: var(--sidebar-collapsed); }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -100%; top: 0; height: 100%;
    width: var(--sidebar-width) !important;
    z-index: 300; transition: left 200ms ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { left: 0; }
  .topbar-logo-text { display: none; }
  .content-area { padding: 16px 16px 24px; }
  .editor-page { padding: 24px 20px; }
}

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; transform-origin: center; }

/* ── Login page ─────────────────────────────────────────────────────────── */
#login-page {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Google Sans', 'Segoe UI', sans-serif;
}
.login-bg { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.login-blob {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: .45;
  animation: blobFloat 12s ease-in-out infinite;
}
.login-blob-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #4285F4 0%, transparent 70%);
  top: -180px; left: -100px; animation-delay: 0s;
}
.login-blob-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #34A853 0%, transparent 70%);
  bottom: -120px; right: -80px; animation-delay: -4s;
}
.login-blob-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #FBBC05 0%, transparent 70%);
  top: 40%; left: 55%; animation-delay: -8s;
}
@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(.97); }
}
.login-card {
  position: relative; z-index: 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 44px 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column; align-items: center; gap: 0;
  backdrop-filter: blur(16px);
}
.login-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 28px;
}
.login-logo-text {
  font-size: 26px; font-weight: 700; letter-spacing: -.5px;
  color: var(--text);
}
.login-title {
  font-size: 22px; font-weight: 600; color: var(--text);
  margin: 0 0 8px; text-align: center;
}
.login-sub {
  font-size: 14px; color: var(--text-light);
  margin: 0 0 32px; text-align: center; line-height: 1.5;
}
.login-google-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 20px;
  background: var(--bg); color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 10px; cursor: pointer;
  font-size: 15px; font-weight: 500;
  transition: background .15s, box-shadow .15s, border-color .15s;
  justify-content: center;
}
.login-google-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(31,127,230,.15);
}
.login-footer {
  font-size: 12px; color: var(--text-meta);
  margin: 24px 0 0; text-align: center; line-height: 1.6;
}
.login-error {
  width: 100%; padding: 10px 14px; border-radius: 8px;
  background: rgba(234,67,53,.1); color: #EA4335;
  border: 1px solid rgba(234,67,53,.25);
  font-size: 13px; text-align: center;
  margin-bottom: 16px;
}

/* ── Profile menu ─────────────────────────────────────────────────────────── */
.profile-menu {
  position: fixed; z-index: 9999;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  min-width: 240px;
  padding: 6px 0;
  overflow: hidden;
}
.profile-menu-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 12px;
}
.profile-menu-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover;
}
.profile-menu-avatar-letter {
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600;
}
.profile-menu-info { flex: 1; min-width: 0; }
.profile-menu-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-menu-email {
  font-size: 12px; color: var(--text-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.profile-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; font-size: 14px; color: var(--text);
  cursor: pointer; transition: background .1s;
}
.profile-menu-item:hover { background: var(--hover-bg); }
.profile-menu-item-danger { color: #EA4335; }
.profile-menu-item-danger:hover { background: rgba(234,67,53,.08); }

/* ── Callback / loading page ─────────────────────────────────────────────── */
#app:empty::after {
  content: '';
  display: block;
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
