html {
  font-size: 20px;
}

:root {
  --bg-base: #f4f1ea;
  --bg-card: rgba(244, 241, 234, 0.4);
  --text-main: #2b2a27;
  --text-muted: #76736a;
  --border: #dfdcd3;
  --border-hover: #b5b2a9;
  --accent: #45744d;
}

:root.dark-theme {
  --bg-base: #1e1e1e;
  --bg-card: rgba(30, 30, 30, 0.4);
  --text-main: #e4e2de;
  --text-muted: #8b8985;
  --border: #383838;
  --border-hover: #5e5e5e;
  --accent: #45744d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

input,
textarea,
[contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
}

body {
  font-family: "Plus Jakarta Sans", sans-serif;
  background-color: var(--bg-base);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  -webkit-font-smoothing: antialiased;
  transition:
    background-color 0.8s ease,
    color 0.8s ease;
}

/* Paper Texture */
.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.03;
}

:root.dark-theme .noise {
  opacity: 0.03;
}

.math-bg {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120vmin;
  height: 120vmin;
  z-index: -4;
  pointer-events: none;
  opacity: 0.08;
  animation: none;
}

:root.dark-theme .math-bg {
  opacity: 0.05;
}

.math-bg circle,
.math-bg ellipse,
.math-bg line {
  stroke: var(--text-main);
  fill: none;
  stroke-width: 1px;
  transition: stroke 0.8s ease;
}

@keyframes slowSpin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

#dynamic-effects {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  overflow: hidden;
}

.meteor {
  position: absolute;
  width: 100px;
  height: 1px;
  background: linear-gradient(90deg, var(--text-main), transparent);
  opacity: 0;
  transform: rotate(-45deg);
  animation: shootingStar 15s linear infinite backwards;
}

.comet {
  position: absolute;
  width: 200px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 50%;
  opacity: 0;
  transform: rotate(-30deg);
  animation: shootingStar 25s linear infinite backwards;
}

@keyframes shootingStar {
  0% {
    transform: translateX(100vw) translateY(-50vh) rotate(-45deg);
    opacity: 1;
  }

  10% {
    transform: translateX(-50vw) translateY(100vh) rotate(-45deg);
    opacity: 0;
  }

  100% {
    transform: translateX(-50vw) translateY(100vh) rotate(-45deg);
    opacity: 0;
  }
}

.floating-obj {
  position: absolute;
  stroke: var(--text-main);
  fill: none;
  stroke-width: 1.5;
  opacity: 0.15;
  animation: floatObj 20s ease-in-out infinite alternate;
}

@keyframes floatObj {
  0% {
    transform: translateY(0) rotate(0deg);
  }

  100% {
    transform: translateY(-50px) rotate(15deg);
  }
}

/* Weather */
.rain-drop {
  position: absolute;
  width: 1px;
  height: 40px;
  background: var(--text-main);
  opacity: 0.2;
  animation: fallRain linear infinite backwards;
}

@keyframes fallRain {
  0% {
    transform: translateY(-10vh);
  }

  100% {
    transform: translateY(110vh);
  }
}

.snow-flake {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--text-main);
  border-radius: 50%;
  opacity: 0.4;
  animation: fallSnow linear infinite backwards;
}

@keyframes fallSnow {
  0% {
    transform: translateY(-10vh);
  }

  100% {
    transform: translateY(110vh);
  }
}

.cloud {
  position: absolute;
  background: var(--text-muted);
  border-radius: 50px;
  opacity: 0.05;
  animation: driftCloud linear infinite;
}

@keyframes driftCloud {
  from {
    transform: translateX(-20vw);
  }

  to {
    transform: translateX(120vw);
  }
}

.thunder {
  position: absolute;
  inset: 0;
  background: var(--text-main);
  opacity: 0;
  animation: flash 10s infinite;
}

@keyframes flash {

  0%,
  95%,
  98%,
  100% {
    opacity: 0;
  }

  96%,
  99% {
    opacity: 0.1;
  }
}

/* Festive Elements */
.xmas-light {
  position: absolute;
  bottom: 20px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: twinkle 1s infinite alternate;
}

@keyframes twinkle {
  0% {
    opacity: 0.2;
    transform: scale(0.9);
    box-shadow: 0 0 5px var(--accent);
  }

  100% {
    opacity: 0.8;
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent);
  }
}

.xmas-tree {
  position: absolute;
  bottom: 0;
  right: 10%;
  width: 150px;
  opacity: 0.6;
}

.bat {
  position: absolute;
  width: 60px;
  fill: var(--text-main);
  opacity: 0.15;
  animation: flyBat 15s linear infinite;
}

@keyframes flyBat {
  0% {
    transform: translate(-10vw, 80vh) scale(0.5) rotate(15deg);
  }

  50% {
    transform: translate(50vw, 20vh) scale(1) rotate(-10deg);
  }

  100% {
    transform: translate(110vw, 50vh) scale(0.5) rotate(5deg);
  }
}

.halloween-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent, #ff7b0022);
  z-index: -3;
}

.fireworks-canvas {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.top-actions {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.top-action-btn {
  width: 2.15rem;
  height: 2.15rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    border-color 0.22s ease,
    color 0.22s ease,
    transform 0.22s ease,
    background-color 0.22s ease;
}

.top-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.top-action-btn:active {
  transform: translateY(0);
}

/* Layout Container */
.container {
  width: 100%;
  max-width: 900px;
  padding: 2rem;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}

.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(15px);
}

.time {
  font-size: 4.5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.greeting {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

.theme-toggle-btn {
  position: relative;
  overflow: hidden;
}

.theme-icon {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.24s ease,
    transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-icon svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
}

.theme-icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-icon-moon {
  opacity: 0;
  transform: rotate(-35deg) scale(0.55);
}

.theme-toggle-btn.is-dark .theme-icon-sun {
  opacity: 0;
  transform: rotate(35deg) scale(0.55);
}

.theme-toggle-btn.is-dark .theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.add-bookmark-btn {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.2rem;
  line-height: 1;
}

.settings-btn svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
}

.search-wrapper {
  width: 100%;
  max-width: 700px;
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards;
  opacity: 0;
  transform: translateY(15px);
  position: relative;
}

.search-input {
  width: 100%;
  padding: 1rem 0;
  font-size: 1.25rem;
  font-family: "Lora", serif;
  font-style: italic;
  font-weight: 500;
  color: var(--text-main);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border);
  outline: none;
  text-align: center;
  transition: border-color 0.3s ease;
}

.search-input::placeholder {
  color: var(--text-muted);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-style: normal;
  font-weight: 400;
}

.search-input:focus {
  border-bottom-color: var(--accent);
}

.search-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.6rem);
  display: grid;
  gap: 0.35rem;
  padding: 0.45rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-base) 92%, transparent);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.08);
  z-index: 6;
  max-height: 280px;
  overflow-y: auto;
}

.search-suggestion {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.92rem;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.search-suggestion:hover,
.search-suggestion.is-active {
  border-color: var(--border-hover);
  background: var(--bg-card);
  color: var(--accent);
}

.search-suggestion:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.suggestion-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Shortcuts */
.tool-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-main);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.38rem 0.6rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tool-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.shortcuts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  width: 100%;
}

.shortcut {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  transform: translateY(15px);
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  min-width: 0;
  width: clamp(150px, 18vw, 190px);
  flex: 1 1 clamp(150px, 18vw, 190px);
  max-width: 190px;
}

.shortcut:nth-child(1) {
  animation-delay: 0.15s;
}

.shortcut:nth-child(2) {
  animation-delay: 0.2s;
}

.shortcut:nth-child(3) {
  animation-delay: 0.25s;
}

.shortcut:nth-child(4) {
  animation-delay: 0.3s;
}

.shortcut:nth-child(5) {
  animation-delay: 0.35s;
}

.shortcut:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  color: var(--accent);
}

.shortcut svg {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.shortcut span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-favicon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bookmark-favicon-img {
  width: 1.25rem;
  height: 1.25rem;
  object-fit: contain;
}

.bookmark-fallback-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bookmark-fallback-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
}

.shortcut:hover svg {
  transform: scale(1.1);
}

.shortcut-actions {
  position: absolute;
  top: -9px;
  right: -9px;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.shortcut:hover .shortcut-actions,
.shortcut:focus-within .shortcut-actions {
  opacity: 1;
  pointer-events: auto;
}

.shortcut-action {
  width: 1.2rem;
  height: 1.2rem;
  border: 1px solid var(--border-hover);
  background: var(--bg-base);
  color: var(--text-main);
  border-radius: 50%;
  font-size: 0.62rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.shortcut-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.shortcut-action svg {
  width: 0.72rem;
  height: 0.72rem;
  stroke: currentColor;
  fill: none;
  pointer-events: none;
}

/* Weather Link */
.weather {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.62rem;
  border-bottom: 1px solid transparent;
  font-weight: 600;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85rem;
  color: var(--text-main);
  text-decoration: none;
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.5s forwards;
  opacity: 0;
  transform: translateY(15px);
}

#wx-city {
  max-width: 9.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.8em;
}

.wx-unit-toggle {
  min-width: 1.4rem;
  height: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-main);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wx-unit-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hidden {
  display: none !important;
}

:root.effects-paused #dynamic-effects *,
:root.effects-paused .math-bg,
:root.effects-paused .fireworks-canvas {
  animation-play-state: paused !important;
}

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg-base) 88%, black 12%);
  display: grid;
  place-items: center;
  z-index: 20;
}

.onboarding-card {
  width: min(92vw, 520px);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-base) 92%, transparent);
  padding: 1.2rem 1.3rem 1.35rem;
  display: grid;
  gap: 0.6rem;
}

.onboarding-card h2 {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.onboarding-card p {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.onboarding-card label {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.onboarding-card input {
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-main);
  font-size: 1rem;
  padding: 0.45rem 0;
  outline: none;
  font-family: "Plus Jakarta Sans", sans-serif;
}


.onboarding-card input:focus {
  border-bottom-color: var(--accent);
}


.onboarding-submit {
  margin-top: 0.8rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-main);
  padding: 0.5rem 0.8rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  justify-self: start;
  transition: all 0.2s ease;
}

.onboarding-submit:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.bookmark-modal-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg-base) 88%, black 12%);
  display: grid;
  place-items: center;
  z-index: 21;
}

.bookmark-modal-card {
  width: min(92vw, 520px);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-base) 92%, transparent);
  padding: 1.2rem 1.3rem 1.35rem;
  display: grid;
  gap: 0.6rem;
}

.bookmark-modal-card h2 {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.bookmark-modal-card label {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.bookmark-modal-card input {
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-main);
  font-size: 1rem;
  padding: 0.45rem 0;
  outline: none;
  font-family: "Plus Jakarta Sans", sans-serif;
}

.bookmark-modal-card input:focus {
  border-bottom-color: var(--accent);
}

.bookmark-modal-error {
  color: #d85f5f;
  font-size: 0.75rem;
  min-height: 1em;
}

.bookmark-modal-actions {
  margin-top: 0.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.bookmark-modal-actions .tool-btn,
.bookmark-modal-actions .onboarding-submit {
  margin-top: 0;
  min-height: 2.05rem;
  padding: 0.45rem 0.8rem;
  font-size: 0.72rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 760px) {
  .top-actions {
    top: 0.8rem;
    right: 0.8rem;
  }

  .top-action-btn {
    width: 2rem;
    height: 2rem;
  }

  .container {
    padding: 1.2rem;
    gap: 2rem;
  }

  .time {
    font-size: 3.2rem;
  }

  .shortcuts {
    flex-wrap: wrap;
    justify-content: center;
  }

  .shortcut {
    width: calc(50% - 0.5rem);
    flex: 0 1 calc(50% - 0.5rem);
    max-width: 230px;
  }

  .shortcut-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .weather {
    right: 1rem;
    bottom: 1rem;
    padding: 0.35rem 0.45rem;
  }

  #wx-city {
    max-width: 6.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {

  .shortcut,
  .weather,
  .header,
  .search-wrapper,
  .theme-icon,
  .meteor,
  .comet,
  .rain-drop,
  .snow-flake,
  .cloud,
  .floating-obj,
  .bat,
  .xmas-light,
  .thunder,
  .math-bg {
    animation: none !important;
    transition: none !important;
  }

  .shortcut,
  .weather,
  .header,
  .search-wrapper {
    opacity: 1 !important;
    transform: none !important;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
