:root {
  --ink: #1d1d1f;
  --ink-secondary: #6e6e73;
  --ink-tertiary: #8e8e93;
  --fill: #ffffff;
  --fill-secondary: #f5f5f7;
  --fill-tertiary: #ebebed;
  --separator: rgba(60, 60, 67, 0.12);
  --separator-soft: rgba(60, 60, 67, 0.06);
  --blue: #0071e3;
  --blue-press: #0077ed;
  --ok: #1d7a46;
  --bad: #d70015;
  --sidebar: #f5f5f7;
  --sheet-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.04),
    0 1px 2px rgba(0, 0, 0, 0.03),
    0 6px 18px rgba(0, 0, 0, 0.03);
  --control-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.03);
  --radius-sheet: 12px;
  --radius-control: 8px;
  --radius-pill: 980px;
  --font: "Plus Jakarta Sans", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--fill-secondary);
}

body {
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* —— Sidebar —— */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 20px 14px 18px;
  background: var(--sidebar);
  border-right: 0.5px solid var(--separator);
  min-height: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 22px;
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #3a3a3c, #1d1d1f);
  color: #f5f5f7;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.logo-name {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.logo-meta {
  font-size: 11px;
  color: var(--ink-tertiary);
  font-weight: 500;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.nav-label {
  margin: 14px 8px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}

.nav-label:first-child { margin-top: 0; }

.nav-item {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover { background: rgba(0, 0, 0, 0.04); }

.nav-item.active {
  background: rgba(0, 0, 0, 0.06);
  font-weight: 600;
}

.nav-item .ico {
  width: 16px;
  height: 16px;
  color: var(--ink-secondary);
  flex-shrink: 0;
}

.nav-item.active .ico { color: var(--ink); }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 8px 4px;
  border-top: 0.5px solid var(--separator-soft);
}

.pill-soft {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.04);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.sidebar-foot p {
  margin: 0;
  font-size: 11px;
  color: var(--ink-tertiary);
  font-weight: 500;
}

/* —— Workspace —— */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--fill-secondary);
  overflow: hidden;
}

.topbar {
  padding: 22px 32px 0;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-tertiary);
}

.crumbs .sep { opacity: 0.5; }

.crumb-current {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.05);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

.page-head {
  padding: 18px 32px 16px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.page-sub {
  margin: 6px 0 0;
  color: var(--ink-secondary);
  font-size: 14px;
  font-weight: 500;
}

.env-banner {
  margin: 0 32px 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 149, 0, 0.08);
  color: #9a5b00;
  font-size: 12.5px;
  font-weight: 500;
}

.env-banner code {
  font-family: var(--mono);
  font-size: 0.92em;
}

.content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 32px 36px;
}

.panel { display: none; }
.panel.active {
  display: block;
  animation: fade 0.28s ease;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* One-click protection levels */
.presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
  padding: 1px; /* keep active borders from clipping against overflow parents */
}

.preset {
  appearance: none;
  border: 1.5px solid transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  padding: 14px 15px 15px;
  border-radius: 12px;
  background: var(--fill);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.preset:hover {
  background: #fafafa;
}

.preset.active {
  background: var(--fill);
  border-color: var(--blue);
  box-shadow: 0 1px 2px rgba(0, 113, 227, 0.1);
}

.preset-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.preset-desc {
  display: block;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink-secondary);
}

.quick-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 18px;
  margin-bottom: 12px;
}

.password-field {
  flex: 1;
  min-width: 200px;
  margin: 0;
}

.password-field input {
  background: var(--fill);
  border-radius: 10px;
  box-shadow: var(--control-shadow);
  padding: 10px 12px;
}

.preset-hint {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-tertiary);
}

.advanced {
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--fill);
  box-shadow: var(--control-shadow);
  overflow: hidden;
}

.advanced > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  user-select: none;
}

.advanced > summary::-webkit-details-marker { display: none; }

.advanced > summary::after {
  content: "Show";
  float: right;
  font-weight: 500;
  font-size: 12px;
  color: var(--blue);
}

.advanced[open] > summary::after { content: "Hide"; }

.advanced .toolbar {
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  border-top: 0.5px solid var(--separator-soft);
  padding: 8px 8px 10px;
}

@media (max-width: 860px) {
  .presets { grid-template-columns: 1fr; }
}

/* Soft editor toolbar — hairline, not chunky */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px;
  margin-bottom: 14px;
  background: var(--fill);
  border-radius: 10px;
  box-shadow: var(--control-shadow);
}

.tool {
  display: flex;
  align-items: center;
  margin: 0;
}

.tool.grow { flex: 1; min-width: 140px; }

.tool.compact input { width: 52px; text-align: center; }

.tool select,
.tool input[type="text"],
.tool input[type="password"],
.tool input[type="number"],
.tool input[type="email"],
.field input,
.form-row input {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 10px;
  border-radius: 7px;
  width: 100%;
  min-width: 0;
}

.tool select:hover,
.tool input:hover {
  background: rgba(0, 0, 0, 0.03);
}

.tool select:focus,
.tool input:focus,
.field input:focus,
.form-row input:focus,
textarea:focus {
  outline: none;
  background: rgba(0, 113, 227, 0.06);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.tool-rule {
  width: 1px;
  height: 18px;
  background: var(--separator);
  margin: 0 2px;
}

.tool.check {
  gap: 6px;
  padding: 0 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-secondary);
  white-space: nowrap;
  cursor: pointer;
}

.tool.check.block {
  margin-top: 10px;
  padding: 0;
}

.tool.check input {
  width: 14px;
  height: 14px;
  accent-color: var(--blue);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 920px) {
  body { overflow: auto; }
  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    border-right: none;
    border-bottom: 0.5px solid var(--separator);
    padding: 12px 14px;
  }
  .sidebar-brand { padding: 0 8px 0 0; }
  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
  }
  .nav-label, .sidebar-foot { display: none; }
  .nav-item { width: auto; padding: 7px 10px; }
  .nav-item .ico { display: none; }
  .workspace { min-height: 70vh; }
  .split { grid-template-columns: 1fr; }
  .page-head, .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .env-banner { margin-left: 18px; margin-right: 18px; }
}

/* Content sheets — float gently */
.sheet {
  background: var(--fill);
  border-radius: var(--radius-sheet);
  box-shadow: var(--sheet-shadow);
  padding: 16px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.sheet-label,
.field > span,
.cap-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}

textarea {
  width: 100%;
  border: none;
  resize: vertical;
  background: var(--fill-secondary);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 450;
  line-height: 1.55;
  padding: 12px 13px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 0.5px var(--separator-soft);
}

textarea[readonly] {
  background: #fafafa;
}

.capacity { margin-top: 4px; }

.cap-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.cap-bar {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--fill-tertiary);
  overflow: hidden;
}

.cap-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--ink);
  transition: width 0.25s ease, background 0.2s ease;
}

.cap-meta {
  font-size: 12px;
  color: var(--ink-secondary);
  font-weight: 500;
}

.cap-meta.quiet {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-tertiary);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.btn-primary,
.btn-secondary {
  appearance: none;
  border: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover { background: var(--blue-press); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

.btn-secondary:hover { background: rgba(0, 0, 0, 0.08); }
.btn-secondary:active { transform: scale(0.98); }

.meta-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0;
}

.stat {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--fill-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat.wide { grid-column: 1 / -1; }

.stat .k {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-tertiary);
}

.stat .v {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.dump {
  margin: 0;
  padding: 12px 13px;
  border-radius: 10px;
  background: var(--fill-secondary);
  box-shadow: inset 0 0 0 0.5px var(--separator-soft);
  overflow: auto;
  max-height: 200px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ink-secondary);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  min-height: 3.5rem;
}

.dump.tall { max-height: 420px; min-height: 280px; }

.section-title {
  margin: 8px 0 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-title:first-child { margin-top: 0; }

.hint {
  margin: 0 0 8px;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 500;
}

.hint code,
.env-banner code {
  font-family: var(--mono);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.field input,
.form-row input {
  background: var(--fill-secondary);
  border-radius: 10px;
  box-shadow: inset 0 0 0 0.5px var(--separator-soft);
  padding: 10px 12px;
}

.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.form-row input { flex: 1; }

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.list-item {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 13px;
  border-radius: 10px;
  background: var(--fill-secondary);
}

.list-item .title {
  font-size: 13px;
  font-weight: 600;
}

.list-item .meta {
  font-size: 12px;
  color: var(--ink-tertiary);
  font-weight: 500;
}

.list-empty {
  color: var(--ink-tertiary);
  font-size: 13px;
  padding: 4px 0;
}

.ok { color: var(--ok); font-weight: 650; }
.bad { color: var(--bad); font-weight: 650; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 24px; }
}
