/* CENG 301 ER çizim sayfası */
body.er-page { margin: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-soft); }

/* --- Sitenin genel düğme stili (degrade + beyaz yazı + üzerine gelince kayma) bu araca sızmasın.
   :where() ile özgüllük düşük tutulur: aşağıdaki .er-* kuralları bunu ezer. Sınıfsız düğme = birincil (degrade kalır);
   .ghost / .small siteyle aynı. er-* sınıflı düğmelerle .er-seg / .er-tabs içindekiler nötr başlar. */
body.er-page button:hover:not(:disabled) { transform: none; box-shadow: none; }
:where(body.er-page) button:where([class*="er-"], .er-seg > button, .er-tabs > button) {
  background: #fff; color: var(--text); border: 1px solid var(--border); box-shadow: none; transform: none;
  font-weight: 500; font-size: .84rem; padding: 6px 10px; border-radius: 8px; transition: background .15s, border-color .15s, color .15s;
}
:where(body.er-page) button:where([class*="er-"], .er-seg > button, .er-tabs > button):hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
:where(body.er-page) button:where([class*="er-"]):focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
body.er-page button.ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }

/* --- üst çubuk */
.er-top { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--border); }
.er-back { font-weight: 600; text-decoration: none; color: var(--brand); white-space: nowrap; flex: none; }
.er-titles { display: flex; flex-direction: column; min-width: 0; flex: 0 1 auto; }
.er-titles strong { font-size: 1rem; white-space: nowrap; }
.er-sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 24vw; }
.er-status { flex: 1 1 40px; min-width: 0; text-align: right; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.er-status.dirty { color: var(--warn); }
.er-status.ok { color: var(--ok); }
.er-status.bad { color: var(--danger); font-weight: 600; }
.er-actions { display: flex; gap: 5px; align-items: center; flex: none; }
/* canlı: kim diyagramda (renkli çip) + bağlantı durumu noktası */
.er-presence { display: flex; gap: 6px; align-items: center; flex: none; }
.er-chip { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 600; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border-soft); border-radius: 999px; padding: 2px 9px 2px 6px; white-space: nowrap; }
.er-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; box-shadow: 0 0 0 2px #fff; }
.er-chip.off { color: var(--muted); font-weight: 500; background: none; }
.er-chip.off i { background: #cbd5e1; }
.er-live { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #cbd5e1; }
.er-live.live { background: var(--ok); box-shadow: 0 0 0 3px #d1fae5; }
.er-live.connecting { background: var(--warn); animation: er-blink 1s infinite; }
.er-live.polling { background: var(--warn); }
@keyframes er-blink { 50% { opacity: .35; } }
.er-actions .icon { min-width: 30px; padding-left: 7px; padding-right: 7px; font-size: 1rem; line-height: 1; display: inline-grid; place-items: center; height: 30px; }
.er-actions .icon svg { display: block; }
.er-sep { width: 1px; height: 22px; background: var(--border); margin: 0 2px; flex: none; }
.er-find { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 8px; padding: 0 6px; background: #fff; color: var(--muted); }
.er-find:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
body.er-page .er-find input { border: none; outline: none; box-shadow: none; font: inherit; font-size: .82rem; width: 110px; padding: 5px 0; background: none; border-radius: 0; }
.er-find-count { font-size: .72rem; min-width: 0; white-space: nowrap; }
.er-dd { position: relative; }
.er-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; min-width: 260px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.16); padding: 5px; }
.er-menu-right { left: auto; right: 0; }
.er-menu hr { border: none; border-top: 1px solid var(--border-soft); margin: 4px 0; }
.er-menu-h { font-size: .72rem; color: var(--muted); font-weight: 600; padding: 4px 8px 2px; text-transform: uppercase; letter-spacing: .03em; }
.er-menu-i { display: flex; align-items: center; gap: 6px; width: 100%; border: none; background: none; font-size: .84rem; color: var(--text);
  padding: 6px 8px; border-radius: 7px; cursor: pointer; text-align: left; white-space: nowrap; }
.er-menu-i:hover:not(:disabled) { background: var(--brand-soft); color: var(--brand); }
.er-menu-i:disabled { opacity: .45; cursor: default; }
.er-menu-i kbd { margin-left: auto; padding-left: 16px; font-family: inherit; font-size: .72rem; color: var(--muted); }
.er-menu-c { width: 14px; flex: none; color: var(--brand); font-weight: 700; }
.er-alert { margin: 8px 14px 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.er-gate { margin: 24px auto; max-width: 560px; }

/* --- ana düzen */
.er-main { flex: 1; display: grid; grid-template-columns: 196px 1fr 340px; min-height: 0; }
.er-tools { background: #fff; border-right: 1px solid var(--border); padding: 8px 6px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.er-tool { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-color: transparent; border-radius: 9px; background: none;
  font-size: .84rem; color: var(--text); cursor: pointer; text-align: left; white-space: nowrap; }
.er-tool:hover:not(:disabled) { background: var(--surface-2); }
.er-tool[aria-pressed="true"] { background: var(--brand-soft); border-color: #cfd2fb; color: var(--brand); font-weight: 600; }
.er-tool svg { flex: none; }
.er-tool kbd { margin-left: auto; font-size: .7rem; color: var(--muted); font-family: inherit; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; line-height: 1.4; }
.er-tool:disabled { opacity: .45; cursor: default; }
.er-tools hr { border: none; border-top: 1px solid var(--border-soft); margin: 6px 0; }

.er-canvas { position: relative; min-width: 0; min-height: 0; overflow: hidden;
  background-color: #fbfcff; background-image: radial-gradient(#dde1ee 1px, transparent 1px); background-size: 20px 20px; }
.er-svg { width: 100%; height: 100%; display: block; outline: none; touch-action: none; user-select: none; cursor: default; }
.er-svg:focus-visible { box-shadow: inset 0 0 0 2px var(--brand-soft); }
.er-canvas.adding .er-svg { cursor: crosshair; }
.er-canvas.connecting .er-svg { cursor: cell; }
.er-svg .er-node, .er-svg .er-edge { cursor: pointer; }
.er-svg .er-bend { cursor: move; }
.er-hint { position: absolute; left: 12px; bottom: 10px; font-size: .8rem; color: var(--text-2); background: rgba(255,255,255,.94);
  border: 1px solid var(--border-soft); border-radius: 8px; padding: 5px 10px; pointer-events: none; max-width: 70%; box-shadow: 0 2px 8px rgba(15,23,42,.06); }
.er-hint:empty { display: none; }
.er-inline { position: absolute; z-index: 5; font: 600 14px Inter, Arial, sans-serif; text-align: center; border: 2px solid var(--brand);
  border-radius: 6px; padding: 3px 6px; background: #fff; box-shadow: 0 2px 8px rgba(15,23,42,.12); }

/* --- yan panel */
.er-side { background: #fff; border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.er-tabs { display: flex; border-bottom: 1px solid var(--border); }
.er-tabs > button { flex: 1; padding: 9px 2px; white-space: nowrap; border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none;
  font-size: .82rem; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.er-tabs > button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.er-tabs > button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; background: none; }
.er-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 600; line-height: 18px; }
.er-badge.warn { background: var(--warn); }
.er-badge:empty { display: none; }
.er-pane { padding: 12px 14px; overflow-y: auto; font-size: .88rem; line-height: 1.5; flex: 1; }
.er-pane h4 { margin: 14px 0 6px; font-size: .88rem; }
.er-pane h4:first-child { margin-top: 0; }
.er-pane p.note { font-size: .84rem; margin: 6px 0 10px; }
.er-pane .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.er-pane .field > span { font-size: .78rem; color: var(--muted); font-weight: 600; margin: 0; }
.er-pane input[type="text"], .er-pane textarea, .er-pane select { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; width: 100%; box-sizing: border-box; font-size: .88rem; }
.er-pane input[type="text"]:focus, .er-pane textarea:focus, .er-pane select:focus { box-shadow: 0 0 0 3px var(--brand-soft); }
.er-pane textarea { min-height: 70px; resize: vertical; }
.er-pane .choice { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; padding: 7px 10px; border-radius: 9px; cursor: pointer; font-size: .86rem; transition: background .15s, border-color .15s; }
.er-pane .choice:hover { transform: none; box-shadow: none; }
.er-pane .choice:has(input:checked) { box-shadow: none; }
.er-pane .choice input { margin-top: 3px; }
.er-pane .choice small { display: block; color: var(--muted); font-size: .76rem; }
.er-seg { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.er-seg > button { flex: 1; padding: 5px 6px; font-size: .8rem; white-space: nowrap; }
.er-seg > button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.er-seg > button[aria-pressed="true"]:hover:not(:disabled) { background: #4338ca; color: #fff; }
.er-meaning { background: var(--brand-soft); color: #3730a3; border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-weight: 500; }
.er-kbd { color: var(--muted); font-size: .8rem; }
.er-kbd kbd { font-family: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: .75rem; }
.er-issue { display: block; width: 100%; text-align: left; padding: 7px 9px; margin-bottom: 6px; border-radius: 8px; border: 1px solid var(--border-soft);
  background: #fff; font-size: .84rem; cursor: pointer; color: var(--text); line-height: 1.4; }
.er-issue.err { border-left: 4px solid var(--danger); }
.er-issue.warn { border-left: 4px solid var(--warn); }
.er-issue:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); }
.er-issue.err:hover:not(:disabled) { border-left-color: var(--danger); }
.er-issue.warn:hover:not(:disabled) { border-left-color: var(--warn); }
.er-issue b { font-weight: 700; }
.er-issue.err b { color: var(--danger); }
.er-issue.warn b { color: var(--warn); }
.er-ok { color: var(--ok); font-weight: 600; }
.er-card dt { font-weight: 700; color: var(--brand); }
.er-card dd { margin: 0 0 8px; }
.er-legend { display: grid; grid-template-columns: 34px 1fr; gap: 6px 10px; align-items: center; font-size: .8rem; }
.er-legend > span:first-child, .er-legend > strong { text-align: center; }
.er-note-box { white-space: pre-wrap; background: #fff8db; border: 1px solid #ecd98c; border-radius: 8px; padding: 10px; }
.er-btnrow { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.er-btnrow .icon { min-width: 34px; padding: 5px 6px; display: inline-grid; place-items: center; }
.er-btnrow .icon svg { display: block; }
.er-kind { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.er-kind strong { font-size: 1.25rem; color: var(--brand); line-height: 1.25; }
.er-kind span { font-size: .8rem; color: var(--text-2); white-space: pre-wrap; }
.er-presets > span { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; margin: 8px 0 4px; }
.er-kindpics { display: flex; justify-content: space-between; gap: 4px; margin: 2px 0 4px; }
.er-kindpics figure { margin: 0; padding: 4px 2px 2px; border: 1px solid transparent; border-radius: 8px; text-align: center; flex: 1; }
.er-kindpics figure.on { border-color: #c7cbfa; background: var(--brand-soft); }
.er-kindpics figcaption { font-size: .66rem; color: var(--muted); white-space: nowrap; }
.er-kindpics figure.on figcaption { color: var(--brand); font-weight: 700; }
.er-sideq { border: 1px solid var(--border-soft); border-radius: 9px; padding: 8px 10px 4px; margin: 8px 0; }
.er-sideq h5 { margin: 0 0 6px; font-size: .84rem; }
.er-sideq .er-seg { margin-bottom: 6px; }
.er-sideq small { display: block; color: var(--muted); font-size: .76rem; margin-bottom: 4px; }
.er-kindtag { font-size: .72rem; font-weight: 700; color: var(--brand); border: 1px dashed #a5abf5; border-radius: 5px; padding: 0 4px; justify-self: center; }
.er-start { background: var(--brand-soft); border: 1px solid #d5d8fb; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.er-start p { margin: 0; font-size: .84rem; }
.er-start .er-btnrow { margin: 2px 0 0; }
.er-guide { margin-top: 12px; border: 1px solid var(--border-soft); border-radius: 9px; padding: 6px 10px; }
.er-guide summary { cursor: pointer; font-weight: 600; font-size: .86rem; }
.er-guide section { margin: 8px 0; }
.er-guide h5 { margin: 6px 0 2px; font-size: .84rem; }
.er-guide p { margin: 2px 0; font-size: .82rem; }
body.er-page .linkish { border: none; background: none; padding: 0; color: var(--brand); font: inherit; font-size: .8rem; cursor: pointer; text-decoration: underline; box-shadow: none; border-radius: 0; }
body.er-page .linkish:hover:not(:disabled) { color: var(--brand-2); background: none; }
.er-cmt { border: 1px solid var(--border-soft); border-left: 4px solid var(--warn); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; transition: background .3s; }
.er-cmt.done { border-left-color: var(--ok); opacity: .8; }
.er-cmt.flash { background: #fff3c4; }
.er-cmt-head { display: flex; align-items: center; gap: 6px; width: 100%; border: none; border-radius: 4px; background: none; padding: 0; font-size: .88rem; text-align: left; cursor: pointer; color: var(--text); }
.er-cmt-head:hover:not(:disabled) { background: none; color: var(--brand); }
.er-cmt-head:disabled { cursor: default; }
.er-cmt-head small { margin-left: auto; color: var(--muted); font-size: .72rem; }
.er-pin-no { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--warn); color: #fff; font-size: .72rem; font-weight: 700; flex: none; }
.er-cmt.done .er-pin-no { background: var(--ok); }
.er-cmt-text { white-space: pre-wrap; margin: 6px 0; }
.er-cmt-state { font-size: .78rem; color: var(--ok); }

/* --- pencereler */
.er-dlg { border: none; border-radius: 14px; padding: 16px 18px; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(15,23,42,.3); font-size: .9rem; }
.er-dlg::backdrop { background: rgba(15,23,42,.45); }
.er-dlg-wide { width: min(1120px, 96vw); }
.er-dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.er-dlg-head h3 { margin: 0; font-size: 1.05rem; }
.er-dlg-foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.er-dlg-foot .note { margin-right: auto; font-size: .78rem; }
.er-dlg .field { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.er-dlg .field > span { margin: 0; font-size: .78rem; color: var(--muted); font-weight: 600; }
.er-dlg input[type="text"], .er-dlg select { font: inherit; font-size: .86rem; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; width: 100%; box-sizing: border-box; }
.er-dlg .choice { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; cursor: pointer; padding: 0; border: none; background: none; box-shadow: none; transform: none; font-size: .88rem; }
.er-dlg .choice:has(input:checked) { background: none; box-shadow: none; }
.er-dlg .choice small { display: block; color: var(--muted); font-size: .76rem; }
.er-pr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-bottom: 6px; }
.er-dlg p { margin: 6px 0; }
.er-pr-grid .wide { grid-column: 1 / -1; }
.er-ex-body { display: grid; grid-template-columns: 250px 1fr; gap: 14px; min-height: 0; }
.er-ex-list { display: flex; flex-direction: column; gap: 4px; max-height: 70vh; overflow-y: auto; }
.er-ex-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; border: 1px solid var(--border-soft); border-radius: 9px;
  background: #fff; padding: 7px 9px; cursor: pointer; color: var(--text); }
.er-ex-item strong { font-size: .84rem; }
.er-ex-item small { font-size: .72rem; color: var(--muted); }
.er-ex-item[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.er-ex-item[aria-pressed="true"] strong { color: var(--brand); }
.er-ex-view h4 { margin: 0 0 6px; }
.er-ex-view p { margin: 8px 0 0; line-height: 1.5; }
.er-ex-canvas { position: relative; height: min(52vh, 460px); border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden;
  background-color: #fbfcff; background-image: radial-gradient(#dde1ee 1px, transparent 1px); background-size: 20px 20px; }

@media (max-width: 1500px) { .er-find input { width: 80px; } .er-sub { max-width: 18vw; } }
@media (max-width: 1180px) {
  .er-top { flex-wrap: wrap; row-gap: 6px; }
  .er-titles { flex: 1 1 auto; }
  .er-status { flex: 0 1 auto; }
  .er-actions { flex: 1 1 100%; flex-wrap: wrap; }
  .er-main { grid-template-columns: 196px 1fr 300px; }
}
@media (max-width: 900px) {
  .er-ex-body { grid-template-columns: 1fr; }
  .er-ex-list { flex-direction: row; overflow-x: auto; max-height: none; }
  .er-main { grid-template-columns: 1fr; grid-template-rows: auto 1fr 40vh; }
  .er-tools { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 6px; }
  .er-tool { width: auto; }
  .er-tool kbd, .er-tools hr { display: none; }
  .er-side { border-left: none; border-top: 1px solid var(--border); }
}
