/* Forward marketing calendar. Brand: charcoal #231F20, purple #9944FE, light #F2F2F2.
   Geist for headings, Inter for body, Geist Mono for small accents. */

:root {
  --bg: #F2F2F2;
  --surface: #FFFFFF;
  --surface-2: #F8F7F7;
  --ink: #231F20;
  --muted: #6E6869;
  --faint: #9C9697;
  --line: #E2DFDF;
  --line-soft: #EFEDED;
  --accent: #9944FE;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(153, 68, 254, 0.11);
  --tint: 15%;
  --tint-strong: 24%;
  --danger: #C8353A;
  --shadow: 0 1px 2px rgba(35, 31, 32, 0.06), 0 8px 28px rgba(35, 31, 32, 0.10);
  --radius: 10px;
  --font-head: 'Geist', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131112;
    --surface: #1C191A;
    --surface-2: #232021;
    --ink: #F2F2F2;
    --muted: #A49D9F;
    --faint: #7A7375;
    --line: #353031;
    --line-soft: #2A2627;
    --accent: #A970FF;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(169, 112, 255, 0.18);
    --tint: 26%;
    --tint-strong: 38%;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131112;
  --surface: #1C191A;
  --surface-2: #232021;
  --ink: #F2F2F2;
  --muted: #A49D9F;
  --faint: #7A7375;
  --line: #353031;
  --line-soft: #2A2627;
  --accent: #A970FF;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(169, 112, 255, 0.18);
  --tint: 26%;
  --tint-strong: 38%;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

.dark-only { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dark-only { display: inline; }
  :root:not([data-theme="light"]) .light-only { display: none; }
}
:root[data-theme="dark"] .dark-only { display: inline; }
:root[data-theme="dark"] .light-only { display: none; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 var(--font-body);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ic { flex: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- header ---------- */
.header {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  grid-template-areas: "brand views nav tools";
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 10px; }
.logo { width: 22px; height: 22px; }
.brand-name { font: 600 16px/1 var(--font-head); letter-spacing: -0.01em; white-space: nowrap; }
.seg {
  grid-area: views;
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px;
}
.seg button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-weight: 500;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08), 0 0 0 1px var(--line); }
.nav { grid-area: nav; display: flex; align-items: center; gap: 4px; min-width: 0; }
.period { margin: 0 0 0 10px; font: 600 18px/1.2 var(--font-head); letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { grid-area: tools; display: flex; align-items: center; gap: 6px; }
.tz {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); font: 500 12px/1 var(--font-mono); cursor: pointer;
}
.tz:hover { background: var(--surface-2); color: var(--ink); }
.tz-short { color: var(--ink); }
.tz select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

.banner { padding: 8px 20px; background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: 13px; }
.banner p { margin: 0; }

/* ---------- filters ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px 24px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.f-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.f-label { font: 500 11px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); width: 34px; flex: none; }
.f-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.chip:hover { border-color: var(--faint); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.chip.f-all.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip.f-tag.who.on { background: color-mix(in srgb, var(--c) var(--tint-strong), var(--surface)); border-color: var(--c); }
.chip.f-tag.plain.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.status { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 20; font-size: 13px; pointer-events: none; }
.status:not(:empty) { padding: 6px 12px; background: var(--ink); color: var(--surface); border-radius: 8px; box-shadow: var(--shadow); }
.status.error:not(:empty) { background: var(--danger); color: #fff; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 20px 16px; }
.fatal { margin: 48px auto; max-width: 440px; text-align: center; color: var(--muted); }
.fatal h2 { font: 600 20px var(--font-head); color: var(--ink); }

/* ---------- event looks shared by views ---------- */
.m-item, .tg-span, .tg-event {
  --bg-tint: color-mix(in srgb, var(--c) var(--tint), var(--surface));
  border: 0; text-align: left; color: var(--ink);
}
.tentative {
  --stripe: color-mix(in srgb, var(--c) calc(var(--tint) * 0.45), var(--surface));
}
.draft { opacity: 0.75; }

/* ---------- month ---------- */
.month { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.m-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.m-wd { padding: 8px 10px; font: 500 11px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.m-weeks { flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(var(--weeks), minmax(96px, 1fr)); overflow-y: auto; }
.m-week { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line-soft); }
.m-week:last-child { border-bottom: 0; }
.m-cell { border-right: 1px solid var(--line-soft); padding: 4px 6px; min-width: 0; }
.m-cell:last-child { border-right: 0; }
.m-cell.out { background: var(--surface-2); }
.m-cell.out .m-daynum { color: var(--faint); }
.m-daynum {
  display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 4px;
  border: 0; border-radius: 11px; background: transparent; font: 500 12px/1 var(--font-head); color: var(--muted);
}
.m-daynum:hover { background: var(--surface-2); color: var(--ink); }
.m-cell.today .m-daynum { background: var(--accent); color: var(--accent-ink); }
.m-item {
  position: absolute; height: 20px; display: flex; align-items: center; gap: 5px;
  padding: 0 6px; border-radius: 5px; font-size: 12px; line-height: 20px; overflow: hidden; white-space: nowrap;
}
.m-item .n { overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.m-item .t { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.m-item.span { background: var(--bg-tint); box-shadow: inset 3px 0 0 var(--c); }
.m-item.span.cont-l { box-shadow: none; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.m-item.span.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.m-item.dot { background: transparent; }
.m-item.dot:hover, .m-item.span:hover { filter: brightness(0.96); }
.m-item.dot:hover { background: var(--surface-2); }
.m-item .swatch { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.m-item.span.tentative { background: repeating-linear-gradient(135deg, var(--bg-tint) 0 6px, var(--stripe) 6px 12px); }
.m-item.dot.tentative .swatch { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
.m-item.dot.tentative .n { font-style: italic; }
.m-item.draft { outline: 1px dashed var(--c); outline-offset: -1px; background: transparent; box-shadow: none; }
.m-more { position: absolute; white-space: nowrap; overflow: hidden; height: 20px; border: 0; background: transparent; text-align: left; padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); border-radius: 5px; }
.m-more:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- week / day time grid ---------- */
.timegrid { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; --gutter: 64px; }
.tg-head, .tg-allday, .tg-grid { display: grid; grid-template-columns: var(--gutter) 1fr; }
.tg-head { grid-template-columns: var(--gutter) repeat(var(--cols), 1fr); border-bottom: 1px solid var(--line); }
.tg-tzlabel { display: grid; place-items: end center; padding-bottom: 8px; font: 500 10.5px/1 var(--font-mono); color: var(--faint); }
.tg-day {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: 10px 4px 8px; border: 0; border-left: 1px solid var(--line-soft); background: transparent;
}
.tg-day:hover { background: var(--surface-2); }
.tg-day .wd { font: 500 11px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.tg-day .dn { font: 600 18px/1 var(--font-head); color: var(--ink); }
.tg-day.today .dn { color: var(--accent-ink); background: var(--accent); border-radius: 14px; padding: 4px 8px; margin: -4px 0; }
.timegrid.single .tg-day { justify-content: flex-start; padding-left: 12px; }
.tg-allday { border-bottom: 1px solid var(--line); min-height: 32px; }
.tg-allday .tg-gutter { display: grid; place-items: center end; padding-right: 10px; font-size: 11px; color: var(--faint); }
.tg-allday-area { position: relative; }
.tg-col-line { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line-soft); }
.tg-span {
  position: absolute; height: 20px; display: flex; align-items: center; padding: 0 8px; border-radius: 5px;
  background: var(--bg-tint); box-shadow: inset 3px 0 0 var(--c); font-size: 12px; font-weight: 500; overflow: hidden; white-space: nowrap;
}
.tg-span .n { overflow: hidden; text-overflow: ellipsis; }
.tg-span.cont-l { box-shadow: none; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.tg-span.tentative { background: repeating-linear-gradient(135deg, var(--bg-tint) 0 6px, var(--stripe) 6px 12px); }
.tg-span.draft { background: transparent; outline: 1px dashed var(--c); outline-offset: -1px; box-shadow: none; }
.tg-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.tg-grid { position: relative; }
.tg-hours { position: relative; }
.tg-hour { position: absolute; right: 10px; transform: translateY(-50%); font: 500 10.5px/1 var(--font-mono); color: var(--faint); white-space: nowrap; }
.tg-cols { position: relative; display: grid; grid-template-columns: repeat(var(--cols), 1fr); }
.tg-lines { position: absolute; inset: 0; pointer-events: none; }
.tg-lines div { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line-soft); }
.tg-lines div.half { border-top-style: dashed; opacity: 0.6; }
.tg-col { position: relative; border-left: 1px solid var(--line-soft); }
.tg-col.today { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.tg-now { position: absolute; left: -1px; right: 0; height: 2px; background: var(--accent); z-index: 3; }
.tg-now::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.tg-event {
  position: absolute; display: flex; flex-direction: column; gap: 1px;
  padding: 3px 6px 3px 8px; border-radius: 6px; overflow: hidden; z-index: 1;
  background: var(--bg-tint); box-shadow: inset 3px 0 0 var(--c), 0 0 0 1px var(--surface);
  font-size: 12px; line-height: 1.25;
}
.tg-event:hover { z-index: 2; filter: brightness(0.97); }
.tg-event .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-event .t { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-event .m { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-event.short { flex-direction: row; align-items: center; gap: 6px; padding-top: 0; padding-bottom: 0; }
.tg-event.tentative { background: repeating-linear-gradient(135deg, var(--bg-tint) 0 6px, var(--stripe) 6px 12px); }
.tg-event.draft { background: var(--surface); outline: 1px dashed var(--c); outline-offset: -1px; }
.timegrid.single .tg-event .n { font-size: 13px; }

/* ---------- agenda ---------- */
.view-agenda { overflow-y: auto; }
.agenda { max-width: 820px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.ag-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 6px 8px; }
.ag-date { display: flex; align-items: baseline; gap: 10px; margin: 6px 10px 6px; font: 600 15px/1.2 var(--font-head); }
.ag-dn { font-size: 22px; letter-spacing: -0.02em; }
.ag-wd { color: var(--muted); font-weight: 500; }
.ag-today { font: 500 11px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.ag-day.today .ag-dn { color: var(--accent); }
.ag-row {
  display: grid; grid-template-columns: 96px 3px 1fr; gap: 12px; align-items: start;
  width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left;
}
.ag-row:hover { background: var(--surface-2); }
.ag-time { display: flex; flex-direction: column; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; padding-top: 1px; }
.ag-time small { color: var(--faint); font-size: 12px; font-weight: 400; }
.ag-bar { align-self: stretch; border-radius: 2px; background: var(--c); min-height: 32px; }
.ag-row.tentative .ag-bar { background: repeating-linear-gradient(180deg, var(--c) 0 4px, transparent 4px 7px); }
.ag-row.draft .ag-bar { background: transparent; outline: 1px dashed var(--c); }
.ag-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ag-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; font-weight: 600; font-family: var(--font-head); }
.ag-sub { color: var(--muted); font-size: 13px; }
.ag-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px 24px; color: var(--faint); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; font: 500 11px/1 var(--font-mono); letter-spacing: 0.02em; }
.badge.tentative { background: repeating-linear-gradient(135deg, var(--surface-2) 0 5px, var(--line-soft) 5px 10px); border: 1px dashed var(--faint); color: var(--muted); }
.badge.draft { border: 1px dashed var(--muted); color: var(--muted); }

/* ---------- event card ---------- */
.card-dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 64px);
  padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); overflow: visible;
}
.card-dialog::backdrop { background: rgba(19, 17, 18, 0.35); backdrop-filter: blur(2px); }
.card { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 20px 20px 16px 24px; max-height: calc(100dvh - 66px); overflow-y: auto; }
.card-stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--c); border-radius: 14px 0 0 14px; }
.card-dialog:has(.badge.tentative) .card-stripe { background: repeating-linear-gradient(180deg, var(--c) 0 6px, transparent 6px 10px); }
.card-head { display: flex; flex-direction: column; gap: 6px; }
.card-head .badge { align-self: flex-start; }
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { margin: 0; font: 600 20px/1.25 var(--font-head); letter-spacing: -0.015em; }
.card-title-row .icon-btn { margin: -4px -8px 0 0; }
.card-when { margin: 0; font-size: 15px; font-weight: 500; }
.card-origin { margin: 0; color: var(--muted); font-size: 13px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 13px; font-weight: 500; }
.tag.who { background: color-mix(in srgb, var(--c) var(--tint), var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); }
.tag.who i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.tag.plain { background: var(--surface-2); border: 1px solid var(--line); }
.card-fields { display: grid; grid-template-columns: 96px 1fr; gap: 10px 12px; margin: 0; font-size: 14px; }
.card-fields dt { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; padding-top: 2px; }
.card-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.card-fields dd.notes { white-space: pre-wrap; }
.card-fields dd.chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.chip.link { height: 30px; max-width: 100%; padding: 0 12px 0 8px; border-radius: 15px; }
.chip.link:hover { background: var(--surface-2); }
.chip-title { overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.chip-kind { color: var(--faint); font: 500 11px/1 var(--font-mono); flex: none; }
.chip-ic { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; color: var(--muted); flex: none; }
.chip-ic.sheet { background: #1E8E3E; }
.chip-ic.doc { background: #4285F4; }
.chip-ic.slides { background: #F4B400; }
.chip-ic.drive { background: #8A8A8A; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.card-meta { color: var(--faint); font-size: 12px; }
.card-actions { display: flex; gap: 8px; margin-left: auto; }
.atc { position: relative; }
.atc-menu {
  position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5; min-width: 240px;
  display: flex; flex-direction: column; padding: 6px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.atc-menu[hidden] { display: none; }
.atc-menu > * {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 0; border-radius: 6px;
  background: transparent; text-align: left; color: var(--ink); text-decoration: none;
}
.atc-menu > *:hover, .atc-menu > *:focus-visible { background: var(--surface-2); }
.atc-menu strong { font-weight: 600; font-size: 14px; }
.atc-menu small { color: var(--muted); font-size: 12px; }

/* ---------- narrow screens ---------- */
@media (max-width: 719px) {
  .header {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand tools" "views views" "nav nav";
    gap: 10px; padding: 10px 16px;
  }
  .seg { display: grid; grid-template-columns: repeat(4, 1fr); }
  .period { font-size: 16px; }
  .nav .today-btn { order: -1; margin-right: 4px; }
  .filters { flex-direction: column; flex-wrap: nowrap; gap: 8px; padding: 8px 16px; }
  .f-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 1px; }
  .f-chips::-webkit-scrollbar { display: none; }
  main { padding: 8px 8px 12px; }
  .timegrid { --gutter: 48px; }
  .tg-day { flex-direction: column; align-items: center; gap: 4px; }
  .m-wd { padding: 6px 4px; text-align: center; }
  .m-item .t { display: none; }
  .m-item { font-size: 11px; padding: 0 4px; }
  .ag-row { grid-template-columns: 72px 3px 1fr; gap: 10px; }
  .card-dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; }
  .card-stripe { border-radius: 16px 0 0 0; }
  .card-fields { grid-template-columns: 1fr; gap: 4px; }
  .card-fields dd { margin-bottom: 8px; }
}
