/* CP-5 — Design Studio tab (Vega)
 * Theme-aware: consumes Vega semantic CSS vars only.
 * Follows html[data-theme=light|dark] with zero hardcoded dark panels.
 * RTL library is first in DOM (grid col 1 = right in RTL).
 */

.ds-root {
  min-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: transparent;
}

.ds-body {
  flex: 1;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 0;
  align-content: center;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 720px) {
  .ds-body {
    grid-template-columns: 1fr;
  }
  .ds-side {
    order: -1;
    max-height: 180px;
    border-inline: 0 !important;
    border-bottom: 1px solid var(--line);
  }
}

.ds-side {
  border-inline-end: 1px solid var(--line);
  background: var(--surface);
  padding: 12px 10px;
  overflow: auto;
  max-height: calc(100vh - 140px);
}

.ds-side-h {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 800;
  margin-bottom: 10px;
  text-align: right;
}

.ds-lib-empty {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  padding: 4px 2px;
}

.ds-lib-item {
  width: 100%;
  text-align: right;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  cursor: pointer;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.ds-lib-item:hover,
.ds-lib-item.active {
  border-color: color-mix(in srgb, var(--coral) 45%, var(--line));
  background: color-mix(in srgb, var(--coral-soft) 70%, var(--paper));
  box-shadow: var(--shadow-sm);
}

.ds-lib-p {
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.ds-lib-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 10px;
  color: var(--faint);
  font-weight: 700;
}

.ds-main {
  padding: 12px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.ds-panel {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.ds-panel-h {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
}

.ds-ta {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ds-ta::placeholder {
  color: var(--faint);
}

.ds-ta:focus {
  border-color: color-mix(in srgb, var(--coral) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--coral) 16%, transparent);
}

.ds-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.ds-tone {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ds-tone button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ds-tone button.on {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--on-ink);
}

.ds-go {
  margin-inline-start: auto;
  border: 0;
  background: linear-gradient(135deg, var(--coral), var(--coral2));
  color: var(--on-accent);
  border-radius: 11px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 16px -8px var(--accent-glow);
}

.ds-go:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.ds-meta {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  min-height: 16px;
  word-break: break-all;
}

.ds-empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: right;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
  background: var(--paper-soft);
}

.ds-empty-sub {
  display: block;
  font-size: 11px;
  color: var(--faint);
  margin-top: 2px;
}

.ds-empty.ds-busy {
  text-align: center;
  padding: 18px 14px;
  color: var(--ink);
}

.ds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.ds-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.ds-card-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.ds-card img {
  width: 100%;
  display: block;
  background: var(--surface);
  aspect-ratio: 1;
  object-fit: contain;
}

.ds-card-actions {
  display: flex;
  gap: 8px;
  padding: 8px 10px 10px;
}

.ds-card-actions a {
  flex: 1;
  text-align: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}

.ds-card-actions a:hover {
  border-color: var(--card-hover-line);
  background: var(--paper);
}

.ds-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 800;
  border: 1px solid var(--line2);
  background: var(--surface);
  color: var(--muted);
}

.ds-badge.ok {
  border-color: color-mix(in srgb, var(--green) 35%, var(--line));
  background: color-mix(in srgb, var(--green) 12%, transparent);
  color: var(--green);
}

.ds-badge.low {
  border-color: color-mix(in srgb, var(--amber) 35%, var(--line));
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  color: var(--amber);
}

.ds-badge.bad {
  border-color: color-mix(in srgb, var(--red) 35%, var(--line));
  background: color-mix(in srgb, var(--red) 12%, transparent);
  color: var(--red);
}
