@import url('https://fonts.googleapis.com/css2?family=Cormorant+Upright:ital,wght@0,300;0,400;0,500;1,300;1,400&family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&family=Alegreya+Sans:ital,wght@0,300;0,400;0,500;1,300;1,400&family=Lekton&family=IBM+Plex+Sans:wght@300;400;500&family=Dancing+Script:wght@400;500&display=swap');
/* ===== THEME DEFINITIONS ===== */
[data-theme="parchment"] {
  --bg:           #ece7dd;
  --sidebar:      #f5f1ea;
  --sb-border:    #ddd6c8;
  --text:         #2e2a26;
  --text2:        #6e6458;
  --text3:        #a89a88;
  --accent:       #B22244;
  --accent-hover: #921a36;
  --accent-bg:    rgba(178,34,68,.08);
  --input-bg:     #fff;
  --input-border: #d6cfc2;
  --nav-bg:       #26201a;
  --nav-text:     #9a8878;
  --nav-logo:     #ece7dd;
  --paper:        #fff;
  --paper-shadow: rgba(60,50,40,.12);
  --toggle-off:   #ccc5b8;
  --drop-bg:      #fff;
  --drop-hover:   #f5f1ea;
  --border:       #ddd6c8;
  --border-lt:    #ccc5b5;
  --lifted:       #f5f1ea;
  --surface:      #f5f1ea;
  --red-margin:   rgba(178,34,68,.18);
  --rule-line:    #c8c0b0;
  --rule-dot:     #d8d0c0;
  --script-color: rgba(58,53,48,.14);
}
[data-theme="walnut"] {
  --bg:           #1e1b18;
  --sidebar:      #28241f;
  --sb-border:    #3d3832;
  --text:         #c8c0b4;
  --text2:        #8a8278;
  --text3:        #5e5850;
  --accent:       #80b898;
  --accent-hover: #639e80;
  --accent-bg:    rgba(128,184,152,.12);
  --input-bg:     #322e28;
  --input-border: #4a443c;
  --nav-bg:       #151310;
  --nav-text:     #6a6358;
  --nav-logo:     #c8c0b4;
  --paper:        #fff;
  --paper-shadow: rgba(0,0,0,.3);
  --toggle-off:   #4a443c;
  --drop-bg:      #322e28;
  --drop-hover:   #3d3832;
  --border:       #3d3832;
  --border-lt:    #4e4840;
  --lifted:       #322e28;
  --surface:      #28241f;
  --red-margin:   rgba(180,80,60,.18);
  --rule-line:    #b8b0a4;
  --rule-dot:     #c8c0b4;
  --script-color: rgba(30,27,24,.18);
}

*{margin:0;padding:0;box-sizing:border-box}
html{font-size:20px}
body{font-family:'IBM Plex Sans',system-ui,sans-serif;background:var(--bg);color:var(--text);min-height:100vh;display:flex;flex-direction:column;transition:background .3s,color .3s}

/* ──────────────────────────────────────────
   THEME TOGGLE
────────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  color: var(--nav-text);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  transition: border-color 0.2s, color 0.2s;
}
.theme-toggle:hover {
  border-color: rgba(255,255,255,0.3);
  color: var(--nav-logo);
}
.toggle-track {
  width: 28px;
  height: 15px;
  border-radius: 8px;
  background: var(--toggle-off);
  position: relative;
  transition: background 0.3s;
  flex-shrink: 0;
}
.toggle-track.on { background: var(--accent); }
.toggle-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}
.toggle-track.on .toggle-thumb { transform: translateX(13px); }

/* ──────────────────────────────────────────
   NAV
────────────────────────────────────────── */
nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 2.5rem;
  height: 60px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.35s;
}

.nav-logo {
  font-family: 'Cormorant Upright', serif;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--nav-logo);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nav-logo-mark {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255,255,255,0.15);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.nav-logo-mark svg {
  width: 13px;
  height: 13px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.5;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 0.1rem;
  list-style: none;
}
.nav-links a {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--nav-text);
  text-decoration: none;
  padding: 0.35rem 0.85rem;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-links a:hover {
  color: var(--nav-logo);
  border-color: rgba(255,255,255,0.1);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.nav-cta {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 0.45rem 1.1rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
}
.nav-cta:hover { background: var(--accent-hover); }


/* ══════════════════════════════════════════
   RESPONSIVE
   768px — tablet
   480px — mobile
══════════════════════════════════════════ */

/* ──────────────────────────────────────────
   HAMBURGER BUTTON
────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  padding: 0 8px;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block;
  height: 1px;
  background: var(--nav-text);
  transition: transform 0.25s ease, opacity 0.2s ease;
  transform-origin: center;
}
.nav-hamburger.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-hamburger.is-open span:nth-child(2) { opacity: 0; }
.nav-hamburger.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ──────────────────────────────────────────
   NAV DRAWER
────────────────────────────────────────── */
.nav-drawer {
  display: none;
  position: fixed;
  top: 60px;
  left: 0; right: 0;
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 99;
  transform: translateY(-6px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.nav-drawer.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}
.nav-drawer-links {
  list-style: none;
}
.nav-drawer-links li {
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.nav-drawer-links a {
  display: block;
  padding: 1rem 1.5rem;
  font-family: 'Scope One', serif;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--nav-text);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.nav-drawer-links a:hover,
.nav-drawer-links a:focus {
  color: var(--nav-logo);
  background: rgba(255,255,255,0.04);
}
.nav-drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  gap: 1rem;
}
/* Drawer top border */
.nav-drawer-links:first-child {
  border-top: 1px solid rgba(255,255,255,0.06);
}



/* Mobile nav */
@media(max-width:860px){
  .nav-hamburger{display:flex}
  .nav-dropdown-wrap{display:none;position:absolute;top:44px;left:0;right:0;background:var(--nav-bg);flex-direction:column;padding:.5rem 0;border-bottom:1px solid rgba(255,255,255,.1);box-shadow:0 4px 16px rgba(0,0,0,.25);z-index:300}
  .nav-dropdown-wrap.open{display:flex}
  .nav-item{position:static}
  .nav-item>a{padding:.45rem 1rem;font-size:.7rem}
  .nav-sub{position:static;box-shadow:none;border:none;margin-top:0;padding:0;border-radius:0;background:rgba(255,255,255,.03)}
  .nav-sub a{padding:.4rem 1rem .4rem 1.8rem;font-size:.65rem}
  /* On mobile, submenus toggle on click (handled by JS) */
  .nav-item.has-sub>.nav-sub{display:none}
  .nav-item.has-sub.open>.nav-sub{display:block}
}

/* ===== LAYOUT ===== */
.app-layout{display:grid;grid-template-columns:350px 1fr;flex:1;min-height:0}
@media(max-width:860px){
  .app-layout{grid-template-columns:1fr}
  .sidebar{max-height:none;border-right:none;border-bottom:1px solid var(--sb-border)}
}

/* ===== SIDEBAR ===== */
.sidebar{background:var(--sidebar);border-right:1px solid var(--sb-border);padding:1rem;overflow-y:auto;display:flex;flex-direction:column;gap:1rem;transition:background .3s}
.sh{font-size:.6rem;font-weight:600;text-transform:uppercase;letter-spacing:.1em;color:var(--accent);margin-bottom:.35rem}
.fi{width:100%;padding:.45rem .6rem;background:var(--input-bg);border:1px solid var(--input-border);border-radius:5px;color:var(--text);font-family:inherit;font-size:.76rem;outline:none;transition:border-color .15s}
.fi:focus{border-color:var(--accent)}.fi::placeholder{color:var(--text3)}
.fchips{display:flex;flex-wrap:wrap;gap:3px;margin-top:.3rem}
.fc{padding:2px 7px;font-size:.58rem;border:1px solid var(--input-border);border-radius:11px;background:transparent;color:var(--text2);cursor:pointer;font-family:inherit;transition:all .15s}
.fc:hover{border-color:var(--accent);color:var(--accent)}
.fc.active{background:var(--accent);color:#fff;border-color:var(--accent)}
.fdrop{position:absolute;top:100%;left:0;right:0;background:var(--drop-bg);border:1px solid var(--input-border);border-radius:5px;max-height:180px;overflow-y:auto;z-index:100;display:none;margin-top:2px;box-shadow:0 4px 12px var(--paper-shadow)}
.fdrop.open{display:block}
.fdi{padding:.35rem .6rem;cursor:pointer;font-size:.73rem;color:var(--text);border-bottom:1px solid var(--sb-border)}
.fdi:hover{background:var(--drop-hover)}.fdi .cat{font-size:.55rem;color:var(--text3);margin-left:.3rem}
select,textarea{width:100%;padding:.4rem .55rem;background:var(--input-bg);border:1px solid var(--input-border);border-radius:5px;color:var(--text);font-family:inherit;font-size:.73rem;outline:none;transition:border-color .15s}
select:focus,textarea:focus{border-color:var(--accent)}
textarea{resize:vertical;min-height:52px}
.sr{display:flex;align-items:center;gap:.35rem;margin-bottom:.35rem}
.sl-label{font-size:.68rem;color:var(--text2);min-width:82px}
.sl-val{font-size:.68rem;color:var(--accent);min-width:28px;text-align:right;font-weight:500}
input[type=range]{flex:1;-webkit-appearance:none;height:3px;border-radius:2px;background:var(--input-border);outline:none}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;border:none}
.sp{display:flex;flex-wrap:wrap;gap:4px}
.pill{padding:3px 9px;font-size:.63rem;border:1px solid var(--input-border);border-radius:4px;background:transparent;color:var(--text2);cursor:pointer;font-family:inherit;transition:all .15s}
.pill:hover{border-color:var(--accent);color:var(--accent)}
.pill.active{border-color:var(--accent);background:var(--accent-bg);color:var(--accent)}
.tr{display:flex;justify-content:space-between;align-items:center;padding:.15rem 0}
.tl-text{font-size:.7rem;color:var(--text2)}
.tog{width:32px;height:17px;border-radius:9px;background:var(--toggle-off);position:relative;cursor:pointer;transition:background .2s}
.tog.on{background:var(--accent)}
.tog::after{content:'';width:13px;height:13px;border-radius:50%;background:#fff;position:absolute;top:2px;left:2px;transition:transform .2s}
.tog.on::after{transform:translateX(15px)}
.btn-row{display:flex;gap:.4rem;margin-top:.15rem}
.btn-p{flex:1;padding:.5rem;background:var(--accent);color:#fff;border:none;border-radius:5px;font-family:inherit;font-size:.73rem;font-weight:500;cursor:pointer;transition:background .15s}
.btn-p:hover{background:var(--accent-hover)}
.btn-s{flex:1;padding:.5rem;background:transparent;color:var(--text2);border:1px solid var(--input-border);border-radius:5px;font-family:inherit;font-size:.73rem;cursor:pointer}
.btn-s:hover{border-color:var(--text2)}
.lbl{font-size:.63rem;color:var(--text3);display:block;margin-bottom:2px}
.mi{font-size:.55rem;color:var(--text3);text-align:center;margin-top:.3rem}

/* ===== PREVIEW AREA ===== */
.preview-area{display:flex;flex-direction:column;min-height:0;overflow:hidden}

/* Sticky toolbar */
.preview-toolbar{display:flex;align-items:center;gap:1rem;padding:.4rem .8rem;background:var(--sidebar);border-bottom:1px solid var(--sb-border);flex-shrink:0;flex-wrap:wrap}
.tb-group{display:flex;align-items:center;gap:.25rem}
.tb-label{font-size:.58rem;text-transform:uppercase;letter-spacing:.06em;color:var(--text3);margin-right:.2rem}
.tb-btn{width:24px;height:24px;display:flex;align-items:center;justify-content:center;border:1px solid var(--input-border);border-radius:4px;background:transparent;color:var(--text2);font-size:.65rem;cursor:pointer;font-family:inherit;transition:all .15s}
.tb-btn:hover{border-color:var(--accent);color:var(--accent)}
.tb-btn.tb-active{background:var(--accent-bg);border-color:var(--accent);color:var(--accent)}
.tb-val{font-size:.62rem;color:var(--text2);min-width:32px;text-align:center}

/* Paper scroll area */
.paper-scroll{flex:1;overflow:auto;padding:1rem;display:flex;justify-content:center;align-items:flex-start}
.paper{background:var(--paper);border-radius:3px;box-shadow:0 4px 20px var(--paper-shadow);transform-origin:top center;transition:transform .15s}
.paper-hdr{display:flex;justify-content:space-between;align-items:baseline;padding:.75rem 1.2rem .4rem;border-bottom:1px solid #e0dcd6}
.paper-hdr .fn{font-size:.85rem;font-style:italic;color:#555}
.paper-hdr .df{font-size:.68rem;color:#aaa}
.paper-hdr .df span{display:inline-block;width:80px;border-bottom:1px solid #ccc;margin-left:3px}
.canvas-wrap{padding:.25rem 0}
#cv{width:100%;display:block}
.sbar{font-size:.62rem;color:#999;text-align:center;padding:.25rem 0 .55rem}

/* ===== FOOTER ===== */
.site-footer{background:var(--nav-bg);padding:.6rem 1.25rem;flex-shrink:0}
.footer-inner{max-width:900px;margin:0 auto;display:flex;justify-content:center;align-items:center}
.footer-info{display:flex;gap:.4rem;align-items:center;font-size:.5rem;color:var(--nav-text);flex-wrap:wrap;justify-content:center}
.footer-dot{opacity:.3}

/* ===== LOADING ===== */
.lo{display:none;position:fixed;inset:0;background:rgba(0,0,0,.6);z-index:1000;justify-content:center;align-items:center;flex-direction:column;gap:.6rem}
.lo.visible{display:flex}
.spin{width:24px;height:24px;border:3px solid rgba(255,255,255,.2);border-top-color:var(--accent);border-radius:50%;animation:sp .7s linear infinite}
@keyframes sp{to{transform:rotate(360deg)}}
.lo-text{font-size:.75rem;color:#ccc}
.hidden{display:none!important}

/* ===== MOBILE ===== */
@media(max-width:860px){
  .preview-toolbar{padding:.35rem .6rem}
  .paper-scroll{padding:.5rem}
  .paper{max-width:100%}
  .site-footer{padding:.5rem .8rem}
}

/* ──────────────────────────────────────────
   FOOTER
────────────────────────────────────────── */
footer {
  background: var(--nav-bg);
  border-top: 1px solid rgba(255,255,255,0.06);
  transition: background 0.35s;
}
.footer-main { display: grid; grid-template-columns: 10rem 2fr 1fr 1fr 1fr; }
.footer-cell {
  padding: 2.5rem 1.8rem;
  border-right: 1px solid rgba(255,255,255,0.06);
  transition: border-color 0.35s;
}
.footer-cell:last-child { border-right: none; }
.footer-brand {
  font-family: 'Cormorant Upright', serif;
  font-size: 1.05rem;
  color: var(--nav-logo);
  display: block;
  margin-bottom: 0.7rem;
}
.footer-tagline { font-size: 0.85rem; color: var(--nav-text); line-height: 1.7; }
.footer-col-label {
  font-size: 0.58rem;
  color: rgba(255,255,255,0.18);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 1.1rem;
}
.footer-links { list-style: none; display: flex; flex-direction: column; gap: 0.55rem; }
.footer-links a { font-size: 0.88rem; color: var(--nav-text); text-decoration: none; transition: color 0.15s; }
.footer-links a:hover { color: var(--nav-logo); }
.footer-bottom {
  display: grid;
  grid-template-columns: 10rem 1fr auto;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.footer-bottom-cell {
  padding: 0.9rem 1.8rem;
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
}
.footer-bottom-cell:last-child { border-right: none; justify-content: flex-end; }
.footer-copy { font-size: 0.58rem; color: rgba(255,255,255,0.2); letter-spacing: 0.06em; }
.footer-script { font-size: 1.05rem; color: var(--accent); opacity: 0.55; }

@media (max-width: 768px) {

  /* Nav — hide links, show hamburger */
  nav {
    grid-template-columns: 1fr auto;
    padding: 0 1.5rem;
  }
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
  .nav-drawer { display: block; }
  /* theme toggle moves into drawer on tablet/mobile */
  .nav-right .theme-toggle { display: none; }
}
@media (max-width: 480px) {

  /* Nav */
  nav { padding: 0 1rem; height: 54px; }
  .nav-drawer { top: 54px; }
  nav .nav-right .nav-cta{display:none}
}
