/* --- Setup Screen --- */
#setupCard {
  overflow-y: auto;
  padding: 20px;
}

/* Setup header (Locations / Scenarios) */
#setupHeader {
  max-width: 900px;
  margin: 0 auto 12px;
  width: 100%;
}

.setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 6px 4px;

  /* ensures header isn't "hidden" behind sticky navbar when scrolled into view */
  scroll-margin-top: var(--nav-h);
}

.setup-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setup-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setup-header-title {
  font-weight: 900;
  letter-spacing: -0.02em;
  font-size: 1.15rem;
  color: var(--text-main);
}

.setup-header-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.25;
}

/* Location tiles (improved readability + icon beside text) */
.location-tile {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(30, 41, 59, 0.82));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  padding: 16px;

  display: grid;
  grid-template-columns: 60px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 4px;
  align-items: center;

  text-align: left;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, background 0.18s, box-shadow 0.18s;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
}

.location-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.location-tile:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.75);
  outline-offset: 2px;
}

.tile-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;

  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.28);
}

.tile-icon .material-icons-round {
  font-size: 30px;
  color: rgba(219, 234, 254, 0.98);
}

.tile-title {
  grid-column: 2;
  grid-row: 1;

  font-weight: 900;
  letter-spacing: -0.01em;
  font-size: 1.1rem;
  line-height: 1.15;
  color: rgba(248, 250, 252, 0.98);
}

.tile-desc {
  grid-column: 2;
  grid-row: 2;

  color: rgba(226, 232, 240, 0.78);
  font-size: 0.95rem;
  line-height: 1.35;
}

/* Keep scenario cards as-is */
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 0 auto 18px;
  width: 100%;
}

.scenario-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 18px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.scenario-card:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
  border-color: var(--primary);
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}

.scenario-card.open-chat-card {
  border-color: rgba(59, 130, 246, 0.4);
  background: linear-gradient(145deg, var(--bg-card) 0%, rgba(59, 130, 246, 0.1) 100%);
}

.scenario-card h3 {
  margin: 0 0 10px 0;
  font-size: 1.05rem;
}

.scenario-card .desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 12px;
}

.scenario-card .flags {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    'Liberation Mono', monospace;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.settings-panel {
  max-width: 520px;
  margin: 0 auto;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 6px;
  color: var(--text-main);
}

.toggle-row span {
  font-weight: 500;
}

.setup-actions {
  max-width: 520px;
  margin: 14px auto 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.variant-hint {
  max-width: 520px;
  margin: 10px auto 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- Session Screen --- */
#sessionCard {
  overflow: hidden;
  padding: 0;
}

/* Header becomes a 3-column grid so center stays centered even when it wraps */
.session-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto 1fr auto; /* left | center | right */
  align-items: center;
  gap: 12px;

  padding: 10px 16px; /* more vertical padding to support wrapping */
  border-bottom: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(6px);

  /* allow it to grow taller when the title wraps */
  height: auto;
  min-height: 60px;
}

.session-header-left,
.session-header-right {
  display: flex;
  align-items: center;
  min-width: 0;
}

.session-header-center {
  /* true centering in the middle column */
  justify-self: center;
  min-width: 0;
  max-width: 100%;
}

/* Center block: title + goals icon */
.scenario-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  /* This controls how wide the center content is allowed to be */
  max-width: min(680px, 100%);
  min-width: 0;
  text-align: center;
}

/* Allow wrapping instead of ellipsis */
#scenarioTitleDisplay {
  display: block;
  min-width: 0;
  max-width: 100%;

  white-space: normal;        /* wrap */
  overflow: visible;          /* no truncation */
  text-overflow: unset;

  line-height: 1.2;
  text-align: center;

  /* Prevent a single long token from breaking layout */
  overflow-wrap: anywhere;    /* breaks long words if needed */
  word-break: break-word;

  font-size: 0.95rem;
  font-weight: 650;
}


.score-board {
  display: flex;
  flex-direction: column;
}
.score-board .label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.score-board .value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--success);
}

/* Chat area */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: var(--bg-app);
}

/* Choice Buttons */
.choice-buttons {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px 0 16px;
  background: transparent;
  justify-content: center;
}

.choice-btn {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #dbeafe;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
  font-size: 0.95rem;
  transition: all 0.2s;
  max-width: 100%;
}
.choice-btn:hover {
  background: rgba(59, 130, 246, 0.25);
  transform: translateY(-1px);
}
.choice-btn:active {
  transform: translateY(0);
}

.system-message {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 10px 0;
}

.msg {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 1rem;
  line-height: 1.5;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: popIn 0.18s ease-out;
}

@keyframes popIn {
  from {
    transform: translateY(4px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.msg.npc {
  align-self: flex-start;
  background: rgba(51, 65, 85, 0.75);
  border-bottom-left-radius: 6px;
}

.msg.user {
  align-self: flex-end;
  background: rgba(59, 130, 246, 0.85);
  border-bottom-right-radius: 6px;
  border-color: rgba(59, 130, 246, 0.35);
}

.msg.center {
  align-self: center;
  background: rgba(148, 163, 184, 0.18);
  border-color: rgba(148, 163, 184, 0.25);
  border-radius: 14px;
}

.msg-meta {
  display: block;
  font-size: 0.75rem;
  opacity: 0.8;
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.85);
}

.inline-translation {
  margin-top: 8px;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.82);
  border-top: 1px dashed rgba(255, 255, 255, 0.2);
  padding-top: 8px;
  white-space: pre-wrap;
  opacity: 0.95;
}

/* Inline feedback under user messages */
.inline-feedback {
  margin-top: 8px;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.85);
  border-top: 1px dashed rgba(255, 255, 255, 0.2);
  padding-top: 8px;
  white-space: pre-wrap;
}

.inline-feedback .label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
}

/* Loading bubble */
.msg.loading {
  padding: 14px 18px;
  min-width: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg.npc.loading {
  align-self: flex-start;
  background: rgba(51, 65, 85, 0.45);
  border-bottom-left-radius: 6px;
}

.msg.user.loading {
  align-self: flex-end;
  background: rgba(59, 130, 246, 0.45);
  border-bottom-right-radius: 6px;
}

.msg.center.loading {
  align-self: center;
  background: rgba(148, 163, 184, 0.14);
  border-radius: 14px;
}

.typing-dots {
  display: flex;
  gap: 5px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: white;
  border-radius: 50%;
  animation: bounce 0.55s infinite alternate;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.12s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes bounce {
  from {
    transform: translateY(0);
    opacity: 0.7;
  }
  to {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Controls deck */
.controls-deck {
  flex-shrink: 0;
  background: rgba(30, 41, 59, 0.92);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
  z-index: 30;
  backdrop-filter: blur(6px);
}

.mic-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--primary);
  border: 4px solid rgba(59, 130, 246, 0.32);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.25);
  transition: transform 0.1s;
}

.mic-btn:active {
  transform: scale(0.96);
}
.mic-btn span {
  font-size: 30px;
}

.mic-btn.stop {
  background: var(--danger);
  border-color: rgba(239, 68, 68, 0.32);
  box-shadow: 0 12px 28px rgba(239, 68, 68, 0.2);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Pending transcript bar */
.pending-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 92px;
  background: rgba(30, 41, 59, 0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  z-index: 60;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);

  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pending-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.pending-title {
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pending-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.pending-text {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px;
  border-radius: 12px;

  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;

  font-size: 0.98rem;
  line-height: 1.35;
  letter-spacing: normal;

  max-height: 240px;
  overflow-y: auto;
}

.pending-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Keyboard overlay */
.keyboard-area {
  position: absolute;
  inset: 0;
  background: rgba(30, 41, 59, 0.98);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 35;
}

.keyboard-area textarea#typedText {
  flex: 1;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: white;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 16px;
  line-height: 1.35;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  overflow-y: auto;
}

/* Feedback toast */
.feedback-toast {
  position: absolute;
  bottom: 102px;
  left: 14px;
  right: 14px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(245, 158, 11, 0.55);
  padding: 14px 46px 14px 14px;
  border-radius: 14px;
  z-index: 40;
  box-shadow: var(--shadow);
  animation: slideUp 0.22s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.close-toast-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: rgba(245, 158, 11, 0.95);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}

.close-toast-btn:hover {
  opacity: 1;
  background: rgba(245, 158, 11, 0.1);
}

.feedback-title {
  color: rgba(245, 158, 11, 0.95);
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.feedback-original {
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.92rem;
  line-height: 1.35;
  white-space: pre-wrap;
  border-left: 3px solid rgba(245, 158, 11, 0.45);
  padding-left: 10px;
}

.feedback-content {
  color: #fbbf24;
  font-size: 0.95rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.suggestion-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Assist panel */
.assist-panel {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 100px;
  background: rgba(30, 41, 59, 0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  z-index: 45;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.assist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 700;
}

.assist-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.assist-controls,
.assist-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.status-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.translation-result {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    'Liberation Mono', monospace;
  font-size: 0.92rem;
  min-height: 44px;
  white-space: pre-wrap;
}

/* Native text input in assist panel */
.native-text-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.native-text-row input {
  flex: 1;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* Requirements list */
.req-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.req-list li {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-main);
  line-height: 1.25;
}

.req-list li:last-child {
  border-bottom: none;
}
.req-list li .material-icons-round {
  font-size: 20px;
  margin-top: 2px;
}
.req-list li.met {
  color: rgba(16, 185, 129, 0.95);
}
.req-list li.notmet {
  color: rgba(148, 163, 184, 0.95);
}

/* Message action sheet */
.msg-menu {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px;
}

.msg-menu-inner {
  width: min(520px, 96%);
  background: rgba(30, 41, 59, 0.98);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.msg-menu-title {
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.msg-menu-inner button {
  width: 100%;
  padding: 14px 14px;
  background: transparent;
  border: none;
  color: var(--text-main);
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.msg-menu-inner button:hover {
  background: rgba(255, 255, 255, 0.06);
}
.msg-menu-inner button.muted {
  color: var(--text-muted);
}
.msg-menu-inner button:last-child {
  border-bottom: none;
}

.msg,
.msg-menu,
.controls-deck,
.msg-menu-title,
.msg-menu-inner,
.msg-menu-inner * {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}

/* Alternatives list */
.alts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.alt-item {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.35);
  border-radius: 14px;
  padding: 12px;
}

.alt-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.alt-style {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.alt-text {
  white-space: pre-wrap;
  font-size: 1rem;
  line-height: 1.45;
}

.alt-notes {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.alt-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Review */
#reviewCard {
  overflow-y: auto;
  padding: 20px;
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 6px 0 18px;
}

.review-header h2 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.review-score {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--success);
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.card {
  background: rgba(30, 41, 59, 0.88);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
}

.card h3 {
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 800;
}

.text-content {
  margin: 0;
  color: var(--text-main);
  line-height: 1.55rem;
}

.transcript-container {
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.transcript-line {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
  line-height: 1.4;
}

.transcript-line:last-child {
  border-bottom: none;
}
.transcript-line strong {
  color: #93c5fd;
}

/* NEW: highlight currently-playing line during review playback */
.transcript-line.playing {
  background: rgba(59, 130, 246, 0.14);
  border-radius: 10px;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(59, 130, 246, 0.28);
}

.review-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-bottom: 28px;
}

@media (max-width: 600px) {
  .scenario-grid {
    grid-template-columns: 1fr;
  }
  .settings-panel {
    max-width: 100%;
  }
  .msg {
    max-width: 92%;
  }
  .controls-deck {
    gap: 12px;
  }

  /* slightly tighter tile layout on very small screens */
  .location-tile {
    grid-template-columns: 54px 1fr;
    padding: 14px;
  }
  .tile-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
  }
  .tile-title {
    font-size: 1.05rem;
  }
}