:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --text: #f6f6f6;
  --muted: rgba(255, 255, 255, 0.68);
  --line: rgba(255, 255, 255, 0.16);
  --accent: #ffffff;
  --glow: rgba(255, 255, 255, 0.28);
  --retro: #79ff9f;
  --retro-dim: rgba(121, 255, 159, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow-x: hidden;
}

a,
button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

.clock-page {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.clock-app {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 520px;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.08), transparent 26%),
    radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.05), transparent 24%),
    #050505;
  transition: background 320ms ease, color 320ms ease;
}

.topbar,
.admin-nav {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: flex-end;
}

.nav-link,
.nav-button,
.style-button,
.primary-action,
.secondary-action {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.nav-link,
.nav-button {
  padding: 10px 16px;
  font-size: 14px;
}

.home-link {
  margin-right: auto;
}

.nav-link:hover,
.nav-button:hover,
.style-button:hover,
.primary-action:hover,
.secondary-action:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.15);
}

.clock-stage {
  display: grid;
  place-items: center;
  align-content: center;
  gap: clamp(8px, 2vh, 24px);
  min-height: 0;
  text-align: center;
}

.date-line,
.week-line {
  min-height: 1.2em;
  color: var(--muted);
  font-size: clamp(18px, 2.2vw, 34px);
  letter-spacing: 0.1em;
}

.week-line {
  font-size: clamp(16px, 1.8vw, 28px);
}

.digital-clock {
  width: min(96vw, 1500px);
}

.time-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.2vw, 18px);
}

.time-unit {
  position: relative;
  display: grid;
  place-items: center;
  min-width: clamp(118px, 21vw, 330px);
  min-height: clamp(132px, 26vw, 390px);
  border-radius: clamp(18px, 3vw, 44px);
  background: linear-gradient(180deg, #171717, #080808);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.9),
    0 28px 80px rgba(0, 0, 0, 0.58);
  overflow: hidden;
}

.time-unit::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: rgba(0, 0, 0, 0.86);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.08);
  z-index: 2;
}

.time-unit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), transparent 45%, rgba(0, 0, 0, 0.2));
  pointer-events: none;
}

.unit-value {
  position: relative;
  z-index: 1;
  font-size: clamp(88px, 21vw, 318px);
  font-weight: 850;
  line-height: 0.9;
  letter-spacing: -0.08em;
  padding-right: 0.08em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 32px var(--glow);
}

.time-unit.flip-animate .unit-value {
  animation: flipTick 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes flipTick {
  0% {
    transform: rotateX(0deg);
    filter: brightness(1);
  }
  48% {
    transform: rotateX(-72deg) scaleY(0.86);
    filter: brightness(0.55);
  }
  100% {
    transform: rotateX(0deg);
    filter: brightness(1);
  }
}

.time-separator {
  color: rgba(255, 255, 255, 0.76);
  font-size: clamp(70px, 13vw, 220px);
  font-weight: 800;
  line-height: 1;
  transform: translateY(-0.04em);
}

.ampm-label {
  align-self: flex-end;
  margin: 0 0 clamp(22px, 5vw, 78px) 2px;
  color: var(--muted);
  font-size: clamp(18px, 3vw, 42px);
  letter-spacing: 0.08em;
}

.analog-clock {
  display: none;
}

.dial {
  position: relative;
  width: min(68vh, 72vw);
  height: min(68vh, 72vw);
  min-width: 300px;
  min-height: 300px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.1) 0 2px, transparent 3px),
    radial-gradient(circle at center, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02) 56%, rgba(255, 255, 255, 0.08));
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.64), inset 0 0 60px rgba(255, 255, 255, 0.05);
}

.mark {
  position: absolute;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(26px, 4vw, 56px);
  font-weight: 700;
  transform: translate(-50%, -50%);
}

.mark-12 { left: 50%; top: 10%; }
.mark-3 { left: 90%; top: 50%; }
.mark-6 { left: 50%; top: 90%; }
.mark-9 { left: 10%; top: 50%; }

.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 8px;
  border-radius: 999px;
  background: #fff;
  transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(0deg);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.22);
}

.hour-hand {
  height: 25%;
  width: 12px;
}

.minute-hand {
  height: 35%;
  width: 8px;
}

.second-hand {
  height: 40%;
  width: 3px;
  background: #ff4d4d;
  box-shadow: 0 0 20px rgba(255, 77, 77, 0.6);
}

.dial-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.42);
}

.quick-panel {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0 0;
}

.controls-hidden {
  grid-template-rows: 1fr;
  cursor: pointer;
}

.controls-hidden .topbar,
.controls-hidden .quick-panel,
.controls-hidden .date-line,
.controls-hidden .week-line {
  display: none;
}

.controls-hidden .clock-stage {
  min-height: 100%;
}

.style-button {
  padding: 10px 14px;
  font-size: 14px;
}

.style-button.active {
  border-color: rgba(255, 255, 255, 0.46);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.style-minimal {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 42%),
    #07090d;
}

.style-minimal .time-unit {
  min-width: clamp(96px, 19vw, 290px);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.style-minimal .time-unit::before,
.style-minimal .time-unit::after {
  display: none;
}

.style-minimal .unit-value {
  font-weight: 320;
  letter-spacing: -0.05em;
  text-shadow: none;
}

.style-minimal .time-separator {
  font-weight: 260;
}

.style-analog .digital-clock {
  display: none;
}

.style-analog .analog-clock {
  display: block;
}

.style-analog .clock-stage {
  gap: 12px;
}

.style-retro {
  --text: var(--retro);
  --muted: rgba(121, 255, 159, 0.72);
  background:
    repeating-linear-gradient(0deg, rgba(121, 255, 159, 0.035) 0 1px, transparent 1px 5px),
    radial-gradient(circle at center, rgba(121, 255, 159, 0.08), transparent 62%),
    #020604;
  color: var(--retro);
}

.style-retro .time-unit {
  background: linear-gradient(180deg, rgba(121, 255, 159, 0.12), rgba(121, 255, 159, 0.035));
  border-color: rgba(121, 255, 159, 0.28);
  box-shadow: inset 0 0 30px var(--retro-dim), 0 0 70px var(--retro-dim);
}

.style-retro .unit-value,
.style-retro .time-separator,
.style-retro .ampm-label,
.style-retro .date-line,
.style-retro .week-line {
  color: var(--retro);
  text-shadow: 0 0 16px rgba(121, 255, 159, 0.74), 0 0 42px rgba(121, 255, 159, 0.3);
}

.hide-date .date-line,
.hide-week .week-line,
.hide-seconds .seconds-unit,
.hide-seconds .seconds-separator,
.hide-seconds .second-hand {
  display: none;
}

.admin-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.11), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(121, 255, 159, 0.08), transparent 26%),
    #080808;
}

.admin-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.admin-nav {
  margin-bottom: 28px;
}

.admin-card {
  border: 1px solid var(--line);
  border-radius: 34px;
  padding: clamp(26px, 5vw, 58px);
  background: rgba(255, 255, 255, 0.075);
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(20px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(34px, 6vw, 72px);
  letter-spacing: -0.05em;
}

h2 {
  margin-bottom: 18px;
  font-size: clamp(20px, 2.8vw, 28px);
}

.admin-intro {
  max-width: 720px;
  margin-bottom: 34px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.form-block {
  padding: 26px 0;
  border-top: 1px solid var(--line);
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.choice-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.24);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.choice-card:hover,
.choice-card:has(input:checked) {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.12);
}

.choice-card input {
  width: 18px;
  height: 18px;
  accent-color: #fff;
}

.choice-card span {
  font-size: 18px;
  font-weight: 700;
}

.choice-card small {
  color: var(--muted);
  line-height: 1.55;
}

.switch-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.22);
}

.switch-row input {
  width: 48px;
  height: 26px;
  accent-color: #fff;
}

.admin-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 18px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
}

.primary-action {
  background: #fff;
  color: #070707;
}

.secondary-action {
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 920px) {
  .style-grid,
  .switch-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .time-group {
    gap: 6px;
  }
}

@media (max-width: 680px) {
  .clock-app {
    min-height: 480px;
    padding: 14px;
  }

  .topbar {
    gap: 8px;
  }

  .nav-link,
  .nav-button,
  .style-button {
    padding: 9px 11px;
    font-size: 12px;
  }

  .quick-panel {
    gap: 8px;
  }

  .time-unit {
    min-width: 28vw;
    min-height: 31vw;
    border-radius: 18px;
  }

  .unit-value {
    font-size: 27vw;
  }

  .seconds-unit,
  .seconds-separator {
    display: none;
  }

  .style-grid,
  .switch-list {
    grid-template-columns: 1fr;
  }

  .admin-shell {
    width: min(100% - 24px, 1120px);
    padding-top: 18px;
  }

  .admin-card {
    border-radius: 24px;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .clock-app {
    min-height: 100dvh;
  }

  .topbar,
  .quick-panel {
    opacity: 0.34;
    transition: opacity 180ms ease;
  }

  .topbar:hover,
  .quick-panel:hover {
    opacity: 1;
  }

  .date-line,
  .week-line {
    font-size: clamp(14px, 2vw, 24px);
  }

  .time-unit {
    min-height: clamp(96px, 22vw, 260px);
  }

  .unit-value {
    font-size: clamp(80px, 18vw, 230px);
  }
}
