/* ---------- Tokens ---------- */
:root{
  --bg-0: #08090C;
  --bg-1: #0F1116;
  --card: #14161C;
  --card-border: rgba(255,255,255,0.07);
  --text-0: #F2F3F5;
  --text-1: #9AA0AC;
  --text-2: #5C616D;

  --blue: #4E9FFF;
  --blue-dim: rgba(78,159,255,0.14);
  --blue-glow: rgba(78,159,255,0.35);

  --orange: #FF9F4E;
  --orange-dim: rgba(255,159,78,0.14);
  --orange-glow: rgba(255,159,78,0.35);

  --green: #55D6A5;
  --red: #FF5F6D;

  --radius-lg: 26px;
  --radius-md: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Menlo", monospace;
}

*{ box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body{
  margin: 0;
  font-family: var(--font);
  color: var(--text-0);
  overflow-x: hidden;
  background:
    radial-gradient(120% 60% at 15% -10%, rgba(78,159,255,0.10), transparent 55%),
    radial-gradient(120% 60% at 90% 0%, rgba(255,159,78,0.08), transparent 50%),
    var(--bg-0);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.app{
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 40px;
}

/* ---------- Top bar ---------- */
.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.status{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
}

.status-dot{
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-2);
  box-shadow: 0 0 0 0 rgba(0,0,0,0);
  transition: background .3s ease, box-shadow .3s ease;
}
.status-dot.online{
  background: var(--green);
  box-shadow: 0 0 10px 1px rgba(85,214,165,0.65);
}
.status-dot.offline{
  background: var(--red);
  box-shadow: 0 0 10px 1px rgba(255,95,109,0.55);
}
.status-dot.pending{
  background: var(--text-1);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse{ 50%{ opacity: .35; } }

.status-text{
  font-size: 12.5px;
  color: var(--text-1);
  letter-spacing: .01em;
}

.icon-btn{
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, color .15s ease;
}
.icon-btn:active{ transform: scale(0.9); color: var(--text-0); }

/* ---------- Hero card ---------- */
.hero-card{
  background: linear-gradient(155deg, var(--card) 0%, #10131A 100%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.hero-card::after{
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 90% at 100% 0%, var(--blue-dim), transparent 70%);
  pointer-events: none;
}

.hero-time{
  font-size: 44px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.hero-date{
  color: var(--text-1);
  font-size: 13.5px;
  margin-top: 2px;
  letter-spacing: .01em;
}

.hero-temp{
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  color: var(--orange);
  font-size: 14.5px;
  font-weight: 600;
}
.hero-temp svg{ flex-shrink: 0; }
.hero-temp-label{
  color: var(--text-2);
  font-weight: 500;
  font-size: 12.5px;
  margin-left: 2px;
}

/* ---------- Scene grid ---------- */
.grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.tile{
  position: relative;
  appearance: none;
  border: 1px solid var(--card-border);
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 20px 16px 18px;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  text-align: left;
  color: var(--text-0);
  overflow: hidden;
  transition: transform .12s cubic-bezier(.2,.8,.3,1), border-color .2s ease, background .2s ease;
}

/* full-width tile for last odd item */
.tile:nth-child(5){ grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 76px; }
.tile:nth-child(5) .tile-icon{ margin-bottom: 0; }
.tile:nth-child(5) .tile-label{ margin-left: 4px; }
.tile:nth-child(5) .tile-sub{ display: none; }

.tile-glow{
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  top: -60px;
  right: -60px;
  filter: blur(30px);
  opacity: .5;
  pointer-events: none;
  transition: opacity .2s ease;
}
.tile--blue .tile-glow{ background: var(--blue-glow); }
.tile--orange .tile-glow{ background: var(--orange-glow); }

.tile-icon{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.tile--blue .tile-icon{ color: var(--blue); background: var(--blue-dim); }
.tile--orange .tile-icon{ color: var(--orange); background: var(--orange-dim); }

.tile-label{
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tile-sub{
  font-size: 11.5px;
  color: var(--text-2);
  font-family: var(--font-mono);
  margin-top: 4px;
}

.tile:active{
  transform: scale(0.96);
  border-color: rgba(255,255,255,0.16);
}
.tile--blue:active{ background: #171B24; }
.tile--orange:active{ background: #1C1712; }

.tile.is-sending{ opacity: .6; pointer-events: none; }
.tile.is-success{ animation: flashOk .5s ease; }
@keyframes flashOk{
  0%{ box-shadow: 0 0 0 0 transparent; }
  30%{ box-shadow: 0 0 0 3px rgba(85,214,165,0.35); }
  100%{ box-shadow: 0 0 0 0 transparent; }
}
.tile.is-error{ animation: flashErr .5s ease; }
@keyframes flashErr{
  0%{ box-shadow: 0 0 0 0 transparent; }
  30%{ box-shadow: 0 0 0 3px rgba(255,95,109,0.4); }
  100%{ box-shadow: 0 0 0 0 transparent; }
}

.hint{
  text-align: center;
  color: var(--text-2);
  font-size: 12.5px;
  margin-top: 22px;
  line-height: 1.5;
}

/* ---------- Toast ---------- */
.toast{
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translate(-50%, 16px);
  background: rgba(20,22,28,0.92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--card-border);
  color: var(--text-0);
  font-size: 13.5px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  white-space: nowrap;
  z-index: 40;
}
.toast.show{
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Settings sheet ---------- */
.sheet-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 50;
  display: flex;
  align-items: flex-end;
}
.sheet-backdrop.open{ opacity: 1; pointer-events: auto; }

.sheet{
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-1);
  border: 1px solid var(--card-border);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 10px 22px calc(env(safe-area-inset-bottom) + 22px);
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.2,.9,.25,1);
}
.sheet-backdrop.open .sheet{ transform: translateY(0); }

.sheet-handle{
  width: 36px;
  height: 4px;
  background: var(--card-border);
  border-radius: 999px;
  margin: 8px auto 14px;
}

.sheet h2{
  font-size: 17px;
  font-weight: 650;
  margin: 4px 0 14px;
}
.sheet-subhead{ margin-top: 6px; }
.sheet-note{
  color: var(--text-2);
  font-size: 12px;
  margin: -8px 0 12px;
}

.field{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field span{
  font-size: 12.5px;
  color: var(--text-1);
  font-weight: 500;
}
.field span em{ color: var(--text-2); font-style: normal; }
.field input{
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text-0);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s ease;
}
.field input:focus{ border-color: var(--blue); }
.field--compact{ margin-bottom: 10px; }
.field--compact input{ padding: 10px 12px; font-size: 14px; }

.sheet-actions{
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.btn{
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  transition: transform .12s ease, opacity .15s ease;
}
.btn:active{ transform: scale(0.97); }
.btn-secondary{ background: var(--card); color: var(--text-1); border: 1px solid var(--card-border); }
.btn-primary{ background: var(--blue); color: #071019; }

@media (min-width: 540px){
  .app{ padding-top: 40px; }
}
