/* Exercise workspace (js/pages/workspace.js).
   Split view: learning material on the left, editor and results on the right.
   Extends css/app.css; no new tokens. */

.page-workspace { max-width: 1600px; padding-top: 16px; }
.page-workspace .ws-back { margin-bottom: 6px; }
.page-workspace .page-header { margin-bottom: 14px; }
.ws-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; font-size: 13px; color: var(--text-2); }
.ws-meta-item + .ws-meta-item::before { content: "\00B7"; margin-right: 10px; color: var(--text-3); }
.ws-preview-notice { margin: -4px 0 14px; }

/* ---------- Split ---------- */
.ws-split { display: grid; grid-template-columns: minmax(0, 44fr) minmax(0, 56fr); gap: 16px; align-items: start; }
.ws-left, .ws-right { min-width: 0; }
.ws-panel-tabs { padding: 0 12px; }
.ws-panel-scroll { max-height: calc(100vh - 200px); overflow-y: auto; padding: 4px 18px 18px; }
.ws-panel-scroll:focus-visible { outline-offset: -2px; }
.ws-tab-panel { padding-top: 12px; }

/* ---------- Sections inside the learning material ---------- */
.ws-sec { margin-bottom: 22px; }
.ws-sec:last-child { margin-bottom: 0; }
.ws-sec-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); margin-bottom: 8px; }
.ws-objective { margin: 0; font-size: 14.5px; }
.ws-sub { margin-bottom: 10px; }
.ws-sub:last-child { margin-bottom: 0; }
.ws-sub-title { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.ws-list { margin: 0; padding-left: 20px; }
.ws-list li { margin-bottom: 4px; }
.ws-rule { font-size: 13px; color: var(--text-2); margin: 8px 0 0; }

/* Worked examples */
.ws-example { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: var(--surface-2); }
.ws-example:last-child { margin-bottom: 0; }
.ws-example-title { font-size: 13.5px; margin-bottom: 8px; }
.ws-example-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.ws-io-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-3); margin-bottom: 4px; }
.ws-example pre.code { background: var(--surface); }
.ws-example-note { margin: 8px 0 0; font-size: 13px; color: var(--text-2); }

/* Learn tab */
.ws-lesson { margin-bottom: 22px; }
.ws-bridge { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.ws-bridge pre.code { height: 100%; }
.ws-bridge-php pre.code-text { background: var(--code-bg); color: var(--code-text); border: 0; white-space: pre; word-break: normal; }
.ws-bridge .code-wrap { display: flex; flex-direction: column; height: 100%; }
.ws-bridge .code-wrap pre.code { flex: 1 1 auto; border-radius: 0 0 var(--radius) var(--radius); }
.ws-bridge-note { margin-bottom: 10px; }
.ws-bridge-note:last-child { margin-bottom: 0; }
.ws-bridge-note h4 { font-size: 13.5px; margin-bottom: 3px; }
.ws-bridge-note p { margin: 0; color: var(--text-2); }
.ws-learn-actions { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

/* Hints */
.ws-hint { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--surface); }
.ws-hint-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; }
.ws-hint-label { font-weight: 500; }
.ws-hint-body { padding: 10px 12px 10px; border-top: 1px solid var(--border); }
.ws-hints-note { margin: 4px 0 0; }

/* Question threads */
.ws-threads-empty { margin: 0 0 4px; }
.ws-thread { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--surface); }
.ws-thread-toggle { display: flex; width: 100%; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 12px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--text); border-radius: var(--radius); }
.ws-thread-toggle:hover { background: var(--surface-2); }
.ws-thread-toggle:focus-visible { outline-offset: -2px; }
.ws-thread-title { font-weight: 500; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.ws-thread-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; max-width: 55%; }
.ws-thread-body { padding: 4px 12px 12px; border-top: 1px solid var(--border); }
.ws-msg { padding: 8px 10px; margin: 8px 0; border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; }
.ws-msg-learner { border-left-color: var(--neutral); }
.ws-msg-ai { border-left-color: var(--warn); }
.ws-msg-instructor { border-left-color: var(--accent); }
.ws-msg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.ws-msg-author { font-weight: 600; font-size: 13px; }
.ws-msg-text { font-size: 13.5px; }
.ws-thread-attachment { margin: 8px 0 0; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ws-thread-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.ws-reply { margin-top: 10px; }
.ws-reply .field { margin-bottom: 8px; }
.ws-reply .form-actions { margin-top: 0; }

/* Ask form */
.ws-ask { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.ws-ask-title { margin-bottom: 8px; }
.ws-chips-label { margin-bottom: 6px; }
.ws-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ws-chip { height: auto; min-height: 28px; padding: 4px 10px; white-space: normal; text-align: left; font-weight: 400; }
.ws-ask-options { display: flex; gap: 4px 20px; flex-wrap: wrap; }
.ws-ask-form .form-actions { margin-top: 4px; }

/* ---------- Right column ---------- */
.ws-toolbar { display: flex; align-items: center; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ws-filename { font-size: 13px; font-weight: 600; margin-right: 6px; }
.ws-draft-state { white-space: nowrap; }
.ws-spacer { flex: 1 1 auto; }
.ws-editor-host { height: 380px; padding: 10px 12px 0; }
.ws-editor-host.tall { height: 560px; }
.ws-editor-host .jp-editor { height: 100%; }
.ws-fallback-field { height: 100%; margin: 0; display: flex; flex-direction: column; }
.ws-fallback-field .field-label { font-size: 12.5px; color: var(--text-3); margin-bottom: 4px; }
.ws-fallback-field .textarea { flex: 1 1 auto; min-height: 0; resize: none; background: var(--code-bg); color: var(--code-text); border-color: var(--border-strong); tab-size: 4; white-space: pre; overflow: auto; }
.ws-actions { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ws-grading-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); min-height: 20px; }
.ws-shortcut { white-space: nowrap; }
.ws-lower-panel { padding: 14px 18px 18px; }
.ws-running { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.ws-loading { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); margin: 6px 0; }

/* Result */
.ws-result-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ws-result-source { flex-basis: 100%; }
.ws-result .notice { margin-bottom: 10px; }
.ws-result-summary { margin: 0 0 6px; }
.ws-result-explanation { color: var(--text-2); margin-bottom: 10px; }
.ws-notice-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ws-result-title { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.ws-output pre.code { max-height: 220px; overflow: auto; }
.ws-tests .table td { vertical-align: top; }
.ws-tests pre.code { margin: 0; font-size: 12px; padding: 4px 8px; max-height: 160px; overflow: auto; min-width: 80px; }
.ws-tests .ws-col-name { white-space: nowrap; width: 90px; }
.ws-tests .ws-col-result { white-space: nowrap; width: 80px; font-weight: 600; }
.ws-test-pass { color: var(--ok); }
.ws-test-fail { color: var(--err); }
.ws-test-none { color: var(--text-3); }
.ws-result-private { margin: 10px 0 0; font-size: 13px; color: var(--text-2); }

/* AI feedback */
.ws-ai-head { margin-bottom: 10px; }
.ws-ai-section { margin-bottom: 10px; }
.ws-ai-label { font-size: 13px; margin-bottom: 2px; }
.ws-ai-section p { margin: 0; color: var(--text-2); }
.ws-ai-line { margin: 8px 0 0; }
.ws-ai-verdict { margin: 10px 0 0; }

/* History */
.ws-history-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ws-history-time { font-variant-numeric: tabular-nums; }

/* Submission drawer */
.ws-drawer-title { font-size: 14px; margin: 18px 0 8px; }
.ws-drawer .kv { margin-bottom: 4px; }
.ws-snapshot-host { height: 320px; }
.ws-snapshot-host .jp-editor { height: 100%; }
.ws-comments .ws-msg:first-child { margin-top: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .ws-bridge { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .ws-split { grid-template-columns: 1fr; }
  .ws-panel-scroll { max-height: none; }
}
@media (max-width: 640px) {
  .ws-example-grid { grid-template-columns: 1fr; }
  .ws-editor-host { height: 320px; }
  .ws-editor-host.tall { height: 480px; }
  .ws-thread-toggle { flex-direction: column; align-items: flex-start; }
  .ws-thread-meta { max-width: none; justify-content: flex-start; }
  .ws-lower-panel { padding: 12px; }
}
