:root {
  --bg: #16131a;
  --surface: #1f1a24;
  --surface-2: #2a232d;
  --surface-3: #362e39;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4efe9;
  --text-dim: #ab9fac;
  --text-faint: #7a707c;
  --accent-1: #ff6b4a;
  --accent-2: #ffab3d;
  --accent-green: #3ddc84;
  --focus-ring: rgba(255, 140, 90, 0.45);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.65);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf6f1;
    --surface: #ffffff;
    --surface-2: #f4ece4;
    --surface-3: #ece1d7;
    --border: rgba(30, 20, 15, 0.1);
    --text: #211a1d;
    --text-dim: #6c6067;
    --text-faint: #948a8e;
    --accent-1: #e14e2f;
    --accent-2: #e8892c;
    --accent-green: #17a663;
    --focus-ring: rgba(225, 78, 47, 0.35);
    --shadow: 0 24px 50px -28px rgba(60, 30, 10, 0.25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(60% 42% at 50% 36%, rgba(255, 107, 74, 0.10), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: "Public Sans", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.app-card {
  width: 100%;
  max-width: 380px;
  background: radial-gradient(120% 140% at 50% -10%, var(--surface-2), var(--surface) 60%);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 22px 22px 26px;
  box-shadow: var(--shadow);
  position: relative;
}

.app-top {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 14px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.tagline {
  display: none;
  margin: 0 0 26px;
}

.top-controls {
  width: 100%;
  max-width: 380px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 0 12px;
}

.lang-toggle {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px;
  gap: 2px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
}

.lang-toggle button {
  border: none;
  background: transparent;
  color: var(--text-faint);
  padding: 5px 10px;
  border-radius: 100px;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0.04em;
}

.lang-toggle button.active {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #1a1210;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: color .15s ease, transform .15s ease;
}

.icon-btn:hover { color: var(--text); }
.icon-btn.open { color: var(--accent-1); transform: rotate(20deg); }

.settings-panel {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0 0 16px;
}

.settings-panel.open { display: flex; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  position: relative;
}

.settings-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 40px;
  height: 22px;
  margin: 0;
  cursor: pointer;
}

.settings-row .switch {
  width: 40px;
  height: 22px;
  border-radius: 100px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background .15s ease;
}

.settings-row .switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform .15s ease, background .15s ease;
}

.settings-row input[type="checkbox"]:checked + .switch {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-color: transparent;
}

.settings-row input[type="checkbox"]:checked + .switch::after {
  transform: translateX(18px);
  background: #1a1210;
}

.settings-row input[type="checkbox"]:focus-visible + .switch {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.settings-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-faint);
  min-height: 14px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 26px;
}

.mode-tabs button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}

.mode-tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 0 var(--border) inset;
}

.mode-tabs button:focus-visible,
.lang-toggle button:focus-visible,
.ctrl-btn:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.ring-wrap {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 0 auto 24px;
  max-width: 100%;
}

.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 14; }
.ring-red { fill: none; stroke: url(#redGrad); stroke-width: 14; }

.ring-green {
  fill: none;
  stroke: var(--accent-green);
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset .3s linear;
}

.ring-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 0 4px var(--bg), 0 0 14px var(--accent-green);
  top: 0;
  left: 0;
  transition: transform .3s linear, opacity .2s ease;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ring-label {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-1);
  font-weight: 600;
}

.ring-time {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.ring-sub {
  font-size: 12px;
  color: var(--text-faint);
}

.ctrl-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.ctrl-btn {
  font: inherit;
  font-weight: 700;
  font-size: 13.5px;
  padding: 13px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  letter-spacing: 0.02em;
}

.ctrl-btn.primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #1a1210;
  border: none;
}

.ctrl-btn:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 420px) {
  .ring-wrap { width: 210px; height: 210px; }
  .ring-time { font-size: 42px; }
}

/* ---------- desktop / web layout ----------
   Above phone width the card chrome (border, fill, shadow) is dropped so the
   timer sits directly on the page like the reference mockups, and every
   element scales up ~10% for a roomier, less "app widget" feel. */
@media (min-width: 720px) {
  .top-controls {
    position: fixed;
    top: 28px;
    right: 36px;
    max-width: none;
    width: auto;
    margin: 0;
    z-index: 30;
  }

  .settings-panel {
    position: fixed;
    top: 78px;
    right: 36px;
    max-width: none;
    width: 280px;
    margin: 0;
    box-shadow: var(--shadow);
    z-index: 29;
  }

  .app-card {
    max-width: 480px;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }

  .app-top {
    justify-content: center;
    margin-bottom: 4px;
  }

  .app-brand {
    font-family: "Fraunces", Georgia, serif;
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--text);
    gap: 12px;
  }

  .tagline {
    display: block;
    text-align: center;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-faint);
  }

  .mode-tabs {
    padding: 5px;
    gap: 7px;
    margin-bottom: 29px;
    border-radius: 15px;
  }

  .mode-tabs button {
    font-size: 14px;
    padding: 11px 6px;
  }

  .ring-wrap {
    width: 264px;
    height: 264px;
    margin: 0 auto 26px;
  }

  .ring-track, .ring-red { stroke-width: 15; }
  .ring-green { stroke-width: 15; }

  .ring-label { font-size: 12px; }
  .ring-time { font-size: 53px; }
  .ring-sub { font-size: 13px; }

  .ctrl-row { gap: 10px; }

  .ctrl-btn {
    font-size: 15px;
    padding: 15px 10px;
    border-radius: 13px;
  }
}
