/* osir Design Studio. Plain CSS, light by default, dark via [data-theme="dark"] tokens from site.css. */
.ds-wrap { max-width: 1720px; margin: 0 auto; padding: 0 16px; }
.ds-app {
  position: relative; display: flex; flex-direction: column; height: calc(100dvh - var(--header-h) - 28px); min-height: 560px;
  border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface-solid); overflow: hidden; box-shadow: var(--shadow);
}
html.ds-full, html.ds-full body { overflow: hidden; }
html.ds-full .ds-app { position: fixed; inset: 0; z-index: 300; height: 100dvh; min-height: 0; border: 0; border-radius: 0; }
.ds-noscript { padding: 40px 20px; text-align: center; }

/* Top bar */
.ds-top { display: flex; align-items: center; gap: 3px; padding: 6px 8px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; flex: none; }
.ds-b {
  height: 32px; min-width: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; white-space: nowrap; flex: none;
}
.ds-b:hover:not(:disabled) { background: var(--surface-2); }
.ds-b:disabled { opacity: .35; cursor: default; }
.ds-b:focus-visible, .ds-mini:focus-visible, .ds-tile:focus-visible { outline: 2px solid var(--brand-1); outline-offset: 1px; }
.ds-b.is-on { background: color-mix(in srgb, var(--brand-1) 14%, transparent); color: var(--link); border-color: color-mix(in srgb, var(--brand-1) 38%, transparent); }
.ds-b svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ds-b.ds-primary { background: var(--grad); color: #fff; font-weight: 650; padding: 0 12px; }
.ds-b.ds-primary:hover { filter: brightness(1.06); background: var(--grad); }
.ds-sep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 4px; flex: none; }
.ds-grow { flex: 1 1 auto; min-width: 8px; }
.ds-name { height: 32px; width: 220px; min-width: 120px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text); font-weight: 700; font-size: 14px; padding: 0 8px; flex: 0 1 auto; }
.ds-name:hover, .ds-name:focus { border-color: var(--border-strong); background: var(--surface-solid); outline: none; }
.ds-saved { font-size: 12px; color: var(--muted); white-space: nowrap; flex: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.ds-saved.is-error, .ds-saved.is-memory { color: #b91c1c; }
.ds-saved.is-synced { color: #15803d; }
:root[data-theme="dark"] .ds-saved.is-error, :root[data-theme="dark"] .ds-saved.is-memory { color: #fca5a5; }
:root[data-theme="dark"] .ds-saved.is-synced { color: #86efac; }
.ds-zoom { min-width: 54px; font-variant-numeric: tabular-nums; }
.ds-mob { display: none; }
.ds-top > span[data-rw], .ds-top > span[data-ro] { display: inline-flex; gap: 3px; flex: none; align-items: center; }
.ds-top > span[hidden] { display: none; }

/* Body */
.ds-body { position: relative; flex: 1; display: grid; grid-template-columns: 50px 236px minmax(0, 1fr) 300px; min-height: 0; }
.ds-tools { border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; overflow-y: auto; scrollbar-width: none; }
.ds-tools .ds-b { width: 40px; height: 38px; padding: 0; }
.ds-tools hr { width: 26px; border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

.ds-lib { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface-solid); }
.ds-libhead { padding: 8px; display: grid; gap: 6px; border-bottom: 1px solid var(--border); }
.ds-libhead .t-input, .ds-libhead .t-select { height: 34px; font-size: 13px; padding: 4px 10px; }
.ds-libgrid { overflow-y: auto; padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; align-content: start; flex: 1; }
.ds-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding: 6px 3px 5px; border: 1px solid var(--border-strong);
  border-radius: 10px; cursor: grab; min-height: 78px; font: inherit; transition: border-color .15s, transform .15s;
}
.ds-tile:hover { border-color: var(--brand-1); transform: translateY(-1px); }
.ds-tile svg { width: 100%; height: 44px; pointer-events: none; }
.ds-tile-n { font-size: 10.5px; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.ds-libgrid .ds-muted { grid-column: 1 / -1; }

.ds-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.ds-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; }
.ds-svg:focus-visible { box-shadow: inset 0 0 0 2px var(--brand-1); }
.ds-svg .ds-h { cursor: pointer; }
.ds-svg .ds-h-n, .ds-svg .ds-h-s { cursor: ns-resize; }
.ds-svg .ds-h-e, .ds-svg .ds-h-w { cursor: ew-resize; }
.ds-svg .ds-h-nw, .ds-svg .ds-h-se { cursor: nwse-resize; }
.ds-svg .ds-h-ne, .ds-svg .ds-h-sw { cursor: nesw-resize; }
.ds-svg .ds-h-rot { cursor: grab; }
.ds-svg .ds-port { cursor: crosshair; }
.ds-toolopts { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; pointer-events: none; z-index: 3; }
.ds-toolopts > * { pointer-events: auto; }
.ds-sel { height: 30px; font-size: 13px; padding: 0 28px 0 8px; width: auto; max-width: 220px; }
.ds-optl { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; background: color-mix(in srgb, var(--surface-solid) 94%, transparent); border: 1px solid var(--border); border-radius: 9px; padding: 2px 2px 2px 8px; color: var(--text-2); }
.ds-drawbtns { display: inline-flex; gap: 6px; }
.ds-drawbtns .btn { height: 30px; }
.ds-hint { font-size: 12.5px; background: color-mix(in srgb, var(--surface-solid) 94%, transparent); padding: 5px 10px; border-radius: 9px; border: 1px solid var(--border); color: var(--text-2); }
.ds-status { position: absolute; right: 8px; bottom: 8px; font-size: 12px; color: var(--text-2); background: color-mix(in srgb, var(--surface-solid) 90%, transparent); border: 1px solid var(--border); padding: 3px 9px; border-radius: 8px; font-variant-numeric: tabular-nums; pointer-events: none; z-index: 3; max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-banner { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 4; display: flex; gap: 8px; align-items: center; background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 12px; padding: 6px 8px 6px 12px; box-shadow: var(--shadow); font-size: 13px; max-width: calc(100% - 16px); flex-wrap: wrap; }
.ds-edit { position: absolute; z-index: 6; resize: none; border: 2px solid var(--brand-1); border-radius: 6px; padding: 4px 6px; background: #fff; color: #111827; font-family: inherit; line-height: 1.25; box-shadow: var(--shadow-lg); }

/* Analysis panel */
.ds-analysis { position: absolute; left: 8px; bottom: 8px; z-index: 4; width: min(470px, calc(100% - 16px)); max-height: 46%; overflow: auto; background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow-lg); font-size: 13px; }
.ds-ana-sec + .ds-ana-sec { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.ds-ana-h { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.ds-ana-h strong { margin-right: auto; }
.ds-ana-stat { margin: 6px 0 2px; font-weight: 600; }
.ds-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-2); }
.ds-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ds-legend i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; opacity: .85; }

/* Side panel */
.ds-side { border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface-solid); }
.ds-tabs { display: flex; border-bottom: 1px solid var(--border); flex: none; }
.ds-tabs button { flex: 1; height: 38px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.ds-tabs button.is-on { color: var(--link); border-bottom-color: var(--brand-1); }
.ds-sidebody { overflow-y: auto; padding: 4px 12px 24px; font-size: 13px; flex: 1; }
.ds-sec { padding: 8px 0 10px; border-bottom: 1px solid var(--border); }
.ds-sec:last-child { border-bottom: 0; }
.ds-sec h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 8px; font-weight: 700; }
.ds-f { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px; align-items: center; margin: 6px 0; }
.ds-f.is-wide { grid-template-columns: 1fr; gap: 4px; }
.ds-f > span { color: var(--text-2); font-size: 12.5px; }
.ds-f .t-input, .ds-f .t-select { height: 32px; font-size: 13px; padding: 4px 8px; min-width: 0; width: 100%; }
.ds-f .t-textarea { font-size: 13px; padding: 6px 8px; min-height: 0; width: 100%; resize: vertical; }
.ds-f input[type="checkbox"] { width: 18px; height: 18px; justify-self: start; accent-color: var(--brand-1); }
.ds-f input[type="range"] { width: 100%; accent-color: var(--brand-1); }
.ds-grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.ds-grid4 .ds-f { grid-template-columns: auto minmax(0, 1fr); }
.ds-mini { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text); cursor: pointer; white-space: nowrap; }
.ds-mini:hover { border-color: var(--brand-1); }
.ds-mini.is-on { background: color-mix(in srgb, var(--brand-1) 14%, transparent); color: var(--link); border-color: color-mix(in srgb, var(--brand-1) 40%, transparent); }
.ds-danger { color: #b91c1c !important; }
:root[data-theme="dark"] .ds-danger { color: #fca5a5 !important; }
.ds-btnrow, .ds-actbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.ds-actbar { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.ds-col { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.ds-col input[type="color"] { width: 34px; height: 28px; padding: 0 2px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-solid); cursor: pointer; }
.ds-muted { color: var(--muted); font-size: 12.5px; margin: 6px 0; line-height: 1.45; }
.ds-bad { color: #b91c1c; font-weight: 600; margin: 6px 0; }
.ds-good { color: #15803d; font-weight: 600; margin: 6px 0; }
:root[data-theme="dark"] .ds-bad { color: #fca5a5; }
:root[data-theme="dark"] .ds-good { color: #86efac; }
.ds-list { list-style: disc; padding-left: 20px; margin: 8px 0; display: grid; gap: 4px; }
.ds-checks { display: grid; gap: 4px; margin: 6px 0; }
.ds-checks li { border-left: 3px solid var(--border-strong); border-radius: 6px; background: var(--surface-2); }
.ds-checks li.is-bad { border-left-color: #dc2626; }
.ds-checks li.is-warn { border-left-color: #d97706; }
.ds-checks li.is-info { border-left-color: #2563eb; }
.ds-checks li.is-ok { border-left-color: #16a34a; }
.ds-check-b { display: block; width: 100%; text-align: left; background: none; border: 0; color: inherit; font: inherit; font-size: 12.5px; line-height: 1.4; cursor: pointer; padding: 6px 8px; }
.ds-check-b:disabled { cursor: default; }
.ds-layers { display: grid; gap: 4px; }
.ds-layers li { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; border-radius: 8px; border: 1px solid var(--border); }
.ds-layers li.is-active { border-color: color-mix(in srgb, var(--brand-1) 50%, transparent); background: color-mix(in srgb, var(--brand-1) 8%, transparent); }
.ds-layer-n { flex: 1 1 100%; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-weight: 650; cursor: pointer; padding: 2px; }
.ds-outline { display: grid; max-height: 320px; overflow: auto; }
.ds-out-i { width: 100%; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-size: 12.5px; padding: 4px 6px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-out-i:hover { background: var(--surface-2); }
.ds-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ds-tbl th, .ds-tbl td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ds-tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ds-tbl thead th { color: var(--muted); font-weight: 650; font-size: 11.5px; }
.ds-tbl tfoot th, .ds-tbl tfoot td { font-weight: 700; border-bottom: 0; }

/* Menus and dialogs */
.ds-pop { position: fixed; z-index: 500; background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 240px; max-height: 80vh; overflow: auto; }
.ds-pop-i { display: flex; justify-content: space-between; gap: 16px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; background: none; border: 0; color: var(--text); font-size: 13.5px; cursor: pointer; }
.ds-pop-i:hover, .ds-pop-i:focus-visible { background: var(--surface-2); outline: none; }
.ds-pop-i:disabled { opacity: .4; cursor: default; }
.ds-pop-i kbd { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.ds-pop-h { font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 6px 10px 2px; letter-spacing: .06em; font-weight: 700; }
.ds-pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.ds-dlg { border: 1px solid var(--border-strong); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-lg); }
.ds-dlg.is-wide { width: min(920px, calc(100vw - 24px)); }
.ds-dlg::backdrop { background: rgba(8, 12, 28, .5); }
.ds-dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.ds-dlg-title { font-size: 17px; font-weight: 750; margin: 0; }
.ds-dlg-x { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border-strong); background: none; color: var(--text); cursor: pointer; font-size: 18px; line-height: 1; }
.ds-dlg-body { padding: 14px 18px 20px; max-height: min(78vh, 760px); overflow: auto; font-size: 14px; }
.ds-dlg-body > p { margin: 0 0 10px; }
.ds-dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ds-check { display: flex; gap: 8px; align-items: center; margin: 10px 0; font-size: 13.5px; }
.ds-check input { width: 18px; height: 18px; accent-color: var(--brand-1); }
.ds-form { display: grid; gap: 10px; }
.ds-inline { display: flex; gap: 8px; }
.ds-inline .t-input { flex: 1; }
.ds-inline .t-select { width: 90px; }
.ds-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.ds-tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-solid); color: var(--text); cursor: pointer; font: inherit; }
.ds-tpl:hover, .ds-tpl:focus-visible { border-color: var(--brand-1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 18%, transparent); outline: none; }
.ds-tpl strong { font-size: 14.5px; }
.ds-tpl-cat { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--link); font-weight: 700; }
.ds-tpl-d { font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.ds-designs { display: grid; gap: 6px; margin-top: 10px; }
.ds-designs li { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.ds-designs li.is-cur { border-color: color-mix(in srgb, var(--brand-1) 50%, transparent); }
.ds-d-info { display: grid; min-width: 0; }
.ds-d-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-d-act { display: flex; gap: 6px; }
.ds-share { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 16px; align-items: start; }
.ds-link { margin-bottom: 12px; }
.ds-link-l { font-weight: 650; font-size: 13px; display: block; margin-bottom: 4px; }
.ds-link-r { display: flex; gap: 6px; }
.ds-link-r .t-input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; height: 36px; }
.ds-qrw { display: grid; gap: 4px; justify-items: center; }
.ds-qr { width: 150px; height: 150px; border-radius: 8px; }
.ds-keys { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 10px; }
.ds-keys th, .ds-keys td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ds-keys th { white-space: nowrap; width: 38%; }
.ds-keys kbd, .tool-info kbd { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 5px; padding: 1px 6px; }

/* Read-only shared view */
.ds-readonly .ds-tools [data-tool]:not([data-tool="select"]):not([data-tool="pan"]), .ds-readonly .ds-tools hr { display: none; }
.ds-readonly .ds-lib { display: none; }
.ds-readonly .ds-body { grid-template-columns: 50px minmax(0, 1fr) 300px; }

/* Printing */
.ds-print { display: none; }
@media print {
  html.ds-printing body > *:not(.ds-print) { display: none !important; }
  html.ds-printing body { background: #fff; }
  html.ds-printing .ds-print { display: block; color: #000; font: 12px/1.4 system-ui, sans-serif; }
  .ds-print h1 { font-size: 20px; margin: 0 0 4px; }
  .ds-print p { margin: 0 0 10px; color: #444; }
  .ds-print img { display: block; max-width: 100%; max-height: 82vh; margin: 0 auto 14px; }
  .ds-print .ds-tbl { page-break-inside: auto; }
  .ds-print .ds-tbl th, .ds-print .ds-tbl td { border-bottom: 1px solid #ccc; }
}

/* Info below the editor */
.ds-steps { list-style: decimal; padding-left: 22px; display: grid; gap: 8px; margin: 12px 0 14px; color: var(--text-2); }
.ds-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.ds-info-grid .t-card h3 { font-size: 16px; margin-bottom: 6px; }
.ds-info-grid .t-card p, .ds-info-grid .t-card li { font-size: 14.5px; color: var(--text-2); }
.ds-info-grid .t-card ul { list-style: disc; padding-left: 20px; display: grid; gap: 4px; }

/* Narrow screens: library and panel become drawers */
@media (max-width: 1180px) {
  .ds-body { grid-template-columns: 50px 210px minmax(0, 1fr) 260px; }
}
@media (max-width: 960px) {
  .ds-app { height: calc(100dvh - var(--header-h) - 16px); border-radius: 12px; }
  .ds-wrap { padding: 0 8px; }
  .ds-body, .ds-readonly .ds-body { grid-template-columns: 46px minmax(0, 1fr); }
  .ds-mob { display: inline-flex; }
  .ds-lib, .ds-side { position: absolute; top: 0; bottom: 0; z-index: 20; width: min(320px, 88%); box-shadow: var(--shadow-lg); display: none; }
  .ds-lib { left: 46px; }
  .ds-side { right: 0; }
  .ds-app.show-lib .ds-lib, .ds-app.show-side .ds-side { display: flex; }
  .ds-readonly.show-lib .ds-lib { display: none; }
  .ds-name { width: 140px; }
  .ds-saved { display: none; }
  .ds-tools .ds-b { width: 38px; height: 36px; }
}
@media (max-width: 560px) {
  .ds-txt { display: none; }
  .ds-top [data-act="zin"], .ds-top [data-act="zout"], .ds-top [data-act="grid"], .ds-top [data-act="snap"], .ds-top [data-act="cones"], .ds-top .ds-sep { display: none; }
  .ds-name { width: 110px; min-width: 80px; }
  .ds-top { flex-wrap: wrap; overflow: visible; row-gap: 2px; }
  .ds-grow { display: none; }
  .ds-name { flex: 1 1 90px; }
  .ds-optl > span { display: none; }
  .ds-share { grid-template-columns: 1fr; }
  .ds-analysis { max-height: 38%; }
}
