/* ============================================================
   Đồng Hồ STEM — giao diện
   Phong cách: sáng, tông cam ấm (tập trung) + xanh (nghỉ)
   ============================================================ */
:root {
  --bg:        #fff5f0;
  --bg-2:      #ffece3;
  --surface:   #ffffff;
  --line:      #f0e2da;
  --ink:       #2c211d;
  --ink-2:     #6b5b54;
  --ink-3:     #9c8b83;

  --primary:   #ef6c45;   /* cam ấm – học/tập trung */
  --primary-d: #d8542f;
  --primary-l: #ffe8df;
  --rest:      #10a15a;   /* xanh – nghỉ */
  --rest-l:    #e2f6ec;

  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-md: 14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(44,33,29,.06), 0 4px 16px rgba(44,33,29,.06);
  --shadow-md: 0 10px 30px rgba(44,33,29,.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 84% -12%, #ffe1d3 0%, transparent 58%),
    radial-gradient(900px 440px at -6% 0%, #ffeede 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.page { max-width: 940px; margin: 0 auto; padding: 16px 18px 56px; }

/* ---------- Nút quay lại ---------- */
.topbar { display: flex; margin-bottom: 14px; }
.back {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font); font-size: 14.5px; font-weight: 700;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 15px 8px 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color .15s, transform .05s;
}
.back:hover { color: var(--primary-d); }
.back:active { transform: scale(.97); }
.back:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(239,108,69,.3); }

/* ---------- Tiêu đề ---------- */
.hero { text-align: center; margin: 6px 0 22px; }
.hero__title {
  font-size: clamp(1.8rem, 4.6vw, 2.6rem);
  font-weight: 900; letter-spacing: -.02em; line-height: 1.1;
  background: linear-gradient(120deg, #d8542f, #f0803f 55%, #e0546f);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__desc {
  max-width: 600px; margin: 10px auto 0;
  font-size: clamp(.95rem, 2.3vw, 1.05rem);
  font-weight: 500; color: var(--ink-2); line-height: 1.55;
}

/* ---------- Bố cục ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card__title { font-size: 1.15rem; font-weight: 900; text-align: center; margin-bottom: 18px; }

/* ---------- Đồng hồ ---------- */
.clock { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.clock__face { width: 100%; max-width: 260px; }
.analog { width: 100%; height: auto; display: block; }
.analog__rim { fill: #fff; stroke: var(--line); stroke-width: 4; }
.analog__pin { fill: var(--primary); }
.tick { stroke: #d9cabf; stroke-width: 2; }
.tick--hour { stroke: var(--ink-2); stroke-width: 3; }
.num { fill: var(--ink-2); font-family: var(--font); font-weight: 800; font-size: 15px; text-anchor: middle; dominant-baseline: central; }
.hand { stroke-linecap: round; }
.hand--hour   { stroke: var(--ink); stroke-width: 6; }
.hand--minute { stroke: var(--ink); stroke-width: 4; }
.hand--second { stroke: var(--primary); stroke-width: 2; }

.clock__digital { text-align: center; width: 100%; }
.clock__time {
  font-size: clamp(2.2rem, 8vw, 2.8rem);
  font-weight: 900; letter-spacing: .01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.clock__date { font-size: .98rem; font-weight: 600; color: var(--ink-2); margin: 4px 0 14px; text-transform: capitalize; }
.clock__tz { display: flex; align-items: center; gap: 10px; justify-content: center; }
.clock__offset {
  font-size: 13px; font-weight: 800; color: var(--primary-d);
  background: var(--primary-l); border-radius: 999px; padding: 6px 12px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* Select tùy biến */
.select { position: relative; flex: 1; max-width: 220px; }
.select select {
  width: 100%; appearance: none;
  font-family: var(--font); font-size: 14px; font-weight: 700;
  color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 36px 10px 13px; cursor: pointer;
}
.select select:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(239,108,69,.16); }
.select__caret { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }

/* ---------- Pomodoro ---------- */
.pomo { display: flex; flex-direction: column; align-items: center; }
.pomo__ring { position: relative; width: 100%; max-width: 240px; margin-bottom: 6px; }
.pomo__ring svg { width: 100%; height: auto; display: block; }
.ring-track { fill: none; stroke: var(--bg-2); stroke-width: 12; }
.ring-prog {
  fill: none; stroke: var(--primary); stroke-width: 12; stroke-linecap: round;
  transition: stroke-dashoffset .3s linear, stroke .3s;
}
.pomo.is-rest .ring-prog { stroke: var(--rest); }
.pomo__center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.pomo__time { font-size: clamp(2.4rem, 9vw, 3rem); font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; }
.pomo__phase { margin-top: 6px; font-size: .95rem; font-weight: 800; color: var(--primary-d); }
.pomo.is-rest .pomo__phase { color: var(--rest); }

.pomo__sessions { font-size: .92rem; font-weight: 600; color: var(--ink-2); margin: 12px 0 18px; }
.pomo__sessions strong { color: var(--ink); }

.pomo__settings {
  display: flex; align-items: flex-end; gap: 10px;
  width: 100%; margin-bottom: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field label { font-size: 12.5px; font-weight: 800; color: var(--ink-2); }
.field input {
  font-family: var(--font); font-size: 1rem; font-weight: 800; text-align: center;
  color: var(--ink); background: var(--bg); border: 2px solid var(--line);
  border-radius: 10px; padding: 10px; width: 100%;
}
.field input:focus-visible { outline: none; border-color: var(--primary); background: #fff; }

.btn {
  font-family: var(--font); font-weight: 800; font-size: 15px;
  border: none; border-radius: 10px; cursor: pointer;
  transition: background .15s, transform .05s, color .15s;
}
.btn--primary { background: var(--primary); color: #fff; padding: 13px 24px; box-shadow: 0 3px 10px rgba(239,108,69,.35); }
.btn--primary:hover { background: var(--primary-d); }
.btn--primary:active { transform: translateY(1px); }
.pomo.is-running .btn--primary { background: var(--ink); box-shadow: none; }
.btn--ghost { background: var(--surface); color: var(--ink-2); border: 1.5px solid var(--line); padding: 12px 20px; }
.btn--ghost:hover { color: var(--ink); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(239,108,69,.32); }

.pomo__controls { display: flex; gap: 10px; width: 100%; margin-bottom: 16px; }
.pomo__controls .btn { flex: 1; }

.pomo__opt { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.pomo__opt input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .page { padding: 12px 12px 40px; }
  .card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .ring-prog, .back, .btn { transition: none; }
}