/* Site Manager — matched to the Rodriguez Corporation tool design system
   (parchment + navy + gold, Georgia/Palatino serifs). System fonts only — no
   web fonts, no CDN, so the strict self-only CSP stays intact. */
:root {
  --bg:            #F7F5F0;
  --bg-tinted:     #F1EEE5;
  --parchment:     #FDF5E6;
  --paper:         #FFFFFF;
  --cream:         #FAF7F0;

  --navy:          #1A2F4B;
  --navy-deep:     #0F2540;
  --navy-soft:     #2A4163;

  --gold:          #C9A961;
  --gold-deep:     #8C7338;
  --gold-light:    #E5CD9A;

  --ink:           #16203A;
  --text:          #2b2b2b;
  --muted:         #6b6457;

  --border:        #E8E2D2;
  --border-strong: #D6CEB8;
  --hairline:      #F0EBDC;

  --ok:            #2E7D5F;
  --error:         #A0312E;

  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(15,30,51,.06), 0 4px 12px rgba(15,30,51,.04);
  --shadow-md: 0 14px 32px rgba(15,30,51,.10), 0 4px 12px rgba(15,30,51,.05);
  --shadow-navy: 0 6px 18px rgba(15,30,51,.22);
  --inset-light: inset 0 1px 0 rgba(255,255,255,.18);

  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-head: Georgia, "Times New Roman", serif;
  --font-body: "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.55 var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 480px at 50% -10%, var(--parchment), transparent 70%),
    var(--bg);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--gold-deep); }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 18px; color: #F5ECD6;
  background: linear-gradient(180deg, var(--navy-soft) 0%, var(--navy) 55%, var(--navy-deep) 100%);
  border-bottom: 2px solid var(--gold);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: var(--navy-deep); border-radius: 8px; font: 800 13px/1 var(--font-head);
  box-shadow: var(--inset-light);
}
.brand .wordmark { font: 600 19px/1 var(--font-display); letter-spacing: .01em; color: #FBF3DD; }
.brand .back { color: #cdd6e4; text-decoration: none; font: 600 14px/1 var(--font-head); }
.brand .back:hover { color: #fff; }
.site-name { font: 600 17px/1 var(--font-display); color: #FBF3DD; }
.topbar .muted { color: #b9c4d6; }

/* ---- buttons ---- */
.btn {
  appearance: none; cursor: pointer; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 14px/1 var(--font-head); letter-spacing: .015em;
  padding: 10px 18px; min-height: 42px; border-radius: var(--r-sm);
  color: #FFEFCE; border: 1px solid var(--navy-deep);
  background: linear-gradient(180deg, var(--navy-soft), var(--navy) 55%, var(--navy-deep));
  box-shadow: var(--shadow-navy), var(--inset-light);
  transition: transform .08s, filter .12s, box-shadow .12s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.gold {
  color: var(--navy-deep); border-color: var(--gold-deep);
  background: linear-gradient(180deg, #F0DCA8, var(--gold) 60%, var(--gold-deep));
  box-shadow: 0 6px 18px rgba(201,169,97,.34), var(--inset-light);
}
.btn.ghost {
  background: transparent; color: #E7DFC9; border-color: #ffffff3a; box-shadow: none;
}
.btn.ghost:hover { background: #ffffff14; filter: none; }
.btn.sm { min-height: 34px; padding: 7px 12px; font-size: 13px; }

/* ---- shell ---- */
.wrap { max-width: 1040px; margin: 0 auto; padding: 30px 18px 64px; }

.card {
  background: var(--paper); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm); padding: 26px;
}
.login { max-width: 400px; margin: 9vh auto 0; text-align: left; }
.login h1 { font: 600 30px/1.1 var(--font-display); color: var(--navy); margin: 0 0 4px; }
.login form { display: flex; flex-direction: column; gap: 11px; margin-top: 20px; }
.login label { font: 600 13px/1 var(--font-head); color: var(--ink); }
.login input {
  padding: 12px 13px; min-height: 44px; font-size: 16px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--cream);
}
.login input:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.err { color: var(--error); font-size: 14px; margin: 4px 0 0; }

.dash-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.dash-head h1 { font: 600 30px/1.1 var(--font-display); color: var(--navy); margin: 0; }
.dash-head .eyebrow { font: 600 12px/1 var(--font-head); letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold-deep); display: block; margin-bottom: 6px; }
.dash-actions { display: flex; align-items: center; gap: 12px; }
.dash-actions .btn { color: var(--navy); background: var(--paper);
  border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.dash-actions .btn:hover { filter: none; border-color: var(--gold); }

.grid { margin-top: 24px; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.site-card {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text);
  background: var(--paper); border: 1px solid var(--border); border-left: 3px solid var(--gold);
  border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.site-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-left-color: var(--gold-deep); }
.logo-wrap { flex: 0 0 46px; width: 46px; height: 46px; display: grid; place-items: center;
  background: var(--cream); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.logo-wrap img { max-width: 84%; max-height: 84%; object-fit: contain; }
.mono { width: 100%; height: 100%; display: grid; place-items: center;
  background: linear-gradient(180deg, var(--navy-soft), var(--navy)); color: var(--gold-light);
  font: 700 20px/1 var(--font-display); }
.site-body { min-width: 0; }
.site-card h3 { margin: 0 0 2px; font: 600 17px/1.15 var(--font-display); color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-card .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-card.external { border-left-color: var(--navy); }
.site-card.external:hover { border-left-color: var(--gold); }

/* ---- editor: 3-pane split ---- */
.editor-page, .editor-page body { height: 100%; }
.ed-actions { display: flex; align-items: center; gap: 10px; }
.file-path { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font: 13px/1 var(--font-head); min-width: 96px; color: #b9c4d6; }
.status.ok { color: #9ce0bb; } .status.err { color: #ffb3a6; }
.viewtoggle { display: inline-flex; border: 1px solid #ffffff33; border-radius: var(--r-sm); overflow: hidden; }
.viewtoggle button { appearance: none; cursor: pointer; background: transparent;
  color: #d7dde8; border: 0; padding: 7px 12px; font: 600 12px/1 var(--font-head); }
.viewtoggle button.active { background: var(--gold); color: var(--navy-deep); }

.ed-main { display: flex; height: calc(100vh - 59px); }
.sidebar { width: 268px; min-width: 210px; display: flex; flex-direction: column;
  background: var(--bg-tinted); border-right: 1px solid var(--border); overflow: hidden; }
.filter { margin: 10px; padding: 9px 11px; font-size: 14px; background: var(--paper);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); }
.filetree { flex: 1; overflow: auto; padding: 0 8px 16px; }
.filetree details { margin: 0; }
.filetree summary { cursor: pointer; padding: 5px 6px; border-radius: var(--r-sm);
  font: 600 13px/1.4 var(--font-head); color: var(--navy); list-style-position: inside; }
.filetree summary:hover { background: var(--hairline); }
.fileitem { display: block; padding: 6px 8px; border-radius: var(--r-sm); font-size: 13px;
  color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fileitem:hover { background: var(--hairline); }
.fileitem.active { background: var(--navy); color: #fff; }

.code-pane { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.empty { flex: 1; display: grid; place-items: center; color: var(--muted); font-style: italic; }
.CodeMirror { height: 100% !important; font: 13.5px/1.5 var(--font-mono); background: var(--paper); }

.preview-pane { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.preview-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--bg-tinted); border-bottom: 1px solid var(--border); }
.preview-url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 12px/1 var(--font-mono); color: var(--muted); }
.preview-bar .btn { color: var(--navy); background: var(--paper); border-color: var(--border-strong); box-shadow: none; }
.preview-bar .btn.active { color: var(--navy-deep); border-color: var(--gold-deep);
  background: linear-gradient(180deg, #F0DCA8, var(--gold) 60%, var(--gold-deep)); }
#preview { flex: 1; width: 100%; border: 0; background: #fff; }
.CodeMirror .sm-flash { background: rgba(201, 169, 97, .28); transition: background .3s; }

/* view modes */
.ed-main.view-code .preview-pane { display: none; }
.ed-main.view-code .code-pane { border-right: 0; }
.ed-main.view-preview .code-pane { display: none; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  padding: 12px 20px; border-radius: var(--r-sm); font: 600 14px/1 var(--font-head);
  color: #FFEFCE; background: var(--navy); box-shadow: var(--shadow-md); z-index: 60; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--error); }

@media (max-width: 820px) {
  .ed-main { flex-direction: column; height: auto; }
  .sidebar { width: 100%; max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .code-pane, .preview-pane { flex: none; height: 60vh; border-right: 0; }
  .ed-main.view-split .code-pane, .ed-main.view-split .preview-pane { height: 52vh; }
  .file-path { display: none; }
}
