/* Protium shared calendar. Tokens: docs/DESIGN.md "Calendar sharing" (mirrors protium-ui tokens.rs). */
@font-face { font-family: "DM Sans"; src: url("fonts/dmsans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Young Serif"; src: url("fonts/youngserif.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --glass:#E9E9EC; --surface:#FFFFFF; --surface-2:#F5F5F7; --surface-3:#EFEFF2;
  --hairline:rgba(0,0,0,.07); --text:#101012; --text-2:#5C5C66; --text-3:#86868F;
  --accent:#F2613F; --accent-soft:#FFEDE7; --new:#27B594; --new-soft:#E2F6F0;
  --danger:#E5484D; --warn:#F5A524;
  --shadow-card:0 1px 2px rgba(0,0,0,.04),0 8px 28px rgba(0,0,0,.05);
  --r-card:18px; --r-row:14px; --r-field:12px; --r-button:10px; --r-icon:9px; --r-chip:11px; --r-block:8px;
  --hour:48px; --gutter:52px;
  --font-ui:"DM Sans",system-ui,sans-serif; --font-display:"Young Serif",Georgia,serif;
  /* springs approximated: default 0.32/0.12, sheet 0.4/0.16, exit 0.26/0 */
  --ease-default:cubic-bezier(.25,1.1,.4,1); --ease-sheet:cubic-bezier(.2,.8,.2,1); --ease-exit:cubic-bezier(.4,0,.6,1);
  --t-default:320ms; --t-sheet:240ms; --t-exit:260ms; --t-hover:80ms;
  /* page-specific */
  --tint:#3B82F6; --tint-fill:color-mix(in srgb,#3B82F6 13%,var(--surface)); --tint-ink:color-mix(in srgb,#3B82F6 82%,#000);
  --busy-fill:#ECECF0; --busy-bar:var(--text-3); --busy-ink:var(--text-2);
  --off:rgba(0,0,0,.018); --scrim:rgba(16,16,18,.18);
  --line:rgba(0,0,0,.055);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) { :root {
  --glass:#0A0A0A; --surface:#0F0F0F; --surface-2:#181818; --surface-3:#212121;
  --hairline:rgba(255,255,255,.08); --text:#F2F2F2; --text-2:#A3A3A3; --text-3:#737373;
  --accent:#FF7A5C; --accent-soft:#3A211B; --new:#4AD3B4; --new-soft:#17332C;
  --danger:#FF6369; --warn:#FFB84D;
  --shadow-card:0 1px 2px rgba(0,0,0,.2),0 8px 28px rgba(0,0,0,.28),inset 0 1px 0 rgba(255,255,255,.04);
  --tint-fill:color-mix(in srgb,#3B82F6 20%,var(--surface)); --tint-ink:color-mix(in srgb,#3B82F6 18%,#fff);
  --busy-fill:#1E1E1E; --busy-bar:#7A7A7A; --busy-ink:#B4B4B4;
  --off:rgba(255,255,255,.018); --scrim:rgba(0,0,0,.40);
  --line:rgba(255,255,255,.06);
} }
@media (prefers-reduced-motion: reduce) { :root { --t-default:1ms; --t-sheet:1ms; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--glass); color: var(--text);
  font: 400 13.5px/19px var(--font-ui); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.app { max-width: 1280px; margin: 0 auto; padding: 24px; display: grid; gap: 10px; }
.paper { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-card); box-shadow: var(--shadow-card); }
.rise { animation: rise var(--t-sheet) var(--ease-sheet) both; }
.rise + .rise { animation-delay: 30ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .rise { animation: fade 1ms both; } @keyframes fade { from { opacity: 0; } } }

/* calm pages */
.calm { max-width: 440px; margin: 14vh auto 0; padding: 40px 36px 36px; text-align: left; }
.calm-mark { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 22px; background:
  radial-gradient(circle at 50% 50%, transparent 7px, var(--surface-3) 7.5px 11px, transparent 11.5px 15px, var(--surface-2) 15.5px); }
.calm-title { font: 400 26px/32px var(--font-display); margin: 0 0 8px; letter-spacing: -.005em; }
.calm-sub { color: var(--text-2); margin: 0; }
.calm form { margin-top: 22px; display: flex; gap: 8px; }
.calm .note { margin-top: 10px; font-size: 12px; line-height: 16px; color: var(--text-2); min-height: 16px; }
.calm .note.bad { color: var(--danger); }

/* header */
.head { padding: 20px 22px 16px; display: grid; gap: 14px; }
.head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.title { font: 400 26px/32px var(--font-display); margin: 0; letter-spacing: -.005em; }
.meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--text-3); font-size: 12px; line-height: 16px; font-weight: 500; }
.meta .dot::before { content: "·"; margin-right: 10px; }
.fresh { display: inline-flex; align-items: center; gap: 6px; }
.fresh::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: var(--new); }
.fresh.old::before { background: var(--warn); }
.stale { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: var(--r-field); background: var(--surface-2); color: var(--text-2); font-size: 12px; line-height: 16px; font-weight: 500; }
.notice { color: var(--text-3); font-size: 12px; }

.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period { font-weight: 600; font-size: 17px; line-height: 24px; margin: 0 6px 0 4px; min-width: 9ch; }
.grow { flex: 1; }
.icon { width: 32px; height: 32px; border-radius: var(--r-icon); border: 1px solid var(--hairline); background: var(--surface);
  display: inline-grid; place-items: center; color: var(--text-2); transition: background var(--t-hover), transform 80ms; }
.icon:hover { background: var(--surface-3); color: var(--text); }
.icon:active, .btn:active, .seg button:active { transform: scale(.97); }
.icon:disabled { opacity: .35; cursor: default; }
.icon svg { width: 16px; height: 16px; }
a.btn { text-decoration: none; }
.btn { height: 32px; padding: 0 12px; border-radius: var(--r-button); border: 1px solid var(--hairline); background: var(--surface-2);
  font-weight: 500; display: inline-flex; align-items: center; gap: 6px; transition: background var(--t-hover), transform 80ms; white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
.btn.primary svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255,255,255,.22); }
.btn.primary:hover { filter: brightness(1.04); }
.btn.lg { height: 38px; padding: 0 16px; }

.seg { position: relative; display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; height: 36px; }
.seg button { position: relative; z-index: 1; border: 0; background: none; padding: 0 12px; border-radius: 9px; color: var(--text-2); font-weight: 500; transition: color var(--t-hover); }
.seg button[aria-pressed="true"] { color: var(--text); }
.seg .thumb { position: absolute; top: 4px; bottom: 4px; left: 0; border-radius: 9px; background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.06); transition: transform var(--t-default) var(--ease-default), width var(--t-default) var(--ease-default); }
@media (prefers-color-scheme: dark) { .seg .thumb { background: var(--surface-3); } }

/* free summary */
.free { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.free-label { font-size: 11px; line-height: 14px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin-right: 4px; }
.chip { height: 28px; padding: 0 11px; border-radius: var(--r-chip); border: 1px solid var(--hairline);
  background: var(--surface); display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; }
.chip b { font-weight: 600; color: var(--text-2); }
button.chip:hover { background: var(--surface-3); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.none { color: var(--text-2); font-size: 12.5px; }

/* calendar card */
.cal { overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.cols { display: grid; grid-template-columns: var(--gutter) repeat(var(--n), minmax(0, 1fr)); }
.dh { padding: 10px 8px 8px; border-left: 1px solid var(--line); display: flex; align-items: baseline; gap: 6px; background: none; border-top: 0; border-right: 0; border-bottom: 0; text-align: left; color: var(--text-2); }
.dh:first-of-type { border-left-color: transparent; }
.dh .wd { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.dh .dn { font-size: 17px; font-weight: 600; line-height: 24px; color: var(--text); }
.dh.today .dn { color: #fff; background: var(--accent); border-radius: 12px; min-width: 24px; height: 24px; padding: 0 6px; display: inline-grid; place-items: center; font-size: 13px; }
.dh.past .dn { color: var(--text-3); }
.dh .fx { margin-left: auto; font-size: 11px; color: var(--text-3); font-weight: 500; }
.allday { border-top: 1px solid var(--line); min-height: 30px; }
.allday .lab { font-size: 10.5px; color: var(--text-3); padding: 7px 0 0 8px; font-weight: 500; }
.allday .cell { border-left: 1px solid var(--line); padding: 4px; display: grid; gap: 3px; align-content: start; }
.adc { border-radius: 6px; padding: 2px 7px; font-size: 11.5px; line-height: 16px; font-weight: 600; background: var(--busy-fill); color: var(--busy-ink); border: 0; text-align: left; }
.adc.ev { background: var(--tint-fill); color: var(--tint-ink); }

.scroll { overflow-y: auto; border-top: 1px solid var(--line); position: relative; overscroll-behavior: contain; scrollbar-width: thin; }
.grid { position: relative; height: calc(var(--hour) * 24); }
.gut { position: relative; }
.gut span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 10.5px; color: var(--text-3); font-weight: 500; white-space: nowrap; }
.col { position: relative; border-left: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour)); }
.offh { position: absolute; left: 0; right: 0; background: var(--off); pointer-events: none; }
.gap { position: absolute; left: 3px; right: 3px; border-radius: var(--r-block); border: 1px solid transparent; background: none; padding: 4px 7px;
  font-size: 11px; line-height: 14px; color: var(--text-2); font-weight: 500; text-align: left; overflow: hidden; display: block; }
.gap > * { opacity: 0; }
.gap b { display: block; font-weight: 600; color: var(--text); font-size: 11.5px; }
.gap:focus-visible, .gap[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); outline: 0; }
.gap:focus-visible > *, .gap[aria-pressed="true"] > * { opacity: 1; }
.blk { position: absolute; border-radius: var(--r-block); padding: 4px 7px 4px 10px; overflow: hidden; font-size: 11.5px; line-height: 15px;
  background: var(--busy-fill); color: var(--busy-ink); border: 0; text-align: left; display: block; box-shadow: 0 0 0 1.5px var(--surface); }
.blk::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--busy-bar); }
.blk .bt { font-weight: 600; display: block; color: var(--text); }
.blk.busy .bt { color: var(--busy-ink); }
.blk .bm { display: block; opacity: .85; }
.blk .bt, .blk .bm, .adc, .mc .mt { white-space: nowrap; overflow: hidden; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
.blk.ev { background: var(--tint-fill); color: var(--tint-ink); }
.blk.ev::before { background: var(--tint); }
.blk.ev .bt { color: var(--tint-ink); }
.blk.tent { background: color-mix(in srgb, var(--busy-fill) 50%, var(--surface)); box-shadow: 0 0 0 1.5px var(--surface), inset 0 0 0 1px var(--hairline); }
.blk.tent::before { opacity: .45; }
.blk.ev.tent { background: color-mix(in srgb, var(--tint-fill) 50%, var(--surface)); }
.blk.short { padding-top: 1px; padding-bottom: 1px; }
.blk.short .bm { display: none; }
button.blk:hover { filter: brightness(.98) saturate(1.1); }
.now { position: absolute; left: -1px; right: 0; height: 2px; background: var(--accent); z-index: 3; pointer-events: none; }
.now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 4px; background: var(--accent); }

/* month */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mh { padding: 10px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.mc { min-height: 104px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 8px 8px 10px; display: flex; flex-direction: column; gap: 5px; background: none; border-right: 0; border-bottom: 0; text-align: left; color: inherit; }
.mc:nth-child(7n + 1) { border-left-color: transparent; }
.mc.out { opacity: .38; }
.mc .n { font-weight: 600; font-size: 13px; }
.mc.today .n { color: #fff; background: var(--accent); border-radius: 10px; padding: 0 6px; align-self: flex-start; }
.strip { position: relative; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.strip i { position: absolute; top: 0; bottom: 0; background: var(--busy-bar); opacity: .7; }
.mc .ft { font-size: 11px; color: var(--text-2); font-weight: 500; }
.mc .mt { font-size: 11px; line-height: 14px; color: var(--tint-ink); }

/* agenda */
.agenda { padding: 6px 0 10px; }
.ad { display: grid; grid-template-columns: 116px 1fr; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); }
.ad:first-child { border-top: 0; }
.ad h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.ad h3 small { display: block; color: var(--text-3); font-weight: 500; font-size: 12px; }
.ai { display: grid; gap: 6px; }
.row { display: grid; grid-template-columns: 128px 1fr; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 10px; background: none; border: 0; text-align: left; width: 100%; color: inherit; }
.row .tm { color: var(--text-2); font-size: 12.5px; }
.row .tt { font-weight: 600; }
.row .tt small { display: block; font-weight: 400; color: var(--text-2); font-size: 12px; }
.row.busy { background: var(--busy-fill); }
.row.busy .tt { color: var(--busy-ink); font-weight: 500; }
.row.ev { background: var(--tint-fill); }
.row.ev .tt { color: var(--tint-ink); }
.row.free { border-radius: 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); margin: -3px 0; }
.row.free .tt { font-weight: 400; color: var(--text-2); }
button.row.free:hover { background: var(--surface-2); }
.row.free[aria-pressed="true"] { background: var(--accent-soft); border-radius: 10px; border-color: transparent; }

/* detail sheet */
dialog.sheet { border: 1px solid var(--hairline); border-radius: var(--r-card); background: var(--surface); color: var(--text); box-shadow: var(--shadow-card), 0 12px 40px rgba(0,0,0,.12);
  padding: 22px 22px 18px; width: min(420px, calc(100vw - 32px)); animation: rise var(--t-sheet) var(--ease-sheet); }
dialog.sheet::backdrop { background: var(--scrim); }
.sheet h2 { font: 400 22px/28px var(--font-display); margin: 0 30px 6px 0; overflow-wrap: anywhere; }
.sheet .when { color: var(--text-2); margin: 0 0 14px; }
.sheet dl { display: grid; grid-template-columns: 22px 1fr; gap: 8px 8px; margin: 0 0 16px; }
.sheet dt { color: var(--text-3); padding-top: 1px; }
.sheet dt svg { width: 15px; height: 15px; }
.sheet dd { margin: 0; overflow-wrap: anywhere; }
.sheet .x { position: absolute; top: 14px; right: 14px; }
.sheet .acts { display: flex; gap: 8px; }

/* skeleton */
.sk { background: var(--surface-2); border-radius: 8px; }
.sk-head { padding: 22px; display: grid; gap: 12px; }
.sk-cal { height: 520px; }
@media (prefers-reduced-motion: no-preference) { .sk { animation: pulse 1.6s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .55; } }

/* phones */
@media (max-width: 640px) {
  .app { padding: 10px; }
  .head { padding: 16px 16px 14px; gap: 12px; }
  .title { font-size: 23px; line-height: 28px; }
  .seg button { padding: 0 9px; font-size: 13px; }
  .bar .seg { order: 3; width: 100%; } .bar .seg button { flex: 1; }
  .period { font-size: 15px; min-width: 0; }
  .ad { grid-template-columns: 1fr; gap: 6px; padding: 12px 14px; }
  .row { grid-template-columns: 10em 1fr; } .row .tm { white-space: nowrap; }
  .mc { min-height: 64px; padding: 6px 4px; } .mc .mt, .mc .ft { display: none; }
  .calm { margin-top: 8vh; padding: 32px 24px 28px; }
  :root { --gutter: 44px; }
}
