/* Tutor page: settings side panel + chat. */

.tutor-page { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.tutor-page .site-footer { display: none; }

.tutor {
  flex: 1; display: grid; grid-template-columns: 300px 1fr; max-width: 1240px; width: 100%; margin: 0 auto;
  min-height: 0;
}

/* Side panel */
.side { border-right: 1px solid var(--line); background: var(--ivory-2); }
.side-inner { position: sticky; top: 66px; max-height: calc(100vh - 66px); overflow-y: auto; padding: 22px 20px 28px; }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side h2 { font-size: 1.25rem; margin: 0; }
.side-hint, .side-fine { font-size: 0.88rem; color: var(--muted); }
.side-fine { margin-top: 18px; }
.icon-btn.side-close { display: none; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; padding: 0; }
.opt { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-size: 0.97rem; }
.opt input { width: 20px; height: 20px; accent-color: var(--brick); flex: none; }
.field { display: grid; gap: 6px; margin-bottom: 16px; font-weight: 700; font-size: 0.95rem; }
.field small { font-weight: 400; color: var(--muted); }
.field input, .field textarea {
  font: inherit; font-weight: 400; font-size: 0.95rem; padding: 10px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--white); color: var(--ink); resize: vertical;
}
.size-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 0.95rem; }

@media (max-width: 860px) {
  .tutor { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 0 0 auto; width: min(360px, 92vw); z-index: 40; transform: translateX(105%);
    transition: transform 0.2s ease, visibility 0.2s; visibility: hidden; border-right: 0;
  }
  .side.open { transform: none; visibility: visible; box-shadow: -10px 0 30px rgba(43, 33, 28, 0.2); }
  .chat-bar { padding: 8px 16px; }
  .chat-bar .btn { white-space: nowrap; }
  .chat-bar-title { display: none; }
  .side-inner { position: static; max-height: 100%; height: 100%; }
  .icon-btn.side-close { display: inline-grid; }
}
@media (min-width: 861px) { [data-open-side] { display: none; } }

.chip {
  font: inherit; font-size: 0.92rem; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--white); color: var(--ink);
}
.chip:hover { border-color: var(--brick); color: var(--brick); }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--white); color: var(--ink); cursor: pointer; font: inherit; flex: none;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { border-color: var(--brick); color: var(--brick); }
.mic.listening { background: var(--brick); color: var(--white); border-color: var(--brick); }

/* Chat */
.chat { padding: 0; display: flex; flex-direction: column; min-width: 0; min-height: calc(100vh - 66px); min-height: calc(100dvh - 66px); }
.chat-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--line);
  background: var(--ivory);
}
.chat-bar-title { font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; }
.chat-bar #new-chat { margin-left: auto; }

.messages { flex: 1; overflow-y: auto; padding: 24px 20px 12px; display: flex; flex-direction: column; gap: 16px; }

.welcome { max-width: 640px; margin: 4vh auto 0; text-align: center; }
.welcome-mark { width: 56px; height: 56px; margin-bottom: 10px; }
.welcome h1 { font-size: clamp(1.6rem, 3.6vw, 2.2rem); }
.welcome p { color: var(--ink-2); }
.starters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; text-align: left; }
@media (max-width: 560px) { .starters { grid-template-columns: 1fr; } }
.starter {
  font: inherit; font-size: 0.95rem; text-align: left; padding: 14px 16px; border-radius: 14px; cursor: pointer;
  background: var(--white); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow);
}
.starter:hover { border-color: var(--brick); }

.msg { scroll-margin: 80px 0 190px; display: flex; gap: 10px; max-width: 820px; width: 100%; margin: 0 auto; }
.msg-user { justify-content: flex-end; }
.bubble { padding: 12px 16px; border-radius: 18px; max-width: 88%; overflow-wrap: anywhere; }
.msg-user .bubble { background: var(--brick); color: var(--white); border-bottom-right-radius: 6px; }
.msg-tutor .bubble { background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--shadow); max-width: 100%; flex: 1; }
.msg-tutor .avatar { width: 32px; height: 32px; flex: none; margin-top: 4px; }
.bubble p { margin: 0 0 0.6em; }
.bubble p:last-child, .bubble ul:last-child, .bubble ol:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 0.6em; padding-left: 1.3em; }
.bubble li { margin-bottom: 0.25em; }
.bubble code { background: var(--ivory-2); padding: 1px 6px; border-radius: 6px; font-size: 0.95em; }
.bubble strong { color: var(--brick-dark); }
.msg-user .bubble strong { color: var(--white); }
.msg-tools { display: flex; gap: 8px; margin-top: 8px; }
.msg-tools button {
  font: inherit; font-size: 0.82rem; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 4px;
  text-decoration: underline; text-underline-offset: 3px;
}
.msg-tools button:hover { color: var(--brick); }
.msg-note .bubble { background: var(--yellow-soft); border-color: #efd27f; }
.diagram-miss { color: var(--muted); font-style: italic; font-size: 0.92em; }

.typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--clay); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.composer { border-top: 1px solid var(--line); background: var(--ivory); padding: 10px 20px 14px; position: sticky; bottom: 0; }
.quick { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; max-width: 820px; margin: 0 auto; scrollbar-width: thin; }
.quick .chip { white-space: nowrap; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; max-width: 820px; margin: 0 auto; }
.composer-row textarea {
  flex: 1; font: inherit; padding: 11px 16px; border-radius: 22px; border: 1.5px solid var(--line); background: var(--white);
  color: var(--ink); resize: none; max-height: 180px; line-height: 1.45; min-height: 46px;
}
.composer-row textarea:focus { border-color: var(--brick); outline: none; box-shadow: 0 0 0 3px var(--yellow-soft); }
.send { min-height: 46px; }
.send:disabled { opacity: 0.6; cursor: wait; }
.disclaimer { text-align: center; font-size: 0.8rem; color: var(--muted); margin: 8px 0 0; }

/* Learner display choices */
html.easy-font body { font-family: var(--font-easy); letter-spacing: 0.01em; word-spacing: 0.06em; line-height: 1.75; }
html.easy-font .sq-svg g { font-family: var(--font-easy); }
html.contrast {
  --ivory: #ffffff; --ivory-2: #f2f2f2; --ivory-3: #e0e0e0; --white: #ffffff;
  --ink: #000000; --ink-2: #111111; --muted: #333333; --line: #4d4d4d;
  --brick: #7a1f10; --brick-dark: #5a1509;
}
html.contrast .msg-tutor .bubble, html.contrast .chip, html.contrast .starter { border-width: 2px; }
