* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell,
.map-root {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

.map-root {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.glass {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
}

.icon-button:hover {
  color: #fff;
}

.icon {
  display: block;
  width: 1em;
  height: 1em;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-fab {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 30;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  transition: background 180ms ease, color 180ms ease;
  pointer-events: auto;
}

.search-fab:hover {
  background: rgba(255, 255, 255, 0.2);
}

.search-fab .icon {
  width: 20px;
  height: 20px;
}

.search-panel {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.sidebar {
  pointer-events: auto;
  position: relative;
  z-index: 10;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 0;
  transition: all 500ms ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-search-icon {
  flex-shrink: 0;
  margin-left: 0.5rem;
  color: rgba(255, 255, 255, 0.5);
  font-size: 20px;
}

.search-input {
  width: 100%;
  min-width: 0;
  padding-left: 0.75rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.category-select {
  flex-shrink: 0;
  max-width: 135px;
  padding: 0.375rem 0.75rem;
  border: 0;
  border-radius: 999px;
  outline: 0;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.12);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
}

.category-select:hover {
  background: rgba(255, 255, 255, 0.2);
}

.category-select option {
  background: #111827;
  color: #fff;
}

.close-button {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-left: 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 180ms ease, color 180ms ease;
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.satellite-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem;
}

.satellite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.25rem;
  border-radius: 1rem;
  color: inherit;
  background: transparent;
  text-align: left;
  transition: background 300ms ease, box-shadow 300ms ease;
}

.satellite-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.satellite-row.selected {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.12);
}

.satellite-row-inner {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 1rem;
  padding-left: 0.25rem;
}

.color-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  transition: transform 500ms ease, box-shadow 500ms ease;
}

.satellite-label {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.satellite-name {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 180ms ease;
}

.satellite-row:hover .satellite-name,
.satellite-row.selected .satellite-name {
  color: #fff;
}

.norad-id {
  margin-top: 0.125rem;
  color: rgba(255, 255, 255, 0.4);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.empty-state,
.loading-state {
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.875rem;
  text-align: center;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 8rem;
  color: rgba(255, 255, 255, 0.4);
}

.loading-state .icon {
  width: 20px;
  height: 20px;
  margin-bottom: 0.75rem;
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-state p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.empty-state {
  padding: 2rem;
}

.right-rail {
  position: absolute;
  top: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 18rem;
  gap: 1rem;
  pointer-events: none;
}

.tracked-panel,
.definition-panel {
  overflow: hidden;
  border-radius: 1rem;
  pointer-events: auto;
}

.tracked-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  flex-shrink: 1;
}

.definition-panel {
  width: 12rem;
  margin-top: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 180ms ease;
}

.panel-header:hover {
  background: rgba(255, 255, 255, 0.1);
}

.panel-header h2 {
  margin: 0;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title-row .icon {
  width: 16px;
  height: 16px;
  color: rgba(255, 255, 255, 0.7);
}

.panel-toggle {
  width: 20px;
  height: 20px;
  padding: 0;
}

.panel-toggle .icon {
  width: 16px;
  height: 16px;
}

.tracked-list {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

.tracked-card {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 1rem;
}

.tracked-card + .tracked-card {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tracked-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.tracked-card-title {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.75rem;
}

.tracked-card-title strong {
  max-width: 200px;
  overflow: hidden;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-button {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-left: 0.5rem;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.2);
  transition: background 180ms ease, color 180ms ease;
}

.remove-button:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
}

.remove-button .icon {
  width: 14px;
  height: 14px;
}

.stat-grid {
  display: grid;
  flex-shrink: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.625rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
}

.stat {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.stat:nth-child(2) {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding-inline: 0.25rem;
}

.stat-label {
  margin-bottom: 0.125rem;
  color: rgba(255, 255, 255, 0.4);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
  font-weight: 500;
}

.lat-lng {
  font-size: 10px;
  line-height: 1.25;
  text-align: center;
}

.stat-unit {
  color: rgba(255, 255, 255, 0.3);
  font-size: 9px;
}

.details-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 0.375rem;
  margin-top: 0.75rem;
  padding: 0.375rem;
  border-radius: 0.375rem;
  color: rgba(255, 255, 255, 0.4);
  background: transparent;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 180ms ease, color 180ms ease;
}

.details-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.details-button .icon {
  width: 12px;
  height: 12px;
}

.details-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 300ms ease, opacity 300ms ease;
}

.details-content.expanded {
  max-height: 500px;
  opacity: 1;
}

.orbital-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.75rem;
}

.orbital-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.orbital-item:nth-last-child(-n+2) {
  border-bottom: 0;
}

.orbital-item span:first-child {
  color: rgba(255, 255, 255, 0.5);
}

.orbital-item span:last-child {
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 10px;
}

.tle-block {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.tle-label {
  padding-inline: 0.25rem;
  color: rgba(255, 255, 255, 0.5);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tle-code {
  display: block;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 0.5rem;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.4);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  line-height: 1.625;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.definition-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.definition-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.definition-item span {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

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

.custom-scrollbar::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.2);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.4);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@media (min-width: 768px) {
  .search-fab {
    top: 1.5rem;
    left: 1.5rem;
  }

  .search-panel {
    inset: 1.5rem auto 1.5rem 1.5rem;
    width: 20rem;
  }

  .sidebar {
    height: auto;
    max-height: 100%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1.5rem;
  }

  .right-rail {
    top: 1.5rem;
    right: 1.5rem;
    bottom: 1.5rem;
    width: 20rem;
  }

  .tle-code {
    font-size: 11px;
  }
}
