:root {
  color-scheme: dark;
  --panel-primary: #e0ede8;
  --panel-muted: #82948f;
  --panel-surface: rgba(12, 15, 16, 0.88);
  --panel-chrome: rgba(18, 21, 22, 0.82);
  --panel-line: #2b3333;
  --green-signal: #21f287;
  --red-signal: #ff383d;
  --amber-signal: #ff9e38;
  --body-bg: #050707;
  --font-shell: "SF Mono", "Cascadia Mono", "Menlo", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--body-bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--panel-primary);
  font-family: var(--font-shell);
  letter-spacing: 0;
  background:
    linear-gradient(165deg, transparent 0 38%, rgba(33, 242, 135, 0.12) 38.1% 38.35%, transparent 38.45%),
    linear-gradient(96deg, transparent 0 66%, rgba(33, 242, 135, 0.08) 66.1% 66.25%, transparent 66.35%),
    repeating-linear-gradient(90deg, rgba(43, 51, 51, 0.22) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(0deg, rgba(43, 51, 51, 0.22) 0 1px, transparent 1px 32px),
    linear-gradient(180deg, #040606 0%, #09100e 100%);
}

button {
  border: 0;
  border-radius: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  letter-spacing: 0;
}

button:focus-visible {
  outline: 2px solid var(--green-signal);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 590px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(34px + env(safe-area-inset-bottom));
}

.top-control {
  display: grid;
  grid-template-columns: auto auto auto minmax(8px, 1fr) auto auto auto auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 10px;
  background: rgba(18, 21, 22, 0.86);
  border: 1px solid var(--panel-line);
}

.shell-pill,
.shell-pill-filled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 4px 8px;
  border: 1px solid var(--panel-line);
  color: var(--panel-line);
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.shell-pill-filled {
  border-color: var(--green-signal);
  background: var(--green-signal);
  color: #020403;
}

.shell-monitor {
  color: var(--panel-primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
}

.shell-version,
.clock,
.today-date {
  color: var(--panel-muted);
  font-size: 9px;
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--green-signal);
  border-radius: 50%;
}

.shell-live {
  color: var(--green-signal);
  font-size: 9px;
  font-weight: 900;
}

.device-actions {
  display: grid;
  grid-template-columns: 28px;
  gap: 6px;
}

.device-button,
.icon-button,
.modal-close {
  display: grid;
  place-items: center;
  background: rgba(18, 21, 22, 0.8);
  border: 1px solid var(--panel-line);
}

.device-button {
  width: 28px;
  height: 24px;
  color: var(--panel-primary);
}

.device-button svg,
.icon-button svg,
.modal-close svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.device-button:hover,
.icon-button:hover,
.modal-close:hover {
  border-color: var(--green-signal);
  color: var(--green-signal);
}

.command-header,
.panel {
  margin-top: 14px;
  padding: 14px;
  background: var(--panel-surface);
  border: 1px solid var(--panel-line);
}

.command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

h1 {
  margin: 0;
  color: var(--panel-primary);
  font-size: clamp(36px, 11vw, 40px);
  font-weight: 950;
  line-height: 1;
}

.today-date {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.counter-block {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.today-count {
  min-width: 78px;
  padding: 8px 12px;
  color: var(--green-signal);
  background: rgba(33, 242, 135, 0.12);
  border: 1px solid rgba(33, 242, 135, 0.72);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.metric {
  min-width: 0;
  padding: 8px;
  background: rgba(18, 21, 22, 0.74);
  border: 1px solid var(--panel-line);
}

.metric-label {
  color: var(--panel-muted);
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.metric-value {
  overflow: hidden;
  margin-top: 7px;
  color: var(--panel-primary);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  padding: 12px;
}

.panel-title {
  display: grid;
  grid-template-columns: 7px auto minmax(18px, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 12px;
  color: var(--panel-muted);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.title-mark {
  width: 7px;
  height: 7px;
  background: var(--green-signal);
}

.panel-red .title-mark {
  background: var(--red-signal);
}

.title-line {
  height: 1px;
  background: var(--panel-line);
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mood-button {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 12px;
  background: rgba(18, 21, 22, 0.72);
  border: 1px solid var(--panel-line);
  color: var(--panel-primary);
  text-align: left;
}

.mood-button::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--panel-line);
}

.mood-button span {
  overflow: hidden;
  font-size: 15px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mood-button:hover,
.mood-button.active {
  border-color: var(--green-signal);
  color: var(--green-signal);
  background: rgba(33, 242, 135, 0.1);
}

.mood-button.active::before {
  background: var(--green-signal);
}

.action-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
}

.data-tag {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 6px 9px;
  border: 1px solid currentColor;
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0.8px;
}

.data-tag-red {
  color: var(--red-signal);
  background: rgba(255, 56, 61, 0.1);
}

.data-tag-amber {
  color: var(--amber-signal);
  background: rgba(255, 158, 56, 0.1);
}

.action-title {
  margin-top: 18px;
  color: var(--panel-primary);
  font-size: clamp(29px, 8vw, 34px);
  font-weight: 950;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.action-controls,
.result-controls,
.dialog-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 8px;
  margin-top: 18px;
}

.done-button {
  height: 52px;
  background: rgba(33, 242, 135, 0.16);
  border: 1px solid var(--green-signal);
  color: var(--green-signal);
  font-size: 16px;
  font-weight: 950;
}

.icon-button {
  width: 52px;
  height: 52px;
  color: var(--panel-primary);
}

.feedback {
  margin-top: 14px;
  color: var(--panel-primary);
  font-size: 22px;
  font-weight: 950;
  line-height: 1.2;
}

.result-controls,
.dialog-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-controls.maxed {
  grid-template-columns: 1fr;
}

.shell-button {
  display: grid;
  place-items: center;
  min-height: 46px;
  padding: 0 10px;
  background: rgba(18, 21, 22, 0.74);
  border: 1px solid var(--panel-line);
  color: var(--panel-primary);
  font-size: 13px;
  font-weight: 950;
  line-height: 1.1;
  text-align: center;
}

.shell-button-red {
  border-color: var(--red-signal);
  color: var(--red-signal);
}

.history-empty {
  margin-top: 12px;
  padding: 8px 0;
  color: var(--panel-muted);
  font-size: 13px;
  font-weight: 700;
}

.support-copy {
  margin-top: 12px;
  color: var(--panel-primary);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.support-button {
  min-height: 50px;
  color: var(--amber-signal);
  border-color: rgba(255, 158, 56, 0.6);
  background: rgba(255, 158, 56, 0.08);
}

.support-later {
  width: 100%;
  margin-top: 8px;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.history-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px;
  background: rgba(18, 21, 22, 0.64);
  border: 1px solid var(--panel-line);
}

.history-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  background: rgba(33, 242, 135, 0.08);
  border: 1px solid rgba(33, 242, 135, 0.55);
  color: var(--green-signal);
}

.history-icon svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.history-title {
  overflow-wrap: anywhere;
  color: var(--panel-primary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.28;
}

.history-feeling {
  color: var(--panel-muted);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.global-panel {
  overflow: hidden;
}

.global-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.global-stat {
  min-width: 0;
  padding: 8px;
  background: rgba(18, 21, 22, 0.74);
  border: 1px solid var(--panel-line);
}

.global-map {
  position: relative;
  overflow: hidden;
  margin-top: 12px;
  aspect-ratio: 640 / 300;
  background:
    radial-gradient(circle at 50% 50%, rgba(33, 242, 135, 0.08), transparent 58%),
    rgba(3, 9, 8, 0.88);
  border: 1px solid var(--panel-line);
}

.global-map svg {
  display: block;
  width: 100%;
  height: 100%;
}

.map-grid-lines path {
  fill: none;
  stroke: rgba(43, 51, 51, 0.65);
  stroke-width: 1;
}

.map-land path {
  fill: rgba(33, 242, 135, 0.055);
  stroke: rgba(33, 242, 135, 0.28);
  stroke-width: 1.2;
}

.global-marker {
  fill: var(--green-signal);
  stroke: rgba(224, 237, 232, 0.72);
  stroke-width: 1;
}

.global-marker.local {
  fill: var(--red-signal);
  stroke: var(--red-signal);
}

.global-pulse {
  fill: none;
  stroke: var(--green-signal);
  stroke-width: 1.2;
  opacity: 0.45;
  transform-box: fill-box;
  transform-origin: center;
}

.global-pulse.local {
  stroke: var(--red-signal);
}

.scan-line {
  position: absolute;
  inset: -30% 0 auto;
  height: 38%;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(33, 242, 135, 0.08), transparent);
  transform: translateY(-100%);
}

.global-region-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.region-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 8px;
  background: rgba(18, 21, 22, 0.64);
  border: 1px solid var(--panel-line);
}

.region-name {
  overflow: hidden;
  color: var(--panel-primary);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.region-meta {
  color: var(--panel-muted);
  font-size: 9px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.region-bar {
  grid-column: 1 / -1;
  height: 3px;
  background: rgba(43, 51, 51, 0.9);
}

.region-bar span {
  display: block;
  height: 100%;
  background: var(--green-signal);
}

.global-feed-block {
  margin-top: 12px;
}

.compact-title {
  font-size: 9px;
}

.global-feed {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.feed-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px;
  background: rgba(18, 21, 22, 0.64);
  border: 1px solid var(--panel-line);
}

.feed-dot {
  width: 7px;
  height: 7px;
  background: var(--green-signal);
}

.feed-dot.local {
  background: var(--red-signal);
}

.feed-action {
  overflow: hidden;
  color: var(--panel-primary);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-place,
.feed-time {
  color: var(--panel-muted);
  font-size: 9px;
  font-weight: 900;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.modal {
  width: min(calc(100vw - 28px), 430px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--panel-primary);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal-frame {
  margin: 0;
  padding: 14px;
  background: rgba(12, 15, 16, 0.98);
  border: 1px solid var(--panel-line);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.5);
}

.modal-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
}

.modal-title {
  color: var(--panel-primary);
  font-size: 18px;
  font-weight: 950;
  line-height: 1.2;
}

.modal-close {
  width: 34px;
  height: 34px;
  color: var(--panel-muted);
}

.install-steps {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--panel-primary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.install-steps li::marker {
  color: var(--green-signal);
  font-weight: 950;
}

.modal-message {
  margin: 12px 0 0;
  color: var(--panel-muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.choice-grid {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.choice-grid .shell-button {
  width: 100%;
}

@media (max-width: 430px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .top-control {
    grid-template-columns: auto auto minmax(4px, 1fr) auto auto auto;
  }

  .shell-version,
  .shell-pill:not(.shell-pill-filled) {
    display: none;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .support-grid {
    grid-template-columns: 1fr;
  }

  .global-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mood-grid {
    grid-template-columns: 1fr;
  }

  .global-region-grid {
    grid-template-columns: 1fr;
  }

  .command-row {
    grid-template-columns: 1fr;
  }

  .counter-block {
    grid-template-columns: auto auto;
    justify-content: space-between;
    justify-items: start;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .panel,
  .command-header,
  .top-control {
    animation: rise-in 180ms ease-out both;
  }

  .panel:nth-of-type(2) {
    animation-delay: 30ms;
  }

  .panel:nth-of-type(3) {
    animation-delay: 60ms;
  }

  .panel:nth-of-type(4) {
    animation-delay: 90ms;
  }

  .status-dot {
    animation: pulse 1.4s steps(2, end) infinite;
  }

  .scan-line {
    animation: scan 3.8s linear infinite;
  }

  .global-pulse {
    animation: map-pulse 2.4s ease-out infinite;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.28;
  }
}

@keyframes scan {
  to {
    transform: translateY(360%);
  }
}

@keyframes map-pulse {
  to {
    transform: scale(2.4);
    opacity: 0;
  }
}
