* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --accent: #4cdb9b;
}

body.dark {
  --bg: #0d0f12;
  --surface: #161b22;
  --surface-hover: #21262d;
  --text: #f0f6fc;
  --text-muted: #8b949e;
  --border: #30363d;
  --glass: rgba(13, 15, 18, 0.75);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

body.light {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-hover: #f3f4f6;
  --text: #1f2328;
  --text-muted: #656d76;
  --border: #d0d7de;
  --glass: rgba(255, 255, 255, 0.85);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.2s ease, color 0.2s ease;
}

/* scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(150, 150, 150, 0.3);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 150, 150, 0.5);
}

/* background */
.background {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: -2;
  transition: filter 0.3s ease;
}

.background::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.6) 60%, rgba(0, 0, 0, 0.85) 100%);
}

/* hero & clock */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.clock-section {
  text-align: center;
  margin-bottom: 2.5rem;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#clock {
  font-size: clamp(4.5rem, 9vw, 7.5rem);
  font-weight: 700;
  letter-spacing: -3px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#date {
  margin-top: 10px;
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.85);
}

/* search */
.search-section {
  width: min(640px, 92vw);
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
  height: 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: 0.2s ease;
}

.search-container:hover {
  border-color: var(--accent);
}

.search-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(70, 203, 143, 0.2), 0 12px 30px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

#engine-button {
  width: 50px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 16px 0 0 16px;
  cursor: pointer;
  transition: background 0.2s;
}

#engine-button:hover {
  background: var(--surface-hover);
}

#engine-icon {
  width: 22px;
  height: 22px;
}

#search-input {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0 1rem 0 0.5rem;
}

#search-input::placeholder {
  color: var(--text-muted);
}

/* engine dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 100;
}

.dropdown button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}

.dropdown button:hover {
  background: var(--surface-hover);
}

.dropdown img {
  width: 20px;
  height: 20px;
}

/* quick links / favorites */
.favorites {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 2rem;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.favorite {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.favorite i {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: 0.2s ease;
}

.favorite:hover i {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--surface-hover);
}

.favorite span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
}

body.light .favorite span {
  color: var(--text-muted);
}

/* floating buttons */
.apod-button,
#settings-button {
  position: fixed;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  z-index: 1000;
  transition: 0.2s ease;
}

.apod-button {
  top: 20px;
  left: 20px;
}

.apod-button:hover {
  background: var(--accent);
  border-color: var(--accent);
}

#settings-button {
  bottom: 20px;
  right: 20px;
  font-size: 1.1rem;
}

#settings-button:hover {
  transform: rotate(45deg);
}

/* settings modal */
#settings-panel {
  position: fixed;
  right: 20px;
  bottom: 76px;
  width: 280px;
  padding: 1.5rem;
  background: var(--glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  color: var(--text);
  z-index: 999;
}

#settings-panel h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.setting-group {
  margin-top: 1.2rem;
}

.setting-group h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.theme-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.2s ease;
}

.theme-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.accent-picker {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.accent {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.accent:hover {
  transform: scale(1.15);
}

.accent:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.accent:nth-child(1) { background: #46cb8f; }
.accent:nth-child(2) { background: #4f8ef7; }
.accent:nth-child(3) { background: #b26cff; }
.accent:nth-child(4) { background: #ff914d; }
.accent:nth-child(5) { background: #ff5e7e; }

/* search active state */
body.search-active .background {
  filter: brightness(0.4) blur(8px);
}

body.search-active .clock-section,
body.search-active .favorites,
body.search-active .apod-button,
body.search-active .scroll-indicator,
body.search-active .madeby {
  opacity: 0.15;
  pointer-events: none;
}

/* news */
.news-section {
  min-height: 100vh;
  padding: 5rem 8% 4rem;
  background: var(--bg);
}

.news-header {
  margin-bottom: 2rem;
}

.news-header h2 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.news-header p {
  color: var(--text-muted);
  font-size: 1rem;
}

.news-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 1.2rem;
}

.news-tab {
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.2s ease;
}

.news-tab:hover {
  border-color: var(--accent);
}

.news-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#news-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.news-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: 0.2s ease;
}

.news-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
}

.news-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.news-card:hover img {
  transform: scale(1.03);
}

.news-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.25rem;
  gap: 0.6rem;
}

.news-content h3 {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
}

.news-content p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.news-footer {
  margin-top: auto;
  padding-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* footer & indicators */
.scroll-indicator {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.1rem;
  animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% {
    transform: translate(-50%, 0);
  }
  50% {
    transform: translate(-50%, 8px);
  }
}

.madeby {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.madeby span {
  color: var(--accent);
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* mobile */
@media (max-width: 768px) {
  .news-section {
    padding: 3.5rem 5% 3rem;
  }

  .news-header h2 {
    font-size: 1.8rem;
  }

  #news-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  #clock {
    font-size: 4rem;
  }

  .favorites {
    gap: 14px;
  }

  .favorite i {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  #settings-panel {
    right: 12px;
    bottom: 70px;
    width: calc(100vw - 24px);
  }
}