/* ── Claros worksheet app ── */

.app-main {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(1.4rem, 3.5vw, 2.5rem) clamp(1rem, 3vw, 1.6rem) 4rem;
}

/* ── Page header ── */
.app-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 1.6rem;
}

.app-page-title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.app-page-subtitle {
  margin-top: 0.3rem;
  font-size: 0.95rem;
  color: var(--muted);
  max-width: 52ch;
}

.step-indicator {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.step-indicator-item {
  padding: 0.34rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Workspace grid ── */
.app-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 384px);
  gap: 1.3rem;
  align-items: start;
}

.app-left {
  display: grid;
  gap: 1.3rem;
  min-width: 0;
}

/* ── Upload card ── */
.start-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(1.1rem, 2.5vw, 1.5rem);
  display: grid;
  gap: 1rem;
}

.start-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.btn-test-pdf {
  padding: 0.55rem 1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn-test-pdf:hover {
  border-color: var(--iris);
  color: var(--iris-deep);
  background: var(--iris-soft);
}

.btn-test-pdf:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.upload-zone {
  display: block;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-soft);
  padding: 1.6rem 1rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-zone:hover {
  border-color: var(--iris);
  background: var(--iris-soft);
}

.upload-zone.hover {
  border-color: var(--iris);
  background: var(--iris-soft);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.16);
}

.upload-zone input { display: none; }

.btn-upload-trigger {
  margin-top: 0.85rem;
  padding: 0.62rem 1.15rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn-upload-trigger:hover {
  border-color: var(--iris);
  color: var(--iris-deep);
  background: var(--iris-soft);
}

.upload-zone:hover .btn-upload-trigger,
.upload-zone.hover .btn-upload-trigger {
  border-color: var(--iris);
}

.upload-inner {
  display: grid;
  justify-items: center;
  gap: 0.7rem;
}

.upload-art {
  display: block;
  width: 2.7rem;
  height: 3.3rem;
  border-radius: 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  position: relative;
  box-shadow: var(--shadow-soft);
}

.upload-art::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -55%);
  width: 1.1rem;
  height: 1.1rem;
  background: var(--iris);
  clip-path: polygon(50% 0%, 92% 42%, 66% 42%, 66% 100%, 34% 100%, 34% 42%, 8% 42%);
}

.upload-art::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0.5rem;
  transform: translateX(-50%);
  width: 1.2rem;
  height: 0.16rem;
  border-radius: 999px;
  background: var(--border-strong);
}

.upload-copy {
  display: grid;
  gap: 0.1rem;
}

.upload-main {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink);
}

.upload-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.setup-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
}

.info-card {
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  display: grid;
  gap: 0.55rem;
  align-content: start;
}

.info-card-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
}

.info-card-list {
  list-style: none;
  display: grid;
  gap: 0.4rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.info-card-list li {
  padding-left: 1rem;
  position: relative;
}

.info-card-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.58em;
  width: 0.32rem;
  height: 0.32rem;
  border-radius: 999px;
  background: var(--iris);
}

/* Once a worksheet is loaded, the upload card steps back */
body.has-assignment .setup-info-grid { display: none; }

body.has-assignment .upload-zone { padding: 0.85rem 1rem; }

body.has-assignment .upload-inner {
  grid-template-columns: auto 1fr;
  align-items: center;
  text-align: left;
  justify-items: start;
}

body.has-assignment .upload-art {
  width: 2rem;
  height: 2.4rem;
}

body.has-assignment .upload-art::before {
  width: 0.85rem;
  height: 0.85rem;
}

/* ── Worksheet card ── */
.worksheet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(1.1rem, 2.5vw, 1.5rem);
  display: grid;
  gap: 1rem;
}

.worksheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
}

.assignment-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow-wrap: anywhere;
}

body:not(.has-assignment) .assignment-title {
  color: var(--muted);
  font-weight: 600;
}

.questions-container:empty::before {
  content: "Questions will appear here after you upload a worksheet or load the sample.";
  display: block;
  padding: 2.2rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.question-card:last-of-type { margin-bottom: 0; }

.question-card:focus-within {
  border-color: var(--iris-line);
  box-shadow: var(--shadow-soft);
}

.question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.question-index {
  min-width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--iris-deep);
  background: var(--iris-soft);
  margin-right: 0.6rem;
  flex-shrink: 0;
}

.question-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.question-meta {
  color: var(--warn);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

/* "Answer stated" badge: injected by app.js, shown when ready */
.ready-badge {
  display: none;
  padding: 0.16rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--success-soft);
  border: 1px solid var(--success-line);
  color: var(--success);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.question-card.answer-ready .ready-badge { display: inline-flex; }

.question-card.answer-ready {
  border-color: var(--success-line);
}

/* "Writing…" state */
.question-card.writing {
  border-color: var(--warn-line);
  box-shadow: 0 0 0 3px rgba(255, 179, 103, 0.2);
}

.question-card.writing .question-meta::before {
  content: "Writing\2026";
}

.question-card.writing .answer-field {
  border-color: var(--warn-line);
  background: var(--warn-soft);
}

.question-text {
  color: var(--ink-soft);
  font-size: 0.94rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 0.7rem;
}

.answer-field {
  min-height: 4.2rem;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  caret-color: var(--iris);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.answer-field:hover { border-color: var(--iris-line); }

.answer-field:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

.answer-field:focus {
  outline: none;
  border-color: var(--iris);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.18);
}

/* ── Voice console (dark panel) ── */
.session-panel {
  position: sticky;
  top: 4.6rem;
  background: var(--dark-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-mid);
  padding: 1.15rem;
  display: grid;
  gap: 0.85rem;
  color: var(--dark-text);
  max-height: calc(100vh - 5.6rem);
  overflow-y: auto;
}

.session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.session-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--dark-text);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.24rem 0.6rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--dark-border);
  background: var(--dark-surface);
  color: var(--dark-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-badge::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: var(--dark-muted);
  transition: background 0.18s ease;
}

/* light up the badge only while a session is running */
.session-panel.is-live .status-badge::before,
.session-panel.is-listening .status-badge::before,
.session-panel.is-speaking .status-badge::before,
.session-panel.is-writing .status-badge::before,
.session-panel:has(.status-bar.listening) .status-badge::before,
.session-panel:has(.status-bar.speaking) .status-badge::before,
.session-panel:has(.status-bar.writing) .status-badge::before {
  background: var(--success-bright);
}

/* Status bar: className is fully replaced by app.js: "status-bar <mode>" */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--dark-border);
  background: var(--dark-surface);
  color: var(--dark-muted);
  font-size: 0.88rem;
  font-weight: 700;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.status-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  background: var(--dark-muted);
  flex-shrink: 0;
}

.status-bar.connecting {
  color: var(--info-bright);
  border-color: rgba(255, 192, 120, 0.34);
  background: rgba(255, 192, 120, 0.1);
}
.status-bar.listening {
  color: var(--success-bright);
  border-color: rgba(87, 217, 154, 0.3);
  background: rgba(87, 217, 154, 0.08);
}
.status-bar.speaking {
  color: #ffce96;
  border-color: rgba(255, 206, 150, 0.32);
  background: rgba(255, 206, 150, 0.1);
}
.status-bar.writing {
  color: var(--warn-bright);
  border-color: rgba(255, 179, 103, 0.34);
  background: rgba(255, 179, 103, 0.1);
}

.status-bar.connecting .status-dot { background: var(--info-bright); }
.status-bar.listening .status-dot { background: var(--success-bright); }
.status-bar.speaking .status-dot { background: #ffce96; }
.status-bar.writing .status-dot { background: var(--warn-bright); }

.status-bar.connecting .status-dot,
.status-bar.listening .status-dot,
.status-bar.speaking .status-dot,
.status-bar.writing .status-dot {
  animation: pulse 1.15s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.82); opacity: 0.5; }
  50% { transform: scale(1.08); opacity: 1; }
}

.meter-wrap {
  height: 0.3rem;
  border-radius: 999px;
  background: rgba(255, 230, 206, 0.12);
  overflow: hidden;
}

.meter-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--iris), var(--success-bright));
}

.session-checklist {
  display: grid;
  gap: 0.45rem;
}

.checklist-title {
  color: var(--dark-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.66rem;
  font-weight: 700;
}

.setup-list {
  display: grid;
  gap: 0.4rem;
  list-style: none;
}

.setup-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--dark-border);
  background: var(--dark-surface);
  color: var(--dark-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.setup-item::before {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 1.5px solid rgba(197, 170, 143, 0.5);
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.setup-item.done {
  color: var(--dark-text);
  border-color: rgba(87, 217, 154, 0.25);
}

.setup-item.done::before {
  background: var(--success-bright);
  border-color: var(--success-bright);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5' fill='none' stroke='%2316131e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}

.setup-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Transcript ── */
.transcript {
  min-height: 11rem;
  max-height: 20rem;
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--dark-border);
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.86rem;
  line-height: 1.6;
  overflow-y: auto;
  overflow-x: hidden;
}

.transcript:empty::before {
  content: "Your conversation will appear here once the session starts.";
  display: block;
  color: var(--dark-muted);
  text-align: center;
  padding: 2.6rem 0.8rem;
}

.transcript::-webkit-scrollbar { width: 8px; }
.transcript::-webkit-scrollbar-thumb {
  background: rgba(197, 170, 143, 0.4);
  border-radius: 999px;
}

.msg {
  word-break: break-word;
  padding: 0.28rem 0;
  color: var(--dark-text);
}

.msg-label {
  font-weight: 700;
  margin-right: 0.35rem;
  font-size: 0.78rem;
}

.msg.user .msg-label { color: var(--info-bright); }
.msg.claros .msg-label { color: var(--success-bright); }
.msg.partial { opacity: 0.55; }

/* ── Notices & errors ── */
.notice {
  font-size: 0.84rem;
  line-height: 1.5;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(87, 217, 154, 0.3);
  background: rgba(87, 217, 154, 0.1);
  color: #c4efd8;
}

.notice:empty { display: none; }

.errors {
  font-size: 0.84rem;
  line-height: 1.5;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 143, 165, 0.35);
  background: rgba(255, 143, 165, 0.1);
  color: #ffd0da;
}

.errors:empty { display: none; }

.session-privacy-note {
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--dark-muted);
}

/* ── Buttons ── */
.session-actions {
  display: grid;
  gap: 0.55rem;
}

.btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  cursor: not-allowed;
}

.btn.session-btn {
  background: var(--iris);
  color: #fff;
  min-height: 3rem;
  box-shadow: 0 10px 24px rgba(249, 115, 22, 0.36);
}

.btn.session-btn:hover:not(:disabled) {
  background: var(--iris-deep);
  transform: translateY(-1px);
}

.btn.session-btn:disabled {
  background: var(--dark-raised);
  color: var(--dark-muted);
  box-shadow: none;
}

.btn.session-btn.stop {
  background: #c22a4a;
  box-shadow: 0 10px 24px rgba(194, 42, 74, 0.3);
}

.btn.session-btn.stop:hover:not(:disabled) {
  background: #a91e3c;
}

.btn.interrupt {
  background: transparent;
  color: var(--dark-text);
  border: 1px solid var(--dark-border);
  display: none;
}

.btn.interrupt:hover {
  border-color: rgba(255, 230, 206, 0.4);
  background: var(--dark-surface);
}

.btn.interrupt.visible { display: block; }

.btn.export {
  background: var(--ink);
  color: #fff;
  display: none;
  box-shadow: var(--shadow-soft);
}

.btn.export:hover {
  background: var(--iris-deep);
  transform: translateY(-1px);
  box-shadow: var(--shadow-mid);
}

.btn.export.visible { display: block; }

/* ── Responsive ── */
@media (max-width: 1080px) {
  .app-workspace {
    grid-template-columns: 1fr;
  }

  .app-left { display: contents; }

  .start-card { order: 1; }
  .session-panel {
    order: 2;
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  .worksheet-card { order: 3; }

  .transcript { min-height: 8.5rem; max-height: 14rem; }
}

@media (max-width: 600px) {
  .app-main { padding: 1.15rem 0.9rem 2.25rem; }

  .app-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }

  .step-indicator {
    gap: 0.35rem;
  }

  .step-indicator-item {
    font-size: 0.72rem;
    padding: 0.32rem 0.62rem;
  }

  .start-card,
  .worksheet-card,
  .session-panel { padding: 0.95rem; border-radius: var(--radius-md); }

  .start-card-head { flex-direction: column; align-items: flex-start; }

  .btn-test-pdf { width: 100%; }

  .question-card { padding: 0.85rem 0.9rem; }

  .question-header { flex-wrap: wrap; }

  .question-meta { white-space: normal; }
}
