:root {
  --bg: #000000;
  --fg: #f2f2f2;
  --muted: #a0a0a0;
  --green: #00f45a;
  --green-soft: rgba(0, 244, 90, 0.25);
  --orange: #ff8a00;
  --orange-soft: rgba(255, 138, 0, 0.3);
  --panel: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 255, 255, 0.15);
  --error: #ff4040;
  --glow-green: 0 0 8px var(--green), 0 0 22px var(--green-soft);
  --glow-orange: 0 0 8px var(--orange), 0 0 22px var(--orange-soft);
  --font-main: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Fira Code", "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-main);
  line-height: 1.6;
}

.app-shell {
  min-height: 100vh;
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 24px 18px 28px;
}

.empty-state,
.main-view,
.error-state {
  display: none;
}

.empty-state.active,
.main-view.active,
.error-state.active {
  display: block;
}

.empty-state {
  min-height: calc(100vh - 52px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 22px;
}

.empty-state.active {
  display: flex;
}

.stiffer-placeholder {
  position: relative;
  width: 180px;
  height: 120px;
  animation: pulse 2s ease-in-out infinite;
}

.bolt {
  position: absolute;
  width: 70px;
  height: 90px;
  border: 4px solid var(--orange);
  border-right: none;
  border-bottom: none;
  transform: skewY(-24deg) rotate(18deg);
  box-shadow: var(--glow-orange), 0 0 12px var(--green-soft);
}

.bolt.left {
  left: 14px;
  top: 18px;
}

.bolt.right {
  right: 14px;
  top: 0;
  transform: skewY(-24deg) rotate(20deg) scaleX(-1);
}

.empty-copy {
  margin: 0;
  font-size: clamp(0.95rem, 2vw, 1.12rem);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  text-shadow: var(--glow-green);
}

.ghost-btn,
.action-btn {
  font-family: var(--font-mono);
  font-weight: 500;
  border: 1px solid var(--green);
  background: transparent;
  color: var(--green);
  padding: 10px 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: 160ms ease;
}

.ghost-btn:hover,
.action-btn:hover {
  background: var(--green-soft);
}

.action-btn-warn {
  border-color: var(--orange);
  color: var(--orange);
}

.action-btn-warn:hover {
  background: var(--orange-soft);
}

.action-btn.unit-metric {
  color: #22c55e;
  border-color: #22c55e;
}

.action-btn.unit-freedom {
  color: #f97316;
  border-color: #f97316;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.3);
}

.system-warning {
  margin: -6px 0 12px;
  font-family: var(--font-mono);
  color: #f97316;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  animation: freedom-pulse 1.1s ease-in-out infinite;
}

.system-warning.hidden {
  display: none;
}

.top-bar {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.home-link {
  font-family: var(--font-mono);
  font-weight: 500;
  border: 1px solid var(--green);
  color: var(--green);
  text-decoration: none;
  padding: 10px 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: 160ms ease;
}

.home-link:hover {
  background: var(--green-soft);
}

.top-bar h1 {
  font-family: var(--font-mono);
  font-weight: 500;
  margin: 0;
  text-align: center;
  font-size: clamp(1rem, 2.8vw, 1.35rem);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.current-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 18px;
}

.current-temp-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.env-inline .v {
  color: var(--green);
}

.env-inline .v.warn {
  color: var(--orange);
  text-shadow: var(--glow-orange);
}

.current-temp {
  margin: 0;
  font-size: clamp(3.1rem, 9vw, 5rem);
  font-weight: 700;
  text-shadow: var(--glow-green);
}

.celestial-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  position: relative;
}

.celestial-icon.sun {
  background: var(--orange);
  box-shadow: var(--glow-orange), 0 0 0 6px rgba(255, 138, 0, 0.2);
  animation: pulse 2.4s ease-in-out infinite;
}

.celestial-icon.moon {
  background: var(--orange);
  box-shadow: var(--glow-orange), 0 0 16px var(--green-soft);
  animation: pulse 2.4s ease-in-out infinite;
}

.celestial-icon.moon::after {
  content: "";
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg);
  top: 2px;
  left: 14px;
}

.current-footer {
  margin-top: 12px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.gear-row {
  display: flex;
  gap: 14px;
  align-items: center;
}

.env-inline {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.85rem;
  line-height: 1.35;
  white-space: nowrap;
}

.env-inline .k,
.env-inline .sep {
  color: var(--muted);
}

.gear-icon {
  width: 56px;
  height: 56px;
  position: relative;
}

.gear-label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-top: 4px;
}

.gear-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px 10px;
  min-width: 118px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}

.gear-umbrella::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 13px;
  width: 42px;
  height: 20px;
  border: 3px solid var(--green);
  border-bottom: none;
  border-radius: 42px 42px 2px 2px;
  box-shadow: var(--glow-green);
}

.gear-umbrella::after {
  content: "";
  position: absolute;
  left: 27px;
  top: 33px;
  width: 3px;
  height: 18px;
  background: var(--orange);
  border-radius: 3px;
  box-shadow: var(--glow-orange);
}

.gear-umbrella {
  animation: umbrella-rock 2s ease-in-out infinite;
}

.gear-beanie::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 14px;
  width: 36px;
  height: 25px;
  border: 3px solid var(--green);
  border-bottom: 6px solid var(--green);
  border-radius: 14px 14px 10px 10px;
  box-shadow: var(--glow-green);
}

.gear-beanie::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 3px solid var(--orange);
  border-radius: 50%;
  left: 22px;
  top: 4px;
  box-shadow: var(--glow-orange);
}

.gear-glasses::before,
.gear-glasses::after {
  content: "";
  position: absolute;
  top: 20px;
  width: 16px;
  height: 14px;
  border: 3px solid var(--orange);
  border-radius: 4px;
  box-shadow: var(--glow-orange);
}

.gear-glasses::before {
  left: 8px;
}

.gear-glasses::after {
  right: 8px;
}

.gear-glasses {
  border-top: 3px solid var(--orange);
  top: 4px;
  box-shadow: inset 0 8px 0 -6px var(--orange-soft);
}

.gear-cloud::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 22px;
  width: 38px;
  height: 18px;
  border-radius: 24px;
}

.gear-cloud.day::before {
  border: 3px solid var(--green);
  box-shadow: var(--glow-green);
}

.gear-cloud.night::before {
  border: 3px solid var(--orange);
  box-shadow: var(--glow-orange);
}

.forecast-panel {
  margin-top: 18px;
}

.forecast-panel h2 {
  font-family: var(--font-mono);
  font-weight: 500;
  margin: 0 0 10px;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.forecast-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(120px, 1fr);
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 8px;
}

.forecast-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  scroll-snap-align: start;
}

.forecast-item:hover,
.daily-item:hover,
.gear-card:hover {
  border-color: rgba(0, 244, 90, 0.75);
  box-shadow: 0 0 12px rgba(0, 244, 90, 0.22);
}

.daily-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(130px, 1fr);
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 8px;
}

.daily-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  scroll-snap-align: start;
}

.app-shell.freedom-mode .forecast-item:hover,
.app-shell.freedom-mode .daily-item:hover,
.app-shell.freedom-mode .gear-card:hover {
  border-color: rgba(249, 115, 22, 0.82);
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.26);
}

.daily-item .d {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
  padding-top: 5px;
}

.daily-item .r {
  font-family: var(--font-mono);
  font-weight: 500;
  margin-top: 4px;
  font-size: 1.05rem;
  color: var(--green);
}

.forecast-item .t {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
  padding-top: 5px;
}

.app-shell.freedom-mode .forecast-item,
.app-shell.freedom-mode .daily-item {
  min-height: 176px;
}

.forecast-item .v {
  font-family: var(--font-mono);
  font-weight: 500;
  margin-top: 4px;
  font-size: 1.2rem;
  color: var(--green);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
}

.overlay.hidden {
  display: none;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(9px);
  background: rgba(0, 0, 0, 0.7);
}

.search-modal {
  position: relative;
  width: min(700px, calc(100% - 30px));
  border: 1px solid var(--line);
  background: rgba(5, 5, 5, 0.95);
  border-radius: 14px;
  padding: 16px;
  z-index: 1;
}

.search-modal h2 {
  font-family: var(--font-mono);
  font-weight: 500;
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--green);
  text-transform: uppercase;
}

.search-input {
  font-family: var(--font-main);
  width: 100%;
  border: 1px solid var(--green);
  background: #070707;
  color: var(--fg);
  padding: 10px;
  outline: none;
}

.search-status {
  font-family: var(--font-mono);
  font-weight: 500;
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  text-transform: uppercase;
}

.search-results {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  max-height: 44vh;
  overflow: auto;
}

.search-results button {
  font-family: var(--font-main);
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg);
  padding: 10px;
  cursor: pointer;
}

.search-results button:hover {
  border-color: var(--green);
  background: rgba(0, 244, 90, 0.1);
}

.error-state {
  border: 1px solid var(--error);
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 64, 64, 0.08);
}

.error-headline {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--error);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.03);
    opacity: 1;
  }
}

@keyframes umbrella-rock {
  0%,
  100% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(3deg);
  }
}

@keyframes freedom-pulse {
  0%,
  100% {
    opacity: 0.52;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 660px) {
  .app-shell {
    padding-inline: 12px;
  }

  .top-bar {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "home search"
      "purge unit"
      "location location";
  }

  #backHomeLink {
    grid-area: home;
    justify-self: start;
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  #openSearchBtn {
    grid-area: search;
    justify-self: end;
  }

  #clearStateBtn {
    grid-area: purge;
    justify-self: start;
  }

  #unitToggle {
    grid-area: unit;
    justify-self: end;
  }

  #locationLabel {
    grid-area: location;
  }
}
