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

:root {
  --bg: #1a1c24;
  --surface: #23252f;
  --border: #363a4a;
  --text: #edf0fc;
  --text-muted: #808498;
  --accent: #5a9dff;
  --gap: 12px;
  --radius: 6px;
  --titlebar-h: 42px;
  --font: 'Outfit', sans-serif;
}

html {
  height: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  filter: blur(8px);
  transform: scale(1.08);
}

.site-header {
  padding: 16px 16px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.site-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 1fr 1fr;
  gap: var(--gap);
  padding: var(--gap);
  height: calc(100vh - 53px);
}

.window {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#window-links {
  grid-row: 1 / 3;
}

.window-titlebar {
  height: var(--titlebar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.window-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.window-body {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  min-height: 0;
}

.window-body--centered {
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
}

.link-btn {
  aspect-ratio: 1;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(145deg, #13141e 0%, #0a0b12 60%, #111320 100%);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.link-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), inset 0 0 20px rgba(90, 157, 255, 0.07);
}

.link-btn img {
  width: 58%;
  height: 58%;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 1;
}

.link-btn-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(8, 9, 14, 0.78);
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  padding: 3px 5px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}

.empty-text {
  color: var(--text-muted);
  font-size: 14px;
}

.btn-fullscreen {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-fullscreen:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#window-filesystem.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border-radius: 0;
  border: none;
}

#window-filesystem.is-fullscreen .window-body {
  padding: 8px;
}

.fs-tree {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
}

.fs-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
}

.fs-row--dir {
  color: var(--text);
  font-weight: 500;
}

.fs-row:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.fs-icon {
  font-size: 11px;
  width: 14px;
  flex-shrink: 0;
  text-align: center;
}

.fs-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fs-size {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

.fs-children {
  padding-left: 14px;
  margin-left: 13px;
  border-left: 1px solid var(--border);
}

.fs-status {
  padding: 4px 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.fs-status--err {
  color: #ff6b6b;
  font-style: normal;
}

#custom-zone {
  padding: var(--gap);
}

#custom-windows {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: flex-start;
}

.custom-window {
  flex-shrink: 0;
  width: auto;
  height: auto;
}

.custom-window-body {
  padding: 0;
  overflow: hidden;
  flex: 0 0 auto;
}

.custom-window-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 220px;
  max-height: 180px;
  object-fit: contain;
}

#wall-zone {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: var(--gap);
  padding: 0 var(--gap) var(--gap);
  height: 340px;
}

#window-wall-latest .wall-latest-body {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.wall-latest-body img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wall-latest-time {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.wall-player-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wall-player-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0a0b12;
}

.wall-player-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wall-player-bar-wrap {
  padding: 10px 14px 8px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.wall-player-bar {
  position: relative;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
}

.wall-player-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  pointer-events: none;
  width: 0%;
}

.wall-player-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: var(--text);
  border-radius: 50%;
  pointer-events: none;
  left: 0%;
  box-shadow: 0 0 0 2px var(--surface);
}

.wall-player-times {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 10px;
  color: var(--text-muted);
}

.wall-player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wall-player-counter {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.wall-play-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.wall-play-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wall-play-btn.loading {
  opacity: 0.5;
  cursor: default;
}

.monitor-updated {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.mon-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.mon-row:last-child {
  border-bottom: none;
}

.mon-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.mon-dot--ok       { background: #4ade80; }
.mon-dot--changed  { background: #facc15; box-shadow: 0 0 6px #facc1580; }
.mon-dot--baseline { background: var(--accent); }
.mon-dot--err      { background: #ff6b6b; }

.mon-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mon-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mon-name:hover { color: var(--accent); }

.mon-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-close {
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  font-family: var(--font);
  transition: color 0.15s;
}

.btn-close:hover {
  color: var(--text);
}

body.has-bg .site-header {
  background: rgba(22, 24, 32, 0.82);
  backdrop-filter: blur(10px);
}

body.has-bg .window {
  background: rgba(30, 32, 42, 0.82);
  backdrop-filter: blur(10px);
}

@media (max-width: 700px) {
  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    min-height: unset;
  }

  #window-links {
    grid-row: auto;
    min-height: 280px;
  }

  #window-monitoring,
  #window-filesystem {
    min-height: 180px;
  }

  #wall-zone {
    grid-template-columns: 1fr;
    height: auto;
    grid-template-rows: 240px 420px;
  }

  #window-wall-player {
    min-height: 0;
  }

  .wall-player-body {
    min-height: 0;
  }

  .wall-player-bar {
    height: 10px;
    border-radius: 5px;
  }

  .wall-player-thumb {
    width: 22px;
    height: 22px;
  }

  .wall-player-bar-wrap {
    padding: 14px 14px 10px;
  }
}
