/* WikiCV — the app shell (editor chrome). The article's own styling lives in wiki-theme.js. */

:root {
  --bg: #f1f3f5;
  --panel: #ffffff;
  --ink: #1f2328;
  --ink-soft: #616b74;
  --line: #d8dde2;
  --line-soft: #e8ebee;
  --accent: #3366cc;
  --accent-dark: #2a55a8;
  --danger: #b62828;
  --radius: 6px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top bar ─────────────────────────────────────────────────── */

.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #202122;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1;
}
.brand-name { font-weight: 600; letter-spacing: .2px; }

.tabs { display: flex; gap: 2px; background: #eceff1; padding: 3px; border-radius: var(--radius); }
.tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
}
.tab.is-active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.save-status {
  font-size: 12px;
  color: var(--ink-soft);
  margin-right: 6px;
  white-space: nowrap;
}
.save-status.is-saving { color: var(--accent); }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f6f8fa; border-color: #c3cad1; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fdf2f2; border-color: #e6b8b8; }

.btn-add {
  width: 100%;
  border-style: dashed;
  color: var(--ink-soft);
  padding: 9px;
  margin-top: 4px;
}

/* ── Workspace / panes ───────────────────────────────────────── */

.workspace {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  min-height: 0;
}

.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-edit { background: var(--panel); border-right: 1px solid var(--line); }
.pane-preview { background: var(--bg); }

.pane-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
}

.pane-preview .pane-scroll { padding: 22px; display: flex; justify-content: center; }

/* The rendered article sits on a "page" */
.wikicv-article {
  width: 100%;
  max-width: 900px;
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 18px 24px 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ── Groups (collapsible editor sections) ────────────────────── */

.group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--panel);
}
.group[open] { box-shadow: 0 1px 2px rgba(0,0,0,.04); }

.group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 13px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
  user-select: none;
}
.group-head::-webkit-details-marker { display: none; }
.group-head::before {
  content: "▸";
  color: var(--ink-soft);
  font-size: 11px;
  transition: transform .12s ease;
}
.group[open] > .group-head::before { transform: rotate(90deg); }
.group-head:hover { background: #f7f9fa; }

.group-title { font-weight: 600; }
.group-hint { font-size: 12px; color: var(--ink-soft); }

.group-body { padding: 4px 13px 14px; border-top: 1px solid var(--line-soft); }

/* ── Fields ──────────────────────────────────────────────────── */

.field { display: block; margin-top: 12px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.field-label em { font-weight: 400; font-style: normal; color: var(--ink-soft); }
.field-help { display: block; font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }

input[type="text"], input[type="url"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 9px;
  font: inherit;
  color: var(--ink);
  background: #fdfdfe;
}
textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.8px;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51,102,204,.13);
  background: #fff;
}
::placeholder { color: #a8b0b8; }

/* ── Repeatable rows (infobox + references) ──────────────────── */

.rows { display: flex; flex-direction: column; gap: 7px; }

.row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 6px;
  align-items: start;
}
.row-ref { grid-template-columns: 1fr auto; }
.row-ref .row-sub { grid-column: 1 / -1; }

.icon-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 4px;
  width: 28px;
  height: 34px;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.icon-btn:hover { background: #f0f2f4; color: var(--ink); }
.icon-btn.is-danger:hover { background: #fdf2f2; color: var(--danger); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }

/* ── Sections ────────────────────────────────────────────────── */

.sections { display: flex; flex-direction: column; gap: 10px; }

.section-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px 11px;
  background: #fbfcfd;
}
.section-head { display: flex; gap: 4px; align-items: center; margin-bottom: 7px; }
.section-head input { font-weight: 600; }
.section-card textarea { min-height: 110px; background: #fff; }

/* ── Cheatsheet ──────────────────────────────────────────────── */

.cheatsheet { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; }
.cheatsheet td { padding: 5px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.cheatsheet td:first-child { white-space: nowrap; width: 45%; }
.cheatsheet code {
  background: #f3f5f7;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.8px;
}
.demo-wikilink { color: var(--accent); }
.demo-ref { color: var(--accent); font-size: .78em; }

.footnote {
  font-size: 11.8px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 14px 2px 4px;
}
.footnote code {
  background: #eceff1;
  border-radius: 3px;
  padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ── Toast ───────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  background: #202122;
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ── Responsive: one pane at a time ──────────────────────────── */

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .pane { display: none; }
  .pane.is-active { display: flex; }
  .pane-preview .pane-scroll { padding: 12px; }
  .wikicv-article { padding: 14px 16px 22px; }
  .save-status { display: none; }

  /* The buttons no longer fit on one line. Let the bar grow (a fixed height here
     makes them spill over the article) and give them their own scrollable row. */
  .topbar {
    height: auto;
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 9px 10px;
  }
  .tabs { margin-left: auto; }
  .actions {
    order: 3;
    width: 100%;
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 1px;
  }
  .actions::-webkit-scrollbar { height: 0; }
  .actions .btn { padding: 7px 10px; flex: 0 0 auto; }
}

@media (min-width: 901px) {
  .tabs { display: none; }        /* both panes are visible; tabs are pointless */
  .pane { display: flex !important; }
}
