/* ==========================================================================
   KAIROS - Calm Modern Interval Timer
   Mobile-First Aesthetic System
   ========================================================================== */

:root {
  /* Warm Zen & Ceramic Tone Palette */
  --canvas-base: #F8F7F4;
  --surface-card: #FFFFFF;
  --surface-pill: rgba(24, 25, 27, 0.04);
  --surface-border: rgba(24, 25, 27, 0.07);
  --glass-surface: rgba(255, 255, 255, 0.82);

  /* Deep Calm Inks */
  --ink-primary: #18191B;
  --ink-secondary: #6B7077;
  --ink-tertiary: #9EA3AB;
  --ink-track: #EBE8E1;

  /* State: Idle (Minimal Charcoal) */
  --accent-start: #484E59;
  --accent-end: #6C7484;
  --accent-soft: rgba(72, 78, 89, 0.08);
  --aura-glow: rgba(72, 78, 89, 0.12);

  /* State Palette References */
  --work-start: #E45834;
  --work-end: #F27E52;
  --work-soft: rgba(228, 88, 52, 0.10);
  --work-aura: rgba(228, 88, 52, 0.22);

  --rest-start: #2F7C5E;
  --rest-end: #4BA682;
  --rest-soft: rgba(47, 124, 94, 0.10);
  --rest-aura: rgba(47, 124, 94, 0.20);

  --ready-start: #D98C32;
  --ready-end: #EDB05E;
  --ready-soft: rgba(217, 140, 50, 0.10);
  --ready-aura: rgba(217, 140, 50, 0.22);

  --complete-start: #5752D8;
  --complete-end: #7A76E8;
  --complete-soft: rgba(87, 82, 216, 0.10);
  --complete-aura: rgba(87, 82, 216, 0.22);

  /* Shadows & Radius */
  --shadow-dock: 0 20px 40px -12px rgba(24, 25, 27, 0.12), 0 4px 12px rgba(24, 25, 27, 0.04);
  --shadow-subtle: 0 4px 20px rgba(24, 25, 27, 0.04);
  --shadow-hero: 0 12px 28px -6px var(--aura-glow);

  --radius-full: 9999px;
  --radius-panel: 32px;
  --radius-card: 20px;
  --radius-sm: 12px;

  --ease-spring: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base & Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--canvas-base);
  color: var(--ink-primary);
  font-family: 'Plus Jakarta Sans', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
}

/* Ambient dynamic background lighting aura */
.ambient-glow {
  position: fixed;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 90vw);
  height: min(520px, 90vw);
  border-radius: var(--radius-full);
  background: radial-gradient(circle, var(--aura-glow) 0%, rgba(248, 247, 244, 0) 70%);
  filter: blur(55px);
  pointer-events: none;
  z-index: 0;
  transition: background 0.8s ease;
}

/* --------------------------------------------------------------------------
   Mobile App Viewport Shell
   -------------------------------------------------------------------------- */
.mobile-viewport {
  width: min(100vw, 420px);
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 18px 20px 18px;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}

/* On larger desktop screens, frame it gracefully like a premium mobile interface */
@media (min-width: 600px) and (min-height: 700px) {
  .mobile-viewport {
    height: 90vh;
    max-height: 840px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 46px;
    box-shadow: 0 24px 64px -16px rgba(24, 25, 27, 0.08), 0 2px 8px rgba(24, 25, 27, 0.02);
    padding: 20px 22px 26px 22px;
  }
}

/* --------------------------------------------------------------------------
   Top Navigation & Segmented Routine Progress Bar
   -------------------------------------------------------------------------- */
.top-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  padding-top: env(safe-area-inset-top, 4px);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--accent-start);
  box-shadow: 0 0 10px var(--accent-start);
  transition: background-color 0.5s ease;
}

.app-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--ink-primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-secondary);
  box-shadow: var(--shadow-subtle);
  transition: all 0.2s var(--ease-spring);
  flex-shrink: 0;
}

.nav-btn:hover {
  color: var(--ink-primary);
  transform: translateY(-1px);
}

.nav-btn:active {
  transform: scale(0.92);
}

.nav-btn .icon {
  width: 18px;
  height: 18px;
}

/* Segmented Timeline (15 sets progress bars) */
.timeline-container {
  width: 100%;
}

.timeline-segments {
  display: flex;
  gap: 3px;
  width: 100%;
  height: 4px;
  border-radius: var(--radius-full);
}

.segment-pill {
  flex: 1;
  min-width: 0;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--ink-track);
  transition: background 0.4s ease, transform 0.2s ease;
}

.segment-pill.completed {
  background: var(--accent-start);
}

.segment-pill.active {
  background: var(--accent-start);
  transform: scaleY(1.6);
  box-shadow: 0 0 6px var(--accent-start);
}

/* --------------------------------------------------------------------------
   Hero Stage (Center Visuals)
   -------------------------------------------------------------------------- */
.hero-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
  margin: auto 0;
}

.phase-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.phase-subtitle {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  transition: color 0.4s ease;
}

.phase-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  transition: color 0.4s ease;
}

/* Circular Progress Ring */
.ring-container {
  position: relative;
  width: min(290px, 70vw);
  height: min(290px, 70vw);
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--ink-track);
  stroke-width: 7;
}

.ring-stroke {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 929.91; /* 2 * PI * 148 */
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 8px var(--aura-glow));
  transition: stroke 0.4s ease;
}

.ring-data {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.counter-digits {
  font-family: 'Outfit', 'Pretendard', sans-serif;
  font-size: clamp(3.6rem, 12.5vw, 4.6rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 8px;
}

.counter-set-badge {
  background: var(--surface-pill);
  border: 1px solid var(--surface-border);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
}

/* Metrics Strip (Bottom of Hero) */
.metrics-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-card);
  padding: 12px 18px;
  width: 100%;
  max-width: 320px;
  box-shadow: var(--shadow-subtle);
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.metric-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-tertiary);
  margin-bottom: 2px;
}

.metric-val {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

.metric-divider {
  width: 1px;
  height: 22px;
  background-color: var(--surface-border);
}

/* --------------------------------------------------------------------------
   Floating Bottom Dock (Tactile Capsule)
   -------------------------------------------------------------------------- */
.floating-dock {
  background: var(--glass-surface);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-dock);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 10px;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  z-index: 10;
}

.dock-btn {
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all 0.22s var(--ease-spring);
  color: var(--ink-secondary);
  flex-shrink: 0;
}

.dock-btn.secondary {
  width: 42px;
  height: 42px;
}

.dock-btn.secondary svg {
  width: 20px;
  height: 20px;
}

.dock-btn.secondary:hover {
  background: var(--surface-pill);
  color: var(--ink-primary);
  transform: translateY(-1px);
}

.dock-btn.secondary:active {
  transform: scale(0.88);
}

/* Giant Hero Play/Pause Button */
.dock-btn.hero-action {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent-start) 0%, var(--accent-end) 100%);
  color: #FFFFFF;
  box-shadow: var(--shadow-hero);
}

.dock-btn.hero-action:hover {
  transform: translateY(-2px) scale(1.04);
}

.dock-btn.hero-action:active {
  transform: scale(0.93);
}

.dock-btn.hero-action .play-svg {
  width: 28px;
  height: 28px;
  margin-left: 3px;
}

.dock-btn.hero-action .pause-svg {
  width: 26px;
  height: 26px;
}

/* Wake indicator */
.wake-indicator {
  text-align: center;
  font-size: 0.68rem;
  color: var(--ink-tertiary);
  font-weight: 500;
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Native iOS Style Bottom Sheet (Settings)
   -------------------------------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 25, 27, 0.40);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.sheet-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: min(100vw, 420px);
  max-width: 100vw;
  max-height: 88vh;
  background: var(--surface-card);
  border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  box-shadow: 0 -12px 48px rgba(24, 25, 27, 0.12);
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.36s var(--ease-spring);
  transform: translateY(0);
  box-sizing: border-box;
}

.sheet-backdrop.hidden,
.sheet-panel.hidden {
  opacity: 0;
  pointer-events: none;
}

.sheet-panel.hidden {
  transform: translateY(100%);
}

.sheet-handle-bar {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 10px;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: var(--radius-full);
  background-color: var(--ink-track);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 14px 18px;
  border-bottom: 1px solid var(--surface-border);
}

.sheet-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink-tertiary);
  display: block;
  margin-bottom: 2px;
}

.sheet-title {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.sheet-close-btn {
  background: var(--surface-pill);
  border: none;
  border-radius: var(--radius-full);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-secondary);
  transition: all 0.2s ease;
}

.sheet-close-btn:hover {
  color: var(--ink-primary);
}

.sheet-content {
  padding: 14px 18px 28px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-secondary);
}

/* Modern Preset Cards with Flexible Columns */
.preset-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  width: 100%;
}

.preset-card {
  background: var(--surface-pill);
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  padding: 10px 10px;
  text-align: left;
  cursor: pointer;
  transition: all 0.22s var(--ease-spring);
  min-width: 0;
  overflow: hidden;
}

.preset-card:hover {
  background: rgba(24, 25, 27, 0.07);
}

.preset-card.active {
  background: var(--work-soft);
  border-color: rgba(228, 88, 52, 0.35);
}

.preset-card.active .preset-name {
  color: var(--work-start);
}

.preset-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  gap: 4px;
}

.preset-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: var(--radius-full);
  background: rgba(24, 25, 27, 0.08);
  color: var(--ink-secondary);
  flex-shrink: 0;
}

.preset-card.active .preset-badge {
  background: rgba(228, 88, 52, 0.16);
  color: var(--work-start);
}

.preset-meta {
  font-size: 0.65rem;
  color: var(--ink-secondary);
  line-height: 1.25;
  word-break: keep-all;
}

/* Stepper Rows */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-border);
  gap: 8px;
}

.row-label-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.row-desc {
  font-size: 0.68rem;
  color: var(--ink-tertiary);
}

.stepper-capsule {
  display: flex;
  align-items: center;
  background: var(--surface-pill);
  border-radius: var(--radius-full);
  padding: 2px 4px;
  gap: 2px;
  flex-shrink: 0;
}

.step-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.step-btn:hover {
  background: #FFFFFF;
  color: var(--ink-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.step-btn:active {
  transform: scale(0.9);
}

.input-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
}

.custom-num-input {
  width: 30px;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-primary);
  text-align: right;
  outline: none;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.custom-num-input::-webkit-outer-spin-button,
.custom-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.unit {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-tertiary);
  margin-left: 2px;
}

/* Summary Banner & Confirm */
.summary-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-pill);
  border-radius: var(--radius-card);
  padding: 12px 16px;
}

.summary-lead {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.summary-highlight {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--ink-primary);
}

.confirm-btn {
  background: var(--ink-primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  padding: 15px 20px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s var(--ease-spring);
  box-shadow: 0 4px 14px rgba(24, 25, 27, 0.15);
}

.confirm-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(24, 25, 27, 0.22);
}

.confirm-btn:active {
  transform: scale(0.98);
}

.hidden {
  display: none !important;
}
