*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --hue:  245;
  --cols: 4;
  --text:    #f0eff8;
  --sub:     rgba(240, 239, 248, 0.52);
  --glass:   rgba(255, 255, 255, 0.07);
  --glass-b: rgba(255, 255, 255, 0.11);
}

html, body {
  height: 100%;
  font-family: -apple-system, "SF Pro Display", system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Comble le blanc sous le contenu quand la page est courte */
html { background-color: hsl(var(--hue), 38%, 7%); }
@media (prefers-color-scheme: light) {
  html { background-color: hsl(var(--hue), 38%, 93%); }
}

[hidden] { display: none !important; }

/* ── Wallpaper ─────────────────────────────────────────────────────────── */
.wallpaper {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: hsl(var(--hue), 38%, 7%);
  background-image:
    radial-gradient(ellipse 75% 60% at 15% 10%,  hsl(var(--hue), 70%, 22%) 0%, transparent 58%),
    radial-gradient(ellipse 60% 50% at 85% 8%,   hsl(calc(var(--hue) + 48), 58%, 16%) 0%, transparent 55%),
    radial-gradient(ellipse 70% 60% at 68% 90%,  hsl(calc(var(--hue) - 28), 62%, 18%) 0%, transparent 60%),
    radial-gradient(ellipse 48% 38% at 5% 78%,   hsl(calc(var(--hue) + 22), 52%, 12%) 0%, transparent 52%);
  transition: background-color 0.6s, background-image 0.6s;
}

@media (prefers-color-scheme: light) {
  :root {
    --text:    #111;
    --sub:     rgba(0, 0, 0, 0.48);
    --glass:   rgba(255, 255, 255, 0.52);
    --glass-b: rgba(255, 255, 255, 0.80);
  }
  .wallpaper {
    background-color: hsl(var(--hue), 38%, 93%);
    background-image:
      radial-gradient(ellipse 75% 60% at 15% 10%,  hsl(var(--hue), 65%, 82%) 0%, transparent 58%),
      radial-gradient(ellipse 60% 50% at 85% 8%,   hsl(calc(var(--hue) + 48), 55%, 87%) 0%, transparent 55%),
      radial-gradient(ellipse 70% 60% at 68% 90%,  hsl(calc(var(--hue) - 28), 58%, 84%) 0%, transparent 60%),
      radial-gradient(ellipse 48% 38% at 5% 78%,   hsl(calc(var(--hue) + 22), 50%, 89%) 0%, transparent 52%);
  }
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 56px 20px 40px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Top bar ───────────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.portal-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.portal-logo {
  width: 36px;
  height: 36px;
  border-radius: 22.5%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.portal-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.greeting {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.15;
  text-shadow: 0 1px 8px rgba(0,0,0,0.3);
}

/* ── Search ────────────────────────────────────────────────────────────── */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--glass);
  border: 1px solid var(--glass-b);
  border-radius: 12px;
  padding: 9px 13px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: text;
  flex-shrink: 0;
}

.search-icon {
  width: 15px;
  height: 15px;
  color: var(--sub);
  flex-shrink: 0;
}

.search-wrap input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  width: 120px;
  transition: width 0.25s ease;
}

.search-wrap input::placeholder {
  color: var(--sub);
}

.search-wrap:focus-within {
  border-color: rgba(255,255,255,0.22);
}

.search-wrap:focus-within input {
  width: 160px;
}

/* ── Apps grid ─────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 36px 16px;
  flex: 1;
  align-content: flex-start;
}

.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.app-item.hidden {
  display: none;
}

.app-icon {
  width: 96px;
  height: 96px;
  border-radius: 22.5%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.app-item:hover .app-icon {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.45), 0 3px 8px rgba(0,0,0,0.25);
}

.app-item:active .app-icon {
  transform: scale(0.91);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition-duration: 0.08s;
}

.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.app-icon-gradient {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-icon-gradient svg {
  width: 42px;
  height: 42px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.app-name {
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
  letter-spacing: 0.01em;
}

/* No results */
.grid-empty {
  width: 100%;
  text-align: center;
  color: var(--sub);
  font-size: 14px;
  padding: 32px 0;
}

/* ── Widgets ───────────────────────────────────────────────────────────── */
.widgets {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.widget {
  background: var(--glass);
  border: 1px solid var(--glass-b);
  border-radius: 18px;
  padding: 14px 18px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.widget-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--sub);
}

.widget-title {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
}

.widget-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: background 0.3s;
}

.widget-dot.online  { background: #4ade80; box-shadow: 0 0 6px #4ade8099; }
.widget-dot.offline { background: rgba(255,255,255,0.2); }

.nas-stats {
  display: flex;
  align-items: stretch;
}


.nas-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
}

.nas-divider {
  width: 1px;
  background: var(--glass-b);
  margin: 4px 0;
  flex-shrink: 0;
}

.nas-stat b {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  line-height: 1;
}

.nas-stat span {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--sub);
}

/* ── Settings button ───────────────────────────────────────────────────── */
.settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-b);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--sub);
  text-decoration: none;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.settings-btn:hover { color: var(--text); background: var(--glass-b); }
.settings-btn svg { width: 17px; height: 17px; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 360px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 24px 12px; }
  .app-icon, .app-icon img { width: 80px; height: 80px; }
}

@media (min-width: 600px) {
  .page { padding-top: 80px; }
  .greeting { font-size: 32px; }
  .grid { grid-template-columns: repeat(4, 1fr); }
}
