:root {
  --accent: #8b5cf6;
  --accent-rgb: 139, 92, 246;
  --bg: #08090c;
  --surface: rgba(24, 25, 31, 0.84);
  --surface-solid: #18191f;
  --surface-2: #22232b;
  --text: #f7f7fa;
  --muted: #9799a5;
  --hairline: rgba(255, 255, 255, 0.08);
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.16;
  pointer-events: none;
}
.ambient-one { background: var(--accent); top: -140px; right: -130px; }
.ambient-two { background: #2864ff; bottom: 5%; left: -230px; opacity: 0.09; }

.app-shell {
  position: relative;
  width: min(100%, 660px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 8px) 18px calc(104px + var(--safe-bottom));
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 34px; letter-spacing: -0.045em; }
h2 { margin-bottom: 0; font-size: 24px; letter-spacing: -0.035em; }
h3 { margin-bottom: 4px; font-size: 15px; }
.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 15px;
  background: var(--surface);
  backdrop-filter: blur(22px);
}
.material-symbols-rounded { font-size: 23px; font-variation-settings: "FILL" 0, "wght" 430; }
.offline-banner {
  align-items: center;
  gap: 8px;
  margin: -10px 0 16px;
  padding: 10px 13px;
  border-radius: 13px;
  background: rgba(255, 69, 58, 0.13);
  color: #ff6961;
  font-size: 13px;
}
.offline-banner:not([hidden]) { display: flex; }
.view { display: none; animation: view-in 0.22s ease; }
.view.active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--hairline);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.045);
}
.segment {
  min-height: 40px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.segment.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.city-picker { margin-bottom: 16px; }
.clock-card, .form-card, .settings-card, .hero-card {
  border: 1px solid var(--hairline);
  background: linear-gradient(150deg, rgba(var(--accent-rgb), 0.1), transparent 42%), var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px);
}
.clock-card {
  overflow: hidden;
  padding: 20px;
  border-radius: var(--radius-xl);
}
.clock-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), .85);
}
.clock-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  margin: 42px -10px 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#clock-main { font-size: clamp(48px, 13vw, 78px); font-weight: 600; letter-spacing: -0.075em; }
#clock-ms { min-width: 60px; margin-left: 4px; color: var(--accent); font-size: clamp(19px, 5vw, 30px); font-weight: 600; }
.clock-date { margin-bottom: 36px; text-align: center; color: var(--muted); font-size: 14px; text-transform: capitalize; }
.wide-button, .primary-button {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 16px;
  font-weight: 700;
}
.wide-button { background: rgba(255,255,255,.07); }
.primary-button {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 26px rgba(var(--accent-rgb), .25);
}
.info-card, .notice-card, .about-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.035);
}
.info-card p, .notice-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.card-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(var(--accent-rgb), .14);
  color: var(--accent);
}
.card-icon.large { width: 62px; height: 62px; margin-bottom: 18px; border-radius: 20px; }
.card-icon.large .material-symbols-rounded { font-size: 32px; }
.location-card > div:nth-child(2) { flex: 1; min-width: 0; }
.small-button {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(var(--accent-rgb), .13);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.hero-card { padding: 24px; border-radius: var(--radius-xl); }
.hero-card > p:last-child { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.compact-hero { display: flex; align-items: center; gap: 14px; padding: 18px; }
.compact-hero .eyebrow { margin-bottom: 3px; }
.compact-hero h2 { font-size: 21px; }
.form-card { margin-top: 14px; padding: 18px; border-radius: var(--radius-xl); }
.field { display: block; margin-bottom: 14px; }
.field > span, .profile-row > span {
  display: block;
  margin: 0 0 7px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .material-symbols-rounded {
  position: absolute;
  left: 13px;
  color: var(--muted);
  font-size: 20px;
  pointer-events: none;
}
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  outline: none;
  background: rgba(255,255,255,.045);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: rgba(var(--accent-rgb), .65); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .1); }
.input-wrap input, .input-wrap select { padding: 0 14px 0 43px; }
textarea { min-height: 82px; padding: 13px; resize: vertical; }
.date-input, .number-input { padding: 0 13px; }
.duration-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.duration-grid .field { min-width: 0; }
.section-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 28px 2px 12px;
}
.section-heading h2 { font-size: 20px; }
.top-heading { margin-top: 4px; }
.counter {
  min-width: 25px;
  padding: 3px 7px;
  border-radius: 99px;
  background: rgba(var(--accent-rgb), .13);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.item-list { display: grid; gap: 10px; }
.empty-state {
  padding: 28px 16px;
  border: 1px dashed var(--hairline);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}
.empty-state .material-symbols-rounded { display: block; margin-bottom: 8px; font-size: 30px; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.list-item-copy { flex: 1; min-width: 0; }
.list-item strong { display: block; overflow: hidden; margin-bottom: 5px; text-overflow: ellipsis; white-space: nowrap; }
.list-item small { color: var(--muted); }
.countdown { color: var(--accent) !important; font-variant-numeric: tabular-nums; font-weight: 700; }
.delete-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: rgba(255,69,58,.1);
  color: #ff6961;
}
.delete-button .material-symbols-rounded { font-size: 20px; }

.haptic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.haptic-card {
  min-height: 145px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 17px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: left;
}
.haptic-card:active { transform: scale(.975); }
.haptic-card > .material-symbols-rounded { margin-bottom: auto; color: var(--accent); font-size: 28px; }
.haptic-card strong { margin-bottom: 4px; }
.haptic-card small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.haptic-card.accent { background: linear-gradient(145deg, rgba(var(--accent-rgb), .28), rgba(var(--accent-rgb), .07)); }
.notice-card { align-items: flex-start; }
.notice-card > .material-symbols-rounded { color: var(--accent); }

.settings-card { overflow: hidden; border-radius: var(--radius-lg); }
.setting-row, .setting-column { padding: 15px; }
.setting-row { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting-row + .setting-row, .setting-column + .setting-row { border-top: 1px solid var(--hairline); }
.setting-copy { display: flex; align-items: center; gap: 12px; }
.setting-copy strong, .setting-copy small { display: block; }
.setting-copy strong { margin-bottom: 3px; font-size: 14px; }
.setting-copy small { color: var(--muted); font-size: 11px; }
.setting-icon { color: var(--accent); }
.compact-select { width: auto; min-height: 36px; padding: 0 30px 0 10px; border-radius: 10px; font-size: 12px; }
.setting-column .setting-copy { margin-bottom: 15px; }
.color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.color-dot {
  aspect-ratio: 1;
  min-width: 0;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: inset 0 0 0 3px var(--surface-solid);
}
.color-dot.active { border-color: var(--text); }
.button-row { width: 100%; border: 0; background: transparent; text-align: left; }
.chevron { color: var(--muted); }
.switch { position: relative; flex: 0 0 auto; width: 48px; height: 29px; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #3a3b43; transition: .2s; }
.switch span::after {
  content: "";
  position: absolute;
  width: 23px;
  height: 23px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 5px rgba(0,0,0,.28);
  transition: .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(19px); }
.about-card { margin-top: 24px; }
.app-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: var(--accent); color: white; }
.about-card strong, .about-card small { display: block; }
.about-card small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.tabbar {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(calc(100% - 22px), 620px);
  min-height: 68px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: 23px;
  background: rgba(19, 20, 25, .88);
  box-shadow: 0 16px 45px rgba(0,0,0,.45);
  backdrop-filter: blur(30px);
  transform: translateX(-50%);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: var(--muted);
}
.tab small { font-size: 9px; font-weight: 600; }
.tab.active { background: rgba(var(--accent-rgb), .13); color: var(--accent); }
.tab.active .material-symbols-rounded { font-variation-settings: "FILL" 1, "wght" 450; }

.sheet-backdrop { position: fixed; z-index: 30; inset: 0; background: rgba(0,0,0,.52); backdrop-filter: blur(4px); }
.bottom-sheet {
  position: fixed;
  z-index: 31;
  left: 50%;
  bottom: 0;
  width: min(100%, 660px);
  max-height: 88vh;
  overflow: auto;
  padding: 9px 18px calc(20px + env(safe-area-inset-bottom));
  border: 1px solid var(--hairline);
  border-bottom: 0;
  border-radius: 30px 30px 0 0;
  background: #17181d;
  box-shadow: 0 -30px 70px rgba(0,0,0,.48);
  transform: translate(-50%, 105%);
  transition: transform .3s cubic-bezier(.22, .8, .25, 1);
}
.bottom-sheet.open { transform: translate(-50%, 0); }
.sheet-handle { width: 38px; height: 5px; margin: 0 auto 14px; border-radius: 9px; background: #4a4b53; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; padding: 2px 0 17px; }
.sheet-content { overflow: hidden; border: 1px solid var(--hairline); border-radius: 20px; background: rgba(255,255,255,.025); }
.signal-row { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; }
.signal-row strong, .signal-row small { display: block; }
.signal-row small { max-width: 250px; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.signal-row.secondary { min-height: 58px; }
.profile-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 15px 14px; }
.profile-row > span { margin: 0; }
.profile-row select { width: 130px; min-height: 38px; padding: 0 8px; border-radius: 10px; font-size: 12px; }
.divider { height: 1px; margin: 0 15px; background: var(--hairline); }

.fullscreen-clock {
  position: fixed;
  z-index: 100;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: var(--bg);
}
.fullscreen-clock:not([hidden]) { display: flex; }
.exit-fullscreen {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: rgba(255,255,255,.06);
}
.fullscreen-location { margin-bottom: 10px; color: var(--accent); font-size: 14px; font-weight: 700; }
.fullscreen-time { display: flex; align-items: baseline; font-variant-numeric: tabular-nums; white-space: nowrap; }
#fullscreen-main { font-size: min(18vw, 170px); font-weight: 600; letter-spacing: -.075em; }
#fullscreen-ms { min-width: 8vw; margin-left: .7vw; color: var(--accent); font-size: min(6vw, 58px); font-weight: 600; }
.fullscreen-date { margin-top: 12px; color: var(--muted); text-transform: capitalize; }
.rotate-hint { position: absolute; bottom: max(28px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }

.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  max-width: calc(100% - 36px);
  padding: 11px 15px;
  border: 1px solid var(--hairline);
  border-radius: 13px;
  background: rgba(38,39,46,.94);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
  transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

body.light {
  --bg: #f4f4f8;
  --surface: rgba(255,255,255,.82);
  --surface-solid: #fff;
  --surface-2: #fff;
  --text: #111116;
  --muted: #6f717c;
  --hairline: rgba(0,0,0,.08);
  --shadow: 0 20px 45px rgba(30,32,45,.09);
  color-scheme: light;
}
body.light .tabbar { background: rgba(250,250,252,.88); }
body.light .bottom-sheet { background: #f8f8fb; }
body.light .switch span { background: #d7d7dd; }
body.light input, body.light select, body.light textarea { background: rgba(0,0,0,.035); }

@media (orientation: landscape) {
  .rotate-hint { display: none; }
}
@media (max-width: 380px) {
  .app-shell { padding-left: 13px; padding-right: 13px; }
  .tabbar { width: calc(100% - 14px); }
  .tab small { font-size: 8px; }
  #clock-main { font-size: 46px; }
  #clock-ms { min-width: 52px; font-size: 18px; }
}
@media (min-width: 700px) {
  .app-shell { padding-left: 22px; padding-right: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
