/* WBS Creator — colourful, offline, accessible basics */
:root{
  --bg: #0b1020;
  --panel: rgba(255,255,255,0.06);
  --panel2: rgba(255,255,255,0.08);
  --text: #eaf0ff;
  --muted: rgba(234,240,255,0.72);
  --border: rgba(234,240,255,0.12);

  --primary: #7c5cff;
  --primary2: #5ad7ff;
  --danger: #ff4d6d;
  --ok: #34d399;
  --warn: #fbbf24;

  --shadow: 0 12px 30px rgba(0,0,0,0.35);
  --radius: 16px;

  --s1: 6px;
  --s2: 10px;
  --s3: 14px;
  --s4: 18px;
  --s5: 24px;

  --font: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

:root[data-theme="light"]{
  --bg: #f6f7ff;
  --panel: rgba(0,0,0,0.04);
  --panel2: rgba(0,0,0,0.06);
  --text: #101424;
  --muted: rgba(16,20,36,0.65);
  --border: rgba(16,20,36,0.14);
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--font);
  background:
    radial-gradient(900px 550px at 20% 10%, rgba(124,92,255,0.35), transparent 60%),
    radial-gradient(900px 550px at 80% 20%, rgba(90,215,255,0.25), transparent 60%),
    radial-gradient(700px 450px at 50% 95%, rgba(255,77,109,0.20), transparent 65%),
    var(--bg);
  color: var(--text);
}

.skip-link{
  position:absolute;
  left:-999px;
  top:10px;
  padding: 10px 12px;
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  z-index:999;
}
.skip-link:focus{ left: 10px; }

.app-header{
  position: sticky;
  top:0;
  z-index: 20;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s3) var(--s4);
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(0,0,0,0.18), rgba(0,0,0,0.05));
  border-bottom: 1px solid var(--border);
}

.brand{ display:flex; align-items:center; gap: var(--s3); min-width: 240px; }
.logo{
  width:44px; height:44px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(124,92,255,0.95), rgba(90,215,255,0.85));
  display:grid; place-items:center;
  box-shadow: var(--shadow);
}
.logo svg{ width:22px; height:22px; fill: white; opacity: 0.95; }

.title{ font-weight: 800; letter-spacing: 0.2px; }
.subtitle{ font-size: 12px; color: var(--muted); margin-top: 2px; }

.header-actions{ display:flex; align-items:center; gap: var(--s2); flex-wrap: wrap; justify-content:flex-end;}
.divider{ width:1px; height:28px; background: var(--border); margin: 0 2px; }

.btn{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  font-weight: 650;
}
.btn:hover{ transform: translateY(-1px); background: rgba(255,255,255,0.10); }
.btn:active{ transform: translateY(0px) scale(0.99); }
.btn:disabled{ opacity: 0.5; cursor: not-allowed; transform:none; }

.btn.primary{
  border-color: rgba(124,92,255,0.55);
  background: linear-gradient(135deg, rgba(124,92,255,0.95), rgba(90,215,255,0.70));
  color: white;
}
.btn.secondary{
  background: rgba(255,255,255,0.04);
}
.btn.danger{
  border-color: rgba(255,77,109,0.55);
  background: rgba(255,77,109,0.15);
  color: var(--text);
}

.icon-btn{
  width:42px; height:42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  display:grid; place-items:center;
  cursor:pointer;
  transition: transform .12s ease, background .12s ease;
}
.icon-btn:hover{ transform: translateY(-1px); background: rgba(255,255,255,0.10); }
.icon-btn:active{ transform: translateY(0px) scale(0.99); }
.icon-btn svg{ width:20px; height:20px; fill: currentColor; }
.icon-btn:focus-visible, .btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .tool-btn:focus-visible{
  outline: 3px solid rgba(90,215,255,0.65);
  outline-offset: 2px;
}

.layout{
  display:grid;
  grid-template-columns: 420px 1fr;
  gap: var(--s4);
  padding: var(--s4);
  padding-bottom: 64px;
}

@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .left{ order: 2; }
}

.panel{
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-title{
  display:flex; align-items:center; justify-content: space-between;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  font-weight: 800;
}
.panel-title .right{ display:flex; gap: var(--s2); align-items:center; }
.pill{
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(0,0,0,0.08);
}

.search-row{
  display:flex; gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}
input[type="search"], input[type="text"], textarea, select{
  width:100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.12);
  color: var(--text);
  font: inherit;
}
:root[data-theme="light"] input[type="search"], :root[data-theme="light"] input[type="text"], :root[data-theme="light"] textarea, :root[data-theme="light"] select{
  background: rgba(255,255,255,0.75);
}
textarea{ resize: vertical; }
select{ cursor:pointer; }

.toolbar{
  display:flex; flex-wrap: wrap;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}
.tool-btn{
  display:flex; align-items:center; gap: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  cursor:pointer;
  transition: transform .12s ease, background .12s ease;
  font-weight: 700;
}
.tool-btn svg{ width:18px; height:18px; }
.tool-btn:hover{ transform: translateY(-1px); background: rgba(255,255,255,0.10); }
.tool-btn:active{ transform: translateY(0px) scale(0.99); }
.tool-btn:disabled{ opacity: 0.5; cursor:not-allowed; transform:none; }
.tool-btn.danger{
  border-color: rgba(255,77,109,0.55);
  background: rgba(255,77,109,0.12);
}

.outline{
  padding: var(--s2) 0;
  max-height: calc(100vh - 310px);
  overflow:auto;
}
@media (max-width: 980px){
  .outline{ max-height: 48vh; }
}

.node{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px var(--s3);
  margin: 4px var(--s3);
  border-radius: 14px;
  border: 1px solid transparent;
  cursor:pointer;
  user-select: none;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  position: relative;
}
.node:hover{ background: rgba(255,255,255,0.06); transform: translateY(-1px); }
.node[aria-selected="true"]{
  border-color: rgba(90,215,255,0.60);
  background: rgba(90,215,255,0.10);
}
.node:focus-visible{
  outline: 3px solid rgba(90,215,255,0.65);
  outline-offset: 2px;
}

.node .indent{
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: var(--node-color, rgba(124,92,255,0.6));
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
}
.node .mainline{ flex: 1; min-width: 0; }
.node .topline{ display:flex; align-items: baseline; gap: 8px; }
.node .code{
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.2px;
  font-size: 12px;
}
.node .name{
  font-weight: 800;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node .meta{
  display:flex; gap: 8px; flex-wrap: wrap;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.badge{
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.10);
}
.badge.ok{ border-color: rgba(52,211,153,0.55); background: rgba(52,211,153,0.12); }
.badge.warn{ border-color: rgba(251,191,36,0.55); background: rgba(251,191,36,0.12); }
.badge.muted{ opacity: 0.85; }

.chev-btn{
  width:30px; height:30px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  display:grid; place-items:center;
  cursor:pointer;
}
.chev-btn svg{ width:18px; height:18px; fill: currentColor; transition: transform .12s ease;}
.node[data-collapsed="true"] .chev-btn svg{ transform: rotate(-90deg); }

.hint{
  margin: var(--s3);
  padding: var(--s3);
  border-radius: 14px;
  border: 1px dashed rgba(90,215,255,0.35);
  background: rgba(90,215,255,0.07);
  color: var(--text);
}
.hint-title{ font-weight: 900; margin-bottom: 6px; }

.main{ display:flex; flex-direction: column; gap: var(--s4); }
.details{ padding-bottom: var(--s3); }
.empty-state{
  padding: 48px var(--s4);
  text-align:center;
}
.empty-state h2{ margin: 12px 0 6px; font-size: 22px; }
.empty-state p{ margin: 0 0 18px; color: var(--muted); }
.sparkle{ font-size: 34px; }
.row{ display:flex; justify-content:center; gap: var(--s2); flex-wrap: wrap; }

.form{ padding: var(--s4); }
.grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}
@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
}
.field label{ display:block; font-weight: 800; margin-bottom: 8px; }
.field .req{ color: var(--danger); }
.field .helptext{ font-size: 12px; color: var(--muted); margin-top: 6px; }
.field .error{ margin-top: 8px; color: #ffd0d8; background: rgba(255,77,109,0.15); border: 1px solid rgba(255,77,109,0.35); padding: 8px 10px; border-radius: 12px; }
.field.full{ grid-column: 1 / -1; }

.code-row{ display:flex; gap: var(--s2); align-items:center; }
.code-badge{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.14);
  font-weight: 900;
  letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
}

.form-actions{
  margin-top: var(--s4);
  display:flex;
  gap: var(--s2);
  align-items:center;
  flex-wrap: wrap;
}
.spacer{ flex: 1; }

.pm-note{
  margin-top: var(--s4);
  padding: var(--s3);
  border-radius: 14px;
  border: 1px solid rgba(124,92,255,0.35);
  background: rgba(124,92,255,0.10);
  color: var(--text);
}

.help{ }
.help-body{
  padding: var(--s4);
  color: var(--text);
}
.help-body ul{ margin: 0 0 16px; padding-left: 20px; color: var(--muted); }
.help-body b{ color: var(--text); }
.callout{
  border: 1px solid rgba(251,191,36,0.45);
  background: rgba(251,191,36,0.10);
  padding: var(--s3);
  border-radius: 14px;
}
.callout-title{ font-weight: 900; margin-bottom: 6px; }

.statusbar{
  position: fixed;
  bottom:0; left:0; right:0;
  display:flex; justify-content: space-between; align-items:center;
  gap: var(--s3);
  padding: 10px var(--s4);
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  backdrop-filter: blur(10px);
}
.statusbar #statusLeft{ color: var(--muted); }
.status-right{
  display:flex; align-items:center; gap: 10px;
  color: var(--muted);
}
.kbd{
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  padding: 2px 8px;
  border-radius: 8px;
  color: var(--text);
}
.dot{ width:5px; height:5px; border-radius: 50%; background: var(--border); }

.toast{
  position: fixed;
  right: var(--s4);
  bottom: 62px;
  max-width: 360px;
  background: rgba(0,0,0,0.68);
  color: white;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: var(--shadow);
}

.menu{ position: relative; }
.menu-panel{
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  padding: 8px;
  display:none;
}
:root[data-theme="light"] .menu-panel{ background: rgba(255,255,255,0.92); }
.menu-panel[data-open="true"]{ display:block; }
.menu-item{
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.menu-item:hover{ background: rgba(255,255,255,0.08); }
.menu-item.danger{ color: #ffd0d8; }
.menu-sep{ height:1px; background: var(--border); margin: 6px 0; }
.chev{ width: 18px; height: 18px; fill: currentColor; vertical-align: middle; margin-left: 6px; }

.modal::backdrop{ background: rgba(0,0,0,0.6); }
.modal{
  border: none;
  padding: 0;
  background: transparent;
}
.modal-card{
  width: min(520px, calc(100vw - 24px));
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  padding: var(--s4);
}
:root[data-theme="light"] .modal-card{ background: rgba(255,255,255,0.94); }
.modal-title{ font-weight: 900; font-size: 18px; margin-bottom: 12px; }
.modal-actions{ display:flex; gap: var(--s2); justify-content:flex-end; margin-top: var(--s3); }
.micro{ margin-top: 10px; font-size: 12px; color: var(--muted); }

.sr-only{
  position:absolute!important;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);
  white-space:nowrap;border:0;
}

.confetti{
  position: fixed;
  inset: 0;
  pointer-events: none;
  display:none;
}
.confetti[data-on="true"]{ display:block; }
