:root {
  /* Design tokens: values and roles are defined in DESIGN.md. */
  --color-primary: #2d627f;
  --color-secondary: #445d6e;
  --color-tertiary: #76a8c3;
  --color-neutral: #c4d1dc;
  --color-surface: #dce5ec;
  --color-surface-raised: #e4edf3;
  --color-surface-pressed: #c7d2dc;
  --color-on-surface: #18222b;
  --color-error: #8e3b46;

  --font-hand: "Short Stack", cursive, sans-serif;
  --font-digits: "Inter", system-ui, sans-serif;
  --text-label: 11px;
  --text-body: 13px;
  --text-title: 16px;
  --text-headline: 20px;
  --text-display: 23px;
  --text-input: 16px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-plate: 54px;
  --radius-full: 9999px;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-xxl: 32px;

  --shadow-pill:
    3px 3px 6px rgba(168, 183, 196, 0.6),
    -3px -3px 6px rgba(255, 255, 255, 0.95);

  /* Older names kept so existing rules keep working. */
  --bg-base: var(--color-surface);
  --text-color: var(--color-on-surface);

  /* Outer squircle plate: smooth multi-angle drop and highlight */
  --outer-plate-shadow:
    14px 16px 32px rgba(165, 180, 194, 0.65),
    -14px -14px 30px rgba(255, 255, 255, 0.95),
    inset 1px 1px 1.5px rgba(255, 255, 255, 0.6);

  /* Outer Beveled Trench Well */
  --well-socket-shadow:
    inset 5px 6px 10px rgba(158, 174, 188, 0.65),
    inset -5px -5px 10px rgba(255, 255, 255, 0.95),
    0 2px 4px rgba(255, 255, 255, 0.8);

  /* POPPED OUT STATE (Raised / Idle / Paused) */
  --dial-popped-shadow:
    9px 12px 20px rgba(155, 172, 188, 0.72),
    -8px -8px 18px rgba(255, 255, 255, 0.98),
    inset 1px 1px 2px rgba(255, 255, 255, 0.9),
    inset -1px -1px 2px rgba(170, 185, 198, 0.4);

  /* PUSHED DOWN STATE (Sunken / Running) */
  --dial-pushed-shadow:
    inset 6px 7px 12px rgba(142, 158, 172, 0.8),
    inset -5px -5px 9px rgba(255, 255, 255, 0.75),
    1px 1px 2px rgba(255, 255, 255, 0.85);
}

body {
  background-color: var(--bg-base);
  font-family: "Inter", sans-serif;
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 20px;
  user-select: none;
  -webkit-user-select: none;
}

/* 1. Outer Squircle Card Plate */
.squircle-plate {
  width: 256px;
  height: 256px;
  background-color: var(--bg-base);
  border-radius: var(--radius-plate);
  box-shadow: var(--outer-plate-shadow);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

/* 2. Concentric Sunken Circular Socket / Well */
.socket-well {
  width: 172px;
  height: 172px;
  border-radius: 50%;
  background-color: var(--bg-base);
  box-shadow: var(--well-socket-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* 3. The Physical Central Tactile Dial */
.push-button-dial {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  outline: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.22s ease,
    background 0.22s ease;

  /* DEFAULT: POPPED OUT / RAISED */
  background: radial-gradient(
    circle at 35% 30%,
    #f4f8fb 0%,
    #dde6ee 60%,
    #c8d5e1 100%
  );
  box-shadow: var(--dial-popped-shadow);
  transform: scale(1) translateY(0);
}

/* Hover effect while popped up */
.push-button-dial:not(.is-pushed):hover {
  box-shadow:
    11px 14px 24px rgba(150, 168, 184, 0.8),
    -9px -9px 20px rgba(255, 255, 255, 1),
    inset 1px 1px 2px rgba(255, 255, 255, 0.95);
  transform: translateY(-1px);
}

/* PUSHED DOWN (RUNNING STATE) */
.push-button-dial.is-pushed {
  transform: scale(0.96) translateY(2px) !important;
  background: radial-gradient(
    circle at 50% 50%,
    #d2dce4 0%,
    #c7d2dc 70%,
    #b8c4ce 100%
  );
  box-shadow: var(--dial-pushed-shadow);
}

/* Subtle click spring active state */
.push-button-dial:active {
  transform: scale(0.94) translateY(3px);
}

/* Digits Display */
.time-digits {
  font-family: var(--font-digits);
  font-size: var(--text-display);
  font-weight: 500;
  letter-spacing: 1.5px;
  color: var(--color-on-surface);
  font-variant-numeric: tabular-nums;
  transition:
    transform 0.2s ease,
    color 0.2s ease;
}

.push-button-dial.is-pushed .time-digits {
  color: var(--color-on-surface);
  transform: translateY(1px);
}

/* Running status dot inside the dial: the at-a-glance "running" cue. */
.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  margin-top: var(--space-xs);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.push-button-dial.is-pushed .status-indicator {
  opacity: 1;
  animation: dial-running-pulse 2s ease-in-out infinite;
}
@keyframes dial-running-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@media (prefers-reduced-motion: reduce) {
  .push-button-dial.is-pushed .status-indicator { animation: none; }
}

/* Hand-Drawn Annotation */
.annotation-box {
  position: absolute;
  left: calc(100% - 15px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  white-space: nowrap;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.annotation-box.is-hidden {
  opacity: 0;
}

.handwritten-text {
  font-family: var(--font-hand);
  font-size: var(--text-label);
  line-height: 1;
  color: var(--color-on-surface);
  margin-left: 6px;
  letter-spacing: 0.3px;
}

/* Minimal discreet controls on hover */
.minimal-controls {
  opacity: 0.45;
  transform: translateY(2px);
  transition: all 0.25s ease;
}
.stage-wrapper:hover .minimal-controls,
.minimal-controls:focus-within {
  opacity: 1;
  transform: translateY(0);
}

.pill-btn {
  background-color: var(--bg-base);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-pill);
  font-size: var(--text-label);
  font-family: var(--font-hand);
  color: var(--color-secondary);
  padding: var(--space-xs) var(--space-md);
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.pill-btn:disabled {
  box-shadow: none;
  color: var(--color-secondary);
  opacity: 0.6;
  cursor: default;
}

.pill-btn:not(:disabled):hover {
  box-shadow:
    2px 2px 4px rgba(165, 180, 193, 0.75),
    -2px -2px 4px rgba(255, 255, 255, 1);
  color: var(--color-on-surface);
}

.pill-btn:active,
.pill-btn.active {
  box-shadow:
    inset 2px 2px 4px rgba(155, 170, 183, 0.75),
    inset -2px -2px 4px rgba(255, 255, 255, 0.85);
  color: var(--color-on-surface);
}

.timer-title {
  margin: 0 0 24px;
  font-family: var(--font-hand);
  font-size: var(--text-headline);
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
  color: var(--text-color);
}

/* Quiet heading and break-mode caption */
.timer-title {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.45s ease,
    transform 0.45s ease;
  animation: title-arrive 0.6s ease-out;
}
.stage-wrapper.title-is-quiet .timer-title {
  opacity: 0;
  transform: translateY(-6px);
}
.stage-wrapper.title-is-quiet:has(:focus-visible) .timer-title {
  opacity: 1;
  transform: translateY(0);
}
@media (hover: hover) {
  .stage-wrapper.title-is-quiet:hover .timer-title {
    opacity: 1;
    transform: translateY(0);
  }
}
.break-message {
  position: absolute;
  bottom: 16px;
  left: 0;
  width: 100%;
  margin: 0;
  font-family: var(--font-hand);
  font-size: var(--text-body);
  line-height: 18px;
  font-weight: 400;
  text-align: center;
  color: var(--text-color);
  pointer-events: none;
  opacity: 0;
  transform: translateY(5px);
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}
.squircle-plate.is-break .break-message {
  opacity: 1;
  transform: translateY(0);
}
@keyframes title-arrive {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .timer-title,
  .break-message {
    animation: none;
    transition: none;
  }
}

.squircle-plate.is-break.is-running .break-message {
  opacity: 0;
  transform: translateY(5px);
}

/* Sidebar extracted from the provided design. */
.sidebar-panel {
  --card-base: var(--bg-base);
  --shadow-raised-sm:
    6px 8px 16px rgba(186, 200, 212, 0.6),
    -6px -6px 14px rgba(255, 255, 255, 0.95),
    inset 1px 1px 1.5px rgba(255, 255, 255, 0.5);
  box-sizing: border-box;
  align-self: flex-start;
  font-family: var(--font-hand);
  width: 270px;
  background: var(--card-base);
  border-radius: 0 0 var(--radius-xl) 0;
  box-shadow:
    12px 14px 28px rgba(182, 196, 209, 0.55),
    -4px 0 20px rgba(255, 255, 255, 0.8);
  padding: 32px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-shrink: 0;
}

/* Quote header with thin left bar */
.quote-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-left: 2px;
  margin-bottom: 2px;
}

.quote-bar {
  width: 2px;
  height: 38px;
  background-color: var(--color-secondary);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.quote-text {
  font-size: var(--text-body);
  line-height: 1.35;
  color: var(--color-on-surface);
  letter-spacing: 0.2px;
}

/* Widgets / Subcards */
.sidebar-widget {
  background: var(--card-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised-sm);
  padding: 16px 16px 18px;
}

.widget-title {
  font-size: var(--text-title);
  color: var(--color-on-surface);
  margin-bottom: 12px;
}

/* Goal beads */
.goal-beads-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 2px;
}

.goal-bead {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: default;
  border: none;
  outline: none;
  position: relative;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Active blue bead (first 2 in reference) */
.goal-bead.active {
  background: radial-gradient(
    circle at 35% 30%,
    #99c7dd 0%,
    #76a8c3 60%,
    #5d8ea7 100%
  );
  box-shadow:
    2.5px 3.5px 7px rgba(93, 142, 167, 0.45),
    -2px -2px 5px rgba(255, 255, 255, 0.9),
    inset 1px 1px 1.5px rgba(255, 255, 255, 0.6);
  transform: translateY(-1px);
}

/* Inactive cool gray/slate bead */
.goal-bead:not(.active) {
  background: radial-gradient(
    circle at 35% 30%,
    #dae4eb 0%,
    #c4d1dc 65%,
    #adc0cd 100%
  );
  box-shadow:
    2px 3px 5px rgba(173, 192, 205, 0.45),
    -1.5px -1.5px 4px rgba(255, 255, 255, 0.85),
    inset 1px 1px 1px rgba(255, 255, 255, 0.6);
}

.goal-bead {
  display: inline-block;
  pointer-events: none;
}

/* Calendar Widget */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: var(--text-label);
  color: var(--color-secondary);
  margin-bottom: 8px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 5px;
  text-align: center;
  font-size: var(--text-label);
  color: var(--color-on-surface);
}

.cal-day-cell {
  height: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.cal-day-cell:hover:not(:empty) {
  background: rgba(255, 255, 255, 0.4);
}

/* Roomy circular border around the selected calendar date. */
.cal-day-cell.active-date .day-num {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.2px solid rgba(60, 68, 77, 0.75);
  border-radius: 50%;
}

/* Tiny event indicator dots underneath days */
.dots-row {
  display: flex;
  gap: 1.5px;
  margin-top: 1.5px;
  height: 3px;
  align-items: center;
  justify-content: center;
}

.dot {
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background-color: var(--color-secondary);
}

body {
  padding: 0;
  align-items: stretch;
}
.pomodoro-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}
.pomodoro-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 140px 64px 40px;
}
.sidebar-panel .goal-bead:focus-visible,
.sidebar-panel .cal-day-cell:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}
@media (max-width: 860px) {
  .pomodoro-layout {
    flex-direction: column;
  }
  .sidebar-panel {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  }
  .quote-box {
    grid-column: 1 / -1;
  }
  .sidebar-widget {
    min-width: 0;
  }
  .pomodoro-main {
    padding: 64px 20px 110px;
  }
  .annotation-box {
    left: 50%;
    top: auto;
    bottom: -88px;
    transform: translateX(-50%);
  }
}
@media (max-width: 540px) {
  .sidebar-panel {
    display: flex;
  }
}

/* Hover-revealed sidebar */
.sidebar-shell {
  position: fixed;
  top: 24px;
  left: 24px;
  width: 56px;
  height: 56px;
  z-index: 20;
}
.sidebar-toggle {
  width: 56px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  box-shadow:
    5px 6px 12px rgba(165, 180, 194, 0.4),
    -5px -5px 12px rgba(255, 255, 255, 0.85);
  cursor: pointer;
}
.sidebar-toggle span {
  width: 27px;
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--color-secondary);
  transition:
    transform 0.25s ease,
    opacity 0.25s ease;
}
.sidebar-shell.is-open .sidebar-toggle span:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}
.sidebar-shell.is-open .sidebar-toggle span:nth-child(2) {
  opacity: 0;
}
.sidebar-shell.is-open .sidebar-toggle span:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 5px;
}
.sidebar-shell .sidebar-panel {
  position: absolute;
  top: 72px;
  left: 0;
  width: min(270px, calc(100vw - 48px));
  max-height: calc(100dvh - 120px);
  overflow-y: auto;
  display: flex;
  border-radius: var(--radius-xl);
  padding: 26px 22px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-12px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s;
}
.sidebar-shell.is-open .sidebar-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}
.pomodoro-main {
  padding: 80px 20px 110px;
}
@media (prefers-reduced-motion: reduce) {
  .sidebar-shell .sidebar-panel,
  .sidebar-toggle span {
    transition: none;
  }
}

/* Detachable Goal and Calendar cards */
.widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.widget-drag-handle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: grab;
  touch-action: none;
}
.widget-grip {
  font-size: var(--text-title);
  color: var(--color-secondary);
  opacity: 0.55;
}
.widget-return {
  display: none;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-secondary);
  font: var(--text-title)/1 sans-serif;
  cursor: pointer;
}
.movable-widget.is-floating {
  --card-base: var(--bg-base);
  --shadow-raised-sm:
    6px 8px 16px rgba(186, 200, 212, 0.6),
    -6px -6px 14px rgba(255, 255, 255, 0.95),
    inset 1px 1px 1.5px rgba(255, 255, 255, 0.5);
  position: fixed;
  z-index: 25;
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  font-family: var(--font-hand);
}
.is-floating .widget-return {
  display: block;
}
.is-dragging .widget-drag-handle {
  cursor: grabbing;
}
.movable-widget.is-dragging {
  z-index: 30;
}
.widget-return:hover {
  background: rgba(255, 255, 255, 0.35);
}
.widget-placeholder {
  width: 100%;
  padding: 15px 12px;
  border: 1px dashed rgba(101, 125, 142, 0.35);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--color-secondary);
  font: var(--text-label)/18px var(--font-hand);
  cursor: pointer;
}
.movable-widget
  :is(
    .widget-drag-handle,
    .widget-return,
    .goal-bead,
    .cal-day-cell
  ):focus-visible,
.widget-placeholder:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}
.widget-move-hint {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Profile card from the supplied design */
.sidebar-shell .sidebar-panel {
  width: min(424px, calc(100vw - 48px));
}
.profile-card {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 380px;
  background: var(--color-surface-raised);
  border-radius: var(--radius-xl);
  padding: 24px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
  box-shadow:
    10px 12px 24px rgba(166, 180, 192, 0.6),
    -8px -8px 20px rgba(255, 255, 255, 0.95),
    inset 1px 1px 2px rgba(255, 255, 255, 0.6),
    inset -1px -1px 2px rgba(166, 180, 192, 0.25);
}
.profile-drag-bar {
  position: absolute;
  top: 7px;
  left: 14px;
  right: 12px;
  margin: 0;
  height: 18px;
}
.profile-drag-bar .widget-drag-handle {
  justify-content: flex-end;
}
.profile-drag-bar .widget-grip {
  font-size: var(--text-body);
}
.profile-drag-bar .widget-return {
  height: 18px;
  font-size: var(--text-title);
}
.avatar-wrapper {
  box-sizing: border-box;
  width: 110px;
  height: 110px;
  border-radius: var(--radius-xl);
  background: var(--color-surface-raised);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow:
    inset 3px 3px 6px rgba(166, 180, 192, 0.55),
    inset -3px -3px 6px rgba(255, 255, 255, 0.95),
    0 1px 2px rgba(255, 255, 255, 0.8);
}
.avatar-svg,
.profile-photo {
  width: 100%;
  height: 100%;
  display: block;
}
.profile-photo {
  object-fit: cover;
  border-radius: var(--radius-lg);
}
.profile-photo[hidden],
.avatar-svg[hidden] {
  display: none;
}
.profile-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}
.user-name {
  max-width: 160px;
  margin: 0 0 3px;
  font-size: var(--text-title);
  line-height: 1.25;
  color: var(--color-on-surface);
  font-weight: 400;
  overflow-wrap: anywhere;
}
.user-role {
  margin: 0 0 2px;
  font-size: var(--text-label);
  color: var(--color-secondary);
  overflow-wrap: anywhere;
}
.user-joined {
  font-size: var(--text-label);
  color: var(--color-secondary);
  margin-bottom: 10px;
}
.btn-edit-profile {
  background: var(--color-surface-raised);
  border: none;
  font-family: var(--font-hand);
  font-size: var(--text-label);
  color: var(--color-secondary);
  padding: 6px 18px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow:
    3px 4px 8px rgba(166, 180, 192, 0.5),
    -3px -3px 7px rgba(255, 255, 255, 0.9),
    inset 1px 1px 1.5px rgba(255, 255, 255, 0.7),
    inset -1px -1px 1.5px rgba(166, 180, 192, 0.2);
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease;
  margin-bottom: 10px;
}
.btn-edit-profile:hover {
  box-shadow:
    4px 5px 10px rgba(166, 180, 192, 0.65),
    -3px -3px 8px white;
}
.btn-edit-profile:active {
  transform: scale(0.97);
  box-shadow:
    inset 2px 2px 4px rgba(166, 180, 192, 0.6),
    inset -2px -2px 4px rgba(255, 255, 255, 0.9);
}
.user-focus {
  font-size: var(--text-label);
  color: var(--color-primary);
  letter-spacing: 0.2px;
}
.profile-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(350px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  background: var(--color-surface-raised);
  color: var(--color-on-surface);
  font-family: var(--font-hand);
  box-shadow: 10px 12px 30px rgba(100, 122, 139, 0.2);
}
.profile-dialog::backdrop {
  background: rgba(74, 96, 112, 0.2);
  backdrop-filter: blur(4px);
}
.profile-dialog h2 {
  margin: 0 0 8px;
  font-size: var(--text-headline);
  font-weight: 400;
}
.profile-dialog label {
  display: block;
  margin: 17px 0 8px;
  font-size: var(--text-label);
}
.profile-dialog input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  color: var(--color-on-surface);
  box-shadow:
    inset 2px 2px 4px rgba(166, 180, 192, 0.45),
    inset -2px -2px 4px white;
  font: var(--text-label)/18px var(--font-hand);
  user-select: text;
  -webkit-user-select: text;
}
.profile-save-note {
  margin: 8px 0;
  font-size: var(--text-label);
  color: var(--color-secondary);
}
.profile-text-button {
  border: none;
  background: transparent;
  padding: 6px 0;
  font: var(--text-label) var(--font-hand);
  color: var(--color-primary);
  cursor: pointer;
}
.profile-text-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.profile-text-button:active {
  color: var(--color-on-surface);
}
.profile-text-button:disabled {
  color: var(--color-secondary);
  opacity: 0.6;
  text-decoration: none;
  cursor: default;
}
.profile-form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
  margin-top: 18px;
}
.profile-form-actions .btn-edit-profile {
  margin-bottom: 0;
}
.profile-form-status {
  min-height: 15px;
  margin-top: 8px;
  font-size: var(--text-label);
  color: var(--color-secondary);
}
.profile-dialog :focus-visible,
.btn-edit-profile:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}
@media (max-width: 480px) {
  .profile-card {
    padding: 26px 12px 18px;
    gap: 12px;
  }
  .avatar-wrapper {
    width: 72px;
    height: 80px;
    border-radius: var(--radius-lg);
  }
  .user-name {
    font-size: var(--text-body);
  }
  .user-role {
    font-size: var(--text-label);
  }
  .user-joined {
    font-size: var(--text-label);
  }
  .user-focus {
    font-size: var(--text-label);
  }
  .btn-edit-profile {
    font-size: var(--text-label);
    padding: 6px 12px;
  }
}

/* Match the reference profile alignment and larger avatar artwork. */
.profile-card .avatar-wrapper {
  padding: 4px;
  overflow: hidden;
}
.profile-card .avatar-svg {
  border-radius: var(--radius-lg);
}
.profile-card .user-name {
  margin-bottom: 4px;
}
.profile-card .user-role {
  line-height: 14px;
}
.profile-card .user-joined {
  line-height: 11px;
  margin-bottom: 12px;
}
.profile-card .btn-edit-profile {
  width: 100%;
  margin-bottom: 12px;
}
.profile-card .user-focus {
  width: 100%;
  text-align: center;
}

/* Align the avatar with the full height of the profile details. */
.profile-card {
  align-items: stretch;
}
.profile-card .avatar-wrapper {
  height: auto;
  min-height: 110px;
  align-self: stretch;
}
.profile-card .avatar-svg {
  height: auto;
  align-self: stretch;
  flex: 1;
  min-height: 0;
}
.profile-card .avatar-wrapper {
  position: relative;
}
.profile-card .profile-photo {
  position: absolute;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
}
@media (max-width: 480px) {
  .profile-card .avatar-wrapper {
    min-height: 80px;
  }
}

/* Give the aligned profile avatar a square shape. */
.profile-card .avatar-wrapper {
  width: 139px;
}
@media (max-width: 480px) {
  .profile-card {
    gap: 10px;
  }
  .profile-card .avatar-wrapper {
    width: 96px;
  }
}

.avatar-upload-button {
  border: 0;
  cursor: pointer;
  font: inherit;
}
.avatar-upload-overlay {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  z-index: 1;
  padding: 9px 4px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: rgba(57, 85, 105, 0.75);
  color: #f2f7fa;
  text-align: center;
  font-size: var(--text-label);
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
}
.avatar-upload-button:hover .avatar-upload-overlay,
.avatar-upload-button:focus-visible .avatar-upload-overlay {
  opacity: 1;
  transform: translateY(0);
}
.avatar-upload-button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
}
.avatar-upload-button:disabled {
  cursor: progress;
}
.avatar-upload-status {
  position: absolute;
  bottom: 5px;
  left: 22px;
  right: 22px;
  font-size: var(--text-label);
  line-height: 10px;
  text-align: right;
  color: var(--color-primary);
}
@media (prefers-reduced-motion: reduce) {
  .avatar-upload-overlay {
    transition: none;
  }
}

/* Compact sidebar with more space inside the outer panel. */
.sidebar-shell .sidebar-panel {
  width: min(424px, calc(100vw - 48px));
  padding: 34px 32px;
}
.sidebar-widget {
  padding: 24px 28px 26px;
}
.profile-card {
  max-width: none;
  padding: 32px 24px;
  gap: 12px;
}
.profile-card .user-role {
  font-size: var(--text-label);
}
@media (max-width: 480px) {
  .sidebar-shell .sidebar-panel {
    padding: 30px 24px;
  }
  .sidebar-widget {
    padding: 22px 20px 24px;
  }
  .profile-card {
    padding: 32px 16px 30px;
    gap: 10px;
  }
  .profile-card .user-role {
    font-size: var(--text-label);
  }
}

/* Slide the sidebar without shrinking text or touch targets. */
.sidebar-shell .sidebar-panel {
  transform-origin: top left;
  transform: translateX(-12px);
}
.sidebar-shell.is-open .sidebar-panel {
  transform: translateX(0);
}

/* Custom daily session goals wrap neatly for larger targets. */
.goal-beads-row {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 14px;
}
.goal-bead {
  flex-shrink: 0;
}

/* Actual focus history in the calendar. */
.calendar-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -2px 0 12px;
}
.calendar-navigation button {
  border: 0;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-secondary);
  font: var(--text-label)/16px var(--font-hand);
  cursor: pointer;
}
.calendar-navigation button:hover {
  background: rgba(255, 255, 255, 0.4);
}
.calendar-navigation button:first-child,
.calendar-navigation button:last-child {
  font-size: var(--text-headline);
}
.cal-day-cell {
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  color: inherit;
}
.cal-day-cell[aria-current="date"] .day-num {
  color: var(--color-primary);
  font-weight: 600;
}
.calendar-extra {
  font-size: var(--text-label);
  line-height: 6px;
  color: var(--color-secondary);
}
.calendar-navigation button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.persistence-note {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  color: var(--color-secondary);
  box-shadow: 2px 3px 10px rgba(100, 122, 139, 0.18);
  font: var(--text-label)/15px var(--font-hand);
  z-index: 40;
}

/* Small floating history card, outside the scaled sidebar. */
.history-popup {
  position: fixed;
  z-index: 50;
  box-sizing: border-box;
  width: min(176px, calc(100vw - 24px));
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow:
    5px 7px 16px rgba(166, 180, 192, 0.4),
    -4px -4px 12px rgba(255, 255, 255, 0.8),
    inset 1px 1px 2px rgba(255, 255, 255, 0.65);
  color: var(--color-on-surface);
  font-family: var(--font-hand);
  pointer-events: none;
  animation: history-popup-in 0.16s ease-out;
}
.history-popup[hidden] {
  display: none;
}
.history-popup p {
  margin: 0;
}
.history-popup-date {
  font-size: var(--text-label);
  line-height: 15px;
}
.history-popup .history-popup-sessions {
  margin-top: 9px;
  font-size: var(--text-label);
  line-height: 16px;
}
.history-popup .history-popup-duration {
  margin-top: 4px;
  font-size: var(--text-label);
  line-height: 14px;
  color: var(--color-primary);
}
.history-popup-beads {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.history-popup-beads[hidden] {
  display: none;
}
.history-popup-bead {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #99c7dd, #76a8c3 65%, #5d8ea7);
  box-shadow:
    1px 2px 3px rgba(93, 142, 167, 0.3),
    -1px -1px 3px rgba(255, 255, 255, 0.8);
}
.history-popup-extra {
  font-size: var(--text-label);
  line-height: 11px;
  color: var(--color-primary);
}
@keyframes history-popup-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .history-popup {
    animation: none;
  }
}

/* Completed focus session travels from the dial into a goal bead. */
.session-transfer-orb {
  position: fixed;
  z-index: 100;
  border-radius: 50%;
  pointer-events: none;
  transform-origin: center;
  background: radial-gradient(
    circle at 35% 30%,
    #b5d8e8 0%,
    #82b4ce 60%,
    #5882a0 100%
  );
  box-shadow:
    6px 8px 20px rgba(88, 130, 160, 0.25),
    inset 1px 1px 3px rgba(255, 255, 255, 0.85);
}
.goal-bead.active.is-receiving-session {
  background: radial-gradient(
    circle at 35% 30%,
    #dae4eb 0%,
    #c4d1dc 65%,
    #adc0cd 100%
  );
  box-shadow:
    2px 3px 5px rgba(173, 192, 205, 0.45),
    -1.5px -1.5px 4px rgba(255, 255, 255, 0.85);
}
.goal-bead.is-rewarded {
  animation: session-bead-pop 0.6s ease-out;
}
@keyframes session-bead-pop {
  0% {
    transform: scale(0.8);
  }
  40% {
    transform: scale(1.3);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .goal-bead.is-rewarded {
    animation: none;
  }
}

.timer-duration-settings {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}
.timer-duration-settings legend {
  font-size: var(--text-body);
  margin-bottom: 5px;
}
.timer-duration-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.profile-dialog .timer-duration-grid label {
  font-size: var(--text-label);
  margin-top: 10px;
  min-height: 24px;
}
.timer-duration-grid input {
  min-width: 0;
}

.current-task {
  font-family: var(--font-hand);
  width: min(285px, 75vw);
  margin-top: 25px;
  text-align: center;
}
.current-task label {
  display: block;
  margin-bottom: 10px;
  font-size: var(--text-label);
  color: var(--color-secondary);
}
.current-task input {
  width: 100%;
  border: 0;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font: inherit;
  font-size: var(--text-body);
  text-align: center;
  color: var(--color-on-surface);
  background: var(--color-surface);
  box-shadow:
    inset 3px 3px 6px #c5d0d8,
    inset -3px -3px 6px #f1faff;
}
.current-task input::placeholder {
  color: var(--color-secondary);
}
.current-task input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
}
.history-popup-tasks {
  list-style: none;
  padding: 10px 0 0;
  margin: 10px 0 0;
  border-top: 1px solid rgba(88, 130, 160, 0.15);
  max-width: 225px;
}
.history-popup-tasks li {
  font-size: var(--text-label);
  line-height: 1.6;
  overflow-wrap: anywhere;
  color: var(--color-secondary);
}

.current-task[hidden] {
  display: none;
}
.profile-dialog .profile-task-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-top: 22px;
  line-height: 1.6;
}
.profile-dialog .profile-task-option input {
  appearance: none;
  flex: 0 0 38px;
  width: 38px;
  height: 22px;
  padding: 3px;
  margin: 0;
  border-radius: var(--radius-full);
  cursor: pointer;
  background: var(--color-neutral);
  box-shadow:
    inset 2px 2px 4px #b6c4ce,
    inset -2px -2px 4px #f1faff;
}
.profile-task-option input::before {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-surface-raised);
  box-shadow: 1px 2px 3px #9eafbc;
  transition: transform 0.2s ease;
}
.profile-dialog .profile-task-option input:checked {
  background: var(--color-tertiary);
}
.profile-task-option input:checked::before {
  transform: translateX(16px);
}
@media (prefers-reduced-motion: reduce) {
  .profile-task-option input::before {
    transition: none;
  }
}

.weekly-stats {
  font-family: var(--font-hand);
}
.weekly-stats-range {
  color: var(--color-secondary);
  font-size: var(--text-label);
  margin: -4px 0 18px;
}
.weekly-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}
.weekly-stats-grid dt {
  font-size: var(--text-label);
  color: var(--color-secondary);
  margin-bottom: 10px;
}
.weekly-stats-grid dd {
  margin: 0;
  font-size: var(--text-body);
  color: var(--color-primary);
  white-space: nowrap;
}
.weekly-stats-note {
  font-size: var(--text-label);
  line-height: 1.6;
  color: var(--color-secondary);
  margin: 18px 0 0;
}

.reset-layout-button {
  align-self: flex-end;
  margin-bottom: -6px;
  font-size: var(--text-label);
}
.ambient-card {
  font-family: var(--font-hand);
}
.ambient-label {
  display: block;
  font-size: var(--text-label);
  color: var(--color-secondary);
  margin-bottom: 10px;
}
.ambient-play-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ambient-play-row select {
  min-width: 0;
  flex: 1;
  color: var(--color-secondary);
  background: var(--color-surface);
  border: 0;
  border-radius: var(--radius-md);
  padding: 10px;
  font: var(--text-label) var(--font-hand);
  box-shadow:
    inset 2px 2px 4px #c4d0d9,
    inset -2px -2px 4px #f3faff;
}
.ambient-volume-label {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}
#ambientVolume {
  width: 100%;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.ambient-status {
  font-size: var(--text-label);
  line-height: 1.6;
  color: var(--color-secondary);
  margin-top: 12px;
}
.ambient-card :focus-visible,
.reset-layout-button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
}
.minimal-controls {
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 360px;
}
.minimal-controls > * {
  margin-left: 0 !important;
}

.interval-setting {
  display: flex;
  align-items: center;
  gap: 12px;
}
.profile-dialog .interval-setting input {
  width: 68px;
  flex-shrink: 0;
}
.interval-setting span {
  font-size: var(--text-label);
  color: var(--color-secondary);
}
#testNotificationButton:disabled {
  opacity: 0.5;
  cursor: default;
}

.task-queue-card {
  font-family: var(--font-hand);
}
.task-queue-form {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.task-queue-form input {
  min-width: 0;
  flex: 1;
  width: 100%;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-secondary);
  padding: 10px 12px;
  font: var(--text-label) var(--font-hand);
  box-shadow:
    inset 2px 2px 4px #c4d0d9,
    inset -2px -2px 4px #f3faff;
}
.task-queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 290px;
  overflow-y: auto;
}
.task-queue-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 6px;
  border-bottom: 1px solid rgba(88, 130, 160, 0.12);
}
.task-queue-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--color-neutral);
  color: var(--color-primary);
  box-shadow:
    inset 2px 2px 4px #b8c9d5,
    inset -2px -2px 4px #f4faff;
  cursor: pointer;
}
.task-queue-check[aria-pressed="true"] {
  background: var(--color-tertiary);
  color: white;
}
.task-queue-select {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 6px;
  text-align: left;
  background: transparent;
  font: var(--text-label)/1.5 var(--font-hand);
  color: var(--color-secondary);
  cursor: pointer;
}
.task-queue-select span {
  display: block;
  overflow-wrap: anywhere;
}
.task-queue-select small {
  display: block;
  color: var(--color-secondary);
  font-size: var(--text-label);
  margin-top: 5px;
}
.task-queue-select[aria-pressed="true"] {
  background: rgba(130, 168, 191, 0.16);
}
.task-queue-select:disabled,
.task-queue-check:disabled {
  cursor: default;
  opacity: 0.6;
}
.task-queue-row.is-complete .task-queue-select > span {
  text-decoration: line-through;
}
.task-queue-note {
  color: var(--color-secondary);
  font-size: var(--text-label);
  line-height: 1.6;
  margin: 10px 0;
}
.task-queue-completed {
  margin-top: 16px;
  color: var(--color-secondary);
  font-size: var(--text-label);
}
.task-queue-completed summary {
  cursor: pointer;
}
.task-queue-card :focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}
#clearTaskSelection {
  margin-top: 12px;
  font: var(--text-label) var(--font-hand);
}
.current-task input[readonly] {
  color: var(--color-primary);
}

.task-target-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: var(--text-label);
  color: var(--color-secondary);
  margin: -4px 0 15px;
}
.task-target-label input {
  width: 48px;
  border: 0;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-secondary);
  font: inherit;
  box-shadow:
    inset 2px 2px 4px #c4d0d9,
    inset -2px -2px 4px #f3faff;
}
.task-row-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.task-action-button {
  font: var(--text-label) var(--font-hand);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-secondary);
  background: transparent;
  padding: 6px;
  cursor: pointer;
}
.task-action-button:disabled {
  opacity: 0.45;
  cursor: default;
}
.task-action-button:hover:not(:disabled) {
  background: rgba(130, 168, 191, 0.18);
}
.task-queue-select progress {
  appearance: none;
  width: 100%;
  height: 5px;
  border: 0;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  overflow: hidden;
  background: var(--color-neutral);
}
.task-queue-select progress::-webkit-progress-bar {
  background: var(--color-neutral);
  border-radius: var(--radius-sm);
}
.task-queue-select progress::-webkit-progress-value {
  background: var(--color-tertiary);
  border-radius: var(--radius-sm);
}
.task-queue-select progress::-moz-progress-bar {
  background: var(--color-tertiary);
  border-radius: var(--radius-sm);
}
.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}
.profile-dialog .backup-file-label {
  display: inline-block;
  margin: 0;
  padding: 8px 12px;
}
.undo-restore-button {
  margin-top: 12px;
}
@media (max-width: 640px) {
  body {
    display: block;
    padding: 0;
    overflow-x: hidden;
  }
  .pomodoro-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100dvh;
  }
  .pomodoro-main {
    order: -1;
    width: 100%;
    padding: 65px 16px 32px;
  }
  .stage-wrapper {
    max-width: 100%;
  }
  .sidebar-shell {
    position: static;
    width: 100%;
    height: auto;
    padding: 16px;
  }
  .sidebar-toggle {
    display: none;
  }
  .sidebar-shell .sidebar-panel,
  .sidebar-shell.is-open .sidebar-panel {
    position: static;
    width: 100%;
    max-height: none;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    gap: 24px;
    border-radius: var(--radius-xl);
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    overflow: visible;
  }
  .sidebar-widget {
    width: 100%;
    max-width: none;
    padding: 24px 18px;
    flex-shrink: 0;
  }
  .widget-title {
    cursor: default;
    touch-action: auto;
  }
  .widget-grip,
  .widget-return,
  .widget-placeholder {
    display: none !important;
  }
  .task-queue-list {
    max-height: none;
  }
  .task-action-button {
    min-height: 40px;
    padding: 8px;
  }
  .task-queue-check {
    width: 28px;
    height: 28px;
  }
  .task-queue-form input,
  .current-task input,
  .profile-dialog input {
    font-size: var(--text-input);
  }
  .task-queue-select {
    min-height: 44px;
  }
  .pill-btn,
  .profile-text-button,
  .calendar-navigation button {
    min-height: 40px;
  }
  /* Phones: the hint sits inside the plate, above the socket, without its arrow. */
  .annotation-box {
    left: 50%;
    top: var(--space-md);
    bottom: auto;
    transform: translateX(-50%);
  }
  .annotation-box svg {
    display: none;
  }
  .annotation-box .handwritten-text {
    margin-left: 0;
  }
  .profile-card {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 12px;
    padding: 24px 14px;
  }
  .profile-card .avatar-wrapper {
    width: 88px;
    height: 100px;
    min-width: 0;
    align-self: center;
  }
  .profile-card .profile-info {
    min-width: 0;
  }
  .profile-card .user-name {
    font-size: var(--text-body);
    overflow-wrap: anywhere;
  }
  .profile-card .user-role {
    font-size: var(--text-label);
  }
  .profile-card .btn-edit-profile {
    padding: 7px 10px;
  }
  .profile-card .user-focus {
    font-size: var(--text-label);
  }
  .weekly-stats-grid {
    gap: 7px;
  }
  .weekly-stats-grid dd {
    font-size: var(--text-body);
    white-space: normal;
  }
  .profile-dialog {
    padding: 22px;
  }
  .undo-restore-button {
    max-width: calc(100vw - 32px);
  }
}

/* Tabbed profile editor: one scrollable panel and a persistent action footer. */
#profileDialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  overflow: hidden;
}
#profileForm {
  display: flex;
  flex-direction: column;
  height: min(680px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
}
.profile-dialog-header {
  flex-shrink: 0;
  padding: 24px 24px 10px;
}
.profile-tabs {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.1fr 1.3fr;
  gap: 7px;
  padding: 10px 20px 14px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(88, 130, 160, 0.12);
}
.profile-tabs [role="tab"] {
  border: 0;
  border-radius: var(--radius-md);
  min-height: 44px;
  padding: 8px 5px;
  font: var(--text-label)/1.5 var(--font-hand);
  color: var(--color-secondary);
  background: transparent;
  cursor: pointer;
}
.profile-tabs [role="tab"][aria-selected="true"] {
  color: var(--color-primary);
  background: var(--color-surface-raised);
  box-shadow:
    inset 2px 2px 5px #c2d0da,
    inset -2px -2px 5px #f7fcff;
}
.profile-tabs [role="tab"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.profile-panel-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 24px 20px;
}
.profile-panel-scroll [role="tabpanel"][hidden] {
  display: none;
}
.profile-panel-scroll [role="tabpanel"]:focus-visible {
  outline-offset: -2px;
}
.profile-dialog-footer {
  flex-shrink: 0;
  padding: 12px 24px 18px;
  border-top: 1px solid rgba(88, 130, 160, 0.12);
  background: var(--color-surface-raised);
}
.profile-dialog-footer .profile-form-actions {
  margin-top: 6px;
}
.profile-dialog-footer .profile-form-status:empty {
  display: none;
}
.profile-dialog-footer button {
  min-height: 42px;
}
@media (max-width: 640px) {
  #profileDialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    padding: 0;
  }
  #profileForm {
    height: min(680px, calc(100dvh - 24px));
    max-height: calc(100dvh - 24px);
  }
  .profile-dialog-header {
    padding: 20px 18px 8px;
  }
  .profile-tabs {
    padding: 8px 12px 12px;
    gap: 4px;
  }
  .profile-tabs [role="tab"] {
    font-size: var(--text-label);
  }
  .profile-panel-scroll {
    padding: 2px 18px 16px;
  }
  .profile-dialog-footer {
    padding: 10px 18px 14px;
  }
}

/* Mobile keeps the timer central; cards open only through the menu button. */
@media (max-width: 640px) {
  .pomodoro-main {
    min-height: 100dvh;
    padding: 88px 16px 64px;
  }
  .sidebar-shell {
    position: fixed;
    top: 16px;
    left: 16px;
    width: calc(100% - 32px);
    height: 48px;
    padding: 0;
  }
  .sidebar-toggle {
    display: flex;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
  }
  .sidebar-shell .sidebar-panel,
  .sidebar-shell.is-open .sidebar-panel {
    position: absolute;
    top: 64px;
    left: 0;
    width: 100%;
    max-height: calc(100dvh - 104px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: none;
    transition: none;
  }
  .sidebar-shell .sidebar-panel {
    display: none;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }
  .sidebar-shell.is-open .sidebar-panel {
    display: flex;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }
}

.task-queue-row.is-completing {
  border-radius: var(--radius-md);
  animation: queue-task-finish 650ms ease both;
}
.task-queue-row.is-completing .task-queue-check {
  animation: queue-check-pop 500ms cubic-bezier(0.2, 0.8, 0.25, 1.35) both;
}
.task-queue-row.is-completing .task-queue-select > span {
  text-decoration: none;
  position: relative;
  display: inline-block;
}
.task-queue-row.is-completing .task-queue-select > span::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: currentColor;
  transform-origin: left center;
  animation: queue-task-strike 250ms ease-out both;
}
@keyframes queue-check-pop {
  0% {
    transform: scale(0.75);
  }
  45% {
    transform: scale(1.25);
    box-shadow: 0 0 0 7px rgba(130, 168, 191, 0.16);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 12px rgba(130, 168, 191, 0);
  }
}
@keyframes queue-task-strike {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}
@keyframes queue-task-finish {
  0% {
    background: rgba(130, 168, 191, 0.16);
    opacity: 1;
    transform: translateY(0);
  }
  65% {
    background: rgba(130, 168, 191, 0.06);
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}
@media (prefers-reduced-motion: reduce) {
  .task-queue-row.is-completing,
  .task-queue-row.is-completing .task-queue-check,
  .task-queue-row.is-completing .task-queue-select > span::after {
    animation: none;
  }
}

.ambient-status:empty {
  display: none;
}


.focus-preset-settings select {
  width: 100%; min-height: 42px; border: 0; border-radius: var(--radius-md);
  padding: 10px 12px; background: var(--color-surface-raised); color: var(--color-secondary); font: inherit;
  box-shadow: inset 2px 2px 4px #c8d3dc, inset -2px -2px 4px #f4fcff;
}
.preset-actions { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 6px; }
.preset-actions button:disabled { opacity: .45; cursor: default; }
#focusPresetStatus:empty { display: none; }

/* Only the tab holding the browser lock can initialize the application. */
#pomodoroApp:not([hidden]) { display: contents; }
.tab-guard {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(100%, 380px);
  box-sizing: border-box;
  padding: 32px;
  border-radius: var(--radius-xl);
  background: var(--bg-base);
  box-shadow: var(--outer-plate-shadow);
  text-align: center;
}
.tab-guard[hidden] { display: none; }
.tab-guard h1 { font-family: var(--font-hand); font-size: var(--text-headline); }
.tab-guard p { color: var(--color-secondary); line-height: 1.6; }
.tab-guard button { margin: 16px auto 0; }

/* Accessibility: retain the soft surfaces with legible text and visible controls. */
:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}
.minimal-controls { opacity: 1; }
.sidebar-toggle:focus-visible { opacity: 1; }
:is(.user-joined, .user-focus, .weekly-stats-range, .weekly-stats-grid dt,
    .weekly-stats-grid dd, .weekly-stats-note, .task-queue-note,
    .task-queue-select small, .task-target-label, .task-action-button,
    .task-queue-completed, .profile-save-note, .profile-text-button,
    .profile-tabs [role="tab"], .ambient-label, .ambient-status,
    .ambient-background-link, .interval-setting span, .current-task label,
    .cal-weekdays, .calendar-navigation button, .history-popup-sessions,
    .history-popup-duration, .history-popup-tasks) { color: var(--color-secondary); }
.current-task input::placeholder { color: var(--color-secondary); opacity: 1; }
.task-queue-select:disabled { opacity: 1; }
.profile-save-note, .task-queue-note, .task-queue-select small,
.weekly-stats-range, .weekly-stats-grid dt { font-size: var(--text-label); }
.minimal-controls { flex-wrap: wrap; justify-content: center; gap: 10px; }
.profile-form-actions { flex-wrap: wrap; }
.tab-guard { max-height: calc(100dvh - 32px); overflow-y: auto; }
@media (max-width: 640px), (pointer: coarse) {
  :is(.pill-btn, .profile-text-button, .task-action-button, .btn-edit-profile,
      .calendar-navigation button, .task-queue-completed summary, .profile-dialog-footer button) {
    min-height: 44px;
    min-width: 44px;
  }
  .task-queue-check { width: 44px; height: 44px; flex-shrink: 0; }
  .cal-day-cell { min-height: 36px; min-width: 24px; }
  .profile-card .user-role, .profile-card .user-joined,
  .profile-card .user-focus { font-size: var(--text-label); line-height: 1.5; }
  .profile-card .user-role { overflow-wrap: anywhere; }
  .sidebar-toggle { opacity: 1; }
}
@media (max-width: 360px) {
  .profile-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
/* Keep assistive labels offscreen even when the utility CDN is unavailable. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.session-history-dialog { width: min(480px, calc(100vw - 32px)); }
.history-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.session-history-list { list-style: none; margin: 16px 0 0; padding: 0; }
.session-history-list li { padding: 14px 0; border-top: 1px solid var(--color-neutral); overflow-wrap: anywhere; font-size: var(--text-body); }
.session-history-list p { margin: 0 0 8px; }
#sessionHistoryEditForm { padding: 16px; margin-top: 12px; border-radius: var(--radius-lg); box-shadow: inset 2px 2px 5px #ccd9e2, inset -2px -2px 5px #fff; }
#sessionHistoryEditForm h3 { font-size: var(--text-body); font-weight: 400; }
#sessionHistoryQueue { width: 100%; padding: 10px; font: inherit; font-size: var(--text-label); color: inherit; background: var(--color-surface-raised); border: 1px solid var(--color-neutral); border-radius: var(--radius-md); }
.session-history-dialog button { min-height: 40px; }
.session-history-dialog button:disabled { opacity: .5; cursor: default; }

.site-info-links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; }
.site-info-links a, .tab-guard a { color: var(--color-primary); text-underline-offset: 3px; font-size: var(--text-body); }
.site-info-links a { display: inline-flex; align-items: center; min-height: 44px; }
/* Keep editable history controls comfortable at narrow widths and high zoom. */
@media (max-width: 640px), (pointer: coarse) {
  .session-history-dialog button { min-height: 44px; }
  #sessionHistoryQueue { font-size: var(--text-title); }
}
@media (forced-colors: active) {
  button, input, select, .squircle-plate, .sidebar-widget { border: 1px solid ButtonText; }
  .goal-bead.active { outline: 2px solid Highlight; }
}

/* Sidebar type roles stay readable in both docked and floating cards. */
.sidebar-panel, .movable-widget {
  --sidebar-heading-size: var(--text-body);
  --sidebar-body-size: var(--text-label);
  --sidebar-detail-size: var(--text-label);
}
.quote-text { font-size: var(--text-label); line-height: 1.5; }
.sidebar-widget .widget-title { font-size: var(--sidebar-heading-size); line-height: 1.4; }
.sidebar-widget :is(.pill-btn, .btn-edit-profile, .task-action-button,
    .task-queue-select, .ambient-play-row select, .calendar-navigation button,
    .task-queue-completed, .task-target-label),
.sidebar-panel > .reset-layout-button, .widget-placeholder {
  font-size: var(--sidebar-body-size);
  line-height: 1.5;
}
.sidebar-widget :is(.pill-btn, .btn-edit-profile, .task-action-button) { min-height: 40px; }
.sidebar-widget :is(.ambient-label, .ambient-status, .ambient-background-link,
    .profile-text-button, .task-queue-note, .task-queue-select small,
    .weekly-stats-range, .weekly-stats-grid dt) {
  font-size: var(--sidebar-detail-size);
  line-height: 1.5;
}
.sidebar-widget .task-queue-select { font-size: var(--sidebar-body-size); }
.sidebar-widget .weekly-stats-grid dd { font-size: var(--text-body); }
.sidebar-widget .weekly-stats-grid { gap: 8px; }
.sidebar-widget .cal-weekdays { font-size: var(--sidebar-detail-size); }
.sidebar-widget .cal-grid { font-size: var(--sidebar-body-size); row-gap: 6px; }
.sidebar-widget .cal-day-cell { height: 36px; }
.sidebar-widget .calendar-extra { font-size: var(--text-label); line-height: 1; }
.sidebar-widget .calendar-navigation button:first-child,
.sidebar-widget .calendar-navigation button:last-child { font-size: var(--text-title); }
.sidebar-widget .ambient-play-row { flex-wrap: wrap; gap: 10px; }
.sidebar-widget .ambient-play-row select { flex-basis: 140px; }
.sidebar-widget .task-row-actions { flex-shrink: 0; }
.sidebar-widget .user-name { font-size: var(--sidebar-heading-size); line-height: 1.4; }
.profile-card :is(.user-role, .user-joined, .user-focus) {
  font-size: var(--sidebar-detail-size);
  line-height: 1.5;
}
.sidebar-widget .user-name, .sidebar-widget .user-focus,
.sidebar-widget .weekly-stats-range { overflow-wrap: anywhere; }
@media (min-width: 641px) {
  .sidebar-shell .sidebar-panel {
    width: min(360px, calc(100vw - 48px));
    padding: 26px 24px;
  }
  .sidebar-widget:not(.profile-card) { padding: 24px 20px; }
  .profile-card .avatar-wrapper { width: 96px; }
  .sidebar-widget .task-queue-form input { font-size: var(--sidebar-body-size); }
}
@media (max-width: 640px), (pointer: coarse) {
  .sidebar-widget :is(.pill-btn, .btn-edit-profile, .task-action-button) { min-height: 44px; }
  .sidebar-widget .ambient-play-row select { font-size: var(--text-input); }
  .sidebar-widget .user-name { font-size: var(--sidebar-heading-size); }
}
