:root {
  color-scheme: light;
  --font-body: "Space Grotesk", "Roboto", "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Roboto", "Segoe UI", sans-serif;
  --bg: #f1f3f4;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --border: #dadce0;
  --border-soft: #e6e6e6;
  --text: #3c4043;
  --muted: #5f6368;
  --accent: #1a73e8;
  --accent-soft: rgba(26, 115, 232, 0.12);
  --accent-strong: #0b57d0;
  --danger: #d93025;
  --danger-ink: #ffffff;
  --topbar-height: 64px;
  --focus-good: #34a853;
  --focus-warn: #f9ab00;
  --focus-urgent: #ea4335;
  --focus-neutral: var(--text);
  --shadow-sm: 0 1px 2px rgba(60, 64, 67, 0.12);
  --shadow-md: 0 2px 8px rgba(60, 64, 67, 0.16);
  --shadow-lg: 0 4px 12px rgba(60, 64, 67, 0.2);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #202124;
  --panel: #2b2c2f;
  --panel-2: #27272a;
  --border: #3c4043;
  --border-soft: #33363a;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #8ab4f8;
  --accent-soft: rgba(138, 180, 248, 0.2);
  --accent-strong: #a8c7fa;
  --danger: #f28b82;
  --danger-ink: #1f1f1f;
  --focus-good: #6dd58c;
  --focus-warn: #f5c45d;
  --focus-urgent: #ff8a80;
  --focus-neutral: var(--text);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button {
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.action-link:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.countdown-container {
  position: sticky;
  top: var(--topbar-height, 64px);
  z-index: 9;
  margin: 12px 20px 8px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(120deg, var(--accent-soft), transparent);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.countdown-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.countdown-content {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.countdown-title {
  font-size: 1rem;
  font-weight: 600;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.countdown-timer {
  font-family: "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  color: var(--text);
}

.countdown-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.countdown-container.urgent {
  background: linear-gradient(120deg, rgba(234, 67, 53, 0.2), rgba(234, 67, 53, 0.05));
  border-color: rgba(234, 67, 53, 0.4);
}

.countdown-container.urgent .countdown-timer {
  color: var(--focus-urgent);
  border-color: rgba(234, 67, 53, 0.3);
}

.countdown-container.inactive {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--muted);
  box-shadow: none;
}

.countdown-container.inactive .countdown-timer {
  background: transparent;
  border-color: var(--border-soft);
  color: var(--muted);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: var(--font-display);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.title-input {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  border: none;
  background: transparent;
  padding: 0;
  outline: none;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.secondary-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.nav-group {
  display: flex;
  gap: 8px;
}

.view-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

button {
  font-size: 0.85rem;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  background: var(--panel-2);
  border-color: var(--border-soft);
  box-shadow: var(--shadow-sm);
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}

button.primary:hover {
  background: var(--accent-strong);
}

/* View toggle overrides */
.view-toggle button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 6px 12px;
  box-shadow: none;
}

.view-toggle button:hover {
  background: transparent;
  box-shadow: none;
}

.view-toggle button.active {
  background: var(--accent);
  color: #fff;
}

button.ghost {
  background: transparent;
}

button.danger,
.danger-btn {
  background: var(--danger);
  color: var(--danger-ink);
  border-color: transparent;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 260px;
  grid-template-areas: "side calendar tz";
}

.side-panel {
  grid-area: side;
  order: -1;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.calendar-panel {
  grid-area: calendar;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.tz-sidebar {
  grid-area: tz;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.tz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tz-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.tz-subtitle {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.tz-add {
  font-size: 1rem;
  line-height: 1;
}

.tz-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.tz-card {
  background: var(--panel-2);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tz-card.is-local {
  border-left-color: var(--accent);
}

.tz-name {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tz-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tz-offset {
  color: var(--muted);
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.tz-time {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tz-diff {
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 600;
}

.tz-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tz-card:hover .tz-remove {
  opacity: 1;
}

.tz-remove:focus-visible {
  opacity: 1;
}

.tz-remove:hover {
  background: transparent;
  box-shadow: none;
}

.tz-empty {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.month-label {
  margin: 0 0 4px;
  font-size: 1.4rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.weekday-row.hidden {
  display: none;
}

.weekday {
  padding: 8px 12px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.calendar-grid {
  flex: 1;
  min-height: 0;
  background: var(--panel);
}

.calendar-grid.agenda-view {
  display: block;
  overflow-y: auto;
  padding: 16px 20px 24px;
  background: var(--panel);
  scrollbar-gutter: stable;
}

.agenda-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agenda-date-header {
  margin: 12px 0 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  position: sticky;
  top: 0;
  z-index: 2;
}

.agenda-event-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--accent);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.agenda-event-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.agenda-time {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.agenda-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agenda-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.agenda-empty {
  margin: 20px auto 0;
  padding: 24px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--panel-2);
  color: var(--muted);
  text-align: center;
  max-width: 420px;
}

.calendar-grid.month-view {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, 1fr));
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.day-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  background: var(--panel);
  transition: background 0.15s ease;
  animation: cell-fade-in 0.4s ease backwards;
  animation-delay: calc(var(--cell-index, 0) * 15ms);
}

.day-cell:hover {
  background: var(--panel-2);
}

.day-cell.is-outside {
  background: var(--panel-2);
  color: var(--muted);
}

.day-cell.is-today {
  background: var(--accent-soft);
}

.day-cell.is-selected {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.day-number {
  font-size: 0.72rem;
  font-weight: 600;
  color: inherit;
  align-self: flex-end;
}

.event-chip {
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  border: none;
  box-shadow: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
  cursor: pointer;
}

.event-chip:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  filter: brightness(1.1);
}

.event-chip .time {
  font-weight: 600;
  font-size: 0.65rem;
}

.event-more {
  font-size: 0.72rem;
  color: var(--muted);
}

.calendar-grid.week-view,
.calendar-grid.day-view {
  display: grid;
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.time-label {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px 6px;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: right;
  background: var(--panel);
}

.time-label.all-day-label {
  text-align: center;
  font-weight: 600;
}

.time-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.time-cell.all-day {
  background: var(--panel-2);
}

.time-event {
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.68rem;
  color: #fff;
  border: none;
  text-align: left;
  cursor: pointer;
}

.calendar-grid.year-view {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 16px;
  overflow: auto;
  background: var(--bg);
}

.mini-month {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.mini-weekday {
  font-size: 0.6rem;
  text-align: center;
  color: var(--muted);
  text-transform: uppercase;
}

.mini-day {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.65rem;
  padding: 4px 0;
  border-radius: 4px;
  position: relative;
}

.mini-day.is-outside {
  color: var(--muted);
}

.mini-day.is-selected {
  background: var(--accent-soft);
}

.mini-day:hover {
  background: var(--panel-2);
}

.mini-dot {
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  transform: translateX(-50%);
}

.side-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-card.danger {
  border-color: rgba(217, 48, 37, 0.4);
}

.side-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}

.event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  background: var(--panel-2);
  cursor: pointer;
}

.event-item:hover {
  border-color: var(--border);
}

.event-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.event-title {
  font-weight: 600;
  font-size: 0.85rem;
}

.event-time {
  font-size: 0.75rem;
  color: var(--muted);
}

.event-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}

.url-warning {
  margin: 0;
  font-size: 0.72rem;
  color: var(--danger);
}

.stacked-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: clamp(20px, 4vw, 48px);
  background:
    radial-gradient(circle at top left, var(--accent-soft), transparent 45%),
    radial-gradient(circle at bottom right, rgba(0, 0, 0, 0.08), transparent 40%),
    var(--bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.focus-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.focus-overlay[data-tone="good"] .focus-timer,
.focus-overlay[data-tone="good"] .focus-status {
  color: var(--focus-good);
}

.focus-overlay[data-tone="warn"] .focus-timer,
.focus-overlay[data-tone="warn"] .focus-status {
  color: var(--focus-warn);
}

.focus-overlay[data-tone="urgent"] .focus-timer,
.focus-overlay[data-tone="urgent"] .focus-status {
  color: var(--focus-urgent);
}

.focus-overlay[data-tone="neutral"] .focus-timer {
  color: var(--focus-neutral);
}

.focus-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: clamp(24px, 5vw, 56px);
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.focus-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.focus-exit {
  border-color: var(--border-soft);
  background: var(--panel-2);
}

.focus-clock {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
}

.focus-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}

.focus-status {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.35em;
  color: var(--muted);
}

.focus-timer {
  font-family: "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 700;
  color: var(--focus-neutral);
  letter-spacing: 0.08em;
}

.focus-title {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 600;
}

.focus-event {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.focus-time {
  font-size: 1rem;
  color: var(--muted);
}

.focus-upnext {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 520px;
}

.focus-upnext-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--muted);
}

.focus-upnext-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.focus-upnext-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  font-size: 0.9rem;
}

.focus-upnext-time {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.focus-upnext-title {
  font-weight: 600;
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.tz-modal {
  border: none;
  padding: 0;
  background: transparent;
  margin: auto;
}

.tz-modal::backdrop {
  background: rgba(32, 33, 36, 0.6);
}

.tz-modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  width: min(420px, 92vw);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tz-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tz-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.tz-result-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--panel-2);
  font-size: 0.82rem;
  color: var(--text);
}

.tz-result-btn:hover {
  border-color: var(--border);
}

.tz-result-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tz-result-offset {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 33, 36, 0.6);
}

.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: min(520px, 92vw);
  box-shadow: var(--shadow-md);
}

.json-modal-card {
  width: min(720px, 94vw);
}

.qr-modal-card {
  width: min(420px, 92vw);
  text-align: center;
}

.qr-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.qr-code {
  padding: 12px;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.qr-code canvas,
.qr-code img {
  display: block;
}

.qr-warning {
  margin: 0;
  font-size: 0.8rem;
  color: var(--danger);
  background: rgba(217, 48, 37, 0.08);
  border: 1px solid rgba(217, 48, 37, 0.2);
  padding: 10px 12px;
  border-radius: 8px;
  text-align: left;
  align-self: stretch;
  word-break: break-word;
}

.qr-helper {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.qr-modal-actions {
  justify-content: center;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.json-output {
  min-height: 220px;
  font-family: "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;
  resize: vertical;
  white-space: pre;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.85rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.color-palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.color-swatch.active {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
}

.modal-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.modal-error {
  margin: 0;
  font-size: 0.75rem;
  color: var(--danger);
}

.locked-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(32, 33, 36, 0.4);
  z-index: 5;
}

.locked-overlay.hidden {
  display: none;
}

.locked-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  width: min(320px, 80%);
  box-shadow: var(--shadow-md);
}

.mobile-warning {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(32, 33, 36, 0.45);
  z-index: 40;
}

.mobile-warning-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(520px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
}

.mobile-warning-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-warning-title {
  font-size: 0.86rem;
  font-weight: 600;
}

.mobile-warning-text {
  font-size: 0.78rem;
  color: var(--muted);
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 40;
}

.toast {
  background: var(--panel);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 200px;
}

.toast.success {
  border-color: rgba(52, 168, 83, 0.6);
}

.toast.error {
  border-color: rgba(217, 48, 37, 0.6);
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none;
}

@media (max-width: 1100px) {
  .desktop-only {
    display: none !important;
  }
  
  .mobile-only {
    display: block;
  }

  .topbar {
    padding: 0 16px;
  }

  .brand-subtitle {
    display: none;
  }

  .secondary-actions {
    position: fixed;
    top: 64px;
    right: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
    box-shadow: var(--shadow-md);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
  }

  .secondary-actions.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .secondary-actions .view-toggle {
    flex-direction: column;
    width: 100%;
    border-radius: 8px;
  }

  .secondary-actions .view-toggle button {
    width: 100%;
    padding: 10px;
    text-align: left;
    border-radius: 0;
    border-bottom: 1px solid var(--border-soft);
  }

  .secondary-actions .view-toggle button:last-child {
    border-bottom: none;
  }

  .secondary-actions button,
  .secondary-actions .action-link {
    width: 100%;
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-areas: "calendar";
    position: relative;
    overflow: hidden;
  }

  .side-panel,
  .tz-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    background: var(--panel);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    border: none;
  }

  .side-panel.is-active,
  .tz-sidebar.is-active {
    transform: translateX(0);
  }

  .calendar-panel {
    height: 100%;
    overflow: hidden;
  }

  .panel-header {
    padding: 12px 16px;
  }

  .month-label {
    font-size: 1.2rem;
  }

  .panel-actions {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-grid.month-view {
    font-size: 0.8rem;
  }

  .day-cell {
    padding: 4px;
  }

  .event-chip {
    padding: 1px 4px;
    font-size: 0.6rem;
  }

  .side-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 30;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
  }

  .side-close:hover {
    background: var(--bg);
  }
}

@media (max-width: 480px) {
  .brand-text {
    display: none;
  }
  
  .nav-group button {
    padding: 7px 10px;
    font-size: 0.8rem;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: auto;
    padding: 12px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .countdown-container {
    margin: 8px 16px 6px;
    flex-direction: column;
    align-items: flex-start;
  }

  .countdown-content {
    width: 100%;
  }

  .countdown-title {
    max-width: 100%;
    white-space: normal;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .focus-shell {
    padding: 24px;
    border-radius: 20px;
  }

  .focus-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .focus-upnext {
    align-self: stretch;
  }

  .focus-upnext-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .focus-upnext-title {
    text-align: left;
  }

  .calendar-grid.agenda-view {
    padding: 12px 14px 18px;
  }

  .agenda-event-item {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .agenda-time {
    font-size: 0.68rem;
  }

  .mobile-warning-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .mobile-warning-card button {
    align-self: stretch;
  }
}

@media (max-width: 1024px) {
  .mobile-warning {
    display: flex;
  }
}

/* --- World Planner Modal & Grid --- */

.planner-modal-card {
  background: var(--panel);
  width: 95vw;
  max-width: 1200px; /* Wide format for the timeline */
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  height: 85vh; /* Occupy most of height */
  overflow: hidden;
  position: relative;
  animation: modal-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.planner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
  gap: 16px;
}

.planner-controls-left, .planner-controls-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Planner Search Input */
.wp-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 260px;
}

.wp-search-icon {
  position: absolute;
  left: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 2;
}

#wp-add-zone {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.9rem;
}

#wp-add-zone:focus {
  outline: 2px solid var(--accent);
  background: var(--panel);
}

/* Reusing .tz-results styles but positioned for WP */
#wp-tz-results.tz-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  max-height: 300px;
  overflow-y: auto;
  z-index: 50;
  list-style: none;
  padding: 0;
} 

/* Planner Content Grid */
.modal-grid-container {
  display: grid;
  grid-template-columns: 200px 1fr; /* Fixed City Col, Scrollable Timeline */
  flex: 1;
  overflow: hidden; /* Manage overflow internally */
  position: relative;
}

/* Left Column: City Headers */
.city-col {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: hidden; /* Synced with JS if needed, but flex row usually fits */
  display: flex;
  flex-direction: column;
  z-index: 10; /* Stick on top of scroll */
  box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}

.wp-row-header {
  height: 60px; /* Fixed height for alignment */
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  background: var(--panel);
}

/* Home Row distinctive style */
.wp-row-header.home-row {
  background: var(--panel-2);
}

.wp-city-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.wp-home-icon {
  font-size: 0.8rem;
  color: var(--text);
}

.wp-city-time {
  font-size: 1.2rem;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text);
}

.wp-city-date {
  font-size: 0.7rem;
  color: var(--muted);
}

.wp-offset-badge {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
}

/* Controls (hover only) */
.wp-row-controls {
  position: absolute;
  top: 4px;
  right: 4px;
  display: none; /* Show on hover */
  gap: 4px;
}

.wp-row-header:hover .wp-row-controls {
  display: flex;
}

.wp-control-btn {
  background: transparent;
  border: none;
  font-size: 0.7rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.wp-control-btn:hover {
  background: var(--border-soft);
  color: var(--danger);
}

/* Right Column: Timeline Track */
.timeline-col {
  overflow-x: auto;
  overflow-y: auto; /* Allow vertical scroll if many rows */
  position: relative;
  background: var(--bg);
  cursor: crosshair;
}

.timeline-track {
  display: flex;
  flex-direction: column;
  min-width: 960px; /* 24 hours * 40px */
  position: relative;
}

.wp-row-cells {
  display: flex;
  height: 60px;
  border-bottom: 1px solid var(--border-soft);
}

.wp-cell {
  flex: 0 0 4.16666%; /* 100% / 24 */
  min-width: 40px;
  border-right: 1px solid rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  position: relative;
  user-select: none;
}

/* Color Aesthetic "Exact Match" */
/* Business Hours: 8am - 5pm */
.wp-cell.business {
  background: #E3F2FD; /* Light Blue */
  color: #1565C0; /* Dark Blue Text */
}
[data-theme="dark"] .wp-cell.business {
  background: #1e3a8a;
  color: #bfdbfe;
}

/* Active Hours (Evening): 6pm - 10pm */
.wp-cell.active {
  background: #BBDEFB; /* Slightly darker blue */
  color: #0D47A1;
}
[data-theme="dark"] .wp-cell.active {
  background: #172554;
  color: #93c5fd;
}

/* Sleep Hours: 11pm - 7am */
.wp-cell.sleep {
  background: repeating-linear-gradient(
    45deg,
    var(--panel-2),
    var(--panel-2) 5px,
    var(--border-soft) 5px,
    var(--border-soft) 10px
  );
  color: var(--muted);
  opacity: 0.8;
}

/* Date Date Boundary */
.wp-cell.date-boundary {
  background: #FFF9C4 !important; /* Yellow */
  color: #F57F17;
}
[data-theme="dark"] .wp-cell.date-boundary {
  background: #422006 !important;
  color: #fde047;
}

/* Scrubber Overlay */
.scrubber-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4.16666%; /* 1 cell width */
  min-width: 40px;
  border: 2px solid var(--text);
  background: rgba(0,0,0,0.05); /* Transparent fill */
  pointer-events: none; /* Click-through */
  z-index: 20;
  transition: transform 0.05s linear;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.2); /* Dim everything else */
}

/* Ghost Scrubber (Hover) */
.ghost-scrubber {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4.16666%;
  min-width: 40px;
  border: 2px solid var(--muted); /* Lighter border */
  background: transparent;
  pointer-events: none;
  z-index: 15;
  transition: transform 0.05s linear;
  opacity: 0.5;
}

/* Mobile Responsiveness for World Planner */
@media (max-width: 768px) {
  .planner-modal-card {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
  
  .modal-grid-container {
    grid-template-columns: 140px 1fr; /* Smaller city col */
  }

  .wp-row-header {
    padding: 8px 8px;
  }

  .wp-city-time {
    font-size: 1rem;
  }
  
  .wp-control-btn {
    font-size: 1rem;
    padding: 8px; /* Larger hit area */
  }
}

.accent-btn {
  background: var(--panel);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.accent-btn:hover {
  background: var(--accent-soft);
}

/* App Launcher (Waffle Menu) */
.app-launcher-container {
  position: relative;
  display: flex;
  align-items: center;
}

.app-launcher-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: -10px;
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
  padding: 16px;
  z-index: 100;
  transform-origin: top right;
  animation: menu-pop 0.2s cubic-bezier(0.2, 0, 0, 1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Glassmorphism attempt */
@supports (backdrop-filter: blur(12px)) {
  .app-launcher-menu {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}

body[data-theme="dark"] .app-launcher-menu {
  background: #2b2c2f;
}

@supports (backdrop-filter: blur(12px)) {
  body[data-theme="dark"] .app-launcher-menu {
    background: rgba(43, 44, 47, 0.85);
  }
}

.app-launcher-menu.hidden {
  display: none;
  animation: none;
}

@keyframes menu-pop {
  0% { opacity: 0; transform: scale(0.92) translateY(-8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.app-launcher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.app-launcher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  padding: 12px 8px;
  border-radius: 12px;
  transition: background 0.15s ease, transform 0.1s ease;
  text-align: center;
}

.app-launcher-item:hover {
  background: var(--panel-2);
  transform: translateY(-2px);
}

.app-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 24px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.app-launcher-item:hover .app-icon-wrapper {
  transform: scale(1.1);
}

.app-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .app-launcher-menu {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 24px 24px 0 0;
    transform-origin: bottom center;
    animation: slide-up 0.3s cubic-bezier(0.2, 0, 0, 1);
    border-bottom: none;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  }

  @keyframes slide-up {
    0% { transform: translateY(100%); }
    100% { transform: translateY(0); }
  }
}

/* --- Micro-animations & Transitions --- */

/* View Transitions */
.calendar-grid.view-animate-in {
  animation: view-fade-in 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.calendar-grid.view-animate-out {
  animation: view-fade-out 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes view-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes view-fade-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

/* Ripple Effect */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0);
  animation: ripple-animation 0.6s linear;
  pointer-events: none;
}

body[data-theme="dark"] .ripple {
  background: rgba(255, 255, 255, 0.2);
}

@keyframes ripple-animation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Stagger Animation */
@keyframes cell-fade-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--border-soft) 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Hover Lift for Cards */
.side-card, .tz-card, .agenda-event-item, .event-item {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.side-card:hover, .tz-card:hover, .event-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}



