:root{
  /* dark base (default) */
  --bg0:#1b1f26;
  --bg1:#222833;

  /* glass panels (dark) */
  --panel: rgba(26, 30, 38, .74);
  --panelSolid:#1f2430;
  --stroke: rgba(255,255,255,.12);

  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.62);

  --shadow: 0 18px 55px rgba(0,0,0,.55);

  --radius:22px;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;

  /* fisher price prime palette */
  --p-yellow:  #fff200;
  --p-sky:     #00a9df;
  --p-red:     #eb0b2b;
  --p-green:   #85eb00;
  --p-magenta: #be32ff;

  --accent: var(--p-sky);
}

/* Apple-inspired Light Mode */
[data-theme="light"]{
  --bg0: #E8E8ED;
  --bg1: #D8D8DD;

  --panel: rgba(255, 255, 255, .72);
  --panelSolid: #F0F0F2;
  --stroke: rgba(0,0,0,.12);

  --text: #1D1D1F;
  --muted: rgba(29, 29, 31, .56);

  --shadow: 0 4px 24px rgba(0,0,0,.12);

  --accent: #0066CC;

  --p-sky: #0066CC;
}

*{ box-sizing:border-box; }
html, body { height: 100%; scroll-behavior:smooth; }
body{
  margin:0;
  font-family:var(--sans);
  color:var(--text);
  background: var(--bg0);
  min-height:100%;
  transition: background .25s ease, color .25s ease;
}

/* stop browser default link styling */
a{
  color: inherit;
  text-decoration: none;
}

/* =========================
   HEADER
   ========================= */
.header{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:16px 18px;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  border-bottom:1px solid var(--stroke);
  transition: background .25s ease;
}

.headerRight{
  display:flex;
  align-items:center;
  gap:14px;
}

/* Theme Toggle Button (Apple-style) */
.themeToggle{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  border-radius:50%;
  border:1px solid var(--stroke);
  background: var(--panel);
  color: var(--text);
  cursor:pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .2s ease;
}

.themeToggle:hover{
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

.themeToggle:active{
  transform: scale(0.96);
}

/* Show sun in dark mode, moon in light mode */
.themeToggle .iconSun{ display:block; }
.themeToggle .iconMoon{ display:none; }

[data-theme="light"] .themeToggle .iconSun{ display:none; }
[data-theme="light"] .themeToggle .iconMoon{ display:block; }

.brand{ display:flex; gap:12px; align-items:center; }

.mark{
  width:42px;
  height:42px;
  border-radius:16px;
  display:grid;
  place-items:center;
  font-weight:900;
  font-family:var(--mono);
  background:
    radial-gradient(18px 18px at 30% 28%, rgba(255,242,0,.95), rgba(255,242,0,0) 70%),
    radial-gradient(22px 22px at 75% 70%, rgba(190,50,255,.85), rgba(190,50,255,0) 72%),
    rgba(0,169,223,.40);
  border:1px solid var(--stroke);
  box-shadow: 0 12px 22px rgba(0,0,0,.35);
}

.name{ font-weight:850; letter-spacing:.2px; }
.role{ color:var(--muted); font-size:12px; margin-top:2px; }

.statusPill{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(26,30,38,.62);
  box-shadow: 0 10px 25px rgba(0,0,0,.35);
}

.statusPill .dot{
  width:10px;
  height:10px;
  border-radius:999px;
  background: #2ed573;
  box-shadow: 0 0 0 4px rgba(46,213,115,.18);
}

/* =========================
   LAYOUT
   ========================= */
.layout{
  /* Increased max-width to reduce side bezels and make better use of landscape */
  max-width:1600px;
  margin:0 auto;
  padding:20px 28px; /* move content out slightly */
  display:grid;
  grid-template-columns: 380px 1fr; /* wider rail to scale tiles visually */
  gap:12px; /* reduce spacing between tiles */
}

@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .miniStats,
  .tinyGrid{ grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px){
  .heroTop,
  .heroBtns,
  .row{ gap:8px; }
  .miniStats,
  .tinyGrid{ grid-template-columns: 1fr; }
}

/* =========================
   CARDS (single source of truth)
   ========================= */
.card{
  border:1px solid var(--stroke);
  border-radius: calc(var(--radius) * 0.92);
  box-shadow: var(--shadow);
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  padding:18px; /* slightly larger for scaled appearance */
  overflow:hidden;
  /* avoid CSS transform on cards (can break canvas rendering). Use padding/widths instead */
}

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

.railCard{ position:relative; }

.cardTitle{
  font-family:var(--mono);
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.12em;
  color: rgba(255,255,255,.70);
  margin-bottom:12px;
}

/* =========================
   SPOTIFY TILE (full bleed, bottom-only blur)
   ========================= */
.spotifyTile{
  position: relative;
  aspect-ratio: 1 / 1;
  padding: 0;
  overflow: hidden;
}

/* full-bleed art */
.spotifyTile .spArt{
  position: absolute;
  inset: 0;
  z-index: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

/* empty state */
.spotifyTile .spArt.empty{
  background: linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
}

/* content layer pinned to bottom */
.spotifyTile .spOverlay{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px;
  z-index: 3;
}

/* bottom-only treatment with feathered edges */
.spotifyTile::before,
.spotifyTile::after{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
}

/* smooth readability gradient - feathered from middle to bottom */
.spotifyTile::before{
  z-index: 1;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 40%,
    rgba(0,0,0,.05) 55%,
    rgba(0,0,0,.15) 70%,
    rgba(0,0,0,.35) 85%,
    rgba(0,0,0,.55) 100%
  );
}

/* feathered blur using mask-image instead of clip-path */
.spotifyTile::after{
  z-index: 2;
  backdrop-filter: blur(8px) saturate(1.1);
  -webkit-backdrop-filter: blur(8px) saturate(1.1);
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 50%,
    rgba(0,0,0,.3) 70%,
    rgba(0,0,0,.7) 85%,
    black 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 50%,
    rgba(0,0,0,.3) 70%,
    rgba(0,0,0,.7) 85%,
    black 100%
  );
}

/* keep text crisp */
.spotifyTile .spText,
.spotifyTile .spBar{
  position: relative;
  z-index: 4;
}

.spotifyTile .spTitle{
  font-size:18px;
  font-weight:800;
  color: rgba(255,255,255,.92);
  line-height:1.15;
}

.spotifyTile .spArtist{
  font-size:13px;
  color: rgba(255,255,255,.68);
  font-family:var(--mono);
}

.spotifyTile .spBar{
  height:8px;
  border-radius:999px;
  background: rgba(255,255,255,.14);
  overflow:hidden;
}

.spotifyTile .spBar > i{
  display:block;
  height:100%;
  width:0%;
  background: rgba(255,255,255,.78);
}

#spotifyTile.loading .spTitle{ opacity:.85; }

/* =========================
   TERMINAL CARD
   ========================= */
.terminalCard{ padding:0; }

.terminalTop{
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.25);
}

.terminalTop .dot{
  width:10px;
  height:10px;
  border-radius:50%;
  opacity:.9;
}
.terminalTop .dot.red{ background:#ff5a7a; }
.terminalTop .dot.yellow{ background:#ffd166; }
.terminalTop .dot.green{ background:#2ed573; }

.termTitle{
  margin-left: 8px;
  color: rgba(170,220,255,.9);
  font-family: var(--mono);
  font-size: 14px;
}

.console{
  height: clamp(260px, 40vh, 420px);
  overflow:auto;
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  color: rgba(110,255,255,.92);
  background: rgba(0,0,0,.45);
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
}

.console::-webkit-scrollbar{
  width:8px;
}
.console::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.16);
  border-radius:8px;
}

.console .dim{ color: rgba(110,255,255,.6); }

/* =========================
   HERO SECTION
   ========================= */
.board{
  display:flex;
  flex-direction:column;
  gap:18px;
}

.heroTitle{
  font-size:18px;
  font-weight:900;
  letter-spacing:.2px;
}

.heroSub{
  color:var(--muted);
  margin-top:6px;
  line-height:1.4;
  max-width: 720px;
}

.heroTop{
  display:flex;
  gap:16px;
  align-items:flex-start;
  justify-content:space-between;
  flex-wrap:wrap;
}

.heroBadges{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.heroRow{
  display:grid;
  grid-template-columns: 1fr auto;
  gap:12px;
  align-items:end;
  margin-top:14px;
}

@media (max-width: 800px){
  .heroRow{ grid-template-columns: 1fr; }
}

.heroBtns{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
}

/* =========================
   FORM ELEMENTS
   ========================= */
.field{
  display:grid;
  gap:6px;
}

.field span{
  color:var(--muted);
  font-size:12px;
}

input, textarea{
  border-radius:16px;
  border:1px solid var(--stroke);
  background: rgba(26,30,38,.62);
  color:var(--text);
  padding:12px;
  outline:none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

/* keyboard-only focus */
:focus-visible{
  outline:2px solid rgba(0,169,223,.75);
  outline-offset:3px;
}

/* =========================
   GRID LAYOUTS
   ========================= */
.grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap:18px;
}

@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
}

.wide{ grid-column: 1 / -1; }

/* =========================
   CONTENT ELEMENTS
   ========================= */
.big{
  font-family:var(--mono);
  font-size:26px;
  padding:12px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background: rgba(26,30,38,.62);
  width:fit-content;
  min-width: 170px;
}

.sub{
  color:var(--muted);
  margin-top:8px;
  font-size:13px;
  line-height:1.35;
}

.code{
  margin-top:10px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background: rgba(26,30,38,.62);
  padding:12px;
  font-family:var(--mono);
  font-size:12px;
  white-space:pre-wrap;
}

/* =========================
   TODO LIST
   ========================= */
.todo{
  display:grid;
  gap:10px;
  margin-top:10px;
}

.todo label{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background: rgba(26,30,38,.58);
  color: rgba(255,255,255,.78);
}

.todo input{
  width:auto;
  margin:0;
}

/* =========================
   MINI STATS
   ========================= */
.miniStats{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
  margin-top:10px;
}

.miniStats div{
  padding:10px 12px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background: rgba(26,30,38,.58);
}

.miniStats span{
  display:block;
  color:var(--muted);
  font-size:12px;
}

.miniStats b{
  font-family:var(--mono);
  font-size:12px;
}

.tinyGrid{
  margin-top:12px;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
}

.tinyTile{
  padding:10px 12px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background: rgba(26,30,38,.58);
}

.tinyTile span{
  display:block;
  color:var(--muted);
  font-size:12px;
}

.tinyTile b{
  font-family:var(--mono);
  font-size:12px;
}

/* =========================
   WEATHER CARD
   ========================= */
#wxCard .wxTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  margin-top:6px;
}

#wxCard .wxLoc{
  color:var(--muted);
  font-size:11px;
  letter-spacing:.14em;
  text-transform:uppercase;
  font-weight:600;
}

#wxCard .wxTemp{
  font-size:38px;
  line-height:1;
  margin-top:4px;
  font-weight:700;
  letter-spacing: -0.5px;
}

#wxCard .wxUnit{
  font-size:14px;
  color:var(--muted);
  margin-left:6px;
  font-weight:600;
}

#wxCard .wxDesc{
  margin-top:6px;
  color: rgba(255,255,255,.92);
  font-size:14px;
  opacity:0.95;
}

#wxCard .wxMeta{
  margin-top:6px;
  color:var(--muted);
  font-size:12px;
}

#wxCard .wxIconWrap{
  width:86px;
  height:86px;
  border-radius:20px;
  display:grid;
  place-items:center;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.25));
  box-shadow: 0 8px 18px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  transition: transform .18s ease, box-shadow .18s ease;
}

#wxCard .wxIconWrap:hover{ transform: translateY(-3px); box-shadow: 0 12px 28px rgba(0,0,0,0.55); }

#wxCard #wxIcon{
  color: rgba(255,255,255,.9);
  width:56px; height:56px;
}

#wxCard .wxUpdated{
  margin-top:10px;
  font-size:12px;
  color:var(--muted);
}

/* subtle divider and spacing for a cleaner card */
#wxCard{ padding:18px; }
#wxCard .wxTop > *{ min-width:0; }

/* Apple-like refresh button for the weather card */
#wxCard button[data-action="wxRefresh"]{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 14px;
  border-radius:999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(0,0,0,0.20));
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text);
  font-weight:700;
  font-family: var(--sans);
  font-size:13px;
  letter-spacing:0.2px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.02);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

#wxCard button[data-action="wxRefresh"]::before{
  content: "↻";
  display:inline-block;
  font-size:14px;
  line-height:1;
  opacity:0.95;
  transform: translateY(0);
}

#wxCard button[data-action="wxRefresh"]:hover{
  transform: translateY(-3px);
  box-shadow: 0 14px 34px rgba(0,0,0,0.45);
}

#wxCard button[data-action="wxRefresh"]:active{
  transform: translateY(-1px);
}

#wxCard button[data-action="wxRefresh"].ghost{
  background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(0,0,0,0.14));
}

/* =========================
   IFRAME / EMBED
   ========================= */
#toy{
  width:100%;
  max-width:100%;
  height:260px;
  margin-top:12px;
  background:#050607;
  display:block;
  border:none;
  border-radius:18px;
  box-shadow:
    0 18px 45px rgba(0,0,0,.35),
    inset 0 0 0 1px rgba(255,255,255,.06);
  filter: saturate(1.05) contrast(1.05);
}

/* =========================
   FOOTER
   ========================= */
.footer{
  display:flex;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
  gap:12px;
  color:var(--muted);
  font-size:12px;
  padding-bottom:16px;
}

/* =========================
   TOAST
   ========================= */
.toast{
  position:fixed;
  left:50%;
  bottom:18px;
  transform: translateX(-50%);
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(26,30,38,.78);
  font-family:var(--mono);
  font-size:12px;
  color:var(--text);
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease, transform .18s ease;
  z-index:50;
}

.toast.show{
  opacity:1;
  transform: translateX(-50%) translateY(-4px);
}

/* Canvas card - no padding, just the canvas */
.canvasCard {
  padding: 0;
  background: #050607;
  overflow: hidden;
}

.canvasCard canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 600 / 340;
}

/* DOOM card */
.doomCard{
  padding:0;
  background:#000;
  border-radius:12px;
  overflow:hidden;
  border: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  width: 49%;
  aspect-ratio: 320 / 200;
}

#doomWrap{
  width:100%;
  height:100%;
  position: relative;
  background: #000;
}

#doomWrap canvas,
#doomCanvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: fill !important;
  display: block;
}

#doomCover {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 10;
  transition: opacity 0.3s ease;
}

#doomCover.hidden {
  opacity: 0;
  pointer-events: none;
}

.doomPlaceholder{
  display: none;
}

/* Light mode overrides for dark elements */
[data-theme="light"] .terminalTop{
  background: rgba(0,0,0,.04);
}

[data-theme="light"] .console{
  background: rgba(0,0,0,.03);
  color: #1D1D1F;
}

[data-theme="light"] .canvasCard{
  background: #1D1D1F;
}

[data-theme="light"] .doomCard{
  background: #1D1D1F;
}

[data-theme="light"] .mark{
  background:
    radial-gradient(18px 18px at 30% 28%, rgba(0,102,204,.85), rgba(0,102,204,0) 70%),
    radial-gradient(22px 22px at 75% 70%, rgba(0,102,204,.65), rgba(0,102,204,0) 72%),
    rgba(0,102,204,.25);
}

[data-theme="light"] .statusPill .dot{
  box-shadow: 0 0 0 4px rgba(46,213,115,.12);
}

[data-theme="light"] .toast{
  background: rgba(255,255,255,.92);
  color: #1D1D1F;
}

/* reduce motion safety */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
