:root { color-scheme: light; }

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  height: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  background: #d8dde5;
  font-family: Tahoma, Verdana, sans-serif;
  color: #000;
}

.window {
  width: 760px;
  max-width: calc(100% - 24px);
  margin: 40px auto;
  border: 2px solid #4a6ea9;
  background: #f0f3f7;
  box-shadow: 0 0 0 3px #b8c4d4;
}

.titlebar {
  background: linear-gradient(to bottom, #5b84c9, #3c5d99);
  padding: 6px 10px;
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  border-bottom: 1px solid #2a3e6b;
  user-select: none;
  cursor: default;
}

.content {
  padding: 16px;
  font-size: 14px;
  line-height: 1.35;
}

h1 {
  font-size: 22px;
  margin: 0;
  color: #2a3e6b;
}

p { margin: 4px 0; }

.section-title {
  font-size: 16px;
  color: #23385e;
  margin: 14px 0 4px;
  padding: 4px 6px;
  background: #e7edf6;
  border: 1px solid #b5c4dc;
}

.intro {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.intro-logo {
  height: 48px;
  width: auto;
  display: block;
}

.box {
  border: 1px solid #9aaec8;
  background: #ffffff;
  padding: 12px;
  margin-top: 10px;
}

code {
  background: #eef2f7;
  border: 1px solid #ccd6e0;
  padding: 2px 4px;
  font-family: "Courier New", monospace;
  border-radius: 3px;
}

.callout {
  margin-top: 12px;
  border: 1px solid #b5c4dc;
  background: #ffffff;
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid #b5c4dc;
  line-height: 1;
}

.callout-icon-img {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: block;
}

.callout-title {
  margin: 0;
  font-size: 15px;
  font-weight: bold;
  line-height: 1;
  flex: 1;
}

.callout-body {
  padding: 8px 10px;
  color: #2b2b2b;
  line-height: 1.32;
}

.callout-body strong { margin: 4px 0; }
.callout-body br { margin: 0; }

.callout-body code {
  padding: 1px 3px;
  font-size: 13px;
}

.callout.info {
  border-color: #7bb9ff;
  background: #f2f7ff;
}

.callout.info .callout-header {
  background: #dceaff;
  border-bottom-color: #7bb9ff;
}

.callout.info .callout-title { color: #084a88; }

.callout.warning {
  border-color: #d1a94a;
  background: #fff9ea;
}

.callout.warning .callout-header {
  background: #f6e8bf;
  border-bottom-color: #d1a94a;
}

.callout.warning .callout-title { color: #3b2e00; }

.callout.connect {
  border-color: #7bb9ff;
  background: #f2f7ff;
}

.callout.connect .callout-header {
  background: #dceaff;
  border-bottom-color: #7bb9ff;
}

.callout.connect .callout-title { color: #084a88; }

.actions { margin-top: 10px; }
.actions.center { text-align: center; }
.actions.right { text-align: right; }

.actions-row-left {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.linkbtn { text-decoration: none; }

.linkbtn.retro {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  height: 30px;
  padding: 0 10px;
  font-size: 14px;
  background: #e4e4e4;
  border: 2px solid;
  border-color: #ffffff #a0a0a0 #a0a0a0 #ffffff;
  cursor: pointer;
  box-shadow: inset 1px 1px 0 #ffffff, inset -1px -1px 0 #707070;
  color: #000;
}

.linkbtn.retro:hover { background: #dcdcdc; }

.linkbtn.retro:focus-visible {
  outline: 2px dotted #000;
  outline-offset: 2px;
}

.linkbtn.retro:active {
  background: #c8c8c8;
  border-color: #a0a0a0 #ffffff #ffffff #a0a0a0;
  box-shadow: inset 1px 1px 0 #707070, inset -1px -1px 0 #ffffff;
}

.linkbtn.retro.primary { font-weight: 400; }

/* ====== МОДАЛКА ====== */

.modal-overlay[hidden] { display: none !important; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 9999;
}

/* Критично: убираем margin, который задан у .window */
.modal-window {
  width: 520px;
  max-width: calc(100% - 24px);
  position: fixed;
  margin: 0;                 /* <<< фиксим "съезд ниже центра" */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: modalIn 160ms ease-out;
}

.modal-drag-handle {
  cursor: move;
  touch-action: none; /* для тач-устройств */
}

.dragging * {
  user-select: none !important;
}

.footer {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: #44556d;
}

@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% - 6px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

@media (max-width: 480px) {
  .window { margin: 28px auto; }
  .content { padding: 12px; font-size: 13px; }
  h1 { font-size: 18px; }
  .intro-logo { height: 40px; }
  .linkbtn.retro { min-width: 100%; }
  .modal-window { width: 92vw; }
}
