:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --border: #dadce0;
  --border-soft: #e8eaed;
  --text: #1f1f1f;
  --text-2: #5f6368;
  --text-3: #80868b;
  --primary: #1a73e8;
  --primary-soft: #e8f0fe;
  --danger: #d93025;
  --danger-soft: #fce8e6;
  --success: #188038;
  --warning: #e37400;
  --today: #1a73e8;
  --shadow: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  --shadow-lg: 0 4px 8px 3px rgba(60, 64, 67, .15), 0 1px 3px rgba(60, 64, 67, .3);
  --radius: 12px;
  --hour: 48px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131314;
    --surface: #1e1f20;
    --surface-2: #2a2b2d;
    --border: #3c4043;
    --border-soft: #2f3134;
    --text: #e3e3e3;
    --text-2: #bdc1c6;
    --text-3: #9aa0a6;
    --primary: #8ab4f8;
    --primary-soft: #263449;
    --danger: #f28b82;
    --danger-soft: #3c2422;
    --success: #81c995;
    --warning: #fdd663;
    --today: #8ab4f8;
    --shadow: 0 1px 3px rgba(0, 0, 0, .6);
    --shadow-lg: 0 6px 20px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- buttons & inputs */
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 20px;
  padding: 7px 16px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary { color: #062e6f; } }
button.primary:hover { box-shadow: var(--shadow); filter: brightness(1.05); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.danger:hover { background: var(--danger-soft); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button.icon { border: none; background: transparent; border-radius: 50%; width: 36px; height: 36px; padding: 0; justify-content: center; font-size: 18px; color: var(--text-2); }
button.icon:hover { background: var(--surface-2); }
button.fab {
  background: var(--surface); border: none; box-shadow: var(--shadow); border-radius: 16px;
  padding: 12px 20px 12px 16px; font-size: 15px;
}
button.fab:hover { box-shadow: var(--shadow-lg); background: var(--surface); }
button.fab .plus { font-size: 24px; line-height: 1; color: var(--primary); }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: auto; accent-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 14px; }
label.field { display: block; }
label.field > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; font-weight: 500; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row > .shrink { flex: 0 0 auto; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; user-select: none; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; color: var(--text); font-weight: 500; }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #1a73e8, #34a853); color: #fff; font-weight: 700; font-size: 15px;
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 16px; min-width: 0; }
.crumbs .sep { color: var(--text-3); }
.crumbs .current { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.user-menu { position: relative; }
.user-menu .menu {
  position: absolute; right: 0; top: 46px; background: var(--surface); box-shadow: var(--shadow-lg);
  border-radius: 10px; padding: 8px 0; min-width: 220px; z-index: 50;
}
.user-menu .menu .who { padding: 8px 16px 12px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; }
.user-menu .menu button { width: 100%; border: none; border-radius: 0; justify-content: flex-start; background: none; padding: 10px 16px; font-weight: 400; }
.user-menu .menu button:hover { background: var(--surface-2); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 13px; flex: 0 0 auto; text-transform: uppercase;
  border: 2px solid var(--surface);
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 40px; height: 40px; font-size: 15px; }
.avatar-btn { padding: 0; border: none; background: none; border-radius: 50%; }
.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -8px; }

/* ---------------------------------------------------------------- generic layout */
.page { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border-soft); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; gap: 10px; }
.empty { padding: 24px 20px; text-align: center; color: var(--text-3); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-2); text-transform: capitalize;
}
.badge.owner { background: var(--primary-soft); color: var(--primary); }
.badge.editor { background: #e6f4ea; color: #137333; }
.badge.viewer { background: var(--surface-2); color: var(--text-2); }
@media (prefers-color-scheme: dark) { .badge.editor { background: #1e3a28; color: #81c995; } }

.type-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 2px 8px 2px 6px; border-radius: 10px; color: var(--chip); background: color-mix(in srgb, var(--chip) 14%, transparent);
  white-space: nowrap;
}
.type-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--chip); }
@media (prefers-color-scheme: dark) {
  .type-chip { color: color-mix(in srgb, var(--chip) 55%, #fff); background: color-mix(in srgb, var(--chip) 28%, transparent); }
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* ---------------------------------------------------------------- auth page */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: linear-gradient(150deg, #1a73e8 0%, #4285f4 45%, #34a853 120%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-hero h1 { font-size: 40px; line-height: 1.15; margin: 40px 0 16px; font-weight: 600; }
.auth-hero p { font-size: 17px; opacity: .92; max-width: 460px; }
.auth-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; font-size: 15px; }
.auth-hero li { display: flex; gap: 10px; align-items: center; }
.auth-hero li span { width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,.2); display: grid; place-items: center; }
.auth-hero .brand { color: #fff; }
.auth-hero .brand-logo { background: rgba(255, 255, 255, .22); }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 26px; margin-bottom: 6px; }
.tabs-pill { display: flex; background: var(--surface-2); border-radius: 24px; padding: 4px; margin: 24px 0; }
.tabs-pill button { flex: 1; border: none; background: transparent; justify-content: center; }
.tabs-pill button.active { background: var(--surface); box-shadow: var(--shadow); }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.auth-card button.primary { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 24px; }
  .auth-hero h1 { font-size: 28px; margin-top: 20px; }
  .auth-hero ul { display: none; }
}

/* ---------------------------------------------------------------- dashboard */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }
.cal-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.cal-card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; text-align: left;
  color: inherit; padding: 0; font-weight: 400; white-space: normal; align-items: stretch;
}
.cal-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); background: var(--surface); }
.cal-card .stripe { height: 8px; background: var(--c); }
.cal-card .body { padding: 16px 18px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.cal-card .title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cal-card h3 { font-size: 17px; }
.cal-card .desc { color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.cal-card .stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.cal-card .stats b { color: var(--text); font-size: 15px; display: block; }
.cal-card .next { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.cal-card .next .t { font-weight: 500; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-card .foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-soft); padding: 10px 18px; font-size: 12px; color: var(--text-3); }
.new-card {
  border: 2px dashed var(--border); background: transparent; align-items: center; justify-content: center; min-height: 230px;
  color: var(--text-2); font-size: 15px; gap: 8px; flex-direction: column;
}
.new-card:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.new-card .plus { font-size: 34px; line-height: 1; }

.agenda-list { list-style: none; margin: 0; padding: 0 8px 10px; }
.agenda-day { padding: 10px 12px 4px; font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.agenda-day.today { color: var(--today); }
.agenda-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
.agenda-item:hover { background: var(--surface-2); }
.agenda-item .bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--c); flex: 0 0 auto; }
.agenda-item .main { flex: 1; min-width: 0; }
.agenda-item .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-item .t.done { text-decoration: line-through; color: var(--text-3); }
.agenda-item .meta { font-size: 12px; color: var(--text-2); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.agenda-item .when { font-size: 12px; color: var(--text-2); white-space: nowrap; text-align: right; }
.countdown { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.countdown.urgent { background: var(--danger-soft); color: var(--danger); }
.countdown.soon { background: #fef7e0; color: #b06000; }
.countdown.later { background: var(--surface-2); color: var(--text-2); }
.countdown.done { background: #e6f4ea; color: #137333; }
@media (prefers-color-scheme: dark) {
  .countdown.soon { background: #3d3216; color: #fdd663; }
  .countdown.done { background: #1e3a28; color: #81c995; }
}

/* ---------------------------------------------------------------- calendar page shell */
.cal-shell { display: flex; flex-direction: column; height: calc(100vh - 64px); }
.cal-header {
  background: var(--surface); border-bottom: 1px solid var(--border-soft); padding: 14px 20px 0;
}
.cal-header .top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cal-header .swatch { width: 40px; height: 40px; border-radius: 10px; background: var(--c); flex: 0 0 auto; }
.cal-header .name { flex: 1; min-width: 200px; }
.cal-header .name h1 { font-size: 22px; }
.tabs { display: flex; gap: 4px; margin-top: 10px; overflow-x: auto; }
.tabs a {
  padding: 10px 16px; color: var(--text-2); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a:hover { text-decoration: none; color: var(--text); background: var(--surface-2); border-radius: 8px 8px 0 0; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.cal-body { flex: 1; overflow: auto; }
.cal-body.no-scroll { overflow: hidden; display: flex; flex-direction: column; }

/* home tab */
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 900px) { .stat-tiles { grid-template-columns: repeat(2, 1fr); } }
.stat { padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border-soft); }
.stat .n { font-size: 30px; font-weight: 500; line-height: 1.1; }
.stat .l { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.stat.alert .n { color: var(--danger); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.home-col { display: grid; gap: 20px; }
@media (max-width: 1000px) { .home-grid { grid-template-columns: 1fr; } }
.done-toggle { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 auto; cursor: pointer; }

/* activity / history */
.activity { list-style: none; margin: 0; padding: 0 0 8px; }
.activity li { display: flex; gap: 12px; padding: 10px 20px; align-items: flex-start; }
.activity .what { flex: 1; min-width: 0; }
.activity .what b { font-weight: 600; }
.activity .time { color: var(--text-3); font-size: 12px; }
.history-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.history-filters select, .history-filters input { width: auto; min-width: 160px; }
.history-day { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 8px; }
.history-entry { display: flex; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
.history-entry:last-child { border-bottom: none; }
.history-entry .content { flex: 1; min-width: 0; }
.history-entry .line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.history-entry .actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.history-entry .actions button { padding: 4px 12px; font-size: 12px; }
.action-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; flex: 0 0 auto; position: relative; }
.action-icon .avatar { position: absolute; right: -6px; bottom: -6px; width: 20px; height: 20px; font-size: 9px; }
.action-icon.create { background: #e6f4ea; color: #137333; }
.action-icon.update { background: var(--primary-soft); color: var(--primary); }
.action-icon.delete { background: var(--danger-soft); color: var(--danger); }
.action-icon.restore { background: #fef7e0; color: #b06000; }
.action-icon.member, .action-icon.calendar { background: #f3e8fd; color: #9334e6; }
@media (prefers-color-scheme: dark) {
  .action-icon.create { background: #1e3a28; color: #81c995; }
  .action-icon.restore { background: #3d3216; color: #fdd663; }
  .action-icon.member, .action-icon.calendar { background: #33244a; color: #d7aefb; }
}
table.diff { border-collapse: collapse; width: 100%; margin-top: 10px; font-size: 13px; }
table.diff th, table.diff td { text-align: left; padding: 6px 10px; border: 1px solid var(--border-soft); vertical-align: top; }
table.diff th { background: var(--surface-2); font-weight: 500; color: var(--text-2); width: 110px; }
table.diff td.old { background: var(--danger-soft); text-decoration: line-through; color: var(--text-2); }
table.diff td.new { background: #e6f4ea; }
@media (prefers-color-scheme: dark) { table.diff td.new { background: #1e3a28; } }
table.diff td { white-space: pre-wrap; word-break: break-word; }

/* members / settings */
.member-row { display: flex; gap: 12px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border-soft); }
.member-row .who { flex: 1; min-width: 0; }
.member-row select { width: auto; }
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatches label { cursor: pointer; }
.color-swatches input { display: none; }
.color-swatches span { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 3px solid transparent; box-shadow: 0 0 0 1px var(--border); }
.color-swatches input:checked + span { border-color: var(--surface); box-shadow: 0 0 0 2px var(--c); }

/* ---------------------------------------------------------------- calendar views */
.cal-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 20px; flex-wrap: wrap; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.cal-toolbar h2 { font-size: 21px; font-weight: 400; margin: 0 8px; min-width: 170px; }
.cal-toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 7px 14px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--primary-soft); color: var(--primary); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.filter-chip {
  border-radius: 16px; padding: 4px 12px 4px 8px; font-size: 12px; border: 1px solid var(--border);
  font-weight: 500; background: var(--surface);
}
.filter-chip .dot { width: 9px; height: 9px; }
.filter-chip.off { opacity: .45; }
.filter-chip.off .dot { background: transparent !important; box-shadow: inset 0 0 0 2px var(--text-3); }
.view-host { flex: 1; overflow: auto; position: relative; background: var(--surface); }

/* month */
.month { display: grid; grid-template-rows: auto 1fr; height: 100%; min-height: 560px; }
.month .dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border-soft); }
.month .dow div { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-2); padding: 8px 0 6px; text-transform: uppercase; }
.month .weeks { display: grid; grid-template-rows: repeat(6, minmax(92px, 1fr)); }
.month .week { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border-soft); min-height: 0; }
.month .day { border-right: 1px solid var(--border-soft); padding: 4px 4px 2px; overflow: hidden; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.month .day:last-child { border-right: none; }
.month .day.other { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.month .day.other .num { color: var(--text-3); }
.month .day.drop { background: var(--primary-soft); }
.month .num {
  align-self: center; font-size: 12px; font-weight: 500; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 50%; margin-bottom: 2px;
}
.month .num.wide { width: auto; padding: 0 8px; border-radius: 12px; white-space: nowrap; }
.month .day.today .num { background: var(--today); color: #fff; }
@media (prefers-color-scheme: dark) { .month .day.today .num { color: #062e6f; } }
.month .num:hover { background: var(--surface-2); }
.chip {
  font-size: 12px; border-radius: 4px; padding: 1px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; line-height: 18px; display: flex; gap: 4px; align-items: center; flex: 0 0 auto;
}
.chip.block { background: var(--c); color: #fff; }
.chip.timed:hover, .chip.block:hover { filter: brightness(.94); }
.chip.timed:hover { background: var(--surface-2); }
.chip.timed .dot { width: 8px; height: 8px; background: var(--c); }
.chip .tm { color: var(--text-2); }
.chip.done { text-decoration: line-through; opacity: .6; }
.more { font-size: 12px; font-weight: 500; color: var(--text-2); padding: 0 6px; cursor: pointer; border-radius: 4px; }
.more:hover { background: var(--surface-2); }

/* week / day time grid */
.tg { display: flex; flex-direction: column; height: 100%; min-width: 560px; }
.tg.single { min-width: 0; }
.tg-head { display: grid; border-bottom: 1px solid var(--border-soft); flex: 0 0 auto; }
.tg-head .dh { text-align: center; padding: 8px 0 6px; cursor: pointer; }
.tg-head .dh .dn { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; }
.tg-head .dh .dd { font-size: 24px; width: 44px; height: 44px; margin: 2px auto 0; display: grid; place-items: center; border-radius: 50%; }
.tg-head .dh.today .dn { color: var(--today); }
.tg-head .dh.today .dd { background: var(--today); color: #fff; }
@media (prefers-color-scheme: dark) { .tg-head .dh.today .dd { color: #062e6f; } }
.tg-allday { display: grid; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.tg-allday .cell { border-left: 1px solid var(--border-soft); padding: 2px; min-height: 26px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tg-allday .lbl, .tg-head .lbl { font-size: 10px; color: var(--text-3); display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; }
.tg-scroll { flex: 1; overflow-y: auto; position: relative; }
.tg-sticky { position: sticky; top: 0; z-index: 5; background: var(--surface); }
.tg-grid { display: grid; position: relative; }
.tg-hours { position: relative; }
.tg-hours div { height: var(--hour); font-size: 10px; color: var(--text-3); text-align: right; padding-right: 8px; transform: translateY(-7px); }
.tg-col { position: relative; border-left: 1px solid var(--border-soft); height: calc(var(--hour) * 24); }
.tg-col.drop { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
.tg-col .slot { height: var(--hour); border-bottom: 1px solid var(--border-soft); }
.tg-col .slot:nth-child(odd) { }
.tg-event {
  position: absolute; border-radius: 6px; padding: 3px 6px; font-size: 12px; color: #fff; background: var(--c); overflow: hidden;
  cursor: pointer; border: 1px solid var(--surface); line-height: 1.25; z-index: 1;
}
.tg-event:hover { z-index: 3; box-shadow: var(--shadow-lg); }
.tg-event .t { font-weight: 600; }
.tg-event.done { opacity: .55; text-decoration: line-through; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #ea4335; z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: #ea4335; }

/* agenda view */
.agenda-view { max-width: 860px; margin: 0 auto; padding: 8px 12px 40px; }
.agenda-view .ag-day { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.agenda-view .ag-date { display: flex; gap: 10px; align-items: baseline; padding-top: 8px; }
.agenda-view .ag-date .n { font-size: 24px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; }
.agenda-view .ag-date.today .n { background: var(--today); color: #fff; }
.agenda-view .ag-date .w { font-size: 12px; color: var(--text-2); text-transform: uppercase; font-weight: 600; }

/* ---------------------------------------------------------------- dialogs */
dialog {
  border: none; border-radius: 16px; padding: 0; background: var(--surface); color: var(--text);
  box-shadow: 0 24px 38px 3px rgba(0, 0, 0, .14), 0 9px 46px 8px rgba(0, 0, 0, .12); width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(32, 33, 36, .45); }
dialog .d-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 4px; }
dialog .d-head h2 { flex: 1; }
dialog .d-body { padding: 14px 22px; }
dialog .d-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 8px 22px 20px; flex-wrap: wrap; }
dialog .d-foot .left { margin-right: auto; }
.type-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.type-picker label { cursor: pointer; }
.type-picker input { display: none; }
.type-picker span {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 9px; border-radius: 16px; border: 1px solid var(--border);
  font-size: 12px; font-weight: 500;
}
.type-picker span::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--chip); }
.type-picker input:checked + span { background: var(--chip); color: #fff; border-color: var(--chip); }
.type-picker input:checked + span::before { background: #fff; }
.title-input { font-size: 20px; border: none; border-bottom: 2px solid var(--border); border-radius: 0; padding: 6px 2px; margin-bottom: 16px; }
.title-input:focus { outline: none; border-bottom-color: var(--primary); }
.detail-title { display: flex; gap: 14px; align-items: flex-start; }
.detail-title .sq { width: 16px; height: 16px; border-radius: 4px; background: var(--c); margin-top: 6px; flex: 0 0 auto; }
.detail-rows { display: grid; gap: 12px; margin-top: 16px; }
.detail-rows .r { display: flex; gap: 14px; align-items: flex-start; }
.detail-rows .r .ic { width: 16px; color: var(--text-2); text-align: center; flex: 0 0 auto; }
.detail-rows .desc { white-space: pre-wrap; }

/* ---------------------------------------------------------------- toast */
.toasts { position: fixed; left: 24px; bottom: 24px; display: grid; gap: 8px; z-index: 1000; }
.toast {
  background: #323232; color: #fff; padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 14px;
  animation: toast-in .2s ease-out; max-width: 420px;
}
.toast.error { background: #b3261e; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

@media (max-width: 640px) {
  .page { padding: 16px 12px 40px; }
  .brand-text, .hide-sm { display: none; }
  .crumbs { font-size: 14px; }
  .crumbs a { white-space: nowrap; }
  .filters { flex-wrap: nowrap; overflow-x: auto; }
  .filter-chip { flex: 0 0 auto; }
  .month .num.wide { padding: 0 4px; font-size: 11px; }
  .cal-toolbar h2 { font-size: 17px; min-width: 0; }
  .month .weeks { grid-template-rows: repeat(6, minmax(70px, 1fr)); }
  .chip .tm { display: none; }
  .agenda-view .ag-day { grid-template-columns: 70px 1fr; }
}

/* ---------------------------------------------------------------- notifications */
.bell { position: relative; font-size: 17px; }
.bell.off { filter: grayscale(1); opacity: .55; }
.bell.off::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px; background: var(--text-2);
  transform: rotate(-35deg); border-radius: 1px;
}
.bell.on::after {
  content: ""; position: absolute; right: 7px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--success);
}
.notify-banner {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin-bottom: 20px; border-radius: var(--radius);
  background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
}
.notify-banner > span { font-size: 22px; }
.notify-banner > div { flex: 1; }

/* ---------------------------------------------------------------- account search dropdown */
.suggest-wrap { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; list-style: none; margin: 0; padding: 6px 0;
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto;
}
.suggest li { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; }
.suggest li .who { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest li.active, .suggest li:not(.disabled):not(.none):hover { background: var(--surface-2); }
.suggest li.disabled { cursor: default; opacity: .6; }
.suggest li.none { color: var(--text-3); cursor: default; font-size: 13px; }
.suggest .badge { text-transform: none; }

/* ---------------------------------------------------------------- chat */
.tab-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; vertical-align: 1px;
}
.chat-new { font-weight: 600; color: var(--primary); }
.chat { display: flex; flex-direction: column; height: 100%; max-width: 900px; width: 100%; margin: 0 auto; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 12px 16px; }
.chat-inner { display: flex; flex-direction: column; gap: 2px; min-height: 100%; justify-content: flex-end; }
.chat-more { text-align: center; margin-bottom: 8px; }
.chat-empty { margin: auto; text-align: center; display: grid; gap: 6px; padding: 40px 20px; color: var(--text-2); }
.chat-day { text-align: center; margin: 14px 0 6px; }
.chat-day span { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 3px 12px; border-radius: 10px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 78%; }
.msg.first { margin-top: 8px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar, .avatar-gap { width: 28px; height: 28px; flex: 0 0 auto; }
.msg-body { min-width: 0; display: flex; flex-direction: column; }
.msg.mine .msg-body { align-items: flex-end; }
.msg-meta { font-size: 12px; color: var(--text-2); margin: 0 10px 2px; }
.msg-line { display: flex; align-items: center; gap: 4px; }
.msg.mine .msg-line { flex-direction: row-reverse; }
.bubble {
  padding: 8px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border-soft);
  white-space: pre-wrap; word-break: break-word; line-height: 1.4;
}
.msg.mine .bubble { background: var(--primary); border-color: var(--primary); color: #fff; }
.msg.mine .bubble a { color: #fff; text-decoration: underline; }
@media (prefers-color-scheme: dark) { .msg.mine .bubble { color: #062e6f; } .msg.mine .bubble a { color: #062e6f; } }
.bubble.deleted, .msg.mine .bubble.deleted { background: transparent; border: 1px dashed var(--border); color: var(--text-3); font-style: italic; }
.msg-del {
  opacity: 0; border: none; background: transparent; color: var(--text-3); padding: 2px 6px; font-size: 12px; border-radius: 50%;
}
.msg:hover .msg-del, .msg-del:focus { opacity: 1; }
.msg-del:hover { background: var(--surface-2); color: var(--danger); }
.chat-compose {
  display: flex; gap: 10px; align-items: flex-end; padding: 12px 16px 16px; border-top: 1px solid var(--border-soft); background: var(--bg);
}
.chat-compose textarea { min-height: 42px; max-height: 160px; resize: none; border-radius: 21px; padding: 10px 16px; line-height: 1.4; }
.chat-compose button { height: 42px; }
@media (max-width: 640px) { .msg { max-width: 92%; } .msg.mine .msg-del { opacity: 1; } }
.msg:not(.mine) .msg-line { flex-direction: row-reverse; justify-content: flex-end; }

/* ---------------------------------------------------------------- read receipts */
.msg.mine .bubble { --tick: rgba(255, 255, 255, .6); --tick-read: #5ef1ff; }
@media (prefers-color-scheme: dark) { .msg.mine .bubble { --tick: rgba(32, 33, 36, .45); --tick-read: #0b57d0; } }
.receipt {
  display: inline-flex; align-items: center; vertical-align: -1px; margin: 0 -4px 0 6px; padding: 0 2px;
  border: none; background: transparent; border-radius: 4px; color: var(--tick, var(--text-3)); cursor: pointer;
}
.receipt:hover { background: rgba(0, 0, 0, .08); }
.receipt svg { height: 11px; width: auto; }
.receipt.sending svg { height: 12px; }
.receipt.read { color: var(--tick-read, #1a73e8); }
.receipt.read svg path { stroke-width: 2.2; }
.receipt.inline { margin: 0; padding: 0; cursor: default; font-weight: 700; }
.msg-status { font-size: 11px; color: var(--text-3); margin: 3px 6px 0; }
.msg-status.read { color: var(--primary); font-weight: 600; }
.info-bubble { background: var(--primary-soft); border-radius: 12px; padding: 10px 14px; white-space: pre-wrap; word-break: break-word; }
.info-group { margin-bottom: 14px; }
.info-title { display: flex; gap: 8px; align-items: center; font-weight: 600; margin: 0 0 6px; cursor: default; color: var(--text-2); }
.info-title.read { color: var(--primary); }
.info-title span { color: var(--text); }
.info-person { display: flex; gap: 10px; align-items: center; padding: 4px 0 4px 2px; }
