/* ─── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --bg2:       #1e293b;
  --bg3:       #334155;
  --green:     #4ade80;
  --green-dim: #166534;
  --orange:    #fb923c;
  --red:       #f87171;
  --text:      #f1f5f9;
  --text-dim:  #94a3b8;
  --radius:    16px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
}

/* ─── Screens ───────────────────────────────────────────────── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; flex-direction: column; }

/* ─── Auth screens ──────────────────────────────────────────── */
.auth-container {
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 40px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.logo-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--green);
  color: var(--bg);
  font-size: 32px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.logo .tagline { color: var(--text-dim); font-size: 14px; }

form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.field input {
  background: var(--bg2);
  border: 1.5px solid var(--bg3);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--green); }
.field input::placeholder { color: var(--bg3); }

/* ─── Language switcher ─────────────────────────────────────── */
.lang-switcher {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: -8px;
}

.lang-btn {
  background: var(--bg2);
  border: 1.5px solid var(--bg3);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.lang-btn.active {
  border-color: var(--green);
  color: var(--green);
  background: rgba(74,222,128,.1);
}
.lang-btn:hover { border-color: var(--green); color: var(--green); }

/* In header: smaller, icon-only on mobile */
.app-header .lang-btn {
  padding: 4px 8px;
  font-size: 16px;
  border: none;
  background: none;
  color: var(--text-dim);
  border-radius: 6px;
}
.app-header .lang-btn.active { color: var(--green); background: rgba(74,222,128,.1); }

.error-msg {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
}
.success-msg {
  color: var(--green);
  font-size: 13px;
  min-height: 18px;
}

.auth-links {
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  display: flex;
  justify-content: center;
  gap: 8px;
}
.auth-links a { color: var(--green); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  padding: 13px 24px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--green); color: var(--bg); }
.btn-primary:hover { opacity: .9; }

.btn-secondary { background: var(--bg2); color: var(--text); border: 1.5px solid var(--bg3); }
.btn-secondary:hover { background: var(--bg3); }

.btn-danger { background: transparent; color: var(--red); border: 1.5px solid var(--red); }
.btn-danger:hover { background: rgba(248,113,113,.1); }

.btn-full { width: 100%; }
.btn-large {
  width: 100%;
  padding: 18px 24px;
  font-size: 18px;
  border-radius: var(--radius);
  margin-top: 8px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--bg2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ─── App header ────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--bg2);
}
.header-logo { font-size: 18px; font-weight: 800; }
.header-actions { display: flex; gap: 4px; }

/* ─── Home screen ───────────────────────────────────────────── */
.home-content {
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.info-card, .schema-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 20px;
}
.info-card h2, .schema-card h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--green);
}
.info-card p { color: var(--text-dim); font-size: 14px; line-height: 1.7; margin-bottom: 8px; }
.info-card p:last-child { margin-bottom: 0; }

.schema-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.schema-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}
.schema-item.fast { background: rgba(251,146,60,.12); color: var(--orange); }
.schema-item.slow { background: rgba(74,222,128,.12); color: var(--green); }
.schema-item.countdown { background: var(--bg3); color: var(--text-dim); }
.schema-icon { font-size: 16px; }

.schema-repeat {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 4px 0;
}
.total-time {
  text-align: right;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
}

/* ─── Timer screen ──────────────────────────────────────────── */
.timer-content {
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

/* Phase dots */
.phase-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg3);
  transition: background .3s;
}
.phase-dot.active-fast { background: var(--orange); }
.phase-dot.active-slow { background: var(--green); }
.phase-dot.done { background: var(--bg3); opacity: .5; }

/* Timer ring */
.timer-ring-container {
  position: relative;
  width: min(280px, 75vw);
  height: min(280px, 75vw);
}
.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none;
  stroke: var(--bg2);
  stroke-width: 10;
}
.ring-progress {
  fill: none;
  stroke: var(--green);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 603;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .5s linear, stroke .3s;
}
.ring-progress.phase-fast { stroke: var(--orange); }
.ring-progress.phase-slow { stroke: var(--green); }
.ring-progress.phase-countdown { stroke: var(--text-dim); }

.timer-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.timer-display {
  font-size: clamp(44px, 13vw, 64px);
  font-weight: 800;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
}
.timer-phase {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .8px;
  text-align: center;
  padding: 0 20px;
}

.next-phase-info {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  min-height: 20px;
}

.timer-controls {
  display: flex;
  gap: 12px;
  width: 100%;
}
.timer-controls .btn { flex: 1; }

/* ─── Done screen ───────────────────────────────────────────── */
.done-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 32px;
  flex: 1;
  gap: 16px;
  max-width: 420px;
  margin: auto;
}
.done-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--green);
  color: var(--bg);
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.done-container h1 { font-size: 32px; font-weight: 800; }
.done-container p { color: var(--text-dim); font-size: 16px; }
.done-sub { font-size: 14px !important; }

/* ─── Stats screen ──────────────────────────────────────────── */
.stats-content {
  padding: 32px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}
.stats-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding-top: 40px;
}
.stats-placeholder-icon { font-size: 48px; }
.stats-placeholder h2 { font-size: 22px; font-weight: 700; }
.stats-placeholder p { color: var(--text-dim); font-size: 15px; line-height: 1.6; }

#stats-list { width: 100%; margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.stat-item {
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.stat-item-date { color: var(--text-dim); }
.stat-item-badge {
  background: var(--green-dim);
  color: var(--green);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ─── Loader ────────────────────────────────────────────────── */
.btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive tweaks ─────────────────────────────────────── */
@media (max-height: 600px) {
  .auth-container { padding: 20px 24px; }
  .logo-icon { width: 48px; height: 48px; font-size: 24px; }
  .logo h1 { font-size: 22px; }
}
