* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: #1e293b; background: #f1f5f9; }
.muted { color: #64748b; }
.small { font-size: 12px; }
.hint { font-weight: 400; color: #94a3b8; font-size: 11px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px; background: #fff; border-bottom: 1px solid #e2e8f0;
}

.layout { display: grid; grid-template-columns: minmax(380px, 460px) 1fr; gap: 0; height: calc(100vh - 49px); }
.pane { overflow-y: auto; padding: 16px 18px; }
.form-pane { background: #fff; border-right: 1px solid #e2e8f0; }
.preview-pane { background: #e2e8f0; display: flex; flex-direction: column; padding: 12px; }

h2 { font-size: 15px; margin: 4px 0 12px; }
h3 { font-size: 13px; margin: 20px 0 8px; color: #334155; }

label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 12px; }
input, textarea {
  width: 100%; margin-top: 4px; padding: 7px 9px; font: inherit; font-size: 13px; font-weight: 400;
  border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #0f172a; resize: vertical;
}
textarea { font-family: "Noto Sans Bengali", ui-monospace, Menlo, monospace; }
input:focus, textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px #bfdbfe; }

.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.row3 label { margin-bottom: 12px; }

.actions { display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; }
button.primary { background: #1f3a6d; color: #fff; border: 0; padding: 9px 18px; border-radius: 6px; font-weight: 600; cursor: pointer; }
button.primary:hover { background: #16305c; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.list a { color: #2563eb; text-decoration: none; }

button.ghost { background: #fff; color: #475569; border: 1px solid #cbd5e1; padding: 8px 14px; border-radius: 6px; cursor: pointer; }
button.ghost:hover { background: #f8fafc; }

details.group { border: 1px solid #e2e8f0; border-radius: 8px; padding: 6px 10px; margin: 0 0 12px; background: #f8fafc; }
details.group > summary { cursor: pointer; font-size: 12px; font-weight: 700; color: #334155; padding: 4px 0; list-style: none; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before { content: "▸ "; }
details.group[open] > summary::before { content: "▾ "; }
details.group[open] { padding-bottom: 2px; }
details.group label { margin-top: 10px; }

/* Diagram marker tool */
.diag-add { display: flex; gap: 6px; margin-bottom: 10px; }
.diag-add select, .diag-add input { margin-top: 0; padding: 6px 8px; }
.diag-card { border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px; margin-bottom: 12px; background: #fff; }
.diag-card .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.diag-card .head input { width: auto; flex: 1; margin: 0 8px 0 0; font-weight: 600; }
.diag-card .head button { background: none; border: 0; color: #b91c1c; cursor: pointer; font-size: 12px; }
.diag-canvas { position: relative; display: inline-block; cursor: crosshair; border: 1px dashed #cbd5e1; border-radius: 6px; padding: 4px; background: #fafafa; }
.diag-canvas svg { display: block; }
.diag-mk { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; border: 1px solid #fff; box-shadow: 0 0 0 0.5px rgba(0,0,0,.4); pointer-events: none; }
.diag-markers { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.diag-markers .m { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.diag-markers .m input[type=text] { flex: 1; margin: 0; padding: 4px 6px; }
.diag-markers .m input[type=color] { width: 26px; height: 26px; padding: 0; border: 1px solid #cbd5e1; border-radius: 4px; margin: 0; }
.diag-markers .m button { background: none; border: 0; color: #b91c1c; cursor: pointer; }
.diag-markers .empty { color: #94a3b8; font-size: 11px; }

.preview-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#preview { flex: 1; width: 100%; border: 0; background: #e2e8f0; border-radius: 4px; }

/* --- Access gate ---------------------------------------------------------- */
.gate {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(30, 41, 59, 0.55); backdrop-filter: blur(3px);
}
.gate[hidden] { display: none; }
.gate-card {
  width: 100%; max-width: 520px; background: #fff; border-radius: 24px;
  padding: 44px 48px 36px; text-align: center;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}
.gate-icon {
  width: 72px; height: 72px; margin: 0 auto 26px; border-radius: 50%;
  background: #e0e7ff; color: #312e81;
  display: flex; align-items: center; justify-content: center;
}
.gate-title { margin: 0; font-size: 30px; font-weight: 800; color: #111827; letter-spacing: -0.01em; }
.gate-sub { margin: 8px 0 30px; font-size: 17px; color: #64748b; }
.gate-label { display: block; text-align: left; font-size: 15px; font-weight: 700; color: #111827; margin: 0 0 8px; }
.gate-input {
  width: 100%; margin: 0; padding: 15px 16px; font-size: 16px; font-weight: 400;
  border: 1px solid #cbd5e1; border-radius: 12px; background: #fff; color: #0f172a;
}
.gate-input::placeholder { color: #94a3b8; }
.gate-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px #bfdbfe; }
.gate-input.err { border-color: #ef4444; box-shadow: 0 0 0 3px #fecaca; }
.gate-error { text-align: left; color: #dc2626; font-size: 13px; font-weight: 600; margin: 8px 2px 0; }
.gate-error[hidden] { display: none; }
.gate-btn {
  width: 100%; margin-top: 22px; padding: 15px 16px; border: 0; border-radius: 12px;
  font-size: 17px; font-weight: 700; color: #fff; background: #cbd5e1;
  display: flex; align-items: center; justify-content: center; gap: 10px; cursor: not-allowed;
  transition: background 0.15s ease;
}
.gate-btn:not(:disabled) { background: #2563eb; cursor: pointer; }
.gate-btn:not(:disabled):hover { background: #1d4ed8; }
.gate-foot { margin: 22px 0 0; font-size: 15px; color: #64748b; }
