/* StandardCommand Writing Studio - 3-Column Split-Screen Writing & QA Workspace */

.ws-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 84px);
  min-height: 600px;
  background: var(--color-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(38, 48, 68, 0.05);
}

/* Studio Header Bar */
.ws-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: #fafbfd;
  border-bottom: 1px solid var(--line);
  gap: var(--space-2);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.ws-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
}

.ws-header-title-box {
  min-width: 0;
}

.ws-header-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.ws-header-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: 2px;
}

.ws-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Responsive View Switcher for Narrow Screens */
.ws-view-switcher {
  display: none;
  background: var(--color-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.ws-view-switcher button {
  padding: 4px 10px;
  font-size: 11.5px;
  border: none;
  background: transparent;
  border-radius: 4px;
  min-height: 24px;
}

.ws-view-switcher button.active {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Main 3-Column Split Layout */
.ws-body {
  display: grid;
  grid-template-columns: 290px minmax(400px, 1fr) 370px;
  flex: 1;
  min-height: 0;
  background: var(--color-surface);
}

/* Column 1: Outline Navigator */
.ws-col-outline {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fcfdfe;
  min-height: 0;
  overflow: hidden;
}

.ws-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  flex-shrink: 0;
}

.ws-outline-summary {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--hairline);
  background: #fff;
  font-size: 11px;
}

.ws-progress-track {
  width: 100%;
  height: 6px;
  background: var(--hairline);
  border-radius: 3px;
  overflow: hidden;
  margin: var(--space-1) 0;
}

.ws-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.ws-outline-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-1);
  margin: 0;
  list-style: none;
}

.ws-outline-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s ease;
  background: #fff;
}

.ws-outline-item:hover {
  background: var(--color-subtle);
  border-color: var(--line);
}

.ws-outline-item.active {
  background: #edf3fa;
  border-color: #c7d8ed;
}

.ws-sec-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
  background: #cbd5e1;
}

.ws-sec-status-dot.pass {
  background: var(--ok-text);
  box-shadow: 0 0 0 2px var(--ok-bg);
}

.ws-sec-status-dot.warn {
  background: var(--warn-text);
  box-shadow: 0 0 0 2px var(--warn-bg);
}

.ws-sec-status-dot.fail {
  background: var(--danger);
  box-shadow: 0 0 0 2px #fde8e8;
}

.ws-sec-info {
  flex: 1;
  min-width: 0;
}

.ws-sec-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.35;
  margin-bottom: 3px;
  word-break: break-word;
}

.ws-sec-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 10.5px;
}

.ws-tag-format {
  font-family: monospace;
  background: #f1f5f9;
  color: #475569;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

.ws-tag-words {
  color: var(--muted);
}

/* Column 2: Active Section Drafter */
.ws-col-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border-right: 1px solid var(--line);
}

.ws-editor-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Archetype Guidance Card */
.ws-archetype-card {
  background: #f7f9fd;
  border: 1px solid #dce4f0;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 12px;
}

.ws-arch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.ws-arch-code {
  font-family: monospace;
  font-weight: 700;
  color: var(--accent);
  font-size: 11px;
}

.ws-arch-reqs {
  display: flex;
  gap: var(--space-2);
  font-size: 11px;
  color: var(--muted);
}

.ws-arch-desc {
  margin: 0;
  color: var(--color-text);
  line-height: 1.4;
}

/* Live Section Metrics Bar */
.ws-section-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: #fafbfd;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.ws-meter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ws-meter-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.ws-meter-val {
  font-family: monospace;
  font-weight: 700;
  font-size: 12.5px;
}

.ws-meter-val.good {
  color: var(--ok-text);
}

.ws-meter-val.warn {
  color: var(--warn-text);
}

.ws-meter-val.bad {
  color: var(--danger);
}

/* OpenCode Dispatch Toolbar */
.ws-dispatch-box {
  background: #f4f6fa;
  border: 1px solid #e1e6ef;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ws-dispatch-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.ws-dispatch-row select {
  font-size: 11.5px;
  padding: 4px 8px;
  min-height: 28px;
  flex: 1;
  min-width: 160px;
}

.ws-btn-generate {
  background: #2563eb;
  border: 1px solid #1d4ed8;
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  min-height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.ws-btn-generate:hover {
  background: #1d4ed8;
}

.ws-btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Editor Form Fields */
.ws-field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ws-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--color-text);
}

.ws-field-tip {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
}

.ws-h2-input {
  font-size: 14px;
  font-weight: 700;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  width: 100%;
}

.ws-lead-input {
  font-size: 12.5px;
  line-height: 1.45;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  width: 100%;
  resize: vertical;
  min-height: 60px;
}

.ws-body-input {
  font-family: var(--font-body);
  font-size: 12.5px;
  line-height: 1.55;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  width: 100%;
  resize: vertical;
  min-height: 220px;
}

.ws-editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--line);
  background: #fafbfd;
  flex-shrink: 0;
}

/* Column 3: Inspector (QA Scoreboard & Live Preview) */
.ws-col-inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fafbfd;
}

.ws-tab-nav {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: #f1f4f9;
  flex-shrink: 0;
}

.ws-tab-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  border-bottom: 2px solid transparent;
  transition: all 0.12s ease;
}

.ws-tab-btn.active {
  background: #fff;
  color: var(--color-text);
  border-bottom-color: var(--accent);
}

.ws-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  min-height: 0;
}

/* 10-Point QA Scoreboard */
.ws-score-hero {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ws-score-digits {
  font-size: 20px;
  font-weight: 800;
  color: var(--color-text);
  font-family: monospace;
}

.ws-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ws-chip.pass {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.ws-chip.fail {
  background: #fde8e8;
  color: var(--danger);
}

.ws-chip.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.ws-qa-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-3);
}

.ws-qa-check-item {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.12s ease;
}

.ws-qa-check-item.failing {
  border-color: #fca5a5;
  background: #fffafa;
}

.ws-qa-check-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
}

.ws-qa-rule-name {
  font-weight: 600;
  color: var(--color-text);
}

.ws-qa-reason {
  font-size: 10.5px;
  color: var(--danger);
  line-height: 1.35;
}

.ws-qa-facts-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 10.5px;
  color: #166534;
  margin-top: 4px;
}

.ws-qa-facts-title {
  font-weight: 700;
  margin-bottom: 2px;
}

/* Auto-fix Quick Button */
.ws-autofix-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 11.5px;
}

/* Live Nappedia Reader Preview */
.ws-preview-frame {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  font-size: 13px;
  line-height: 1.6;
  color: #24292f;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.ws-preview-frame h2 {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
  margin-top: 0;
  margin-bottom: 12px;
}

.ws-preview-frame .lead {
  font-size: 14px;
  font-weight: 500;
  color: #334155;
  margin-bottom: 14px;
  line-height: 1.5;
}

.ws-preview-frame p {
  margin-bottom: 12px;
}

.ws-preview-frame table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 12px;
}

.ws-preview-frame th, .ws-preview-frame td {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  text-align: left;
}

.ws-preview-frame th {
  background: #f8fafc;
  font-weight: 600;
}

.ws-preview-frame .emdash-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 700;
}

/* Intake / Create Templated Modal */
.ws-intake-dialog {
  max-width: 680px;
  width: calc(100% - 32px);
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.ws-tpl-select-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.ws-tpl-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  background: #fff;
  transition: all 0.12s ease;
}

.ws-tpl-card:hover {
  border-color: var(--accent);
  background: #f8fafc;
}

.ws-tpl-card.selected {
  border-color: var(--accent);
  background: #eff6ff;
  box-shadow: 0 0 0 1px var(--accent);
}

.ws-tpl-card-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--color-text);
  margin-bottom: 2px;
}

.ws-tpl-card-meta {
  font-size: 10.5px;
  color: var(--muted);
}

.ws-outline-preview-box {
  background: #f8fafc;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  max-height: 180px;
  overflow-y: auto;
  font-size: 11px;
  margin-top: var(--space-2);
}

.ws-outline-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid #edf2f7;
}

/* Responsive Media Queries */
@media (max-width: 1080px) {
  .ws-view-switcher {
    display: flex;
  }
  .ws-body {
    display: block;
    position: relative;
  }
  .ws-col-outline, .ws-col-editor, .ws-col-inspector {
    display: none;
    height: 100%;
    border-right: none;
  }
  .ws-body[data-active-pane="outline"] .ws-col-outline {
    display: flex;
  }
  .ws-body[data-active-pane="editor"] .ws-col-editor {
    display: flex;
  }
  .ws-body[data-active-pane="qa"] .ws-col-inspector {
    display: flex;
  }
}

@media (max-width: 600px) {
  .ws-header {
    flex-direction: column;
    align-items: stretch;
  }
  .ws-tpl-select-grid {
    grid-template-columns: 1fr;
  }
}
