/* TypeDrill layout. Tokens from Backstage theme.css (--surface, --primary, etc.). */

.td-mobile-gate {
  display: none;
  max-width: 420px;
  margin: 48px auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  color: var(--text-primary);
}

@media (pointer: coarse) {
  .td-mobile-gate { display: block; }
  #view-session { display: none; }
}

#view-session {
  display: grid;
  gap: 16px;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.td-charset,
.td-sources,
.td-practice,
.td-stats,
.td-progress-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 2px 8px var(--shadow);
}

.td-charset-toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.td-toggle {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.td-toggle[aria-pressed="true"] {
  background: rgba(20,184,166,.15);
  color: var(--primary);
  border-color: var(--primary);
}

.td-focus {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.td-focus-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.td-focus-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px 2px 10px;
  border-radius: 999px;
  background: rgba(20,184,166,.15);
  color: var(--primary);
  font-size: 13px;
  line-height: 1.4;
}

.td-focus-chip button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.7;
}

.td-focus-chip button:hover {
  opacity: 1;
  color: var(--error);
}

.td-focus-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  outline: none;
}

.td-source-options-section {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.td-source-options-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.td-source-options-numbers {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.td-opt-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.td-opt-input {
  width: 70px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.td-custom-text-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.td-custom-text {
  display: block;
  width: 100%;
  min-height: 140px;
  padding: 10px 14px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}

.td-custom-text:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(20,184,166,.2);
}

.td-custom-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.td-custom-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.td-source-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.td-source-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  white-space: nowrap;
}

.td-source-card[aria-pressed="true"] {
  background: rgba(20,184,166,.15);
  color: var(--primary);
  border-color: var(--primary);
}

.td-source-card-chevron {
  display: none;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  transition: transform 150ms ease;
}

.td-source-card[aria-pressed="true"] .td-source-card-chevron {
  display: inline-block;
}

.td-source-card[aria-expanded="true"] .td-source-card-chevron {
  transform: rotate(180deg);
}

.td-source-options {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.td-source-options-empty {
  margin: 0;
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
}

.td-target {
  font-family: "SF Mono", Consolas, "Liberation Mono", monospace;
  font-size: 22px;
  line-height: 1.7;
  padding: 14px 18px;
  min-height: 64px;
  letter-spacing: 0.5px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-primary);
}

.ok-char   { color: var(--success); background: var(--success-bg); }
.bad-char  { color: var(--error); background: var(--error-bg); text-decoration: underline; }
.cur-char  { background: rgba(20,184,166,.15); border-bottom: 2px solid var(--primary); }
.pending   { color: var(--text-light); }

/* Visually-hidden input: still focusable for key capture, no visual presence. */
.td-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.td-target {
  cursor: text;
}

.td-stats {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.td-stat {
  display: flex;
  flex-direction: column;
  min-width: 80px;
}

.td-stat-label { font-size: 12px; color: var(--text-secondary); }
.td-stat-value { font-size: 18px; font-weight: 500; color: var(--text-primary); }

.td-progress-btn {
  margin-left: auto;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.td-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.td-line-indicator { font-size: 13px; color: var(--text-secondary); }

.td-actions {
  display: flex;
  gap: 8px;
}

.td-actions button {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

/* Progress drawer (1M) */

.td-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
}

.td-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 90vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 12px var(--shadow);
  z-index: 101;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
}

.td-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.td-drawer-header h2 {
  margin: 0;
  font-size: 16px;
}

.td-drawer-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
}

.td-drawer-close:hover {
  color: var(--text-primary);
}

.td-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
}

.td-drawer-empty {
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
  margin: 0;
}

.td-drawer-body .td-progress-row {
  display: grid;
  grid-template-columns: 28px 40px 1fr 64px;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  border-radius: 0;
  box-shadow: none;
}

.td-progress-char {
  font-family: "SF Mono", Consolas, "Liberation Mono", monospace;
  font-size: 16px;
  color: var(--text-primary);
  text-align: center;
}

.td-progress-attempts {
  color: var(--text-secondary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.td-acc-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.td-acc-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.td-progress-wpm {
  color: var(--text-secondary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.td-drawer-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.td-drawer-meta {
  color: var(--text-secondary);
  font-size: 13px;
}

.td-drawer-reset {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--error);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.td-drawer-reset:hover {
  background: var(--error);
  color: var(--surface);
  border-color: var(--error);
}
