:root {
  color-scheme: light;
  --bg: #eef3f7;
  --fg: #102a43;
  --muted: #52677a;
  --line: #b8c7d3;
  --panel: #fafdff;
  --panel-2: #e5edf3;
  --accent: #007f9e;
  --accent-ink: #ffffff;
  --danger: #b4232f;
  --warn: #a45f00;
  --code-bg: #071825;
  --code-fg: #d8f6ff;
}


* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.45;
}

a {
  color: var(--accent);
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--fg);
  color: var(--bg);
  padding: .75rem 1rem;
}

.skip:focus {
  top: 1rem;
}

header,
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1 {
  font-size: 1.45rem;
  margin: 0;
}

h2 {
  font-size: 1rem;
  margin: 1.2rem 0 .7rem;
}

button,
input,
textarea,
select {
  min-height: 44px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: .55rem .8rem;
}

button {
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

button.danger {
  color: var(--danger);
}

button:focus,
input:focus,
textarea:focus,
select:focus,
summary:focus,
a:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.toolbar button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  margin-right: .35rem;
}

.toolbar button.icon-button svg {
  margin-right: 0;
}

.control-group {
  display: grid;
  gap: .25rem;
}

.control-group label {
  margin: 0;
  font-size: .85rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .75rem;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 2px;
  padding: .85rem;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
  margin-bottom: 1rem;
}

.metric {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: .75rem;
}

.metric strong {
  display: block;
  font-size: .75rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .04em;
}

.muted {
  color: var(--muted);
}

.status-line {
  min-height: 1.5rem;
}

label {
  display: block;
  font-weight: 650;
  margin: .75rem 0 .25rem;
}

input,
textarea,
select {
  width: min(100%, 28rem);
  background: var(--panel);
  color: var(--fg);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

summary {
  cursor: pointer;
  font-weight: 650;
  margin-top: .75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: .55rem;
  vertical-align: top;
}

.file-list td {
  vertical-align: middle;
}

.file-list button {
  background-color: var(--bg);
  border: none;
  padding: 0;
  max-height: fit-content;
}

.server-shell {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.tabs {
  position: sticky;
  top: 0;
  display: grid;
  gap: .25rem;
}

.tabs a {
  color: var(--fg);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: .6rem .75rem;
  background: var(--panel);
}

.tabs a.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.tabs a[aria-current="page"] {
  background: #d9edf3;
  color: #064e63;
  font-weight: 700;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.icon-button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-toolbar {
  margin-bottom: .75rem;
}

.file-controls {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(8rem, 11rem) minmax(8rem, 11rem) 44px;
  gap: .5rem;
  align-items: end;
  margin: .75rem 0;
}

.file-controls input,
.file-controls select {
  width: 100%;
}

.file-crumbs {
  margin-bottom: .75rem;
}

.file-name-button {
  min-height: 44px;
  text-align: left;
  width: 100%;
}

.file-kind {
  width: 3rem;
  color: var(--muted);
}

.file-size {
  width: 7rem;
  white-space: nowrap;
}

.file-actions {
  display: flex;
  gap: .35rem;
  justify-content: flex-end;
}

.file-kind svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, .55);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: min(92vw, 760px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  border-radius: 2px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.modal-dialog-small {
  width: min(92vw, 32rem);
}

.modal-dialog-wide {
  width: min(92vw, 1100px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
}

.modal-header p {
  margin: .35rem 0 0;
  overflow-wrap: anywhere;
}

.modal-body {
  min-height: 0;
  overflow: auto;
  padding: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: .5rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.modal-message {
  margin: 0;
  white-space: pre-line;
}

.editor-modal .modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.editor-modal textarea {
  width: 100%;
  min-height: 52vh;
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.4;
  resize: none;
}

.restore-picker-list {
  max-height: 44vh;
  overflow: auto;
  min-width: 0;
}

.restore-member {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  min-height: 34px;
  margin: .15rem 0;
  padding-left: calc(var(--depth, 0) * 1rem);
  font-weight: 400;
}

.restore-member input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  margin-top: .25rem;
  flex: 0 0 auto;
}

.restore-member span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.restore-picker-progress {
  min-height: 1.45em;
  margin: 0 0 .75rem;
  color: var(--muted);
}

.restore-picker-progress[data-state="loading"]::before {
  content: "";
  display: inline-block;
  width: .65rem;
  height: .65rem;
  margin-right: .45rem;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 999px;
  vertical-align: -.05rem;
  animation: restore-spin .8s linear infinite;
}

.restore-picker-progress[data-state="error"],
.restore-picker-progress[data-state="empty"] {
  color: var(--danger);
}

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

@media (prefers-reduced-motion: reduce) {
  .restore-picker-progress[data-state="loading"]::before {
    animation: none;
  }
}

.restore-note {
  border-left: 3px solid var(--warn);
  background: var(--panel-2);
  padding: .75rem 1rem;
}

pre {
  overflow: auto;
  min-height: 22rem;
  max-height: 60vh;
  padding: 1rem;
  border: 1px solid var(--line);
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 2px;
  white-space: pre-wrap;
}

.server-identity {
  max-width: none;
  padding-inline: max(1rem, calc((100vw - 1280px) / 2 + 1rem));
  background: #fafdff;
  border-top: 3px solid var(--accent);
}

.eyebrow {
  margin: 0 0 .15rem;
  color: var(--accent);
  font: 700 .7rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
}

.identity-meta,
.identity-state {
  margin: .2rem 0 0;
  color: var(--muted);
  font: .78rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.identity-state {
  color: var(--fg);
  white-space: nowrap;
}

.state-beacon {
  display: inline-block;
  width: .55rem;
  height: .55rem;
  margin-right: .4rem;
  border: 1px solid #00677f;
  background: #00a6c8;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  border-bottom: 1px solid var(--line);
}

.console-viewport > pre {
  min-height: 28rem;
  margin-top: 0;
  font: .82rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.console-dock {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(15rem, 1fr);
  gap: .75rem;
  position: sticky;
  bottom: 0;
  padding: .75rem 0;
  background: linear-gradient(transparent, var(--bg) 18%);
}

.log-new-lines {
  padding: .25rem .45rem;
  border: 1px solid var(--warn);
  color: var(--warn);
  font: 700 .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.metric,
.status-line,
.file-size,
.file-crumbs,
.restore-picker-progress {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

th {
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #e8f2f6;
}

.compact-log {
  min-height: 8rem;
  max-height: 16rem;
}

.error {
  color: var(--danger);
  font-weight: 650;
}

@media (max-width: 760px) {
  .server-shell {
    grid-template-columns: 1fr;
  }

  .tabs {
    position: static;
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .tabs a { min-width: 8rem; scroll-snap-align: start; }

  .server-identity { align-items: flex-start; flex-wrap: wrap; }

  .console-dock { position: static; grid-template-columns: 1fr; }

  .file-list { min-width: 42rem; }

  #server-file-list { overflow-x: auto; }

  .metric-strip,
  .file-controls {
    grid-template-columns: 1fr 1fr;
  }

  .modal-backdrop {
    place-items: stretch;
    padding: .5rem;
  }

  .modal-dialog,
  .modal-dialog-small,
  .modal-dialog-wide {
    width: 100%;
    max-height: calc(100vh - 1rem);
  }

  .modal-header,
  .modal-body,
  .modal-actions {
    padding: .75rem;
  }

  .editor-modal textarea {
    min-height: 58vh;
  }
}
