html {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body.modal-open { overflow: hidden; }

main,
header,
footer,
section,
.section-shell,
.nav-shell,
.hero-copy,
.hero-machine,
.project-grid,
.project-card,
.project-meta,
.studio-grid,
.builder-grid,
.arena-grid,
.code-lab {
  min-width: 0;
  max-width: 100%;
}

.project-dialog {
  width: min(1480px, calc(100vw - 32px));
  max-width: none;
  height: min(900px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border-radius: 24px;
}

.project-dialog[open] {
  display: flex;
  flex-direction: column;
}

.project-dialog-head {
  min-height: 96px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  border-bottom: 1px solid #263650;
}

.project-dialog-head > div { min-width: 0; }
.project-dialog-head .kicker { margin: 0 0 8px; }
.project-dialog h2 { margin: 0; font-size: clamp(28px, 3.2vw, 52px); overflow-wrap: anywhere; }

.project-dialog .dialog-close {
  position: static;
  flex: 0 0 42px;
}

.project-experience {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  direction: ltr;
}

.project-story {
  min-width: 0;
  padding: 28px;
  overflow-y: auto;
  border-right: 1px solid #263650;
  direction: rtl;
}

[dir="ltr"] .project-story { direction: ltr; }
.project-story #dialogSummary { margin: 0 0 18px; color: #f7f9ff; font-size: 18px; font-weight: 800; line-height: 1.65; }
.project-story #dialogDetails { margin: 0; color: #9aabc2; line-height: 1.85; }
.project-story #dialogTech { margin: 28px 0; padding: 14px; border: 1px solid #263650; border-radius: 12px; color: var(--cyan); background: #07101f; overflow-wrap: anywhere; font: 11px/1.7 var(--mono); }
.project-story .dialog-actions { flex-direction: column; }
.project-story .dialog-actions a { display: flex; align-items: center; justify-content: center; min-height: 46px; text-align: center; }

.project-preview-shell {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #040914;
  direction: ltr;
}

.preview-controls {
  min-height: 52px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid #263650;
  color: #8698b2;
}

.preview-controls > span { display: flex; align-items: center; gap: 7px; font: 9px var(--mono); }
.preview-controls > span i { width: 8px; height: 8px; border-radius: 50%; background: #ff5577; }
.preview-controls > span i:nth-child(2) { background: #ffd257; }
.preview-controls > span i:nth-child(3) { background: #45efa5; }
.preview-controls > span b { margin-inline-start: 7px; }
.preview-controls > div { display: flex; gap: 5px; }
.preview-controls button { width: 36px; height: 34px; border: 1px solid #2b3d58; border-radius: 8px; color: #91a4bd; background: #0b1729; }
.preview-controls button.active { color: #041019; border-color: var(--cyan); background: var(--cyan); }

.project-preview-stage {
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow: hidden;
  background-image: linear-gradient(rgba(67, 91, 126, .13) 1px, transparent 1px), linear-gradient(90deg, rgba(67, 91, 126, .13) 1px, transparent 1px);
  background-size: 28px 28px;
}

.project-preview-stage iframe {
  width: 100%;
  height: 100%;
  max-width: 100%;
  border: 1px solid #30435e;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .48);
  transition: width .35s, border-radius .35s;
}

.project-preview-stage[data-size="tablet"] iframe { width: min(768px, 100%); }
.project-preview-stage[data-size="phone"] iframe { width: min(390px, 100%); border-radius: 28px; }
.preview-empty { width: min(680px, 100%); min-height: 320px; position: relative; display: grid; place-items: center; align-content: center; gap: 16px; overflow: hidden; padding: 32px; border: 1px dashed #36506f; border-radius: 18px; color: #8294ae; text-align: center; }
.preview-empty[hidden] { display: none; }
.preview-empty img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .18; }
.preview-empty b,.preview-empty span { position: relative; }
.preview-empty b { color: var(--cyan); font: 900 36px var(--mono); }
.preview-empty span { max-width: 440px; line-height: 1.8; }
.preview-note { min-height: 38px; flex: 0 0 auto; margin: 0; padding: 9px 14px; color: #70829c; border-top: 1px solid #263650; font: 8px/1.6 var(--mono); text-align: center; }

@media (max-width: 900px) {
  .project-experience { grid-template-columns: 1fr; overflow-y: auto; }
  .project-story { overflow: visible; border-right: 0; border-bottom: 1px solid #263650; }
  .project-story .dialog-actions { flex-flow: row wrap; }
  .project-preview-shell { min-height: 650px; }
}

@media (max-width: 680px) {
  html,
  body { overflow-x: clip; }

  .section-shell {
    width: auto;
    max-width: none;
    margin-inline: 14px;
  }

  .nav-shell {
    left: 7px;
    right: 7px;
    width: auto;
    max-width: none;
    transform: none;
  }

  .nav-shell nav { left: 0; right: 0; width: auto; }
  .hero { display: block; width: auto; max-width: none; }
  .hero-grid { inset-inline: -14px; }
  .hero-copy { width: 100%; }
  .hero .eyebrow { min-width: 0; flex-wrap: wrap; }
  .hero .eyebrow b { min-width: 0; overflow-wrap: anywhere; }
  .hero h1 { letter-spacing: -.035em; }
  [dir="rtl"] .hero h1 { letter-spacing: 0; }
  [dir="rtl"] .hero h1 em { line-height: 1.16; }
  .hero-text { max-width: 100%; }
  .hero-actions,
  .hero-actions .button { width: 100%; }
  .hero-machine { contain: layout paint; overflow: hidden; }
  .ring-a { width: min(88vw, 355px); height: min(88vw, 355px); }
  .ring-b { width: min(71vw, 285px); height: min(71vw, 285px); }
  .ring-c { width: min(54vw, 215px); height: min(54vw, 215px); }
  .signal-strip { width: 100%; max-width: 100%; transform: none; }
  .filters { width: 100%; }
  .filters button { flex: 1 1 auto; }
  .project-grid { width: 100%; }
  .project-card { width: 100%; overflow: hidden; }
  .project-meta { width: 100%; }
  .project-meta > div { min-width: 0; }
  .project-meta p { overflow-wrap: anywhere; }
  .skill-orbit { width: 100%; margin-inline: 0; transform: none; overflow: hidden; }
  .skill-orbit::before { width: min(78vw, 310px); height: min(78vw, 310px); }
  .skill-orbit::after { width: min(56vw, 224px); height: min(56vw, 224px); }
  .skill-node { width: 82px; height: 82px; }
  .node-web,.node-systems { left: calc(50% - 41px); }
  .node-mobile { right: 3px; }
  .node-design { left: 3px; }
  .cap-row { width: 100%; min-width: 0; }
  .cap-row > * { min-width: 0; }
  .cap-row h3,.cap-row p { overflow-wrap: anywhere; }
  .module-bank button { flex: 1 1 calc(33% - 8px); }
  .system-board,.bug-field,.code-lab { width: 100%; }
  .lab-toolbar { height: auto; min-height: 66px; flex-wrap: wrap; gap: 6px; padding-block: 8px; }
  .contact-inner,.contact-email,.contact-bottom,footer > div { min-width: 0; max-width: 100%; }
  .achievement { right: 14px; width: calc(100% - 28px); transform: translate3d(calc(100% + 28px), 0, 0); }
  .achievement.show { transform: translate3d(0, 0, 0); }

  .project-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .project-dialog-head { min-height: 82px; padding: 14px; }
  .project-dialog h2 { font-size: clamp(25px, 8vw, 36px); }
  .project-story { padding: 20px 16px; }
  .project-story #dialogSummary { font-size: 16px; }
  .project-story .dialog-actions { flex-direction: column; }
  .project-preview-shell { min-height: 76dvh; }
  .project-preview-stage { min-height: 58dvh; padding: 8px; }
  .project-preview-stage[data-size="phone"] iframe { width: min(390px, 100%); }
  .preview-controls > span b { display: none; }
  .preview-empty { min-height: 280px; padding: 24px 18px; }
}

@media (max-width: 390px) {
  .section-shell { margin-inline: 10px; }
  .nav-shell { left: 5px; right: 5px; }
  .brand img { width: 86px; }
  .lang-button,.menu-button { width: 34px; min-width: 34px; height: 36px; }
  .hero { padding-top: 92px; }
  .hero h1 { font-size: clamp(36px, 11.5vw, 45px); }
  .hero-text { font-size: 15px; }
  .button { min-height: 54px; padding-inline: 16px; }
  .project-visual { height: 330px; }
  .project-dialog-head .kicker { font-size: 8px; }
  .project-story { padding-inline: 13px; }
  .preview-controls { padding-inline: 8px; }
  .preview-controls button { width: 32px; }
}

@supports not (overflow: clip) {
  html,
  body { overflow-x: hidden; }
}

.contact-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px; }
.whatsapp-inline { border-color: rgba(72, 225, 255, .45); color: #eefbff; background: linear-gradient(135deg, rgba(6,54,232,.25), rgba(0,220,232,.12)); }
.whatsapp-inline .whatsapp-icon { width: 22px; height: 22px; flex: 0 0 auto; }
.whatsapp-float {
  position: fixed;
  z-index: 110;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 15px 8px 9px;
  border: 1px solid rgba(77, 226, 255, .5);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, rgba(6, 54, 232, .96), rgba(0, 176, 212, .96));
  box-shadow: 0 16px 42px rgba(0, 54, 190, .28), 0 0 0 1px rgba(255,255,255,.1) inset;
  backdrop-filter: blur(14px);
  font-size: 12px;
  transition: transform .2s ease, background .2s ease;
}
.whatsapp-float:hover { color: #fff; background: linear-gradient(135deg, #1649ff, #00cfe2); transform: translateY(-3px); }
.whatsapp-icon { fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.whatsapp-float .whatsapp-icon { width: 35px; height: 35px; padding: 7px; display: block; flex: 0 0 auto; border-radius: 50%; background: rgba(255,255,255,.16); }
.whatsapp-float b { white-space: nowrap; }
[dir="rtl"] .whatsapp-float { right: auto; left: max(16px, env(safe-area-inset-left)); padding: 8px 9px 8px 15px; }

@media (max-width: 680px) {
  .whatsapp-float { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); min-height: 48px; padding: 6px; }
  [dir="rtl"] .whatsapp-float { right: auto; left: max(10px, env(safe-area-inset-left)); padding: 6px; }
  .whatsapp-float .whatsapp-icon { width: 36px; height: 36px; }
  .whatsapp-float b { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .contact-actions { flex-direction: column; align-items: stretch; }
  .contact-actions > * { width: 100%; }
}

/* WCAG 2.2 contrast and touch-target hardening. */
[data-theme="dark"] .nav-shell nav a span,
[data-theme="dark"] .lab-v2 .builder-copy > .kicker,
[data-theme="dark"] .lab-v2 .section-heading .kicker,
[data-theme="dark"] .lab-v2 .lab-tabs button[aria-selected="true"] { color: #7f9dff; }
[data-theme="dark"] .lab-v2 .lab-tabs button[aria-selected="true"] { border-color: #7f9dff; }

@media (max-width: 680px) {
  .nav-shell .lang-button,
  .nav-shell .theme-button,
  .nav-shell .menu-button { width: 44px; min-width: 44px; height: 44px; }
  .story-button,
  .archive-down,
  .archive-open,
  .lab-action,
  .module-bank button,
  .builder-actions button,
  .lab-back,
  footer > div > a { min-height: 44px; }
  .lab-back,
  footer > div > a { display: inline-flex; align-items: center; }
  .skip { min-height: 44px; display: inline-flex; align-items: center; }
  .lab-tabs button { min-width: 44px; }
}
