/* Calendar by What10 — Cloud Fixation brand system.
   Light by default; dark via :root[data-theme="dark"]. Brand tokens are also
   injected centrally by banner.js (admin > Branding) and override these. */
:root {
  --indigo: #4A00E0; --purple: #8E2DE2; --blue: #00D2FF;
  --grad: linear-gradient(135deg, #4A00E0 0%, #8E2DE2 100%);
  --ok: #0E9F6E; --warn: #C27803; --bad: #DC2626;
  --bg: #F7F8FC; --surface: #FFFFFF; --ink: #0B0F19; --ink-soft: #334155;
  --muted: #64748B; --border: #E6E9F2;
  --shadow: 0 12px 34px -18px rgba(11, 15, 25, 0.24);
  --focus: 0 0 0 4px rgba(0, 210, 255, 0.18);
  --r-sm: 10px; --r: 16px; --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0B0F19; --surface: #121829; --ink: #F1F5F9; --ink-soft: #cbd5e1;
  --muted: #94A3B8; --border: #232c41;
  --shadow: 0 18px 44px -20px rgba(0, 0, 0, 0.7);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { min-height: 100vh; font-family: var(--body); color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; transition: background .25s var(--ease), color .25s var(--ease); }
h1, h2 { font-family: var(--display); letter-spacing: -0.02em; }
.muted { color: var(--muted); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 22px 64px; }

/* top bar */
.cal-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 18px; }
.cal-title h1 { font-size: clamp(24px, 4vw, 32px); margin: 0; line-height: 1.05; }
.cal-sub { color: var(--muted); font-size: 14px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.nav-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; display: grid; place-items: center; font-family: var(--body); }
.nav-btn:hover { border-color: var(--purple); }
.today-btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft); border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--body); }
.today-btn:hover { border-color: var(--purple); color: var(--ink); }
.btn-primary { border: none; border-radius: 999px; background: var(--grad); color: #fff; font-weight: 700; font-size: 14px;
  padding: 10px 18px; cursor: pointer; font-family: var(--body); box-shadow: 0 12px 26px -14px rgba(74,0,224,.55); }
.btn-primary:hover { filter: brightness(1.06); }

/* month grid */
.cal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.dow { padding: 11px 8px; text-align: center; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(104px, 1fr); }
.cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 7px; cursor: pointer;
  min-width: 0; transition: background .12s; position: relative; }
.cell:nth-child(7n) { border-right: none; }
.cell:hover { background: rgba(142,45,226,.05); }
.cell.other { background: transparent; }
.cell.other .cell-num { color: var(--muted); opacity: .5; }
.cell-num { font-size: 13px; font-weight: 600; color: var(--ink); width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cell.today .cell-num { background: var(--grad); color: #fff; }
.cell-evs { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.ev-chip { display: block; width: 100%; text-align: left; border: none; cursor: pointer; font-family: var(--body);
  background: color-mix(in srgb, var(--c) 16%, transparent); color: color-mix(in srgb, var(--c) 72%, var(--ink));
  border-left: 3px solid var(--c); border-radius: 5px; padding: 2px 6px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-chip .ev-t { opacity: .8; font-weight: 700; }
.ev-more { font-size: 11px; color: var(--muted); padding-left: 2px; }

/* upcoming */
.upcoming { margin-top: 26px; }
.upcoming h2 { font-size: 17px; margin: 0 0 12px; }
.up-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; margin-bottom: 8px; cursor: pointer; font-family: var(--body); }
.up-item:hover { border-color: var(--purple); }
.up-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.up-main { display: flex; flex-direction: column; min-width: 0; }
.up-title { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.up-when { font-size: 12.5px; color: var(--muted); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(11,15,25,.5); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 26px; max-width: 440px; width: 100%; box-shadow: 0 40px 80px -24px rgba(11,15,25,.5); }
.modal h2 { margin: 0 0 16px; font-size: 21px; }
.modal .close { position: absolute; top: 14px; right: 16px; border: none; background: none; font-size: 24px; color: var(--muted); cursor: pointer; line-height: 1; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.field input, .field textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 11px 13px; color: var(--ink); font-size: 14px; font-family: var(--body); }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.swatches { display: flex; gap: 8px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.sw.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.act { background: var(--surface); border: 1px solid var(--border); color: var(--ink-soft); border-radius: var(--r-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--body); }
.act.danger { margin-left: auto; } .act.danger:hover { border-color: var(--bad); color: var(--bad); background: rgba(220,38,38,.06); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--surface);
  padding: 11px 20px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s var(--ease); z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.cal-top { align-items: center; }
.period { position: relative; display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; min-width: 0; }
.period-pick { position: relative; display: inline-flex; }
.period-date { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; margin: 0;
  border-radius: 12px; cursor: pointer; color: var(--ink); font-family: var(--body); }
.period-pick:hover .period-date { background: color-mix(in srgb, var(--purple) 10%, transparent); }
.period-date svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.period-pick:hover .period-date svg { color: var(--purple); }
#calMonth { font-size: clamp(22px, 4vw, 30px); margin: 0; line-height: 1.05; white-space: nowrap; }
/* a real native date input laid invisibly over the title so a tap opens the OS picker (incl. iOS/Android) */
.goto-overlay { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0;
  background: none; opacity: 0; cursor: pointer; z-index: 2; color: transparent; -webkit-appearance: none; appearance: none; }
.goto-overlay::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; cursor: pointer; opacity: 0; }
.today-btn[hidden] { display: none; }

/* view switcher */
.view-switch { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.view-btn { border: none; background: none; color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600; padding: 7px 16px; border-radius: 999px; cursor: pointer; font-family: var(--body); }
.view-btn:hover { color: var(--ink); }
.view-btn.active { background: var(--grad); color: #fff; }

/* control bar */
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin: 0 0 16px; }
.bar-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sync-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .55; flex: none; }
.sync-status.s-synced { color: #0E9F6E; }
.sync-status.s-error { color: #C27803; }
.sync-status.s-saving .sync-dot, .sync-status.s-syncing .sync-dot { animation: syncpulse 1s ease-in-out infinite; }
@keyframes syncpulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap svg { position: absolute; left: 11px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search-wrap input { border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 14px 8px 32px; font-family: var(--body); font-size: 13.5px; width: 180px; transition: width .18s; }
.search-wrap input:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); width: 220px; }

/* week / day time grid */
.cal-card.tg { display: flex; flex-direction: column; }
.tg-head, .tg-allday { display: grid; grid-template-columns: 56px repeat(var(--days), 1fr); }
.tg-corner, .tg-allhdr { border-right: 1px solid var(--border); }
.tg-allhdr { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px; text-align: right; align-self: center; }
.tg-dh { text-align: center; padding: 9px 4px; border-left: 1px solid var(--border); cursor: pointer; }
.tg-dh .tg-dow { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tg-dh .tg-dnum { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 600; font-size: 15px; margin-top: 2px; }
.tg-dh.today .tg-dnum { background: var(--grad); color: #fff; }
.tg-allday { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); min-height: 30px; }
.tg-allcell { border-left: 1px solid var(--border); padding: 3px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.tg-scroll { max-height: 62vh; overflow-y: auto; display: grid; grid-template-columns: 56px 1fr; }
.tg-gutter { display: flex; flex-direction: column; }
.tg-hr { height: 48px; border-bottom: 1px solid var(--border); position: relative; }
.tg-hr span { position: absolute; top: -7px; right: 6px; font-size: 10.5px; color: var(--muted); }
.tg-body { display: grid; grid-template-columns: repeat(var(--days), 1fr); position: relative; }
.tg-col { border-left: 1px solid var(--border); position: relative; cursor: pointer;
  background-image: repeating-linear-gradient(transparent 0 47px, var(--border) 47px 48px); }
.tg-ev { position: absolute; left: 3px; right: 3px; border: none; border-left: 3px solid var(--c); border-radius: 6px; cursor: pointer; overflow: hidden;
  background: color-mix(in srgb, var(--c) 18%, var(--surface)); color: color-mix(in srgb, var(--c) 78%, var(--ink)); padding: 3px 6px; text-align: left; font-family: var(--body); }
.tg-ev b { display: block; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ev span { font-size: 11px; opacity: .85; }
.tg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 3; }
.tg-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

/* agenda */
.agenda { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); padding: 8px 10px; }
.ag-day { font-family: var(--display); font-weight: 600; font-size: 13px; color: var(--muted); padding: 14px 8px 6px; text-transform: uppercase; letter-spacing: .04em; }
.ag-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: none; border-radius: 10px; padding: 10px; cursor: pointer; font-family: var(--body); text-decoration: none; }
.ag-item:hover { background: var(--bg); }
.ag-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ag-main { display: flex; flex-direction: column; min-width: 0; }
.ag-title { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.ag-when { font-size: 12.5px; color: var(--muted); }
.ag-item.task .ag-title { color: var(--ink-soft); }

/* modal additions */
.allday-row { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--ink); margin: 0 0 14px; cursor: pointer; }
.allday-row input { width: 16px; height: 16px; }
.dt { display: flex; gap: 8px; }
.dt input[type=date] { flex: 1; min-width: 0; }
.dt .time-in { flex: 0 0 108px; }
.field select { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 11px 13px; color: var(--ink); font-size: 14px; font-family: var(--body); }
.field select:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }

/* drag-drop hint */
.drop-hint { position: fixed; inset: 12px; display: none; place-items: center; border-radius: 22px; background: rgba(74,0,224,.10);
  backdrop-filter: blur(2px); z-index: 300; font-family: var(--display); font-weight: 600; font-size: 22px; color: var(--indigo); border: 3px dashed var(--purple); pointer-events: none; }
body.dropping .drop-hint { display: grid; }

@media (max-width: 620px) {
  .cal-grid { grid-auto-rows: minmax(78px, 1fr); }
  .ev-chip { font-size: 10.5px; padding: 1px 4px; }
  .ev-chip .ev-t { display: none; }
  .cal-bar { gap: 10px; } .bar-tools { width: 100%; }
  .search-wrap input, .search-wrap input:focus { width: 100%; } .search-wrap { flex: 1; }
  .btn-primary { margin-left: auto; }
}

/* tasks overlaid from tasks.what10.com (read-only) */
.ev-chip.task { background:transparent; border:1px dashed var(--border,#E6E9F2); color:var(--ink-soft,#334155); text-decoration:none; }
.ev-chip.task:hover { border-color:var(--purple,#8E2DE2); color:var(--purple,#8E2DE2); }
.ev-chip.task.done { opacity:.55; text-decoration:line-through; }
