/* ==========================================================================
   pqctimeline.com — Plain, Authentic Technical Documentation Stylesheet
   Inspired by GitHub Docs / OpenSSH / Mozilla SSL Config Generator
   ========================================================================== */

:root {
  --bg: #0d1117;
  --bg-subtle: #161b22;
  --bg-hover: #1f242c;
  --bg-active: #21262d;
  --border: #30363d;
  --border-subtle: #21262d;

  --text: #e6edf3;
  --text-2: #8b949e;
  --text-3: #6e7681;

  --link: #58a6ff;

  --ok-text: #3fb950;
  --ok-bg: rgba(46, 160, 67, 0.12);
  --ok-border: rgba(46, 160, 67, 0.35);

  --warn-text: #d29922;
  --warn-bg: rgba(187, 128, 9, 0.12);
  --warn-border: rgba(187, 128, 9, 0.35);

  --info-text: #58a6ff;
  --info-bg: rgba(56, 139, 253, 0.12);
  --info-border: rgba(56, 139, 253, 0.35);

  --bad-text: #f85149;
  --bad-bg: rgba(248, 81, 73, 0.12);
  --bad-border: rgba(248, 81, 73, 0.35);

  --code-bg: #090c10;
  --code-bar: #161b22;
  --code-text: #e6edf3;
  --syn-comment: #8b949e;
  --syn-key: #79c0ff;
  --syn-string: #a5d6ff;
  --syn-pqc: #d2a8ff;

  --radius: 6px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

[data-theme='light'] {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-hover: #eaeef2;
  --bg-active: #e6ebf1;
  --border: #d0d7de;
  --border-subtle: #e5e9ee;

  --text: #1f2328;
  --text-2: #57606a;
  --text-3: #6e7781;

  --link: #0969da;

  --ok-text: #1a7f37;
  --ok-bg: #dafbe1;
  --ok-border: #aceebb;

  --warn-text: #9a6700;
  --warn-bg: #fff8c5;
  --warn-border: #eed888;

  --info-text: #0969da;
  --info-bg: #ddf4ff;
  --info-border: #addcff;

  --bad-text: #cf222e;
  --bad-bg: #ffebe9;
  --bad-border: #ffcecb;

  --code-bg: #f6f8fa;
  --code-bar: #eaeef2;
  --code-text: #1f2328;
  --syn-comment: #6e7781;
  --syn-key: #0550ae;
  --syn-string: #0a3069;
  --syn-pqc: #8250df;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 5px;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.mono {
  font-family: var(--font-mono);
}

/* ---------- Top Navigation Bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 52px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand:hover {
  text-decoration: none;
}

.brand-icon {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.main-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.tab-btn {
  position: relative;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  padding: 0 10px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  font-weight: 600;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 2px;
  background: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.top-ext-link {
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  margin-right: 4px;
}
.top-ext-link:hover {
  color: var(--link);
}

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
}

.btn-xs {
  height: 25px;
  padding: 0 8px;
  font-size: 12px;
}

.text-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-2);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
}
.text-link:hover {
  color: var(--link);
  text-decoration: underline;
}

.field {
  height: 30px;
  padding: 0 9px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
}

.field:focus {
  border-color: var(--link);
}

.field-label {
  font-size: 12.5px;
  color: var(--text-2);
}

.search-field {
  width: 100%;
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

.checkbox-field input {
  margin: 0;
  cursor: pointer;
}

/* ---------- Views ---------- */
.view[hidden] {
  display: none !important;
}

.load-error {
  max-width: 720px;
  margin: 32px auto;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--bad-border);
  background: var(--bad-bg);
  color: var(--bad-text);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* ==========================================================================
   VIEW 1: CONFIG WORKBENCH
   ========================================================================== */
.workbench {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 52px);
}

/* Left Rail */
.rail {
  border-right: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px);
  position: sticky;
  top: 52px;
}

.rail-search {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.rail-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.rail-list::-webkit-scrollbar { width: 6px; }
.rail-list::-webkit-scrollbar-track { background: transparent; }
.rail-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.rail-group {
  margin-bottom: 14px;
}

.rail-group-title {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.rail-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.rail-item:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.rail-item.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 600;
}

.rail-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.rail-edit-link {
  color: var(--text-2);
}
.rail-edit-link:hover {
  color: var(--link);
}

/* Right Stage */
.stage {
  min-width: 0;
  padding: 24px 36px 56px;
  max-width: 960px;
  width: 100%;
}

.mobile-target-bar {
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.mobile-target-bar select {
  flex: 1;
}

.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-subtle);
}

.seg-btn {
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
}
.seg-btn:last-child {
  border-right: none;
}

.seg-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.seg-btn.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 600;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 7px;
}

.domain-field {
  width: 165px;
  font-size: 12.5px;
}

/* Focused Target View */
.target-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.target-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.target-meta-line {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.target-desc {
  margin: 0;
  color: var(--text-2);
  font-size: 13.5px;
  max-width: 680px;
}

/* Code Panel */
.code-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow: hidden;
  margin-bottom: 14px;
}

.code-header {
  background: var(--code-bar);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.code-file {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

.code-profile-tag {
  color: var(--text-2);
  font-size: 11.5px;
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-btn {
  height: 25px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
}

.code-btn:hover {
  background: var(--bg-hover);
}

.code-btn.copied {
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.code-body {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--code-text);
}

.syn-comment { color: var(--syn-comment); }
.syn-key { color: var(--syn-key); }
.syn-string { color: var(--syn-string); }
.syn-pqc { color: var(--syn-pqc); font-weight: 500; }

/* Meta Footer under Code */
.stage-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.meta-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.meta-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}

.meta-cmd {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  overflow-x: auto;
  white-space: nowrap;
}

.note-box {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  font-size: 13px;
  color: var(--text-2);
}

.note-box strong {
  color: var(--text);
}

.profile-footnote {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-2);
}

/* ---------- Restrained Tags ---------- */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-2);
  white-space: nowrap;
}

.tag-ok {
  color: var(--ok-text);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.tag-info {
  color: var(--info-text);
  background: var(--info-bg);
  border-color: var(--info-border);
}

.tag-warn {
  color: var(--warn-text);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.tag-bad {
  color: var(--bad-text);
  background: var(--bad-bg);
  border-color: var(--bad-border);
}

/* ---------- Spec Panel (Identical Frame to Code Panel) ---------- */
.controls-meta {
  font-size: 12px;
  color: var(--text-2);
}

.spec-rows {
  display: flex;
  flex-direction: column;
}

.spec-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  align-items: baseline;
}

.spec-row:last-child {
  border-bottom: none;
}

.spec-key {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
}

.spec-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--code-text);
  overflow-wrap: anywhere;
}

.peer-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.peer-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.peer-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.peer-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.peer-row:last-child {
  border-bottom: none;
}

.peer-row:hover {
  background: var(--bg-subtle);
}

.peer-row.active {
  background: var(--bg-active);
  font-weight: 600;
}

.peer-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.peer-sub {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 400;
}

.rail-status {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  flex-shrink: 0;
}

.rail-status.ok { color: var(--ok-text); }
.rail-status.info { color: var(--info-text); }
.rail-status.warn { color: var(--warn-text); }
.rail-status.bad { color: var(--bad-text); }

.product-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.product-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.product-item:last-child {
  border-bottom: none;
}

.product-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.product-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}

.product-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-2);
  margin-bottom: 5px;
}

.product-details {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
}

@media (max-width: 640px) {
  .spec-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 13px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
}

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .top-ext-link { display: none; }
}

@media (max-width: 900px) {
  .workbench {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail {
    display: none;
  }
  .stage {
    padding: 18px 18px 48px;
  }
  .mobile-target-bar {
    display: flex;
  }
}

@media (max-width: 680px) {
  .topbar-inner {
    padding: 0 12px;
    gap: 8px;
  }
  .topbar-left {
    gap: 12px;
  }
  .hide-sm { display: none; }
  .tab-btn {
    padding: 0 7px;
    font-size: 12.5px;
  }
  .toolbar-search {
    width: 100%;
  }
}
