*, *::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);
}

.iframe-slot {
  width: 100%;
  height: 100%;
  min-height: 100px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.iframe-placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

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

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

#window-filesystem.is-fullscreen .iframe-slot {
  height: calc(100vh - var(--titlebar-h));
  border-radius: 0;
  border: none;
  min-height: unset;
}

#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;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  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;
  }
}
