{
  "id": 139,
  "slug": "time-block-calendar",
  "name": "Interactive Day/Week Time-Block Calendar",
  "kind": "ui",
  "family": "Scheduling & Time",
  "sourceSite": {
    "name": "Morgen",
    "url": "https://www.morgen.so/",
    "verifiedStatus": 200
  },
  "tagline": "Interactive 5-day time-blocking studio with click-to-schedule slots, duration editing, focus vs. meeting meters, and mobile day view.",
  "whyUnique": "Makes time allocation tangible by turning empty hourly cells into instant focus blocks, tracking Deep Work vs. Meetings live, and switching cleanly to a single-day schedule on 390px screens.",
  "theme": "light",
  "mobileStrength": "native-first",
  "tags": [
    "calendar",
    "time-blocking",
    "scheduling",
    "day-week-grid",
    "productivity",
    "planner"
  ],
  "bestFor": [
    "Personal and team time-blocking planners",
    "Resource and studio booking calendars",
    "Deep-work and sprint scheduling tools",
    "Client appointment and shift planners"
  ],
  "palette": [
    {
      "role": "canvas",
      "hex": "#F8F9FC",
      "name": "Morning Mist"
    },
    {
      "role": "surface",
      "hex": "#FFFFFF",
      "name": "Grid White"
    },
    {
      "role": "ink",
      "hex": "#161E2E",
      "name": "Slate Ink"
    },
    {
      "role": "accent",
      "hex": "#6366F1",
      "name": "Focus Indigo"
    },
    {
      "role": "muted",
      "hex": "#64748B",
      "name": "Hour-Axis Gray"
    }
  ],
  "typography": {
    "display": "Inter",
    "body": "Inter",
    "mono": "JetBrains Mono",
    "googleFontsUrl": "https://fonts.googleapis.com/css2?family=Inter:wght@500;600;700&family=JetBrains+Mono:wght@500;600&display=swap",
    "scaleNotes": "11px mono hour axis, 13px bold event titles, 11.5px time range badges, 14px summary meter stats."
  },
  "layoutNotes": "Fixed hour gutter + 5-day CSS Grid columns on desktop; compact Mon–Fri day-pill switcher + single full-width day timeline on <=768px.",
  "interactionNotes": "Click any empty hour slot to create a time block; click any existing block to edit its title, category color, duration (30m/60m/90m/120m), or delete it while live Focus vs. Meeting meters recalculate.",
  "mobileNotes": "Automatically collapses the 5-day grid into a single-day timeline with large Mon–Fri day selector pills so event titles remain completely readable at 390px.",
  "agentGuardrails": {
    "do": [
      "Collapse multi-day calendar grids to a single-day view with day selector pills below 768px.",
      "Use distinct category colors paired with category labels for Deep Work, Meetings, and Admin.",
      "Recalculate daily/weekly time budget meters immediately on block edits."
    ],
    "dont": [
      "Never cram 5 or 7 vertical day columns onto a 390px mobile screen.",
      "Avoid requiring precise pixel-edge dragging as the only way to resize a block's duration."
    ]
  },
  "demoFile": "demos/time-block-calendar.html",
  "thumbDesktop": "thumbs/time-block-calendar-desktop.webp",
  "thumbMobile": "thumbs/time-block-calendar-mobile.webp",
  "urls": {
    "page": "https://templates.michaelpitts.net/t/time-block-calendar",
    "markdown": "https://templates.michaelpitts.net/t/time-block-calendar.md",
    "api": "https://templates.michaelpitts.net/api/templates/time-block-calendar",
    "demo": "https://templates.michaelpitts.net/demos/time-block-calendar.html",
    "thumbDesktop": "https://templates.michaelpitts.net/thumbs/time-block-calendar-desktop.webp",
    "thumbMobile": "https://templates.michaelpitts.net/thumbs/time-block-calendar-mobile.webp"
  },
  "agentPrompt": "Design & build using template #139 \"Interactive Day/Week Time-Block Calendar\" (ui / Scheduling & Time, light theme).\nFull AI blueprint & standalone starter code: https://templates.michaelpitts.net/t/time-block-calendar.md\nLive demo: https://templates.michaelpitts.net/demos/time-block-calendar.html\nReal-world inspiration: Morgen (https://www.morgen.so/)\n\nCore aesthetic: Makes time allocation tangible by turning empty hourly cells into instant focus blocks, tracking Deep Work vs. Meetings live, and switching cleanly to a single-day schedule on 390px screens.\nPalette: canvas: #F8F9FC (Morning Mist), surface: #FFFFFF (Grid White), ink: #161E2E (Slate Ink), accent: #6366F1 (Focus Indigo), muted: #64748B (Hour-Axis Gray)\nTypography: Display=\"Inter\", Body=\"Inter\", Mono=\"JetBrains Mono\"\nLayout: Fixed hour gutter + 5-day CSS Grid columns on desktop; compact Mon–Fri day-pill switcher + single full-width day timeline on <=768px.\nInteractions: Click any empty hour slot to create a time block; click any existing block to edit its title, category color, duration (30m/60m/90m/120m), or delete it while live Focus vs. Meeting meters recalculate.\nMobile: Automatically collapses the 5-day grid into a single-day timeline with large Mon–Fri day selector pills so event titles remain completely readable at 390px.\n\nGuardrails:\n- DO: Collapse multi-day calendar grids to a single-day view with day selector pills below 768px.\n- DO: Use distinct category colors paired with category labels for Deep Work, Meetings, and Admin.\n- DO: Recalculate daily/weekly time budget meters immediately on block edits.\n- DON'T: Never cram 5 or 7 vertical day columns onto a 390px mobile screen.\n- DON'T: Avoid requiring precise pixel-edge dragging as the only way to resize a block's duration.",
  "sourceCode": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>Solstice — Time-Block Studio Calendar</title>\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link href=\"https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400..700;1,9..40,400&family=Instrument+Serif:ital@0;1&display=swap\" rel=\"stylesheet\">\n<style>\n  :root {\n    --bg: #f6f4ef;\n    --surface: #ffffff;\n    --surface-2: #fbfaf7;\n    --border: #e5e0d6;\n    --border-soft: #efeae1;\n    --ink: #1e2124;\n    --muted: #666c75;\n    --focus: #2a6f5e;\n    --focus-bg: #e4f2ed;\n    --focus-bd: #8ec5b5;\n    --meeting: #c86432;\n    --meeting-bg: #fcece4;\n    --meeting-bd: #e8a787;\n    --admin: #4f5f8f;\n    --admin-bg: #eaeef8;\n    --admin-bd: #9fb0db;\n    --personal: #8e527d;\n    --personal-bg: #f5eaf2;\n    --personal-bd: #cea2c2;\n    --radius: 12px;\n    --hour-h: 58px;\n  }\n  * { box-sizing: border-box; margin: 0; padding: 0; }\n  html, body { height: 100%; overflow-x: hidden; }\n  body {\n    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;\n    background: var(--bg);\n    color: var(--ink);\n    line-height: 1.4;\n    -webkit-font-smoothing: antialiased;\n  }\n  .app {\n    max-width: 1280px;\n    margin: 0 auto;\n    padding: 16px 20px 28px;\n    display: flex;\n    flex-direction: column;\n    gap: 14px;\n  }\n  header.topbar {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    justify-content: space-between;\n    gap: 12px;\n    background: var(--surface);\n    border: 1px solid var(--border);\n    border-radius: 16px;\n    padding: 14px 18px;\n    box-shadow: 0 2px 10px rgba(30, 33, 36, 0.04);\n  }\n  .brand {\n    display: flex;\n    align-items: center;\n    gap: 12px;\n  }\n  .brand-mark {\n    width: 38px;\n    height: 38px;\n    border-radius: 10px;\n    background: linear-gradient(135deg, #2a6f5e, #489782);\n    display: grid;\n    place-items: center;\n    color: #fff;\n    font-family: 'Instrument Serif', Georgia, serif;\n    font-size: 22px;\n    flex-shrink: 0;\n  }\n  .brand h1 {\n    font-family: 'Instrument Serif', Georgia, serif;\n    font-weight: 400;\n    font-size: 24px;\n    letter-spacing: -0.01em;\n    line-height: 1.1;\n  }\n  .brand p {\n    font-size: 12.5px;\n    color: var(--muted);\n  }\n  .meter-wrap {\n    display: flex;\n    align-items: center;\n    gap: 16px;\n    flex-wrap: wrap;\n  }\n  .meter-box {\n    min-width: 240px;\n    background: var(--surface-2);\n    border: 1px solid var(--border);\n    border-radius: 12px;\n    padding: 8px 12px;\n  }\n  .meter-labels {\n    display: flex;\n    justify-content: space-between;\n    font-size: 12px;\n    font-weight: 600;\n    margin-bottom: 6px;\n    gap: 10px;\n  }\n  .meter-labels .f { color: var(--focus); }\n  .meter-labels .m { color: var(--meeting); }\n  .meter-labels .o { color: var(--admin); }\n  .meter-bar {\n    height: 8px;\n    border-radius: 99px;\n    background: var(--border-soft);\n    overflow: hidden;\n    display: flex;\n  }\n  .meter-seg { height: 100%; transition: width 0.25s ease; }\n  .meter-seg.focus { background: var(--focus); }\n  .meter-seg.meeting { background: var(--meeting); }\n  .meter-seg.other { background: var(--admin); }\n  .header-actions {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n  }\n  .btn {\n    min-height: 44px;\n    padding: 0 14px;\n    border-radius: 10px;\n    border: 1px solid var(--border);\n    background: var(--surface);\n    color: var(--ink);\n    font: inherit;\n    font-size: 13.5px;\n    font-weight: 600;\n    cursor: pointer;\n    display: inline-flex;\n    align-items: center;\n    gap: 6px;\n    transition: background 0.15s, border-color 0.15s, transform 0.1s;\n  }\n  .btn:hover { background: var(--surface-2); border-color: #cfc8ba; }\n  .btn:active { transform: scale(0.98); }\n  .btn-primary {\n    background: var(--ink);\n    color: #fff;\n    border-color: var(--ink);\n  }\n  .btn-primary:hover { background: #30353a; border-color: #30353a; }\n  .btn-danger {\n    color: #b42318;\n    border-color: #f0c2be;\n    background: #fff5f4;\n  }\n  .btn-danger:hover { background: #fde6e4; }\n\n  .toolbar {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    justify-content: space-between;\n    gap: 10px;\n  }\n  .legend {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 8px;\n  }\n  .chip {\n    display: inline-flex;\n    align-items: center;\n    gap: 6px;\n    font-size: 12.5px;\n    font-weight: 500;\n    padding: 6px 11px;\n    border-radius: 99px;\n    background: var(--surface);\n    border: 1px solid var(--border);\n    cursor: pointer;\n    min-height: 36px;\n    transition: all 0.15s;\n  }\n  .chip.active {\n    background: var(--ink);\n    color: #fff;\n    border-color: var(--ink);\n  }\n  .dot {\n    width: 9px;\n    height: 9px;\n    border-radius: 50%;\n    flex-shrink: 0;\n  }\n  .hint {\n    font-size: 12.5px;\n    color: var(--muted);\n  }\n\n  /* Mobile day switcher */\n  .day-switcher {\n    display: none;\n    grid-template-columns: repeat(5, 1fr);\n    gap: 6px;\n    background: var(--surface);\n    border: 1px solid var(--border);\n    border-radius: 14px;\n    padding: 6px;\n  }\n  .day-tab {\n    min-height: 48px;\n    border: none;\n    background: transparent;\n    border-radius: 10px;\n    font: inherit;\n    color: var(--muted);\n    cursor: pointer;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    justify-content: center;\n    gap: 2px;\n    transition: background 0.15s, color 0.15s;\n  }\n  .day-tab strong { font-size: 14px; color: var(--ink); }\n  .day-tab span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }\n  .day-tab.active {\n    background: var(--ink);\n    color: #fff;\n  }\n  .day-tab.active strong { color: #fff; }\n\n  /* Calendar board */\n  .board {\n    background: var(--surface);\n    border: 1px solid var(--border);\n    border-radius: 16px;\n    overflow: hidden;\n    box-shadow: 0 4px 18px rgba(30, 33, 36, 0.04);\n  }\n  .board-head {\n    display: grid;\n    grid-template-columns: 64px repeat(5, 1fr);\n    border-bottom: 1px solid var(--border);\n    background: var(--surface-2);\n  }\n  .tz-cell {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    font-size: 11px;\n    font-weight: 600;\n    color: var(--muted);\n    border-right: 1px solid var(--border-soft);\n    padding: 10px 4px;\n  }\n  .day-head {\n    padding: 10px 12px;\n    border-right: 1px solid var(--border-soft);\n    display: flex;\n    align-items: baseline;\n    justify-content: space-between;\n  }\n  .day-head:last-child { border-right: none; }\n  .day-head .dow {\n    font-size: 12px;\n    text-transform: uppercase;\n    letter-spacing: 0.05em;\n    color: var(--muted);\n    font-weight: 600;\n  }\n  .day-head .num {\n    font-size: 18px;\n    font-weight: 700;\n    margin-left: 6px;\n  }\n  .day-head.today .num {\n    background: var(--focus);\n    color: #fff;\n    padding: 1px 8px;\n    border-radius: 99px;\n    font-size: 15px;\n  }\n  .day-head .day-hrs {\n    font-size: 11.5px;\n    color: var(--muted);\n    font-variant-numeric: tabular-nums;\n  }\n\n  .board-body {\n    display: grid;\n    grid-template-columns: 64px repeat(5, 1fr);\n    position: relative;\n  }\n  .time-col {\n    border-right: 1px solid var(--border-soft);\n    background: var(--surface-2);\n  }\n  .time-label {\n    height: var(--hour-h);\n    padding: 4px 8px 0 0;\n    text-align: right;\n    font-size: 11px;\n    color: var(--muted);\n    font-variant-numeric: tabular-nums;\n    border-bottom: 1px solid var(--border-soft);\n  }\n  .day-col {\n    position: relative;\n    border-right: 1px solid var(--border-soft);\n    min-height: calc(var(--hour-h) * 10);\n  }\n  .day-col:last-child { border-right: none; }\n  .slot {\n    height: var(--hour-h);\n    border-bottom: 1px solid var(--border-soft);\n    cursor: pointer;\n    position: relative;\n    transition: background 0.12s;\n  }\n  .slot::after {\n    content: \"\";\n    position: absolute;\n    left: 0; right: 0; top: 50%;\n    border-top: 1px dashed #f1ede6;\n    pointer-events: none;\n  }\n  .slot:hover { background: #f8f6f0; }\n  .slot:hover::before {\n    content: \"+ Add block\";\n    position: absolute;\n    right: 8px;\n    top: 6px;\n    font-size: 11px;\n    color: var(--muted);\n    font-weight: 500;\n  }\n\n  .now-line {\n    position: absolute;\n    left: 0;\n    right: 0;\n    height: 2px;\n    background: #d9483b;\n    z-index: 4;\n    pointer-events: none;\n  }\n  .now-line::before {\n    content: \"\";\n    position: absolute;\n    left: -4px;\n    top: -3px;\n    width: 8px;\n    height: 8px;\n    border-radius: 50%;\n    background: #d9483b;\n  }\n\n  .block {\n    position: absolute;\n    left: 5px;\n    right: 5px;\n    border-radius: 10px;\n    padding: 6px 9px;\n    border: 1px solid transparent;\n    border-left-width: 4px;\n    cursor: pointer;\n    overflow: hidden;\n    z-index: 3;\n    display: flex;\n    flex-direction: column;\n    gap: 2px;\n    transition: box-shadow 0.15s, transform 0.12s, opacity 0.15s;\n    user-select: none;\n  }\n  .block:hover {\n    box-shadow: 0 6px 16px rgba(30, 33, 36, 0.12);\n    z-index: 5;\n  }\n  .block.dimmed { opacity: 0.24; }\n  .block.focus { background: var(--focus-bg); border-color: var(--focus-bd); border-left-color: var(--focus); color: #164439; }\n  .block.meeting { background: var(--meeting-bg); border-color: var(--meeting-bd); border-left-color: var(--meeting); color: #6e3113; }\n  .block.admin { background: var(--admin-bg); border-color: var(--admin-bd); border-left-color: var(--admin); color: #243055; }\n  .block.personal { background: var(--personal-bg); border-color: var(--personal-bd); border-left-color: var(--personal); color: #522847; }\n  .block-title {\n    font-size: 12.5px;\n    font-weight: 700;\n    line-height: 1.2;\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n  }\n  .block-meta {\n    font-size: 11px;\n    opacity: 0.82;\n    font-variant-numeric: tabular-nums;\n    display: flex;\n    justify-content: space-between;\n    gap: 4px;\n  }\n  .block-tag {\n    font-size: 10px;\n    font-weight: 600;\n    text-transform: uppercase;\n    letter-spacing: 0.04em;\n    opacity: 0.78;\n  }\n  .resize-handle {\n    position: absolute;\n    left: 10px;\n    right: 10px;\n    bottom: 2px;\n    height: 10px;\n    cursor: ns-resize;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n  }\n  .resize-handle::after {\n    content: \"\";\n    width: 24px;\n    height: 3px;\n    border-radius: 99px;\n    background: currentColor;\n    opacity: 0.3;\n  }\n\n  /* Modal */\n  .modal-backdrop {\n    position: fixed;\n    inset: 0;\n    background: rgba(20, 22, 26, 0.45);\n    backdrop-filter: blur(3px);\n    display: none;\n    align-items: center;\n    justify-content: center;\n    padding: 16px;\n    z-index: 50;\n  }\n  .modal-backdrop.open { display: flex; }\n  .modal {\n    width: 100%;\n    max-width: 420px;\n    background: var(--surface);\n    border: 1px solid var(--border);\n    border-radius: 18px;\n    padding: 20px;\n    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);\n    display: flex;\n    flex-direction: column;\n    gap: 14px;\n  }\n  .modal-header {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n  }\n  .modal-header h2 {\n    font-family: 'Instrument Serif', Georgia, serif;\n    font-weight: 400;\n    font-size: 24px;\n  }\n  .icon-btn {\n    width: 44px;\n    height: 44px;\n    border-radius: 10px;\n    border: 1px solid var(--border);\n    background: var(--surface-2);\n    font-size: 18px;\n    cursor: pointer;\n    color: var(--ink);\n  }\n  .field { display: flex; flex-direction: column; gap: 6px; }\n  .field label {\n    font-size: 12px;\n    font-weight: 600;\n    color: var(--muted);\n    text-transform: uppercase;\n    letter-spacing: 0.04em;\n  }\n  .field input, .field select {\n    min-height: 44px;\n    padding: 0 12px;\n    border-radius: 10px;\n    border: 1px solid var(--border);\n    font: inherit;\n    font-size: 14px;\n    background: var(--surface-2);\n    color: var(--ink);\n  }\n  .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }\n  .cat-picker {\n    display: grid;\n    grid-template-columns: repeat(2, 1fr);\n    gap: 8px;\n  }\n  .cat-opt {\n    min-height: 44px;\n    border-radius: 10px;\n    border: 1.5px solid var(--border);\n    background: var(--surface);\n    font: inherit;\n    font-size: 13px;\n    font-weight: 600;\n    cursor: pointer;\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    padding: 0 12px;\n    color: var(--ink);\n  }\n  .cat-opt.selected { border-color: var(--ink); background: var(--surface-2); }\n  .modal-footer {\n    display: flex;\n    justify-content: space-between;\n    align-items: center;\n    gap: 10px;\n    margin-top: 4px;\n  }\n  .modal-footer .right { display: flex; gap: 8px; margin-left: auto; }\n\n  @media (max-width: 820px) {\n    .app { padding: 12px 12px 24px; }\n    header.topbar { padding: 12px 14px; }\n    .meter-box { width: 100%; min-width: 0; }\n    .day-switcher { display: grid; }\n    .board-head { grid-template-columns: 52px 1fr; }\n    .board-body { grid-template-columns: 52px 1fr; }\n    .day-head:not(.mobile-active),\n    .day-col:not(.mobile-active) { display: none; }\n    .hint { display: none; }\n  }\n</style>\n</head>\n<body>\n<div class=\"app\">\n  <header class=\"topbar\">\n    <div class=\"brand\">\n      <div class=\"brand-mark\">S</div>\n      <div>\n        <h1>Solstice Studio</h1>\n        <p>Week of May 11 – 15 · Product Design Sprint</p>\n      </div>\n    </div>\n    <div class=\"meter-wrap\">\n      <div class=\"meter-box\" aria-live=\"polite\">\n        <div class=\"meter-labels\">\n          <span class=\"f\" id=\"focusStat\">Focus 0h</span>\n          <span class=\"m\" id=\"meetingStat\">Meetings 0h</span>\n          <span class=\"o\" id=\"otherStat\">Other 0h</span>\n        </div>\n        <div class=\"meter-bar\">\n          <div class=\"meter-seg focus\" id=\"barFocus\" style=\"width:0%\"></div>\n          <div class=\"meter-seg meeting\" id=\"barMeeting\" style=\"width:0%\"></div>\n          <div class=\"meter-seg other\" id=\"barOther\" style=\"width:0%\"></div>\n        </div>\n      </div>\n      <div class=\"header-actions\">\n        <button class=\"btn\" id=\"autoProtectBtn\" title=\"Add morning focus blocks to open days\">Protect Focus</button>\n        <button class=\"btn btn-primary\" id=\"newBlockBtn\">+ New Block</button>\n      </div>\n    </div>\n  </header>\n\n  <div class=\"toolbar\">\n    <div class=\"legend\" id=\"filterBar\">\n      <button class=\"chip active\" data-filter=\"all\">All Blocks</button>\n      <button class=\"chip\" data-filter=\"focus\"><span class=\"dot\" style=\"background:var(--focus)\"></span>Deep Focus</button>\n      <button class=\"chip\" data-filter=\"meeting\"><span class=\"dot\" style=\"background:var(--meeting)\"></span>Meetings</button>\n      <button class=\"chip\" data-filter=\"admin\"><span class=\"dot\" style=\"background:var(--admin)\"></span>Ops &amp; Review</button>\n      <button class=\"chip\" data-filter=\"personal\"><span class=\"dot\" style=\"background:var(--personal)\"></span>Recharge</button>\n    </div>\n    <div class=\"hint\">Click any open hour to add · Click a block to edit · Drag bottom edge to resize</div>\n  </div>\n\n  <div class=\"day-switcher\" id=\"daySwitcher\" role=\"tablist\" aria-label=\"Select day\"></div>\n\n  <section class=\"board\" aria-label=\"Weekly time-block calendar\">\n    <div class=\"board-head\" id=\"boardHead\"></div>\n    <div class=\"board-body\" id=\"boardBody\"></div>\n  </section>\n</div>\n\n<div class=\"modal-backdrop\" id=\"modalBackdrop\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"modalTitle\">\n  <form class=\"modal\" id=\"blockForm\">\n    <div class=\"modal-header\">\n      <h2 id=\"modalTitle\">Edit Time Block</h2>\n      <button type=\"button\" class=\"icon-btn\" id=\"closeModalBtn\" aria-label=\"Close\">&times;</button>\n    </div>\n    <div class=\"field\">\n      <label for=\"fTitle\">Block Title</label>\n      <input id=\"fTitle\" type=\"text\" required placeholder=\"e.g., Design system audit\">\n    </div>\n    <div class=\"row-2\">\n      <div class=\"field\">\n        <label for=\"fDay\">Day</label>\n        <select id=\"fDay\"></select>\n      </div>\n      <div class=\"field\">\n        <label for=\"fStart\">Start Time</label>\n        <select id=\"fStart\"></select>\n      </div>\n    </div>\n    <div class=\"row-2\">\n      <div class=\"field\">\n        <label for=\"fDuration\">Duration</label>\n        <select id=\"fDuration\">\n          <option value=\"0.5\">30 minutes</option>\n          <option value=\"1\">1 hour</option>\n          <option value=\"1.5\">1.5 hours</option>\n          <option value=\"2\">2 hours</option>\n          <option value=\"2.5\">2.5 hours</option>\n          <option value=\"3\">3 hours</option>\n        </select>\n      </div>\n      <div class=\"field\">\n        <label for=\"fNote\">Context / Location</label>\n        <input id=\"fNote\" type=\"text\" placeholder=\"Studio A, Figma, Zoom...\">\n      </div>\n    </div>\n    <div class=\"field\">\n      <label>Category</label>\n      <div class=\"cat-picker\" id=\"catPicker\">\n        <button type=\"button\" class=\"cat-opt\" data-cat=\"focus\"><span class=\"dot\" style=\"background:var(--focus)\"></span>Deep Focus</button>\n        <button type=\"button\" class=\"cat-opt\" data-cat=\"meeting\"><span class=\"dot\" style=\"background:var(--meeting)\"></span>Meeting</button>\n        <button type=\"button\" class=\"cat-opt\" data-cat=\"admin\"><span class=\"dot\" style=\"background:var(--admin)\"></span>Ops &amp; Review</button>\n        <button type=\"button\" class=\"cat-opt\" data-cat=\"personal\"><span class=\"dot\" style=\"background:var(--personal)\"></span>Recharge</button>\n      </div>\n    </div>\n    <div class=\"modal-footer\">\n      <button type=\"button\" class=\"btn btn-danger\" id=\"deleteBtn\">Delete</button>\n      <div class=\"right\">\n        <button type=\"button\" class=\"btn\" id=\"cancelBtn\">Cancel</button>\n        <button type=\"submit\" class=\"btn btn-primary\">Save Block</button>\n      </div>\n    </div>\n  </form>\n</div>\n\n<script>\n(() => {\n  const DAYS = [\n    { id: 0, short: 'Mon', label: 'Monday', date: 11 },\n    { id: 1, short: 'Tue', label: 'Tuesday', date: 12, today: true },\n    { id: 2, short: 'Wed', label: 'Wednesday', date: 13 },\n    { id: 3, short: 'Thu', label: 'Thursday', date: 14 },\n    { id: 4, short: 'Fri', label: 'Friday', date: 15 }\n  ];\n  const START_HOUR = 8;\n  const END_HOUR = 18;\n  const HOUR_H = 58;\n  const CAT_LABELS = { focus: 'Focus', meeting: 'Meeting', admin: 'Ops', personal: 'Recharge' };\n\n  let nextId = 100;\n  let blocks = [\n    { id: 1, day: 0, start: 8.5, duration: 2, title: 'Onboarding Flow Wireframes', cat: 'focus', note: 'Figma · Quiet mode' },\n    { id: 2, day: 0, start: 11, duration: 1, title: 'Sprint Kickoff Sync', cat: 'meeting', note: 'Room 4B / Meet' },\n    { id: 3, day: 0, start: 13.5, duration: 1.5, title: 'Token Architecture Spec', cat: 'focus', note: 'Notion' },\n    { id: 4, day: 0, start: 16, duration: 1, title: 'PR & Copy Triage', cat: 'admin', note: 'GitHub' },\n\n    { id: 5, day: 1, start: 8.5, duration: 2.5, title: 'Interactive Prototype Build', cat: 'focus', note: 'No Slack' },\n    { id: 6, day: 1, start: 11.5, duration: 1, title: 'Design Critique', cat: 'meeting', note: 'Core Product' },\n    { id: 7, day: 1, start: 13, duration: 0.5, title: 'Walk + Espresso', cat: 'personal', note: 'Away from desk' },\n    { id: 8, day: 1, start: 14, duration: 1.5, title: 'Customer Interview #4', cat: 'meeting', note: 'Dovetail' },\n    { id: 9, day: 1, start: 16, duration: 1, title: 'Synthesis Notes', cat: 'admin', note: 'Linear' },\n\n    { id: 10, day: 2, start: 9, duration: 2.5, title: 'Responsive Grid Refactor', cat: 'focus', note: 'Deep Work' },\n    { id: 11, day: 2, start: 13, duration: 1, title: 'Eng Handoff Pairing', cat: 'meeting', note: 'With Priya' },\n    { id: 12, day: 2, start: 15, duration: 2, title: 'Accessibility Contrast Audit', cat: 'focus', note: 'WCAG AA' },\n\n    { id: 13, day: 3, start: 9.5, duration: 1, title: 'Roadmap Check-in', cat: 'meeting', note: 'Product Leads' },\n    { id: 14, day: 3, start: 11, duration: 2, title: 'Motion Timing Curves', cat: 'focus', note: 'Rive + CSS' },\n    { id: 15, day: 3, start: 14.5, duration: 1, title: 'Analytics Funnel Review', cat: 'admin', note: 'PostHog' },\n    { id: 16, day: 3, start: 16, duration: 1, title: '1:1 with Elena', cat: 'meeting', note: 'Coffee walk' },\n\n    { id: 17, day: 4, start: 8.5, duration: 2, title: 'Component QA Polish', cat: 'focus', note: 'Storybook' },\n    { id: 18, day: 4, start: 11.5, duration: 1, title: 'Weekly Demo Showcase', cat: 'meeting', note: 'All-hands' },\n    { id: 19, day: 4, start: 14, duration: 1, title: 'Inbox Zero & Next Week', cat: 'admin', note: 'Planning' },\n    { id: 20, day: 4, start: 15.5, duration: 1, title: 'Gym / Reset', cat: 'personal', note: 'Off early' }\n  ];\n\n  let activeDay = 1;\n  let activeFilter = 'all';\n  let editingId = null;\n  let selectedCat = 'focus';\n\n  const boardHead = document.getElementById('boardHead');\n  const boardBody = document.getElementById('boardBody');\n  const daySwitcher = document.getElementById('daySwitcher');\n  const modalBackdrop = document.getElementById('modalBackdrop');\n  const blockForm = document.getElementById('blockForm');\n  const fTitle = document.getElementById('fTitle');\n  const fDay = document.getElementById('fDay');\n  const fStart = document.getElementById('fStart');\n  const fDuration = document.getElementById('fDuration');\n  const fNote = document.getElementById('fNote');\n  const deleteBtn = document.getElementById('deleteBtn');\n  const modalTitle = document.getElementById('modalTitle');\n\n  function fmtHour(h) {\n    const whole = Math.floor(h);\n    const mins = (h % 1) ? '30' : '00';\n    const suffix = whole >= 12 ? 'PM' : 'AM';\n    const hr12 = whole > 12 ? whole - 12 : (whole === 0 ? 12 : whole);\n    return `${hr12}:${mins} ${suffix}`;\n  }\n  function fmtShort(h) {\n    const whole = Math.floor(h);\n    const mins = (h % 1) ? ':30' : '';\n    const hr12 = whole > 12 ? whole - 12 : whole;\n    return `${hr12}${mins}${whole >= 12 ? 'p' : 'a'}`;\n  }\n\n  // Populate modal selects\n  DAYS.forEach(d => {\n    const opt = document.createElement('option');\n    opt.value = d.id;\n    opt.textContent = `${d.label}, May ${d.date}`;\n    fDay.appendChild(opt);\n  });\n  for (let h = START_HOUR; h < END_HOUR; h += 0.5) {\n    const opt = document.createElement('option');\n    opt.value = h;\n    opt.textContent = fmtHour(h);\n    fStart.appendChild(opt);\n  }\n\n  function updateMeters() {\n    let focus = 0, meeting = 0, other = 0;\n    blocks.forEach(b => {\n      if (b.cat === 'focus') focus += b.duration;\n      else if (b.cat === 'meeting') meeting += b.duration;\n      else other += b.duration;\n    });\n    const total = Math.max(focus + meeting + other, 0.1);\n    document.getElementById('focusStat').textContent = `Focus ${focus}h`;\n    document.getElementById('meetingStat').textContent = `Meetings ${meeting}h`;\n    document.getElementById('otherStat').textContent = `Other ${other}h`;\n    document.getElementById('barFocus').style.width = `${(focus / total) * 100}%`;\n    document.getElementById('barMeeting').style.width = `${(meeting / total) * 100}%`;\n    document.getElementById('barOther').style.width = `${(other / total) * 100}%`;\n  }\n\n  function renderSwitcher() {\n    daySwitcher.innerHTML = '';\n    DAYS.forEach(d => {\n      const btn = document.createElement('button');\n      btn.type = 'button';\n      btn.className = 'day-tab' + (d.id === activeDay ? ' active' : '');\n      btn.setAttribute('role', 'tab');\n      btn.setAttribute('aria-selected', d.id === activeDay ? 'true' : 'false');\n      btn.innerHTML = `<span>${d.short}</span><strong>${d.date}</strong>`;\n      btn.addEventListener('click', () => {\n        activeDay = d.id;\n        render();\n      });\n      daySwitcher.appendChild(btn);\n    });\n  }\n\n  function render() {\n    renderSwitcher();\n    updateMeters();\n\n    // Head\n    boardHead.innerHTML = '<div class=\"tz-cell\">PDT</div>';\n    DAYS.forEach(d => {\n      const hrs = blocks.filter(b => b.day === d.id).reduce((s, b) => s + b.duration, 0);\n      const cell = document.createElement('div');\n      cell.className = `day-head${d.today ? ' today' : ''}${d.id === activeDay ? ' mobile-active' : ''}`;\n      cell.innerHTML = `<div><span class=\"dow\">${d.short}</span><span class=\"num\">${d.date}</span></div><span class=\"day-hrs\">${hrs}h</span>`;\n      boardHead.appendChild(cell);\n    });\n\n    // Body\n    boardBody.innerHTML = '';\n    const timeCol = document.createElement('div');\n    timeCol.className = 'time-col';\n    for (let h = START_HOUR; h < END_HOUR; h++) {\n      const lbl = document.createElement('div');\n      lbl.className = 'time-label';\n      lbl.textContent = `${h > 12 ? h - 12 : h} ${h >= 12 ? 'PM' : 'AM'}`;\n      timeCol.appendChild(lbl);\n    }\n    boardBody.appendChild(timeCol);\n\n    DAYS.forEach(d => {\n      const col = document.createElement('div');\n      col.className = `day-col${d.id === activeDay ? ' mobile-active' : ''}`;\n      col.dataset.day = d.id;\n\n      for (let h = START_HOUR; h < END_HOUR; h++) {\n        const slot = document.createElement('div');\n        slot.className = 'slot';\n        slot.addEventListener('click', () => openModal(null, { day: d.id, start: h }));\n        col.appendChild(slot);\n      }\n\n      if (d.today) {\n        const nowLine = document.createElement('div');\n        nowLine.className = 'now-line';\n        nowLine.style.top = `${(11.25 - START_HOUR) * HOUR_H}px`;\n        col.appendChild(nowLine);\n      }\n\n      blocks.filter(b => b.day === d.id).forEach(b => {\n        const el = document.createElement('div');\n        const dimmed = activeFilter !== 'all' && b.cat !== activeFilter;\n        el.className = `block ${b.cat}${dimmed ? ' dimmed' : ''}`;\n        el.style.top = `${(b.start - START_HOUR) * HOUR_H + 2}px`;\n        el.style.height = `${Math.max(b.duration * HOUR_H - 4, 28)}px`;\n        el.innerHTML = `\n          <div class=\"block-title\">${escapeHtml(b.title)}</div>\n          <div class=\"block-meta\">\n            <span>${fmtShort(b.start)}–${fmtShort(b.start + b.duration)}${b.note ? ' · ' + escapeHtml(b.note) : ''}</span>\n            <span class=\"block-tag\">${CAT_LABELS[b.cat]}</span>\n          </div>\n          <div class=\"resize-handle\" title=\"Drag to resize\"></div>\n        `;\n        el.addEventListener('click', (e) => {\n          if (e.target.classList.contains('resize-handle')) return;\n          e.stopPropagation();\n          openModal(b);\n        });\n\n        const handle = el.querySelector('.resize-handle');\n        handle.addEventListener('pointerdown', (e) => {\n          e.stopPropagation();\n          e.preventDefault();\n          const startY = e.clientY;\n          const origDur = b.duration;\n          handle.setPointerCapture(e.pointerId);\n          const onMove = (ev) => {\n            const deltaHrs = Math.round(((ev.clientY - startY) / HOUR_H) * 2) / 2;\n            const maxDur = END_HOUR - b.start;\n            b.duration = Math.max(0.5, Math.min(maxDur, origDur + deltaHrs));\n            el.style.height = `${Math.max(b.duration * HOUR_H - 4, 28)}px`;\n            el.querySelector('.block-meta span').textContent = `${fmtShort(b.start)}–${fmtShort(b.start + b.duration)}${b.note ? ' · ' + b.note : ''}`;\n            updateMeters();\n          };\n          const onUp = () => {\n            handle.removeEventListener('pointermove', onMove);\n            handle.removeEventListener('pointerup', onUp);\n            render();\n          };\n          handle.addEventListener('pointermove', onMove);\n          handle.addEventListener('pointerup', onUp);\n        });\n\n        col.appendChild(el);\n      });\n\n      boardBody.appendChild(col);\n    });\n  }\n\n  function escapeHtml(str) {\n    return str.replace(/[&<>\"']/g, c => ({ '&':'&amp;','<':'&lt;','>':'&gt;','\"':'&quot;',\"'\":'&#39;' }[c]));\n  }\n\n  function setCategory(cat) {\n    selectedCat = cat;\n    document.querySelectorAll('.cat-opt').forEach(btn => {\n      btn.classList.toggle('selected', btn.dataset.cat === cat);\n    });\n  }\n\n  function openModal(block, defaults = {}) {\n    if (block) {\n      editingId = block.id;\n      modalTitle.textContent = 'Edit Time Block';\n      fTitle.value = block.title;\n      fDay.value = block.day;\n      fStart.value = block.start;\n      fDuration.value = block.duration;\n      fNote.value = block.note || '';\n      setCategory(block.cat);\n      deleteBtn.style.display = 'inline-flex';\n    } else {\n      editingId = null;\n      modalTitle.textContent = 'New Time Block';\n      fTitle.value = '';\n      fDay.value = defaults.day ?? activeDay;\n      fStart.value = defaults.start ?? 9;\n      fDuration.value = 1;\n      fNote.value = '';\n      setCategory('focus');\n      deleteBtn.style.display = 'none';\n    }\n    modalBackdrop.classList.add('open');\n    setTimeout(() => fTitle.focus(), 40);\n  }\n\n  function closeModal() {\n    modalBackdrop.classList.remove('open');\n  }\n\n  document.getElementById('catPicker').addEventListener('click', (e) => {\n    const btn = e.target.closest('.cat-opt');\n    if (btn) setCategory(btn.dataset.cat);\n  });\n\n  blockForm.addEventListener('submit', (e) => {\n    e.preventDefault();\n    const start = parseFloat(fStart.value);\n    const dur = Math.min(parseFloat(fDuration.value), END_HOUR - start);\n    const payload = {\n      title: fTitle.value.trim() || 'Untitled Block',\n      day: parseInt(fDay.value, 10),\n      start,\n      duration: Math.max(0.5, dur),\n      cat: selectedCat,\n      note: fNote.value.trim()\n    };\n    if (editingId) {\n      const idx = blocks.findIndex(b => b.id === editingId);\n      if (idx > -1) blocks[idx] = { ...blocks[idx], ...payload };\n    } else {\n      blocks.push({ id: ++nextId, ...payload });\n      activeDay = payload.day;\n    }\n    closeModal();\n    render();\n  });\n\n  deleteBtn.addEventListener('click', () => {\n    if (editingId) {\n      blocks = blocks.filter(b => b.id !== editingId);\n      closeModal();\n      render();\n    }\n  });\n\n  document.getElementById('newBlockBtn').addEventListener('click', () => openModal(null));\n  document.getElementById('closeModalBtn').addEventListener('click', closeModal);\n  document.getElementById('cancelBtn').addEventListener('click', closeModal);\n  modalBackdrop.addEventListener('click', (e) => { if (e.target === modalBackdrop) closeModal(); });\n  document.addEventListener('keydown', (e) => { if (e.key === 'Escape') closeModal(); });\n\n  document.getElementById('filterBar').addEventListener('click', (e) => {\n    const chip = e.target.closest('.chip');\n    if (!chip) return;\n    activeFilter = chip.dataset.filter;\n    document.querySelectorAll('#filterBar .chip').forEach(c => c.classList.toggle('active', c === chip));\n    render();\n  });\n\n  document.getElementById('autoProtectBtn').addEventListener('click', () => {\n    let added = 0;\n    DAYS.forEach(d => {\n      const hasMorning = blocks.some(b => b.day === d.id && b.start < 9.5 && b.start + b.duration > 8);\n      if (!hasMorning) {\n        blocks.push({\n          id: ++nextId,\n          day: d.id,\n          start: 8,\n          duration: 1.5,\n          title: 'Protected Deep Focus',\n          cat: 'focus',\n          note: 'Auto-shielded'\n        });\n        added++;\n      }\n    });\n    if (added === 0) {\n      const openAfternoon = DAYS.find(d => !blocks.some(b => b.day === d.id && b.start < 15 && b.start + b.duration > 13.5));\n      if (openAfternoon) {\n        blocks.push({\n          id: ++nextId,\n          day: openAfternoon.id,\n          start: 13.5,\n          duration: 1.5,\n          title: 'Protected Deep Focus',\n          cat: 'focus',\n          note: 'Auto-shielded'\n        });\n      }\n    }\n    render();\n  });\n\n  render();\n})();\n</script>\n</body>\n</html>\n"
}
