/* ==========================================================================
   1. Minimalist Themes ([data-theme])
   ========================================================================== */
:root,
[data-theme="white"] {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #5a5a5a;
  --surface: #f2f3f5;
  --surface-hover: #e5e7eb;
  --border: rgba(17, 17, 17, 0.14);
  --accent: #111111;
  --accent-fg: #ffffff;
  --overtime: #b91c1c;
  --break: #0f766e;
}

[data-theme="black"] {
  --bg: #0f0f0f;
  --fg: #f5f5f5;
  --muted: #9ca3af;
  --surface: #1c1c1e;
  --surface-hover: #2a2a2e;
  --border: rgba(245, 245, 245, 0.14);
  --accent: #f5f5f5;
  --accent-fg: #0f0f0f;
  --overtime: #f87171;
  --break: #34d399;
}

[data-theme="navy"] {
  --bg: #0b192c;
  --fg: #f0f4f8;
  --muted: #9fb3c8;
  --surface: #142844;
  --surface-hover: #1d375c;
  --border: rgba(240, 244, 248, 0.16);
  --accent: #f0f4f8;
  --accent-fg: #0b192c;
  --overtime: #fca5a5;
  --break: #5eead4;
}

[data-theme="grey"] {
  --bg: #2c3036;
  --fg: #f3f4f6;
  --muted: #b0b7c3;
  --surface: #383d45;
  --surface-hover: #454b54;
  --border: rgba(243, 244, 246, 0.15);
  --accent: #f3f4f6;
  --accent-fg: #2c3036;
  --overtime: #fca5a5;
  --break: #6ee7b7;
}

/* ==========================================================================
   2. Reset & Base Viewport Rules (Zero Overflow)
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ==========================================================================
   3. Fluid clamp() App Shell & Layout
   ========================================================================== */
.app-shell {
  width: 100%;
  height: 100%;
  padding: clamp(6px, 2vw, 18px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: clamp(6px, 2vh, 20px);
  overflow: hidden;
}

.app-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-stats {
  font-size: clamp(0.72rem, 2.2vw, 0.875rem);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.main-stage {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 2vh, 20px);
}

.timer-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 2vh, 20px);
}

.timer-display-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.mode-badge {
  font-size: clamp(0.65rem, 1.8vw, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.mode-badge.is-overtime {
  color: var(--overtime);
}

.mode-badge.is-break {
  color: var(--break);
}

.timer-digits {
  font-size: clamp(2rem, 11vw, 6.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.timer-digits.is-overtime {
  color: var(--overtime);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 1.8vw, 12px);
  width: 100%;
}

/* ==========================================================================
   4. Buttons & Interactive Pills
   ========================================================================== */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: clamp(6px, 1.4vh, 12px) clamp(12px, 3vw, 24px);
  font-size: clamp(0.8rem, 2.4vw, 1rem);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.task-pill:focus-visible,
.theme-chip:focus-visible,
.minute-wheel:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--fg);
}

.btn-secondary:hover {
  background-color: var(--surface-hover);
}

.btn-ghost {
  background-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background-color: var(--surface);
  color: var(--fg);
}

.btn-full {
  width: 100%;
}

.icon-btn {
  appearance: none;
  background-color: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover {
  background-color: var(--surface-hover);
}

.pip-only-btn {
  display: none;
}

/* Bottom Task Reminder Pill */
.bottom-pill-bar {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.task-pill {
  appearance: none;
  max-width: min(92vw, 340px);
  padding: 6px 16px;
  border-radius: 999px;
  background-color: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  font-size: clamp(0.75rem, 2.2vw, 0.9rem);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.task-pill:hover {
  background-color: var(--surface-hover);
}

.strip-pill {
  display: none;
}

/* ==========================================================================
   5. Embedded End-of-Session & Smart Break Cards
   ========================================================================== */
.embedded-card {
  width: min(100%, 380px);
  padding: clamp(12px, 3vw, 22px);
  border-radius: 16px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(10px, 2vh, 16px);
}

.card-prompt {
  font-size: clamp(0.85rem, 2.5vw, 1.05rem);
  font-weight: 600;
  line-height: 1.4;
}

.card-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

/* ==========================================================================
   6. Modals & Scroll-Snap Time Wheel
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 3vw, 18px);
  z-index: 50;
}

.modal-dialog {
  width: min(100%, 320px);
  max-height: 92vh;
  overflow-y: auto;
  background-color: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
}

.wheel-stage {
  position: relative;
  height: 180px;
  border-radius: 12px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

.wheel-highlight {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 72px;
  height: 36px;
  border-radius: 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background-color: var(--surface-hover);
  pointer-events: none;
}

.minute-wheel {
  position: relative;
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  padding-top: 72px;
  padding-bottom: 72px;
}

.minute-wheel::-webkit-scrollbar {
  display: none;
}

.wheel-item {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.wheel-item.is-selected {
  color: var(--fg);
  font-weight: 700;
  font-size: 1.2rem;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.text-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--fg);
  font-size: 0.92rem;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.theme-chip {
  appearance: none;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--fg);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-chip[aria-checked="true"] {
  background-color: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.stats-detail {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ==========================================================================
   7. Narrow Sidebar Adjustments (<= 245px wide, e.g., 200px sidebar or PiP)
   ========================================================================== */
@media (max-width: 245px) {
  .header-stats {
    display: none;
  }

  .app-header {
    justify-content: flex-end;
  }

  .timer-digits {
    font-size: clamp(2rem, 22vw, 3.1rem);
  }

  .controls-row {
    gap: 5px;
  }

  .btn {
    padding: 6px 10px;
    font-size: 0.76rem;
}
}
/* Picture-in-Picture Document Mode */
body.is-pip-window .timer-digits {
font-size: 2.3rem;
}
body.is-pip-window .mode-badge {
display: none;
}
body.is-pip-window #change-time-btn {
display: none;
}
body.is-pip-window .pip-only-btn {
display: inline-flex;
width: 28px;
height: 28px;
}
body.is-pip-window .btn {
padding: 5px 11px;
font-size: 0.76rem;
}
/* ==========================================================================
8. Tiny Top Split-Screen Strip Mode (@media (max-height: 185px))
========================================================================== */
@media (max-height: 185px) {
.app-shell {
padding: 6px 10px;
justify-content: center;
gap: 0;
}
.app-header,
.bottom-pill-bar,
.mode-badge,
#change-time-btn {
display: none !important;
}
.main-stage {
width: 100%;
height: 100%;
flex-direction: row;
justify-content: center;
align-items: center;
}
.timer-wrapper {
width: 100%;
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: 8px;
}
.timer-display-group {
flex-shrink: 0;
}
.timer-digits {
font-size: clamp(1.5rem, 11vh, 2.4rem);
}
.controls-row {
width: auto;
flex-wrap: nowrap;
gap: 6px;
flex-shrink: 0;
}
.controls-row .btn {
padding: 6px 12px;
font-size: 0.78rem;
}
.strip-pill {
display: inline-block;
max-width: clamp(68px, 24vw, 160px);
padding: 4px 10px;
font-size: 0.75rem;
flex-shrink: 1;
}
.embedded-card {
width: 100%;
max-width: none;
flex-direction: row;
justify-content: space-between;
padding: 8px 12px;
gap: 8px;
}
.card-prompt {
font-size: 0.8rem;
text-align: left;
}
.card-actions {
width: auto;
flex-wrap: nowrap;
flex-shrink: 0;
}
}

