:root {
  --canvas: #f7f6f3;
  --surface: #ffffff;
  --sunken: #fbfbfa;
  --line: #eaeaea;
  --line-strong: #d9d8d4;
  --ink: #2f3437;
  --ink-strong: #111111;
  --muted: #787774;
  --select: #e1f3fe;
  --select-ink: #1f6c9f;
  --red-bg: #fdebec; --red: #9f2f2d;
  --blue-bg: #e1f3fe; --blue: #1f6c9f;
  --green-bg: #edf3ec; --green: #346538;
  --yellow-bg: #fbf3db; --yellow: #956400;
  --sans: "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 13px/1.5 var(--sans);
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--select-ink); outline-offset: 1px; }

h1 { font-size: 18px; font-weight: 600; margin: 0 0 14px; color: var(--ink-strong); letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 600; margin: 24px 0 8px; color: var(--ink-strong); text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 12px; }
code, pre, kbd { font-family: var(--mono); font-size: 12px; }
code { background: var(--canvas); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Window ---------- */

.window {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh;
  background: var(--surface);
}
.window.narrow {
  height: auto;
  max-width: 460px;
  margin: 10vh auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--sunken);
}
.brand { font-weight: 600; color: var(--ink-strong); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
}
.address {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  overflow-x: auto;
}
.address a { padding: 1px 3px; border-radius: 3px; }
.address a:hover { background: var(--canvas); text-decoration: none; }
.address a:last-child { color: var(--ink-strong); font-weight: 600; }
.sep { color: var(--muted); }
.actions { display: flex; align-items: center; gap: 6px; }

.panes {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 0;
}

/* ---------- Folder tree ---------- */

.tree {
  overflow: auto;
  padding: 8px 0;
  border-right: 1px solid var(--line);
  background: var(--sunken);
}
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 14px; }
.tree a {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  white-space: nowrap;
}
.tree a:hover { background: var(--canvas); text-decoration: none; }
.tree a.current { background: var(--select); color: var(--select-ink); }
.twisty { display: inline-block; width: 10px; color: var(--muted); font-family: var(--mono); font-size: 11px; text-align: center; }

/* ---------- Icons (CSS primitives) ---------- */

.ico { display: inline-block; flex: none; position: relative; width: 16px; height: 12px; margin-right: 6px; vertical-align: -1px; }
.ico.folder { border: 1px solid #b59a5b; border-radius: 1px 2px 2px 2px; background: #f3e4bd; margin-top: 2px; }
.ico.folder::before {
  content: "";
  position: absolute;
  top: -4px; left: -1px;
  width: 7px; height: 3px;
  border: 1px solid #b59a5b; border-bottom: 0;
  border-radius: 2px 2px 0 0;
  background: #f3e4bd;
}
.ico.folder.open { background: #faf0d4; }
.ico.file { width: 11px; height: 14px; border: 1px solid #9a9a96; border-radius: 1px; background: var(--surface); margin-left: 2px; margin-right: 8px; vertical-align: -2px; }
.ico.file::before { content: ""; position: absolute; left: 2px; right: 2px; top: 4px; height: 1px; background: #c4c4c0; box-shadow: 0 3px 0 #c4c4c0; }

/* ---------- Content ---------- */

.content { overflow: auto; padding: 16px 20px 28px; min-width: 0; }
.content.single { padding: 24px; }

.statusbar {
  padding: 4px 14px;
  border-top: 1px solid var(--line);
  background: var(--sunken);
  color: var(--muted);
  font-size: 12px;
  min-height: 25px;
}

.list { width: 100%; border-collapse: collapse; }
.list th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.list td { padding: 5px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tbody tr:hover { background: var(--sunken); }
.list td a { display: inline-flex; align-items: center; }
.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.detail { font-family: var(--mono); font-size: 11px; color: var(--muted); word-break: break-all; }
.empty { color: var(--muted); padding: 24px 0; }

.props { display: grid; grid-template-columns: 180px 1fr; gap: 0; margin: 0 0 8px; max-width: 760px; }
.props dt, .props dd { margin: 0; padding: 6px 0; border-bottom: 1px solid var(--line); }
.props dt { color: var(--muted); }

.item { padding: 14px 0; border-bottom: 1px solid var(--line); max-width: 760px; }
.item h2 { text-transform: none; letter-spacing: 0; font-size: 14px; margin: 0 0 6px; display: flex; align-items: center; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 0 7px;
  border-radius: 9999px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 18px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--canvas);
  color: var(--muted);
}
.b-active, .b-success, .b-on, .b-paid, .b-published, .b-general, .b-subscribed { background: var(--green-bg); color: var(--green); }
.b-disabled, .b-failed, .b-critical, .b-void, .b-rolled_back, .b-cancelled { background: var(--red-bg); color: var(--red); }
.b-paused, .b-warning, .b-issued, .b-mfa_required, .b-canary, .b-partial, .b-draft, .b-trash { background: var(--yellow-bg); color: var(--yellow); }
.b-info, .b-internal, .b-planned { background: var(--blue-bg); color: var(--blue); }

/* ---------- Forms ---------- */

.form { max-width: 520px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.label { font-weight: 500; color: var(--ink-strong); }
.hint { color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.inline { display: inline; margin: 0; }
.row-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.row-form input:not([type=hidden]) { flex: 1 1 200px; max-width: 360px; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
}
textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-strong);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--canvas); text-decoration: none; }
.btn.small { padding: 1px 8px; font-size: 12px; }
.btn.primary { background: var(--ink-strong); border-color: var(--ink-strong); color: #ffffff; }
.btn.primary:hover { background: #333333; }
.btn.danger { color: var(--red); border-color: #e7c3c2; }
.btn.danger:hover { background: var(--red-bg); }
.btn.disabled { color: var(--muted); cursor: default; }
.btn.provider { width: 100%; padding: 8px 12px; }

.flash { padding: 8px 12px; border-radius: 4px; margin-bottom: 14px; background: var(--green-bg); color: var(--green); }
.flash.error { background: var(--red-bg); color: var(--red); }

.providers { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.steps { padding-left: 18px; max-width: 620px; }
.steps li { margin-bottom: 16px; }
.qr { margin: 10px 0; }
.qr svg { display: block; width: 180px; height: 180px; border: 1px solid var(--line); }
.key { font-size: 13px; letter-spacing: 0.05em; }
.codes { padding: 12px 16px; border: 1px solid var(--line); border-radius: 4px; background: var(--sunken); font-size: 14px; line-height: 1.8; max-width: 260px; }
.notes { white-space: pre-wrap; }
.pager { display: flex; gap: 10px; align-items: center; padding-top: 12px; }

@media (max-width: 760px) {
  .panes { grid-template-columns: 1fr; }
  .tree { display: none; }
  .who .muted { display: none; }
  .props { grid-template-columns: 1fr; }
  .props dt { border-bottom: 0; padding-bottom: 0; }
  .content { padding: 12px 16px 24px; }
  .list { display: block; overflow-x: auto; }
}
