:root {
  --text: #f2f5f9;
  --text-dim: rgba(242, 245, 249, 0.72);
  --tile-bg: rgba(16, 20, 28, 0.86);
  --tile-border: rgba(255, 255, 255, 0.10);
  --tile-bg-hover: rgba(28, 34, 46, 0.92);
  --accent: #5aa2ff;
  --danger: #ffb74d;
  --card-shadow: 0 6px 22px rgba(0, 0, 0, 0.38);
  --name-blur: rgba(10, 13, 18, 0.30);
  --disabled: rgba(120, 130, 145, 0.9);
  --bg-fallback: #10141c;
  --icon-bg: rgba(16, 20, 28, 0.92);
}

html[data-theme="light"] {
  --text: #17202b;
  --text-dim: rgba(23, 32, 43, 0.66);
  --tile-bg: rgba(255, 255, 255, 0.88);
  --tile-border: rgba(0, 0, 0, 0.08);
  --tile-bg-hover: rgba(255, 255, 255, 0.96);
  --card-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
  --name-blur: rgba(255, 255, 255, 0.30);
  --disabled: rgba(120, 130, 145, 0.75);
  --bg-fallback: #e8edf3;
  --icon-bg: rgba(255, 255, 255, 0.94);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  overflow-x: hidden;
  background: var(--bg-fallback);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  transition: background-image 0.6s ease;
}

.shade {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(8, 12, 18, 0.28);
}

html[data-theme="light"] .shade {
  background: rgba(230, 235, 242, 0.06);
}

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 26px;
  z-index: 10;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.clock .time {
  font-size: 44px;
  font-weight: 600;
  letter-spacing: 2px;
  line-height: 1.05;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.clock .date {
  margin-top: 4px;
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

.top-right {
  display: flex;
  gap: 12px;
}

.round-tile {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--tile-border);
  background: var(--tile-bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow);
  transition: transform 0.15s ease, background 0.15s ease;
}

.round-tile:hover {
  transform: translateY(-2px);
  background: var(--tile-bg-hover);
}

.round-tile:active {
  transform: translateY(0);
}

.net-tile.warn svg {
  color: var(--danger);
}

.net-tile.off svg {
  color: var(--disabled);
}

.net-tile.busy svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- grid ---------- */
.grid {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 28px 60px;
}

.grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 20px;
  max-width: 980px;
  width: 100%;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 18px;
  padding: 14px 10px 12px;
  transition: transform 0.15s ease;
  cursor: pointer;
  position: relative;
}

.card:hover {
  transform: translateY(-4px);
}

.card.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.card.disabled:hover {
  transform: none;
}

.icon-wrap {
  width: 66px;
  height: 66px;
  border-radius: 16px;
  background: var(--icon-bg);
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
}

.icon-wrap img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 8px;
}

.name {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: var(--name-blur);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.tag {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  letter-spacing: 0.5px;
}

.card .tag {
  display: none;
}

.card.show-tag .tag {
  display: block;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--card-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 20;
}

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

.loading {
  color: var(--text-dim);
  font-size: 15px;
  letter-spacing: 1px;
}

.error-box {
  text-align: center;
  color: var(--text);
  font-size: 14px;
  line-height: 1.8;
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  border-radius: 16px;
  padding: 24px 30px;
  max-width: 560px;
}
