:root {
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #171512;
  --ink-soft: #8a8480;
  --accent: #5c8a22;
  --accent-soft: #eaf4d6;
  --track: #ececea;
  --line: #171512;
  --shadow: 0 10px 26px rgba(23, 21, 18, 0.08);
  --font-display: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  --font-kr: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-kr);
  display: flex;
  justify-content: center;
  min-height: 100dvh;
  user-select: none;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ---------- 메인 화면 ---------- */

#main-screen {
  padding: env(safe-area-inset-top) 24px env(safe-area-inset-bottom);
  align-items: center;
  height: 100dvh;
  overflow: hidden;
}

.top-bar {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}

.bell-icon {
  color: var(--ink);
  opacity: 0.75;
  display: flex;
}

.main-content {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 6px 0;
  min-height: 0;
}

.timer-caption {
  margin: 0;
  font-family: var(--font-kr);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: -0.1px;
}

.time-display {
  font-family: var(--font-display);
  font-size: clamp(40px, 13vw, 48px);
  font-weight: 500;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: #8e9296;
  line-height: 1;
}

.timer-wrap {
  position: relative;
  width: min(62vw, 260px);
  height: min(62vw, 260px);
  cursor: pointer;
}

.timer-wrap:active {
  transform: scale(0.985);
}

.dial-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.dial-shadow {
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.1)) drop-shadow(0 1px 3px rgba(0, 0, 0, 0.06));
}

.needle {
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
  transition: transform 0.2s linear;
}

.knob-shadow {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
}

.timer-state {
  font-family: var(--font-kr);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.week-progress {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.week-progress-label {
  font-family: var(--font-kr);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
}

.week-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}

.week-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ---------- 하단 컨트롤 ---------- */

.bottom-controls {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 6px 6px 14px;
  flex: none;
}

.control-btn {
  width: 54px;
  height: 54px;
  flex: none;
  border-radius: 50%;
  border: none;
  background: var(--track);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.control-btn:active {
  transform: scale(0.94);
}

/* ---------- 축하 오버레이 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 21, 18, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.celebrate-card {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 28px;
  padding: 40px 28px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.celebrate-emoji {
  font-size: 52px;
  margin-bottom: 12px;
}

.celebrate-message {
  font-family: var(--font-kr);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 18px;
  color: var(--ink);
}

.celebrate-percent {
  font-family: var(--font-kr);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  margin-bottom: 24px;
}

.primary-btn {
  width: 100%;
  border: none;
  background: var(--accent);
  color: white;
  font-family: var(--font-kr);
  font-size: 18px;
  font-weight: 700;
  padding: 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

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

/* ---------- 지난 기록 화면 ---------- */

#history-screen {
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
  background: var(--bg);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 10px;
}

.history-header h2 {
  font-family: var(--font-kr);
  font-size: 21px;
  margin: 0;
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--track);
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-soft);
}

.icon-btn:active {
  transform: scale(0.96);
}

.header-spacer {
  width: 44px;
}

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

.history-item {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.history-item.current {
  border: 3px solid var(--accent);
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.history-item-range {
  font-family: var(--font-kr);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
}

.history-item-tag {
  font-family: var(--font-kr);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  margin-left: 8px;
}

.history-item-percent {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--ink);
}

.history-item-bar {
  margin-top: 10px;
  height: 8px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}

.history-item-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.history-item-hours {
  margin-top: 8px;
  font-family: var(--font-kr);
  font-size: 14px;
  color: var(--ink-soft);
}

.history-empty {
  text-align: center;
  font-family: var(--font-kr);
  color: var(--ink-soft);
  font-size: 16px;
  margin-top: 60px;
}
