:root {
  color-scheme: light;
  --surface: #ffffff;
  --surface-2: #f5f9f8;
  --surface-3: #eef5f3;
  --ink: #172523;
  --ink-2: #415653;
  --muted: #6e817e;
  --line: #cbd9d6;
  --line-2: #e1eae8;
  --accent: #08726c;
  --accent-strong: #075b57;
  --accent-soft: #dcefeb;
  --shadow: 0 18px 52px rgba(16, 34, 59, .11);
  --sans: Inter, "Segoe UI", Arial, sans-serif;
  --arabic: "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(242, 39, 139, .06), transparent 28rem),
    radial-gradient(circle at 88% 100%, rgba(255, 190, 83, .08), transparent 32rem),
    #edf3f1;
  font-family: var(--arabic);
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1880px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.ontology-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 108px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(110deg, #fff 0%, #fbfdfd 72%, #f1f8f6 100%);
}

.title-block {
  min-width: 270px;
}

.label {
  display: block;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .02em;
}

h1 {
  margin: 0;
  font-size: clamp(1.2rem, 1.8vw, 1.8rem);
  line-height: 1.35;
}

.brand-and-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  direction: ltr;
}

.pyra-logo {
  width: 104px;
  height: 64px;
  object-fit: contain;
  flex: 0 0 auto;
}

.small-btn,
.primary {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-2);
  background: var(--surface);
  font-size: .76rem;
  font-weight: 750;
  transition: border-color .18s ease, color .18s ease, background .18s ease, transform .18s ease;
}

.small-btn:hover,
.small-btn:focus-visible,
.primary:hover,
.primary:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.small-btn:active,
.primary:active {
  transform: translateY(1px);
}

.icon-btn {
  width: 34px;
  padding: 0;
  font: 800 1rem/1 var(--sans);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: .72rem;
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
}

.gesture-help {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 2;
  max-width: calc(100% - 24px);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 5px 16px rgba(16, 34, 59, .06);
  font-size: .69rem;
  backdrop-filter: blur(8px);
}

.plan-graph-stage {
  height: clamp(540px, calc(100vh - 220px), 760px);
}

.plan-semantic-layout {
  min-height: 0;
}

.plan-graph-inspector {
  overflow: auto;
  max-height: calc(100vh - 128px);
}

.plan-mode-btn,
.plan-language-switch button,
.plan-relation-btn {
  font-family: inherit;
}

.plan-mode-switch {
  direction: rtl;
}

#plan-semantic-graph[dir="ltr"] .plan-mode-switch {
  direction: ltr;
}

#plan-semantic-graph[dir="rtl"] .plan-layer-note {
  border-right: 3px solid var(--accent);
  border-left: 0;
}

#plan-semantic-graph[dir="rtl"] .gesture-help {
  right: auto;
  left: 12px;
}

@media (max-width: 1180px) {
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-and-controls {
    justify-content: space-between;
    width: 100%;
  }

  .plan-graph-inspector {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .page-shell {
    padding: 8px;
  }

  .ontology-card {
    border-radius: 12px;
  }

  .panel-head {
    gap: 14px;
    padding: 15px;
  }

  .brand-and-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .pyra-logo {
    align-self: flex-start;
    width: 90px;
    height: 54px;
  }

  .plan-mode-switch {
    grid-template-columns: 1fr 1fr;
  }

  .plan-mode-btn {
    min-width: 0;
    padding-inline: 8px;
  }

  .plan-graph-stage {
    height: 560px;
  }

  .plan-graph-toolbar {
    padding: 9px;
  }

  .gesture-help {
    display: none;
  }
}

html:not(.passkey-open) .page-shell {
  display: none;
}

html.passkey-open .passkey-gate {
  display: none;
}

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

.passkey-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 24px;
  background: radial-gradient(ellipse at 30% 20%, #041934 0%, #000d19 50%, #000204 100%);
  font-family: "Source Sans 3", Inter, "Segoe UI", sans-serif;
}

.passkey-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
}

.passkey-gate.is-visible .passkey-field {
  opacity: 0.4;
}

.passkey-ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: passkey-spin 28s linear infinite;
}

.passkey-ring-2 {
  animation-duration: 40s;
  animation-direction: reverse;
}

.passkey-ring-3 {
  animation-duration: 52s;
}

.passkey-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 28rem;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(.2, .9, .3, 1);
}

.passkey-gate.is-visible .passkey-panel {
  opacity: 1;
  transform: translateY(0);
}

.passkey-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  filter: drop-shadow(0 0 28px rgba(3, 163, 207, 0.25));
}

.passkey-mark {
  display: block;
  width: 58px;
  height: 88px;
  overflow: hidden;
}

.passkey-mark img {
  display: block;
  width: auto;
  max-width: none;
  height: 88px;
}

.passkey-word {
  color: #f3f3f4;
  font-size: 52px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
}

.passkey-product {
  margin: 32px 0 0;
  color: #94a3b8;
  font-size: 14px;
  letter-spacing: 0.025em;
  text-align: center;
}

.passkey-form {
  width: 100%;
  margin-top: 40px;
}

.passkey-form.is-shake {
  animation: passkey-shake 0.4s ease;
}

.passkey-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.passkey-row input {
  min-width: 0;
  flex: 1;
  padding: 12px 16px;
  border: 1px solid rgba(125, 140, 155, 0.2);
  border-radius: 2px;
  outline: none;
  background: rgba(0, 8, 20, 0.6);
  color: #f3f3f4;
  font: inherit;
  font-size: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.passkey-row input::placeholder {
  color: #64748b;
}

.passkey-row input:focus {
  border-color: #03a3cf;
  box-shadow: 0 0 0 1px rgba(3, 163, 207, 0.33);
}

.passkey-form.is-error .passkey-row input {
  border-color: #de001b;
  box-shadow: 0 0 0 1px rgba(222, 0, 27, 0.25);
}

.passkey-row button {
  flex-shrink: 0;
  padding: 12px 24px;
  border: 0;
  border-radius: 2px;
  background: #03a3cf;
  color: #041934;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.025em;
}

.passkey-row button:hover {
  opacity: 0.9;
}

.passkey-row button:active {
  opacity: 0.8;
}

.passkey-error {
  min-height: 1.25rem;
  margin: 12px 0 0;
  color: #de001b;
  font-size: 14px;
  text-align: center;
  opacity: 0;
}

.passkey-form.is-error .passkey-error {
  opacity: 1;
}

@media (min-width: 640px) {
  .passkey-mark {
    width: 72px;
    height: 110px;
  }

  .passkey-mark img {
    height: 110px;
  }

  .passkey-word {
    font-size: 64px;
  }

  .passkey-row {
    flex-direction: row;
    align-items: stretch;
  }
}

@keyframes passkey-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes passkey-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
