  :root {
    color-scheme: dark;
    --bg: #0b0e13;
    --surface: #141820;
    --surface-2: #1b212b;
    --surface-3: #252d3a;
    --border: rgba(255, 255, 255, 0.12);
    --border-hover: rgba(255, 255, 255, 0.22);
    --text: #edf3fb;
    --muted: #9aa6b5;
    --accent: #4f9a94;
    --accent-strong: #3f817c;
    --accent-soft: rgba(79, 154, 148, 0.14);
    --accent-border: rgba(79, 154, 148, 0.34);
    --success: #20b486;
    --danger: #f05262;
    --warning: #eab308;
    --special: #d6b45f;
    --special-soft: rgba(214, 180, 95, 0.14);
    --special-border: rgba(214, 180, 95, 0.4);
    --radius: 8px;
    font-family: "Noto Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.light {
    color-scheme: light;
    --bg: #f5efe4;
    --surface: #fffaf1;
    --surface-2: #f7efdf;
    --surface-3: #efe4d0;
    --border: rgba(89, 67, 41, 0.14);
    --border-hover: rgba(89, 67, 41, 0.24);
    --text: #2f271d;
    --muted: #746653;
    --accent-soft: rgba(79, 154, 148, 0.1);
    --accent-border: rgba(79, 154, 148, 0.24);
  }

  * { box-sizing: border-box; letter-spacing: 0; }

  html { width: 100%; overflow-x: hidden; }

  body {
    min-height: 100vh;
    margin: 0;
    padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    transition: background 0.25s ease, color 0.25s ease;
  }

  button, input, textarea, select { font: inherit; }
  button { cursor: pointer; }
  button:active { transform: scale(0.98); }

  .top-projects {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto 12px;
    animation: fadeUp 0.35s ease both;
  }

  .top-projects-inner {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .top-project {
    min-width: 0;
    min-height: 48px;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 8px;
    text-align: left;
    text-decoration: none;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
    transition: 0.15s ease;
  }

  .top-project:hover {
    border-color: var(--accent-border);
    background: var(--surface-2);
    transform: translateY(-1px);
  }

  .top-project.active {
    border-color: var(--accent-border);
    background: var(--accent-soft);
  }

  .top-project.disabled {
    opacity: 0.72;
    border-style: dashed;
    cursor: not-allowed;
  }

  .top-project-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--accent);
    font-size: 1rem;
  }

  .top-project-text {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  .top-project-name {
    font-size: 0.78rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-project-desc {
    color: var(--muted);
    font-size: 0.64rem;
  }

  .top-project-pill {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    padding: 2px 7px;
    font-size: 0.62rem;
    font-weight: 700;
    white-space: nowrap;
  }

  .top-project.active .top-project-pill {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-soft);
  }

  .schedule-shell {
    width: 100%;
    max-width: 1760px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
    animation: fadeUp 0.35s ease both;
  }

  .side-panel {
    display: grid;
    gap: 10px;
    min-width: 0;
  }

  .card {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
  }

  .right-panel {
    align-content: start;
  }

  .right-panel .quick-add-panel {
    position: sticky;
    top: 12px;
    z-index: 8;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  }

  .clock-card { text-align: center; }

  #clock {
    font-family: "DM Mono", monospace;
    font-size: 2rem;
    font-weight: 500;
    line-height: 1;
    color: var(--accent);
  }

  #clockDate {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.7rem;
  }

  .day-nav, .cal-head, .schedule-header, .header-actions, .modal-actions, .progress-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .day-nav h1, .schedule-header h2, .summary-card h2, .focus-card h2, .quick-add-card h2, .quick-add-panel h3, .edit-box h2 {
    margin: 0;
    font-size: 1.05rem;
  }

  .eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  .btn, .theme-btn {
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    padding: 8px 12px;
    transition: 0.15s ease;
  }

  .nav-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    padding: 0;
    line-height: 1;
    display: inline-grid;
    place-items: center;
    font-weight: 700;
    transition: 0.15s ease;
  }

  .btn:hover, .theme-btn:hover, .nav-btn:hover {
    border-color: var(--accent-border);
    background: var(--surface-3);
  }

  .btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
  }

  .btn-primary:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
  }

  .btn-danger {
    color: var(--danger);
  }

  .date-input, .modal-input {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    padding: 7px 10px;
    outline: none;
  }

  .time-control {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 30px;
    gap: 5px;
    align-items: center;
  }

  .time-input {
    text-align: center;
    font-family: "DM Mono", monospace;
    font-weight: 700;
  }

  .time-step {
    width: 30px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    display: grid;
    place-items: center;
    padding: 0;
    font-weight: 800;
    transition: 0.15s ease;
  }

  .time-step:hover {
    border-color: var(--accent-border);
    background: var(--accent-soft);
    color: var(--accent);
  }

  .date-input:focus, .modal-input:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }

  textarea.modal-input {
    min-height: 86px;
    resize: vertical;
  }

  .today-btn {
    width: 100%;
    margin-top: 10px;
    min-height: 38px;
    border: 1px solid var(--accent-border);
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
  }

  .quick-add-card {
    display: grid;
    gap: 10px;
  }

  .cal-head {
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 700;
  }

  .cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
  }

  .day-name {
    padding-bottom: 6px;
    color: var(--muted);
    opacity: 0.78;
    font-size: 0.64rem;
    font-weight: 700;
  }

  .cal-day {
    position: relative;
    min-height: 32px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 0.78rem;
    cursor: pointer;
    transition: 0.15s ease;
  }

  .cal-day:hover {
    background: var(--surface-2);
    color: var(--accent);
  }

  .cal-day.holiday {
    color: var(--danger);
    font-weight: 800;
  }

  .cal-day.holiday:hover {
    color: var(--danger);
    background: rgba(240, 82, 98, 0.1);
  }

  .cal-day.special-day {
    color: var(--special);
    font-weight: 800;
  }

  .cal-day.special-day:hover {
    color: var(--special);
    background: var(--special-soft);
  }

  .cal-day.today {
    color: var(--accent);
    font-weight: 800;
  }

  .cal-day.today::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid var(--accent-border);
    border-radius: inherit;
  }

  .cal-day.today.holiday::before {
    border-color: rgba(240, 82, 98, 0.42);
  }

  .cal-day.today.special-day::before {
    border-color: var(--special-border);
  }

  .cal-day.selected {
    background: var(--accent);
    color: #ffffff;
    font-weight: 800;
  }

  .cal-day.selected.holiday {
    background: var(--danger);
    color: #ffffff;
  }

  .cal-day.selected.special-day {
    background: var(--special);
    color: #111318;
  }

  .cal-dots {
    position: absolute;
    left: 50%;
    bottom: 4px;
    display: flex;
    gap: 3px;
    transform: translateX(-50%);
    pointer-events: none;
  }

  .cal-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
  }

  .cal-dots .work { background: #4f9a94; }
  .cal-dots .study { background: #60a5fa; }
  .cal-dots .exercise { background: #22c55e; }
  .cal-dots .rest { background: #a78bfa; }
  .cal-dots .travel { background: #f59e0b; }
  .cal-dots .other { background: #94a3b8; }

  .field-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
  }

  .schedule-card {
    padding: 0;
    overflow: hidden;
  }

  .schedule-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .selected-date-line {
    margin-top: 5px;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
  }

  .now-jump-btn {
    color: var(--danger);
    border-color: rgba(240, 82, 98, 0.28);
    background: rgba(240, 82, 98, 0.08);
  }

  .now-jump-btn:hover {
    color: var(--danger);
    border-color: rgba(240, 82, 98, 0.48);
    background: rgba(240, 82, 98, 0.14);
  }

  .quick-add-panel {
    display: grid;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
  }

  .quick-add-title-row {
    display: grid;
    gap: 10px;
  }

  .duration-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }

  .duration-chip {
    min-height: 27px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    padding: 4px 9px;
    font-size: 0.68rem;
    font-weight: 700;
  }

  .duration-chip:hover,
  .duration-chip.active {
    border-color: var(--accent-border);
    background: var(--accent-soft);
    color: var(--accent);
  }

  .quick-add-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
  }

  .quick-field {
    display: grid;
    gap: 4px;
  }

  .add-wide {
    min-height: 36px;
  }

  .quick-tip {
    margin: 0;
    color: var(--muted);
    font-size: 0.68rem;
  }

  .conflict-warning {
    border: 1px solid rgba(234, 179, 8, 0.35);
    border-radius: var(--radius);
    background: rgba(234, 179, 8, 0.1);
    color: var(--warning);
    padding: 8px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.45;
  }

  .conflict-warning[hidden] {
    display: none;
  }

  .timeline-scroll {
    max-height: min(78vh, 940px);
    min-height: 650px;
    overflow-y: auto;
    border-bottom: 1px solid var(--border);
    scrollbar-color: var(--accent) var(--surface-2);
    scrollbar-width: thin;
  }

  .timeline-scroll::-webkit-scrollbar {
    width: 10px;
  }

  .timeline-scroll::-webkit-scrollbar-track {
    background: var(--surface-2);
  }

  .timeline-scroll::-webkit-scrollbar-thumb {
    border: 2px solid var(--surface-2);
    border-radius: 999px;
    background: var(--accent);
  }

  .timeline {
    --slot-height: 30px;
    --time-column: 72px;
    position: relative;
    display: grid;
    grid-template-columns: var(--time-column) minmax(0, 1fr);
    grid-template-rows: repeat(96, var(--slot-height));
    min-height: calc(96 * var(--slot-height));
  }

  .hour-label {
    grid-column: 1;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    color: var(--muted);
    font-family: "DM Mono", monospace;
    font-size: 0.82rem;
    line-height: 1;
  }

  .hour-band {
    grid-column: 2;
    border-bottom: 1px solid var(--border);
    pointer-events: none;
  }

  .now-line {
    position: absolute;
    left: var(--time-column);
    right: 0;
    height: 0;
    border-top: 2px solid var(--danger);
    pointer-events: none;
    z-index: 6;
    filter: drop-shadow(0 0 7px rgba(240, 82, 98, 0.45));
  }

  .now-line::before {
    content: "";
    position: absolute;
    left: -5px;
    top: -5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
  }

  .now-line-label {
    position: absolute;
    left: 8px;
    top: -18px;
    border: 1px solid rgba(240, 82, 98, 0.45);
    border-radius: 999px;
    background: var(--surface);
    color: var(--danger);
    padding: 1px 7px;
    font-family: "DM Mono", monospace;
    font-size: 0.68rem;
    font-weight: 800;
    white-space: nowrap;
  }

  .empty-slot-btn {
    grid-column: 2;
    align-self: stretch;
    min-height: 0;
    margin: 6px 10px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    text-align: left;
    padding: 8px 12px;
    opacity: 0;
    transition: 0.15s ease;
  }

  .empty-slot-btn:hover,
  .empty-slot-btn:focus {
    opacity: 1;
    border-color: var(--accent-border);
    color: var(--accent);
    background: var(--accent-soft);
  }

  .activity-card {
    --category-color: var(--accent);
    --category-soft: rgba(79, 154, 148, 0.18);
    grid-column: 2;
    z-index: 2;
    min-height: 0;
    margin: 4px 10px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--category-color);
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--category-soft), var(--surface-2));
    padding: 8px 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    overflow: hidden;
  }

  .activity-card.pulse {
    animation: focusPulse 0.9s ease;
  }

  .activity-card.is-long {
    align-content: start;
    border-left-width: 6px;
  }

  .activity-card.is-short {
    align-items: center;
    padding-block: 6px;
  }

  .activity-card[data-category="work"] { --category-color: #4f9a94; --category-soft: rgba(79, 154, 148, 0.2); }
  .activity-card[data-category="study"] { --category-color: #60a5fa; --category-soft: rgba(96, 165, 250, 0.18); }
  .activity-card[data-category="exercise"] { --category-color: #22c55e; --category-soft: rgba(34, 197, 94, 0.16); }
  .activity-card[data-category="rest"] { --category-color: #a78bfa; --category-soft: rgba(167, 139, 250, 0.16); }
  .activity-card[data-category="travel"] { --category-color: #f59e0b; --category-soft: rgba(245, 158, 11, 0.16); }
  .activity-card[data-category="other"] { --category-color: #94a3b8; --category-soft: rgba(148, 163, 184, 0.14); }

  .activity-card.done {
    opacity: 0.65;
    border-left-color: var(--success);
  }

  .activity-card.done .activity-title {
    text-decoration: line-through;
  }

  .activity-check {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border-hover);
    border-radius: 7px;
    background: var(--surface);
    color: transparent;
    display: grid;
    place-items: center;
    padding: 0;
    font-weight: 800;
  }

  .activity-card.done .activity-check {
    border-color: var(--success);
    background: rgba(32, 180, 134, 0.14);
    color: var(--success);
  }

  .activity-main {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  .activity-time {
    color: var(--category-color);
    font-family: "DM Mono", monospace;
    font-size: 0.72rem;
    font-weight: 700;
  }

  .activity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
  }

  .duration-pill {
    border: 1px solid color-mix(in srgb, var(--category-color) 55%, transparent);
    border-radius: 999px;
    background: var(--category-soft);
    color: var(--category-color);
    padding: 1px 6px;
    font-size: 0.64rem;
    font-weight: 800;
  }

  .category-pill {
    border: 1px solid color-mix(in srgb, var(--category-color) 45%, transparent);
    border-radius: 999px;
    color: var(--category-color);
    padding: 1px 6px;
    font-size: 0.64rem;
    font-weight: 800;
  }

  .resize-handle {
    position: absolute;
    left: 12px;
    right: 12px;
    height: 10px;
    border: 0;
    background: transparent;
    cursor: ns-resize;
    opacity: 0;
  }

  .resize-handle.top { top: 0; }
  .resize-handle.bottom { bottom: 0; }

  .activity-card:hover .resize-handle,
  .resize-handle:focus {
    opacity: 1;
  }

  .resize-handle::before {
    content: "";
    display: block;
    width: 42px;
    height: 3px;
    margin: 3px auto;
    border-radius: 999px;
    background: color-mix(in srgb, var(--category-color) 65%, transparent);
  }

  .activity-title {
    overflow-wrap: anywhere;
    line-height: 1.25;
    font-weight: 700;
  }

  .activity-card.is-short .activity-title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }

  .activity-actions {
    display: flex;
    gap: 5px;
  }

  .icon-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--muted);
    display: grid;
    place-items: center;
    padding: 0;
  }

  .icon-btn:hover {
    color: var(--accent);
    border-color: var(--accent-border);
  }

  .icon-btn.delete:hover {
    color: var(--danger);
    border-color: rgba(240, 82, 98, 0.35);
  }

  .empty-state {
    padding: 28px 18px;
    color: var(--muted);
    text-align: center;
  }

  .summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 8px 0;
  }

  .summary-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 8px 6px;
    text-align: center;
  }

  .summary-item span {
    display: block;
    color: var(--accent);
    font-weight: 800;
    font-size: 0.96rem;
  }

  .summary-item small {
    color: var(--muted);
    font-size: 0.62rem;
  }

  .progress-label {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.78rem;
  }

  .progress-wrap {
    height: 9px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
    margin-top: 8px;
  }

  .progress-bar {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--success));
    transition: width 0.2s ease;
  }

  .day-agenda-card {
    display: grid;
    gap: 10px;
  }

  .compact-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .compact-card-head h2 {
    margin: 0;
    font-size: 1.05rem;
  }

  .compact-card-head span {
    min-width: 26px;
    border: 1px solid var(--accent-border);
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 2px 8px;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 800;
  }

  .day-agenda-list {
    display: grid;
    gap: 6px;
    max-height: 230px;
    overflow-y: auto;
    padding-right: 2px;
  }

  .agenda-item {
    width: 100%;
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    padding: 8px;
    text-align: left;
  }

  .agenda-item:hover {
    border-color: var(--accent-border);
    background: var(--accent-soft);
  }

  .agenda-item.done {
    opacity: 0.62;
  }

  .agenda-item.done strong {
    text-decoration: line-through;
  }

  .agenda-dot {
    width: 8px;
    height: 28px;
    border-radius: 999px;
    background: var(--accent);
  }

  .agenda-dot.work { background: #4f9a94; }
  .agenda-dot.study { background: #60a5fa; }
  .agenda-dot.exercise { background: #22c55e; }
  .agenda-dot.rest { background: #a78bfa; }
  .agenda-dot.travel { background: #f59e0b; }
  .agenda-dot.other { background: #94a3b8; }

  .agenda-main {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  .agenda-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
  }

  .agenda-main small,
  .day-agenda-empty {
    color: var(--muted);
    font-size: 0.7rem;
  }

  .next-activity {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
  }

  .next-activity strong {
    color: var(--text);
  }

  .edit-dialog {
    width: min(460px, calc(100vw - 32px));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 0;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  }

  .edit-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
  }

  .edit-box {
    display: grid;
    gap: 10px;
    padding: 18px;
  }

  .cal-dot-tooltip {
    position: fixed;
    z-index: 30;
    min-width: 176px;
    max-width: 240px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 9px 10px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: 0.14s ease;
  }

  .cal-dot-tooltip.show {
    opacity: 1;
    transform: translateY(0);
  }

  .cal-dot-tooltip-row {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
  }

  .cal-dot-tooltip-row + .cal-dot-tooltip-row {
    margin-top: 5px;
  }

  .cal-dot-tooltip-row i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: 0 0 auto;
  }

  .toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(360px, calc(100vw - 36px));
    border: 1px solid var(--accent-border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 12px 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: 0.18s ease;
    z-index: 20;
  }

  .toast.show {
    opacity: 1;
    transform: translateY(0);
  }

  @media (min-width: 820px) {
    .schedule-shell {
      grid-template-columns: 230px minmax(0, 1fr);
    }

    .right-panel {
      grid-column: 1 / -1;
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (min-width: 1140px) {
    .schedule-shell {
      grid-template-columns: 230px minmax(0, 1fr) 280px;
    }

    .right-panel {
      grid-column: auto;
      grid-template-columns: 1fr;
    }
  }

  @media (min-width: 1500px) {
    .schedule-shell {
      grid-template-columns: 240px minmax(0, 1fr) 300px;
    }
  }

  @media (max-width: 820px) {
    .top-projects-inner {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .top-project.disabled {
      display: none;
    }

    .right-panel .quick-add-panel {
      position: static;
    }
  }

  @media (max-width: 620px) {
    body {
      padding: 12px;
    }

    .side-panel {
      grid-template-columns: 1fr;
    }

    .top-projects-inner {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }

    .top-project {
      min-height: 48px;
      grid-template-columns: 30px minmax(0, 1fr);
    }

    .top-project-pill, .top-project-desc {
      display: none;
    }

    .schedule-header {
      align-items: stretch;
      flex-direction: column;
    }

    .header-actions {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      align-items: stretch;
    }

    .header-actions .nav-btn,
    .header-actions .btn,
    .header-actions .theme-btn {
      width: 100%;
      min-width: 0;
      border-radius: var(--radius);
    }

    .header-actions .theme-btn {
      grid-column: 1 / -1;
    }

    .quick-add-title-row {
      align-items: stretch;
      flex-direction: column;
    }

    .duration-chips {
      justify-content: flex-start;
    }

    .quick-add-grid {
      grid-template-columns: 1fr 1fr;
    }

    .title-field, .add-wide {
      grid-column: 1 / -1;
    }

    .hour-row {
      grid-template-columns: 58px minmax(0, 1fr);
    }

    .timeline {
      --slot-height: 28px;
      --time-column: 58px;
      grid-template-columns: var(--time-column) minmax(0, 1fr);
    }

    .timeline-scroll {
      max-height: 72vh;
      min-height: 440px;
    }

    .hour-label {
      padding: 12px 8px;
      font-size: 0.74rem;
    }

    .activity-card {
      grid-template-columns: auto minmax(0, 1fr);
      margin-inline: 8px;
    }

    .activity-actions {
      grid-column: 2;
      justify-content: flex-end;
    }

  }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes focusPulse {
    0%, 100% { box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22); }
    35% { box-shadow: 0 0 0 3px var(--accent-border), 0 18px 36px rgba(0, 0, 0, 0.28); }
  }

  /* Phase 5: daily planning polish */
  .schedule-card {
    border-color: color-mix(in srgb, var(--border) 78%, var(--accent-border));
  }

  .schedule-header {
    position: sticky;
    top: 0;
    z-index: 9;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
  }

  .schedule-header h2 {
    font-size: 1.14rem;
  }

  .header-actions {
    gap: 8px;
  }

  .timeline-scroll {
    max-height: min(74vh, 880px);
    min-height: 610px;
    background:
      linear-gradient(90deg, color-mix(in srgb, var(--surface-2) 58%, transparent) 0 var(--time-column), transparent var(--time-column)),
      var(--surface);
  }

  .timeline {
    --slot-height: 31px;
  }

  .hour-label {
    position: relative;
    padding: 12px 12px 8px;
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    font-size: 0.78rem;
  }

  .hour-band {
    background:
      linear-gradient(to bottom, transparent calc(50% - 1px), rgba(255, 255, 255, 0.035) calc(50% - 1px), rgba(255, 255, 255, 0.035) calc(50% + 1px), transparent calc(50% + 1px));
  }

  .empty-slot-btn {
    margin: 5px 12px;
    padding: 7px 11px;
    font-size: 0.8rem;
  }

  .activity-card {
    margin: 4px 12px;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 10px;
    border-color: color-mix(in srgb, var(--category-color) 22%, var(--border));
    background:
      linear-gradient(90deg, color-mix(in srgb, var(--category-color) 18%, transparent), transparent 62%),
      var(--surface-2);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  }

  .activity-card:hover {
    border-color: color-mix(in srgb, var(--category-color) 48%, var(--border));
    transform: translateY(-1px);
  }

  .activity-title {
    font-size: 0.96rem;
  }

  .activity-time {
    font-size: 0.76rem;
  }

  .duration-pill,
  .category-pill {
    font-size: 0.68rem;
    padding: 2px 7px;
  }

  .activity-actions {
    opacity: 0;
    transition: opacity 0.15s ease;
  }

  .activity-card:hover .activity-actions,
  .activity-card:focus-within .activity-actions {
    opacity: 1;
  }

  .activity-check {
    width: 24px;
    height: 24px;
  }

  .quick-add-panel {
    gap: 14px;
    border-color: color-mix(in srgb, var(--border) 76%, var(--accent-border));
  }

  .duration-chip {
    min-height: 32px;
    padding-inline: 11px;
    font-size: 0.74rem;
  }

  .quick-add-grid {
    gap: 10px;
  }

  .quick-field {
    gap: 6px;
  }

  .time-control {
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    gap: 6px;
  }

  .time-step {
    width: 34px;
  }

  .add-wide {
    min-height: 42px;
  }

  .day-agenda-list {
    max-height: 260px;
  }

  .agenda-item {
    min-height: 48px;
    padding: 9px;
  }

  .agenda-main strong {
    font-size: 0.88rem;
  }

  .summary-item {
    padding: 10px 7px;
  }

  @media (max-width: 620px) {
    .schedule-header {
      position: static;
    }

    .timeline {
      --slot-height: 30px;
      --time-column: 62px;
    }

    .timeline-scroll {
      min-height: 520px;
      max-height: 68vh;
    }

    .activity-card {
      grid-template-columns: 24px minmax(0, 1fr);
      margin-inline: 8px;
    }

    .activity-actions {
      opacity: 1;
    }
  }
