:root { --bar-h: 72px; --gutter: clamp(16px, 4vw, 48px); }

body { padding-top: var(--bar-h); }

/* ---------- Fixierte Betriebsleiste ---------- */
.bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  min-height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 24px 0 var(--gutter);
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: -0.02em;
  text-decoration: none;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.brand em { color: var(--muted); }

.metrics {
  display: flex;
  min-width: 0;
}
.m[data-k="net"] { flex-grow: 1.7; }
.m[data-k="up"], .m[data-k="power"] { flex-grow: 1.2; }
.m {
  flex: 1 1 0;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 10px 16px;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.m-val {
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-val small { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.m-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.m-bar i { display: block; height: 100%; width: 0; background: var(--text); transition: width .6s var(--ease), background .3s; }
.m.warn .m-val { color: var(--warn); }
.m.warn .m-bar i { background: var(--warn); }
.m.crit .m-val { color: var(--crit); }
.m.crit .m-bar i { background: var(--crit); }

.bar-toggle {
  padding: 0 var(--gutter) 0 24px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  white-space: nowrap;
  transition: color .2s;
}
.bar-toggle:hover, .bar-toggle[aria-expanded="true"] { color: var(--text); }
.bar-toggle .t-close { display: none; }
.bar-toggle[aria-expanded="true"] .t-open { display: none; }
.bar-toggle[aria-expanded="true"] .t-close { display: inline; }

.bar-offline {
  padding: 8px var(--gutter);
  font-size: 11px;
  color: var(--ink);
  background: var(--warn);
  letter-spacing: .04em;
}

/* ---------- Detailansicht der Betriebsdaten ---------- */
.details {
  max-height: calc(100dvh - var(--bar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--line);
  background: var(--bg);
  animation: drop .35s var(--ease);
}
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
.d-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  border-left: 1px solid var(--line);
}
.d-sec {
  padding: 22px 24px 26px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
  align-content: start;
}
.d-sec h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1;
}
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; }
.kv dt { color: var(--muted); white-space: nowrap; }
.kv dd { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: break-word; }
.kv dd.warn { color: var(--warn); }
.kv dd.crit { color: var(--crit); }
.cores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.core { display: grid; gap: 4px; }
.core .track { height: 36px; background: var(--bg-raise); position: relative; border: 1px solid var(--line); }
.core .track i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--text); transition: height .6s var(--ease); }
.core span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 56px; display: block; border-bottom: 1px solid var(--line); }
.meter { height: 2px; background: var(--line); }
.meter i { display: block; height: 100%; background: var(--text); }
.d-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.d-actions .btn { height: 40px; padding: 0 16px; font-size: 11px; }
.d-url { word-break: break-all; text-decoration: none; border-bottom: 1px solid var(--line-strong); }

/* ---------- Ansicht ---------- */
.view { padding: clamp(28px, 6vw, 72px) var(--gutter) 96px; }

.intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: clamp(24px, 4vw, 44px);
}
.display {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(64px, 11vw, 168px);
  line-height: .84;
  letter-spacing: -0.04em;
}
.display sup {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0;
  vertical-align: top;
  color: var(--muted);
  margin-left: 6px;
  position: relative;
  top: .6em;
}
.filters { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); }
.chip {
  padding: 9px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  border-right: 1px solid var(--line);
}
.chip:last-child { border-right: 0; }
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--ink); }

/* ---------- Kacheln ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  min-height: clamp(220px, 30vw, 340px);
  padding: 22px 24px 24px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  text-align: left;
  overflow: hidden;
  isolation: isolate;
  transition: color .35s var(--ease);
  animation: rise .6s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--paper);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform .45s var(--ease);
}
.tile-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.tile-num { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile-status { font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.tile-status.s-aktiv { color: var(--text); }
.tile-name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 4.2vw, 56px);
  line-height: .95;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.tile-desc {
  color: var(--muted);
  margin-top: 12px;
  max-width: 44ch;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--dim); }
.tile-go { letter-spacing: .14em; text-transform: uppercase; }

@media (hover: hover) {
  .tile:hover { color: var(--ink); }
  .tile:hover::before { transform: scaleY(1); }
  .tile:hover .tile-num, .tile:hover .tile-status, .tile:hover .tile-desc, .tile:hover .tile-foot { color: #3d3d3b; }
}
.tile:active::before { transform: scaleY(1); }
.tile:active { color: var(--ink); }

.tile.new { background: var(--bg-sunk); cursor: pointer; }
.tile.new .tile-name em { color: var(--muted); transition: color .35s; }
.tile.new:hover .tile-name em { color: #3d3d3b; }
.tile-line { height: 1px; background: currentColor; width: 32px; flex: none; transition: width .5s var(--ease); }
.tile.new:hover .tile-line { width: 96px; }
.tile.new .tile-foot { align-items: center; }
.tile-hint { color: var(--dim); }

/* ---------- Hochladen ---------- */
.intro-tools { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  color: var(--muted);
  flex: none;
  transition: color .2s, border-color .2s, background .2s;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: square; }
.icon-btn:hover { color: var(--ink); background: var(--text); border-color: var(--text); }
.p-block .head .icon-btn { width: 34px; min-height: 34px; }
.drop-hint { font-size: 11px; color: var(--dim); }

.drop {
  position: fixed;
  inset: 0;
  z-index: 90;
  padding: 16px;
  background: rgba(10, 10, 10, .82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
  animation: fade .2s ease;
}
.drop[hidden] { display: none; }
.drop-inner {
  height: 100%;
  border: 1px dashed var(--muted);
  display: grid;
  place-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px;
}
.drop-title {
  font-family: var(--serif);
  font-size: clamp(48px, 8vw, 120px);
  line-height: .9;
  letter-spacing: -0.04em;
}
.drop .label { max-width: 52ch; margin: 0 auto; line-height: 1.7; }

.upl {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  width: min(380px, calc(100vw - 32px));
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  padding: 18px 20px 20px;
  display: grid;
  gap: 8px;
  animation: pop .35s var(--ease);
}
.upl-head { display: flex; justify-content: space-between; align-items: center; }
.upl-close { font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.upl-close:hover { color: var(--text); }
.upl-title { font-family: var(--serif); font-size: 30px; line-height: 1; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.upl-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: pre; }
.upl-bar { height: 2px; background: var(--line); }
.upl-bar i { display: block; height: 100%; width: 0; background: var(--text); transition: width .3s var(--ease); }
.upl-msg p { font-size: 12px; color: var(--muted); }
.upl-fail { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 120px; overflow: auto; }

.empty {
  grid-column: 1 / -1;
  padding: 48px 24px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

/* ---------- Projektansicht ---------- */
.back {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 28px;
}
.back:hover { color: var(--text); border-color: var(--text); }
.p-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 14px; }
.p-title {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  font-family: var(--serif);
  font-size: clamp(52px, 9vw, 132px);
  line-height: .9;
  letter-spacing: -0.04em;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.p-title:focus { border-color: var(--text); }
.p-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 0;
  border-left: 1px solid var(--line);
}
.p-col { border-right: 1px solid var(--line); }
.p-block { padding: 24px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.p-block .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.notes { min-height: 340px; font-size: 14px; border: 0; padding: 0; }
.saved { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); transition: color .3s; }
.saved.busy { color: var(--warn); }
.files { display: grid; }
.file {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.file:last-child { border-bottom: 0; }
.file .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file.dir .n { color: var(--text); }
.file.dir .n::after { content: "/"; color: var(--dim); }
.file .s { color: var(--muted); font-variant-numeric: tabular-nums; }
.path { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; user-select: all; }
.status-set { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); }
.status-set button {
  padding: 12px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.status-set button:nth-child(2n) { border-right: 0; }
.status-set button:nth-last-child(-n+2) { border-bottom: 0; }
.status-set button[aria-pressed="true"] { background: var(--text); color: var(--ink); }

/* ---------- Dialog / Bottom-Sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .72); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  padding: clamp(24px, 4vw, 40px);
  display: grid;
  gap: 24px;
  animation: pop .35s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(16px); } }
.sheet-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(40px, 7vw, 60px);
  line-height: .95;
  letter-spacing: -0.03em;
}
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.sheet p { color: var(--muted); }

/* ---------- Mobil ---------- */
@media (max-width: 1100px) {
  .m.wide[data-k="power"] { display: none; }
}
@media (max-width: 900px) {
  .m.wide { display: none; }
  .p-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .bar-row { grid-template-columns: 1fr auto; grid-template-rows: auto auto; min-height: 0; }
  .brand { padding: 12px 16px 10px; border-right: 0; font-size: 22px; }
  .bar-toggle { grid-row: 1; grid-column: 2; padding: 0 16px; }
  .metrics { grid-row: 2; grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .m { padding: 8px 10px 9px 12px; }
  .m[data-k="disk"] { border-right: 0; }
  .m-val { font-size: 14px; }
  .label { font-size: 9px; }
  .tile { min-height: 200px; padding: 18px 18px 20px; gap: 20px; }
  .tile-name { font-size: 40px; }
  .p-block { padding: 20px 16px; }
  .d-sec { padding: 20px 16px 22px; }
  .sheet { place-items: end stretch; padding: 0; }
  .sheet-panel {
    width: 100%;
    max-height: 92dvh;
    border-left: 0; border-right: 0; border-bottom: 0;
    padding: 28px 16px calc(24px + env(safe-area-inset-bottom));
    animation: slideup .35s var(--ease);
  }
  @keyframes slideup { from { transform: translateY(100%); } }
  .sheet-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
