/* Mobile-first styles: base rules target small screens, @media widens up. */

:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1a1d24;
  --surface-2: #22262f;
  --text: #f2f3f5;
  --text-dim: #9aa1ac;
  --green: #37b24d;
  --red: #e03131;
  --amber: #f08c00;
  --blue: #339af0;
  --purple: #7048e8;
  --border: #2c3038;
  --radius: 14px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

body {
  padding-bottom: calc(var(--nav-h) + 16px);
  min-height: 100vh;
}

body.no-nav-gap {
  padding-bottom: 0;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}

h1 {
  font-size: 1.4rem;
  margin: 4px 0 16px;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

a { color: var(--blue); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.badge {
  display: block;
  text-align: center;
  border-radius: var(--radius);
  padding: 22px 16px;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.badge .sub {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  margin-top: 6px;
  opacity: 0.9;
}

.badge.no { background: color-mix(in srgb, var(--red) 25%, var(--surface)); border: 1px solid var(--red); color: #ffc9c9; }
.badge.unknown { background: color-mix(in srgb, var(--amber) 25%, var(--surface)); border: 1px solid var(--amber); color: #ffe8cc; }
.badge.idle { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }

@property --charge-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes charge-spin {
  to { --charge-angle: 360deg; }
}

.badge.ok {
  color: #d3f9d8;
  border: 2px solid transparent;
  background:
    linear-gradient(color-mix(in srgb, var(--green) 25%, var(--surface)), color-mix(in srgb, var(--green) 25%, var(--surface))) padding-box,
    conic-gradient(from var(--charge-angle), var(--green), color-mix(in srgb, var(--green) 10%, transparent) 50%, var(--green)) border-box;
  animation: charge-spin 2.5s linear infinite;
}

.tutorial-hero {
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(to bottom, #000000 0%, #000000 18%, #ffffff 58%);
  padding: 28px 20px 40px;
  text-align: center;
}

.wb-normal {
  font-family: 'Poppins', sans-serif;
}

.wb-handwritten {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  margin-left: 2px;
}

.tutorial-logo {
  font-family: 'Poppins', sans-serif;
  font-size: 1.7rem;
  font-weight: 400;
  color: #fff;
  margin-bottom: 30px;
  letter-spacing: 0.01em;
}

.tutorial-logo .wb-handwritten {
  font-size: 2.2rem;
  color: #fff;
}

.tutorial-image {
  width: 100%;
  max-width: 600px;
  height: auto;
  border-radius: 12px;
  margin-bottom: 32px;
}

.tutorial-image-badge {
  width: auto;
  max-height: 40vh;
  max-height: 40dvh;
}

.tutorial-icon {
  color: #16181c;
  margin-bottom: 32px;
}

.tutorial-hero h2 {
  margin: 0 0 32px;
  color: #fff;
}

.tutorial-text {
  max-width: 340px;
  margin: 0 auto;
  line-height: 1.6;
  font-size: 1.05rem;
  color: #16181c;
}

.stat-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-row-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat {
  flex: 1 1 120px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
}

.stat .value {
  font-size: 1.3rem;
  font-weight: 700;
}

.stat .label {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.stat .cost {
  margin-top: 2px;
}

.stat .price-fixed {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-dim);
}

form.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-size: 0.85rem;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
input[type="date"],
select {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-row input { width: 20px; height: 20px; }

button, .btn {
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 16px;
  border-radius: 10px;
  border: none;
  background: var(--blue);
  color: #06131f;
  cursor: pointer;
}

button:active { opacity: 0.85; }

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--text-dim); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }

.chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--text-dim); font-size: 8px; }
.chart-empty { fill: var(--text-dim); font-size: 12px; }

.muted { color: var(--text-dim); font-size: 0.85rem; }

.field-hint { font-size: 0.78rem; color: var(--text-dim); margin-top: -6px; }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-pill.on { background: color-mix(in srgb, var(--green) 30%, transparent); color: #d3f9d8; }
.status-pill.off { background: color-mix(in srgb, var(--red) 30%, transparent); color: #ffc9c9; }

/* Bottom app-style navigation */
nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 640px;
  margin: 0 auto;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 10;
}

nav.bottom-nav a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-decoration: none;
}

nav.bottom-nav a .icon {
  width: 26px;
  height: 26px;
  transition: color 0.15s ease;
}

nav.bottom-nav a.active { color: var(--blue); }

/* Desktop: widen content, keep bottom nav fixed but roomier */
@media (min-width: 720px) {
  main { max-width: 860px; padding: 24px 24px 8px; }

  nav.bottom-nav { max-width: 860px; }

  .stat-row { flex-wrap: nowrap; }
}
