/* ==========================================================================
   Solution Studio
   ========================================================================== */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--gray-500); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

/* Hero */
.studio-hero { padding: 64px 0 52px; }
.studio-hero h1 { max-width: 820px; margin: 0 auto 14px; }
.studio-hero .lede { max-width: 720px; }
.studio-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 28px 0 0;
}
.studio-badges li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(6px);
}
.studio-badges svg { width: 18px; height: 18px; fill: none; stroke: #7df5ff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Layout */
.studio { background: linear-gradient(180deg, #f3f7ff 0%, #ffffff 40%); }
.studio-top {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 28px;
  align-items: start;
}
.studio-panel {
  background: #fff;
  border: 1px solid rgba(10, 31, 61, 0.12);
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 2px 6px rgba(10, 31, 61, 0.05), 0 14px 34px rgba(10, 31, 61, 0.09);
}
.studio-panel h2 { font-size: 1.35rem; display: flex; align-items: center; gap: 12px; margin: 0 0 8px; }
.studio-panel > p { margin: 0 0 16px; }
.step {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 0.9rem;
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
}

/* Form */
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 0.88rem; color: var(--gray-500); }
.chip-btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--navy);
  background: #eef3ff;
  border: 1px solid rgba(18, 53, 102, 0.2);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.chip-btn:hover { background: #dfe9ff; transform: translateY(-1px); }
.studio textarea,
.studio input[type="text"],
.studio select {
  width: 100%;
  font: inherit;
  color: var(--gray-700);
  background: #f7f9fc;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 14px;
}
.studio textarea { resize: vertical; min-height: 190px; line-height: 1.55; }
.studio textarea:focus,
.studio input:focus,
.studio select:focus { outline: 2px solid var(--blue-bright); outline-offset: 1px; background: #fff; }

.drop {
  margin: 14px 0 6px;
  padding: 16px 18px;
  text-align: center;
  border: 2px dashed rgba(18, 53, 102, 0.28);
  border-radius: 14px;
  background: #f7f9fc;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.drop p { margin: 0 0 6px; }
.drop.is-over { background: #e6f1ff; border-color: var(--blue-bright); }
.link-btn { font: inherit; background: none; border: none; color: var(--blue-bright); font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; }
.file-list { margin-top: 10px; text-align: left; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-top: 6px; border-radius: 8px; background: #fff; border: 1px solid var(--gray-200); font-size: 0.88rem; }
.file-name { font-weight: 600; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { margin-left: auto; color: var(--gray-500); font-size: 0.8rem; white-space: nowrap; }
.file-x { border: none; background: none; font-size: 1.3rem; line-height: 1; color: var(--gray-500); cursor: pointer; }
.file-x:hover { color: #c62828; }

.studio-actions { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 18px; }
.scale-label { display: grid; gap: 6px; font-size: 0.82rem; font-weight: 700; color: var(--navy); min-width: 220px; }
.studio-error { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; background: rgba(237, 27, 36, 0.08); color: #a31d1d; font-size: 0.92rem; }

/* Privacy panel */
.studio-safe { position: sticky; top: 92px; background: linear-gradient(165deg, #0b2a8a 0%, #071a5c 70%, #050f3d 100%); color: rgba(255, 255, 255, 0.86); border-color: rgba(125, 245, 255, 0.25); }
.studio-safe h2 { color: #fff; }
.studio-safe h2 svg { width: 24px; height: 24px; fill: none; stroke: #5cf0c8; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.studio-safe dl { margin: 0 0 18px; }
.studio-safe dt { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #7df5ff; margin-top: 14px; }
.studio-safe dd { margin: 4px 0 0; font-size: 0.92rem; }
.studio-safe code { font-family: ui-monospace, Consolas, monospace; background: rgba(255, 255, 255, 0.1); padding: 2px 8px; border-radius: 6px; color: #fff; }
#where.is-saved { color: #ffd9a8; }
#where.is-local { color: #9ff5d8; }
.studio-safe .muted { color: rgba(255, 255, 255, 0.62); }
.studio-safe .btn { width: 100%; justify-content: center; margin-top: 10px; }
.studio-safe .muted.small { margin: 8px 0 0; }
.field-label { display: block; font-size: 0.8rem; font-weight: 700; margin: 14px 0 6px; color: #fff; }
.studio-safe input[type="text"] { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.22); color: #fff; font-size: 0.8rem; font-family: ui-monospace, Consolas, monospace; }
.studio-safe input::placeholder { color: rgba(255, 255, 255, 0.45); }
.copy-row { display: flex; gap: 8px; }
.copy-row .chip-btn { flex: none; }
.btn--outline-dark { background: rgba(255, 255, 255, 0.1); color: #fff; border: 1.5px solid rgba(255, 255, 255, 0.5); }
.btn--outline-dark:hover:not(:disabled) { background: rgba(255, 255, 255, 0.2); }
.btn--outline-dark:disabled, .btn--danger:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--danger { background: linear-gradient(180deg, #e0463f 0%, #c62828 55%, #9d1b1b 100%); color: #fff; border: 1px solid rgba(0, 0, 0, 0.25); box-shadow: 0 6px 16px rgba(157, 27, 27, 0.35); }
.btn--danger:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.modal .btn--outline-dark { background: #fff; color: var(--navy); border-color: var(--gray-200); }

.studio-deleted {
  margin-top: 26px;
  padding: 18px 22px;
  border-radius: 14px;
  background: rgba(39, 201, 63, 0.1);
  border: 1px solid rgba(39, 201, 63, 0.4);
  color: #14561f;
  display: grid;
  gap: 4px;
}

/* Results */
.studio-results { margin-top: 44px; }
.results-head h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 22px 0 18px; border-bottom: 2px solid var(--gray-100); }
.tab {
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 11px 20px;
  background: none;
  border: none;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab:hover { color: var(--navy); }
.tab[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--red); }

.secure-view {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.secure-view h3 { margin: 22px 0 6px; }
.pane-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.pane-head h3 { margin: 22px 0 6px; }

.need-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.need-chip { padding: 7px 14px; border-radius: 999px; font-size: 0.86rem; font-weight: 700; color: #fff; background: linear-gradient(135deg, #1f56c9, #12b9ad); }

.tier-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 14px; }
.tier-card {
  font: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  border-radius: 16px;
  background: #fff;
  border: 2px solid var(--gray-100);
  box-shadow: 0 6px 18px rgba(10, 31, 61, 0.07);
  cursor: pointer;
  color: var(--gray-700);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.tier-card:hover { transform: translateY(-3px); }
.tier-card.is-active { border-color: var(--blue-bright); box-shadow: 0 10px 28px rgba(2, 152, 253, 0.22); }
.tier-card strong { font-size: 1.15rem; color: var(--navy); }
.tier-tag { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--red); }
.tier-stack { font-weight: 600; font-size: 0.9rem; color: var(--navy-light); }
.tier-best { font-size: 0.88rem; }
.tier-card ul { margin: 4px 0 0; padding-left: 18px; list-style: disc; font-size: 0.88rem; }
.tier-card li { margin-bottom: 4px; }
.tier-rec { margin-top: auto; font-size: 0.78rem; font-weight: 700; color: #0a8a4a; }

.questions { margin-top: 12px; padding: 18px 22px; border-radius: 14px; background: #fff7ec; border: 1px solid rgba(254, 131, 9, 0.3); }
.questions h3 { margin-top: 0; }
.questions ul { padding-left: 20px; list-style: disc; }
.questions li { margin-bottom: 6px; }

.tier-switch { display: inline-flex; padding: 4px; border-radius: 999px; background: #eef3ff; border: 1px solid rgba(18, 53, 102, 0.15); }
.tier-switch button { font: inherit; font-size: 0.85rem; font-weight: 700; padding: 7px 16px; border: none; border-radius: 999px; background: none; color: var(--navy); cursor: pointer; }
.tier-switch button[aria-pressed="true"] { background: var(--navy); color: #fff; }

/* Diagram canvas */
.diagram-frame {
  position: relative;
  margin-top: 14px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 80% 0%, rgba(42, 140, 255, 0.28), transparent 55%),
    radial-gradient(ellipse at 0% 100%, rgba(139, 108, 246, 0.2), transparent 55%),
    linear-gradient(160deg, #0b2a8a 0%, #071a5c 55%, #050f3d 100%);
  border: 1px solid rgba(125, 245, 255, 0.3);
  box-shadow: 0 18px 40px rgba(5, 15, 61, 0.35);
}
.diagram-scroll { overflow: auto; padding: 12px; }
.diagram-scroll svg { display: block; max-width: none; margin: 0 auto; }
.diagram-scroll { -webkit-overflow-scrolling: touch; }
.watermark { position: absolute; inset: 0; pointer-events: none; background-repeat: repeat; opacity: 0.07; }

.legend { display: flex; flex-wrap: wrap; gap: 18px; margin: 14px 0 0; font-size: 0.84rem; color: var(--gray-500); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.lg { display: inline-block; width: 22px; height: 0; border-top: 2px solid #12b9ad; }
.lg--lock { height: 12px; width: 12px; border: none; border-radius: 3px; background: #5cf0c8; box-shadow: inset 0 0 0 3px #0b2a8a; }
.lg--dot { height: 10px; width: 10px; border: none; border-radius: 50%; background: #1fb6ee; }
.lg--async { border-top: 2px dashed #ff9f45; }
.lg--ext { height: 12px; width: 20px; border: 2px dashed #ff9f45; border-radius: 4px; }

.sec-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 16px 0; }
.sec-grid > div { padding: 20px 22px; border-radius: 14px; background: #fff; border: 1px solid var(--gray-100); box-shadow: 0 6px 18px rgba(10, 31, 61, 0.06); }
.sec-grid h4 { margin: 0 0 8px; font-size: 1.02rem; }
.sec-grid p { margin: 0; font-size: 0.93rem; }
.sec-grid code, .honest code { font-family: ui-monospace, Consolas, monospace; background: #eef3ff; padding: 1px 6px; border-radius: 5px; }
.honest { padding: 16px 20px; border-radius: 12px; background: #fff7ec; border: 1px solid rgba(254, 131, 9, 0.35); font-size: 0.92rem; }

/* Diagram SVG parts */
.diagram text { font-family: Inter, -apple-system, "Segoe UI", sans-serif; }
.d-col { fill: #9fe9ff; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; text-anchor: middle; }
.d-col-rule { stroke: #2fd6e8; stroke-width: 2; stroke-linecap: round; }
.d-group { fill: rgba(47, 214, 232, 0.05); stroke: rgba(125, 245, 255, 0.4); stroke-width: 1.4; stroke-dasharray: 7 5; }
.d-group--data { fill: rgba(139, 108, 246, 0.08); stroke: rgba(179, 157, 251, 0.55); }
.d-group-label { fill: #9fe9ff; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; }
.d-node { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1.2; }
.d-node--external { fill: rgba(255, 159, 69, 0.08); stroke: #ff9f45; stroke-width: 1.6; stroke-dasharray: 6 4; }
.d-node--decision { fill: #d9731a; stroke: #ffd09a; }
.d-node-top { fill: #a999f5; stroke: rgba(255, 255, 255, 0.4); stroke-width: 1.2; }
.d-label { fill: #fff; font-size: 12.5px; font-weight: 700; text-anchor: middle; }
.d-label--sm { font-size: 12px; }
.d-sub { fill: rgba(255, 255, 255, 0.78); font-size: 10.5px; font-weight: 500; text-anchor: middle; }
.d-edge { fill: none; stroke: rgba(125, 245, 255, 0.55); stroke-width: 1.8; }
.d-edge--secure { stroke: rgba(94, 240, 200, 0.72); }
.d-edge--async, .d-edge--back { stroke: rgba(255, 184, 107, 0.75); stroke-dasharray: 6 5; }
.d-edge--ops { stroke: rgba(31, 184, 159, 0.8); stroke-dasharray: 6 5; }
.d-arrow { fill: #7df5ff; }
.d-arrow--async { fill: #ffb86b; }
.d-dot { fill: #fff; filter: drop-shadow(0 0 4px #7df5ff); }
.d-dot--secure { fill: #5cf0c8; filter: drop-shadow(0 0 4px #5cf0c8); }
.d-chip { fill: #0a1f55; stroke: rgba(125, 245, 255, 0.45); stroke-width: 1; }
.d-edge-label { fill: #d9fbff; font-size: 10.5px; font-weight: 600; text-anchor: middle; }
.d-lock rect { fill: #5cf0c8; }
.d-lock path { stroke: #5cf0c8; stroke-width: 1.6; }
.d-lane--0 { fill: rgba(255, 255, 255, 0.03); }
.d-lane--1 { fill: rgba(255, 255, 255, 0.075); }
.d-lane-head { fill: rgba(47, 214, 232, 0.18); }
.d-lane-label { fill: #fff; font-size: 13px; font-weight: 700; text-anchor: middle; }
.d-badge { fill: #ff9f45; stroke: #071a5c; stroke-width: 2; }
.d-badge-text { fill: #071a5c; font-size: 10px; font-weight: 800; text-anchor: middle; }

/* Modal + privacy shield */
.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: rgba(5, 15, 61, 0.65); backdrop-filter: blur(4px); }
.modal-box { max-width: 460px; padding: 28px; border-radius: 18px; background: #fff; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4); }
.modal-box h3 { margin: 0 0 10px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.shield { position: fixed; inset: 0; z-index: 2000; display: none; place-items: center; text-align: center; padding: 24px; cursor: pointer; color: #fff; font-weight: 700; font-size: 1.1rem; background: rgba(5, 15, 61, 0.86); backdrop-filter: blur(18px); }
body.studio-obscured .shield { display: grid; }
body.studio-obscured .diagram-scroll,
body.studio-obscured .secure-view { visibility: hidden; }

@media print {
  body * { display: none !important; }
  body::before { content: "Printing is disabled for protected content."; display: block !important; padding: 2rem; color: #000; font: 18px sans-serif; }
}

@media (max-width: 960px) {
  .studio-top { grid-template-columns: 1fr; }
  .studio-safe { position: static; }
  .tier-cards, .sec-grid { grid-template-columns: 1fr; }
  .studio-panel { padding: 22px; }
}
