:root {
  color-scheme: dark;
  --bg: #080a09;
  --surface: #101411;
  --surface-2: #161c18;
  --text: #f1f4f1;
  --muted: #909991;
  --faint: #68716a;
  --accent: #b7f36a;
  --accent-soft: rgba(183, 243, 106, .11);
  --border: rgba(255, 255, 255, .1);
  --danger: #ff9d9d;
  --digit-width: clamp(54px, 17.5vw, 250px);
  --digit-height: clamp(84px, 25vw, 350px);
  --digit-font: clamp(4.4rem, 18vw, 17rem);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(183, 243, 106, .035), transparent 42%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
body.drawer-open { overflow: hidden; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.skip-link {
  position: fixed;
  z-index: 400;
  top: 12px;
  left: 12px;
  padding: 9px 13px;
  border-radius: 8px;
  background: var(--accent);
  color: #071008;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.ambient-controls {
  position: fixed;
  z-index: 100;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  pointer-events: none;
}
.auto-hide-control {
  opacity: 0;
  pointer-events: auto;
  transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease, background-color .2s ease, border-color .2s ease;
}
body.controls-visible .auto-hide-control,
.auto-hide-control:hover,
.auto-hide-control:focus-visible,
body.drawer-open .auto-hide-control {
  opacity: 1;
  transform: translateY(0);
}
.brand-control {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0 11px 0 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -.03em;
  text-decoration: none;
}
.brand-control:hover { border-color: var(--border); background: rgba(16, 20, 17, .9); }
.brand-control svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.6;
  stroke-linecap: round;
}
.brand-dot { color: var(--accent); }
.menu-button, .icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(16, 20, 17, .9);
  color: var(--text);
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}
.menu-button:hover, .icon-button:hover {
  border-color: rgba(183, 243, 106, .4);
  background: var(--surface-2);
  color: var(--accent);
}
.menu-button svg, .icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.app {
  display: grid;
  width: 100%;
  min-height: 100dvh;
  padding: clamp(48px, 8vh, 88px) clamp(10px, 2vw, 28px);
  place-items: center;
}
.clock-stage {
  display: flex;
  width: 100%;
  max-width: 1800px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: clamp(8px, 1.8vh, 16px);
}
.flip-clock {
  display: flex;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: clamp(1px, .35vw, 6px);
}
.digit-group, .seconds-unit {
  display: flex;
  align-items: center;
  gap: 0;
}
.digit {
  position: relative;
  width: var(--digit-width);
  height: var(--digit-height);
  flex: 0 0 var(--digit-width);
  font-variant-numeric: tabular-nums;
}
.separator {
  width: clamp(22px, 4vw, 62px);
  margin: 0 clamp(-8px, -.4vw, -2px);
  color: var(--muted);
  font-size: clamp(3.2rem, 9vw, 8rem);
  font-weight: 200;
  line-height: 1;
  text-align: center;
  transform: translateY(-.06em);
}
.half {
  position: absolute;
  left: 0;
  display: flex;
  width: 100%;
  height: 50%;
  justify-content: center;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  font-size: var(--digit-font);
  font-variant-numeric: tabular-nums;
  font-weight: 250;
  letter-spacing: -.075em;
  line-height: 1;
}
.top { top: 0; align-items: flex-end; }
.bottom { bottom: 0; align-items: flex-start; }
.top span { transform: translateY(50%); }
.bottom span { transform: translateY(-50%); }
.flip-top, .flip-bottom { display: none !important; }
.clock-context {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(11px, 1vw, 14px);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.clock-context span[aria-hidden="true"] { color: var(--faint); }
body.show-seconds {
  --digit-width: clamp(36px, 10.8vw, 166px);
  --digit-height: clamp(64px, 16vw, 245px);
  --digit-font: clamp(3.2rem, 11vw, 11.5rem);
}
body.show-seconds .separator { width: clamp(16px, 2.8vw, 42px); font-size: clamp(2.5rem, 6vw, 5.5rem); }
body.favorite-clocks-visible {
  overflow: auto;
}

body.favorite-clocks-visible .app {
  min-height: 100dvh;
  padding: clamp(76px, 10vh, 112px) clamp(14px, 4vw, 56px) clamp(28px, 5vh, 56px);
}

.favorite-clocks-stage {
  width: 100%;
  max-width: 1440px;
}

.favorite-clock-grid {
  display: grid;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: clamp(10px, 1.4vw, 18px);
  list-style: none;
}

.favorite-clock-grid[data-count="1"] {
  max-width: 620px;
}

.favorite-clock-grid[data-count="2"] {
  max-width: 920px;
}

.favorite-clock-tile {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: clamp(174px, 25vh, 270px);
  align-items: center;
  justify-content: center;
  padding: clamp(22px, 4vw, 42px) clamp(16px, 3vw, 32px);
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: clamp(14px, 1.5vw, 20px);
  background: rgba(16, 20, 17, .32);
  container-type: inline-size;
}

.favorite-clock-tile.is-current::before {
  position: absolute;
  top: 16px;
  width: 24px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  content: "";
}

.favorite-clock-city {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(11px, 1vw, 14px);
  font-weight: 700;
  letter-spacing: .09em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.favorite-clock-time {
  margin: clamp(8px, 1.5vh, 16px) 0 clamp(7px, 1vh, 12px);
  color: var(--text);
  font-size: clamp(3.3rem, 7.5vw, 7.8rem);
  font-size: clamp(3rem, 28cqi, 7rem);
  font-variant-numeric: tabular-nums;
  font-weight: 250;
  letter-spacing: -.07em;
  line-height: .9;
  white-space: nowrap;
}

body.show-seconds .favorite-clock-time {
  font-size: clamp(2.2rem, 4.4vw, 4.6rem);
  font-size: clamp(2.2rem, 18cqi, 4.6rem);
}

.favorite-clock-offset {
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: .06em;
}
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(0, 0, 0, .56);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 200;
  display: flex;
  width: min(430px, 100%);
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: rgba(8, 12, 10, .98);
  box-shadow: -24px 0 70px rgba(0, 0, 0, .38);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform .26s ease, visibility 0s linear .26s;
}

.settings-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform .26s ease;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.drawer-header h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -.025em;
}

.drawer-content {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(183, 255, 90, .25) transparent;
}

.panel-section {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-section h3 {
  margin: 0 0 13px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
}

.section-heading {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h3 {
  margin: 0;
}

.section-count {
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
}

.section-help {
  margin: 2px 0 12px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.45;
}

.favorite-current-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
}

.favorite-current-button[aria-pressed="true"] {
  border-color: rgba(183, 255, 90, .35);
  background: var(--accent-soft);
  color: var(--accent);
}

.favorite-current-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.favorite-current-button[aria-pressed="true"] svg {
  fill: currentColor;
}

.search-field {
  position: relative;
}

.search-field > svg {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--faint);
  stroke-linecap: round;
  stroke-width: 1.8;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input,
.field input,
.field select {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}

.search-field input {
  padding: 0 13px 0 41px;
}

.field input,
.field select {
  padding: 0 11px;
}

.search-field input:focus,
.field input:focus,
.field select:focus {
  border-color: rgba(183, 255, 90, .48);
  box-shadow: 0 0 0 3px rgba(183, 255, 90, .08);
}

.search-field input::placeholder {
  color: var(--faint);
}

.search-results {
  max-height: 262px;
  margin: 8px 0 0;
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  list-style: none;
}

.search-result-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.search-result-button:hover,
.search-result-button:focus-visible,
.search-results li.is-active .search-result-button {
  background: var(--accent-soft);
}

.search-result-button strong,
.search-result-button small {
  display: block;
}

.search-result-button strong {
  font-size: 13px;
}

.search-result-button small {
  margin-top: 2px;
  color: var(--faint);
  font-size: 10px;
}

.search-result-button > span:last-child {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.favorites-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.favorite-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  min-height: 62px;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(18, 27, 22, .72);
  transition: border-color .2s ease, background-color .2s ease, opacity .2s ease;
}

.favorite-card.is-current {
  border-color: rgba(183, 255, 90, .3);
  background: var(--accent-soft);
}

.favorite-card.is-dragging {
  opacity: .45;
}

.drag-handle {
  display: grid;
  width: 34px;
  height: 42px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.favorite-select {
  min-width: 0;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.favorite-select strong,
.favorite-select small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-select strong {
  color: var(--text);
  font-size: 13px;
}

.favorite-select small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.favorite-actions {
  display: flex;
  align-items: center;
}

.card-action {
  display: grid;
  width: 30px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--faint);
}

.card-action:hover {
  background: rgba(255, 255, 255, .055);
  color: var(--text);
}

.card-action.remove:hover {
  color: var(--danger);
}

.card-action:disabled {
  opacity: .22;
  cursor: not-allowed;
}

.card-action svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.setting-list {
  display: grid;
}

.setting-row {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.setting-row span,
.setting-row strong,
.setting-row small {
  display: block;
}

.setting-row strong {
  color: var(--text);
  font-size: 13px;
}

.setting-row small {
  margin-top: 2px;
  color: var(--faint);
  font-size: 10px;
}

.switch-input {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 42px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 99px;
  outline: none;
  background: #242b27;
  cursor: pointer;
  appearance: none;
  transition: background-color .2s ease, border-color .2s ease;
}

.switch-input::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition: transform .2s ease, background-color .2s ease;
}

.switch-input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.switch-input:checked::after {
  background: #071008;
  transform: translateX(18px);
}

.secondary-button {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  padding: 0 13px;
  border: 1px solid rgba(183, 255, 90, .26);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.secondary-button:hover {
  border-color: rgba(183, 255, 90, .5);
  background: rgba(183, 255, 90, .18);
}

.secondary-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.control-hint {
  min-height: 1.4em;
  margin: 7px 2px 0;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.4;
}

.converter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .03em;
}

.swap-button {
  display: inline-flex;
  grid-column: 1 / -1;
  width: fit-content;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  margin: -3px auto;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.swap-button:hover {
  background: rgba(255, 255, 255, .05);
  color: var(--text);
}

.swap-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.converter-result {
  display: block;
  min-height: 54px;
  margin-top: 13px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(183, 255, 90, .055);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-height: 540px) and (orientation: landscape) {
  :root {
    --digit-width: clamp(58px, 14vh, 118px);
    --digit-height: clamp(82px, 20vh, 166px);
    --digit-font: clamp(3rem, 12vh, 6.2rem);
  }

  body.show-seconds {
    --digit-width: clamp(42px, 10vh, 88px);
    --digit-height: clamp(60px, 14vh, 124px);
    --digit-font: clamp(2.2rem, 8vh, 4.5rem);
  }

  .app {
    padding-block: 52px 28px;
  }
}

@media (max-width: 480px) {
  .ambient-controls {
    padding: 10px;
  }

  .brand-control span {
    display: none;
  }

  .brand-control {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .clock-stage {
    gap: 14px;
  }
  body.favorite-clocks-visible .app {
    align-items: start;
    padding: 68px 10px 20px;
  }

  .favorite-clock-grid {
    gap: 8px;
  }

  .favorite-clock-tile {
    min-height: 154px;
    border-radius: 14px;
  }

  .settings-drawer {
    border-left: 0;
  }

  .drawer-header {
    padding: 17px 16px 14px;
  }

  .panel-section {
    padding: 19px 16px;
  }
}

@media (pointer: coarse) {
  .auto-hide-control {
    opacity: .62;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .flip-top,
  .flip-bottom {
    display: none;
  }
}
