/* =====================================================
   TF Support Chat — Industrial Precision Theme
   ===================================================== */

:root {
  --tf-red:        #E5001E;
  --tf-red-dark:   #B5001A;
  --tf-red-glow:   rgba(229,0,30,0.18);

  --bg-page:       #0E0F11;
  --bg-card:       #16181D;
  --bg-input:      #1E2028;
  --bg-msg-agent:  #1A1C22;
  --bg-msg-user:   #E5001E;
  --bg-header:     #13141A;
  --bg-overlay:    rgba(0,0,0,0.82);

  --border:        rgba(255,255,255,0.07);
  --border-focus:  rgba(229,0,30,0.6);

  --text-primary:  #F0F0F2;
  --text-secondary:#9299A8;
  --text-dim:      #555C6A;
  --text-agent:    #E8E9ED;

  --green:         #22C55E;
  --yellow:        #F59E0B;
  --shadow-card:   0 24px 64px rgba(0,0,0,0.6);
  --radius-card:   16px;
  --radius-msg:    14px;
  --radius-input:  12px;

  --font-display:  'Rajdhani', sans-serif;
  --font-body:     'DM Sans', sans-serif;
  --font-mono:     'DM Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: -webkit-fill-available;
}
body {
  height: 100vh;
  height: 100dvh;           /* Dynamic viewport — shrinks with browser chrome */
  background: var(--bg-page);
  font-family: var(--font-body);
  color: var(--text-primary);
  overflow: hidden;
  overscroll-behavior: none;         /* No pull-to-refresh */
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; /* No grey tap flash */
}

a { color: var(--tf-red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Screens ─────────────────────────────────────── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  /* Safe area for notched/island phones */
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.screen.active { display: flex; }

/* ── Modal backdrop ──────────────────────────────── */
.modal-backdrop {
  position: absolute; inset: 0;
  background: var(--bg-page);
}

/* ── Modal card ──────────────────────────────────── */
.modal-card {
  position: relative;
  z-index: 1;
  margin: auto;
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}

/* ── Logo ─────────────────────────────────────────── */
.modal-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.logo-mark {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  background: var(--tf-red);
  color: #fff;
  padding: 3px 9px;
  letter-spacing: 2px;
  clip-path: polygon(0 0, 94% 0, 100% 100%, 6% 100%);
}
.logo-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.modal-card h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  color: var(--text-primary);
}
.sub-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ── Disclaimer ──────────────────────────────────── */
.disclaimer-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 16px;
}
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}
.checkbox-label input[type="checkbox"] {
  display: none;
}
.checkmark {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input);
  position: relative;
  transition: border-color 0.2s, background 0.2s;
  margin-top: 1px;
}
.checkbox-label input:checked ~ .checkmark {
  background: var(--tf-red);
  border-color: var(--tf-red);
}
.checkmark::after {
  content: '';
  position: absolute;
  left: 5px; top: 2px;
  width: 6px; height: 10px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity 0.15s;
}
.checkbox-label input:checked ~ .checkmark::after { opacity: 1; }

/* ── Form elements ───────────────────────────────── */
.form-group {
  margin-bottom: 18px;
  flex: 1;
}
.form-row {
  display: flex;
  gap: 14px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 7px;
}
.req { color: var(--tf-red); margin-left: 2px; }
.opt { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-dim); }

.form-group input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}
.form-group input::placeholder { color: var(--text-dim); }
.form-group input:focus { border-color: var(--border-focus); }

.model-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hint-icon { font-size: 13px; }
.form-error {
  color: #FF6B6B;
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ── Code input ──────────────────────────────────── */
.code-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  justify-content: center;
}
.code-digit {
  width: 48px;
  height: 58px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 10px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  caret-color: var(--tf-red);
}
.code-digit:focus { border-color: var(--border-focus); }
.code-digit.filled { border-color: var(--tf-red); color: var(--tf-red); }
.code-sep {
  color: var(--text-dim);
  font-size: 20px;
  margin: 0 4px;
  user-select: none;
}

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 14px 20px;
  background: var(--tf-red);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
}
.btn-primary:hover:not(:disabled) { background: var(--tf-red-dark); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-arrow { font-size: 18px; }

.btn-ghost {
  width: 100%;
  padding: 11px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  margin-top: 10px;
  transition: color 0.2s, border-color 0.2s;
}
.btn-ghost:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.2); }

.btn-ghost-sm {
  padding: 5px 12px;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.2s;
}
.btn-ghost-sm:hover { background: rgba(255,255,255,0.08); }

/* ── CHAT SCREEN ─────────────────────────────────── */
#screen-chat {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;            /* Fixes flex overflow on some Android browsers */
  background: var(--bg-page);
}
#screen-chat.active { display: flex; }

/* ── Header ──────────────────────────────────────── */
.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.title-main {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.title-sub {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}
.agent-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
}
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.4s;
  box-shadow: 0 0 0 0 transparent;
}
.status-dot.online {
  background: var(--green);
  animation: pulse-green 2.5s infinite;
}
.status-dot.offline {
  background: var(--tf-red);
}
.status-dot.checking {
  background: var(--yellow);
}
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50%       { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

/* ── Message area ────────────────────────────────── */
.chat-messages {
  flex: 1;
  min-height: 0;            /* Critical: allows flex child to scroll on mobile */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Momentum scroll on iOS */
  overscroll-behavior-y: contain;    /* Don't propagate scroll to page */
  padding: 24px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ── Message bubbles ─────────────────────────────── */
.msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: min(520px, 85%);
  gap: 4px;
}
.msg-wrap.user { align-self: flex-end; align-items: flex-end; }
.msg-wrap.agent { align-self: flex-start; align-items: flex-start; }
.msg-wrap.system { align-self: center; max-width: 100%; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-msg);
  line-height: 1.65;
  font-size: 15px;
  word-break: break-word;
}
.msg-wrap.user  .msg-bubble {
  background: var(--bg-msg-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-wrap.agent .msg-bubble {
  background: var(--bg-msg-agent);
  color: var(--text-agent);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  font-family: var(--font-body);
}
.msg-wrap.system .msg-bubble {
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  border: none;
  padding: 4px 0;
}

/* Images in messages */
.msg-bubble img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  display: block;
  margin-top: 6px;
}
/* Timestamp */
.msg-time {
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 4px;
}

/* Quick action context note */
.context-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 0 8px;
  letter-spacing: 0.2px;
}

/* Feedback row */
.msg-feedback {
  display: flex;
  gap: 6px;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.msg-wrap:hover .msg-feedback { opacity: 1; }
.feedback-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.feedback-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.feedback-btn.voted { border-color: var(--tf-red); color: var(--tf-red); }

/* ── Typing indicator ────────────────────────────── */
.typing-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
}
.typing-dots {
  display: flex; gap: 5px;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: bounce 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick actions (initial state) ──────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 0 4px;
  width: 100%;
  max-width: 480px;
  align-self: center;
}
.quick-btn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-msg-agent);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
  color: var(--text-primary);
  font-family: var(--font-body);
}
.quick-btn:hover { border-color: var(--tf-red); background: rgba(229,0,30,0.06); }
.quick-btn-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.quick-btn-text strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 2px;
}
.quick-btn-text span {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Resolved prompt ─────────────────────────────── */
.resolved-prompt {
  align-self: flex-start;
  background: var(--bg-msg-agent);
  border: 1px solid var(--border);
  border-radius: var(--radius-msg);
  padding: 12px 16px;
  font-size: 13.5px;
  max-width: min(380px, 85%);
}
.resolved-prompt p {
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.resolved-btns {
  display: flex; gap: 8px;
}
.res-btn {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  transition: background 0.15s, border-color 0.15s;
}
.res-btn:hover { background: rgba(255,255,255,0.07); }
.res-btn.yes { border-color: var(--green); color: var(--green); }
.res-btn.yes:hover { background: rgba(34,197,94,0.1); }
.res-btn.no { border-color: var(--tf-red); color: var(--tf-red); }
.res-btn.no:hover { background: rgba(229,0,30,0.1); }

/* ── Input area ──────────────────────────────────── */
.chat-input-area {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-header);
  padding: 12px 16px 14px;
}
.img-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.img-preview-bar img {
  width: 36px; height: 36px;
  object-fit: cover;
  border-radius: 5px;
}
.img-preview-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.img-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}
.img-remove:hover { color: var(--text-primary); }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.attach-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  color: var(--text-secondary);
  background: var(--bg-input);
  transition: color 0.2s, border-color 0.2s;
}
.attach-btn:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.2); }

textarea#chat-input {
  flex: 1;
  min-height: 42px;
  max-height: 160px;
  resize: none;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
  overflow-y: hidden;
  box-sizing: border-box;
}
textarea#chat-input::placeholder { color: var(--text-dim); }
textarea#chat-input:focus { border-color: var(--border-focus); }

.send-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  background: var(--tf-red);
  border: none;
  border-radius: 9px;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
}
.send-btn:hover:not(:disabled) { background: var(--tf-red-dark); }
.send-btn:active:not(:disabled) { transform: scale(0.93); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.input-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  padding: 0 2px;
}
.char-count { font-size: 11px; color: var(--text-dim); }
.char-count.warn { color: var(--yellow); }
.char-count.danger { color: #FF6B6B; }
.input-hint { font-size: 11px; color: var(--text-dim); }

/* ── Offline banner ──────────────────────────────── */
.offline-banner {
  flex-shrink: 0;
  text-align: center;
  padding: 10px 16px;
  background: rgba(229,0,30,0.12);
  border-top: 1px solid rgba(229,0,30,0.25);
  font-size: 13px;
  color: #FFA0A0;
}
.offline-banner a { color: var(--tf-red); font-weight: 600; }

/* ── Idle warning ────────────────────────────────── */
.idle-warning {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 9px 16px;
  background: rgba(245,158,11,0.1);
  border-top: 1px solid rgba(245,158,11,0.2);
  font-size: 13px;
  color: var(--yellow);
}

/* ── Ticket overlay ──────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  z-index: 100;
  background: var(--bg-overlay);
  display: flex; align-items: center; justify-content: center;
}
.overlay-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 36px 32px;
  max-width: 400px;
  width: 92%;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.overlay-icon { font-size: 44px; margin-bottom: 14px; }
.overlay-card h3 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 10px;
}
.overlay-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 14px;
}
.ticket-ref {
  background: var(--bg-input);
  border: 1px solid var(--tf-red);
  border-radius: 8px;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--tf-red);
  margin-bottom: 14px;
}
.ticket-email-note { font-size: 12px !important; color: var(--text-dim) !important; }

/* ── Loading spinner inline ──────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile tweaks ───────────────────────────────── */
/* ── Mobile: full app-like experience ─────────────── */
@media (max-width: 768px) {
  /* Layout */
  .modal-card    { padding: 28px 20px; border-radius: 0; max-height: 100vh; height: 100%; }
  .modal-backdrop { display: none; }
  .screen        { align-items: flex-start; }
  .form-row      { flex-direction: column; gap: 0; }
  .input-hint    { display: none; }
  .overlay-card  { border-radius: 16px; padding: 28px 20px; }

  /* Header */
  .chat-header   { padding: 14px 16px; }
  .chat-header-name { font-size: 17px; }
  .chat-header-sub  { font-size: 13px; }

  /* Messages */
  .chat-messages { padding: 16px 12px; gap: 14px; }
  .msg-wrap      { max-width: 88%; }
  .msg-bubble    { font-size: 17px !important; line-height: 1.7 !important; padding: 14px 18px !important; border-radius: 18px !important; }
  .msg-wrap.user .msg-bubble  { border-bottom-right-radius: 5px !important; }
  .msg-wrap.agent .msg-bubble { border-bottom-left-radius: 5px !important; }
  .msg-bubble p  { font-size: 17px !important; margin: 6px 0 !important; }
  .msg-bubble li { font-size: 17px !important; margin: 5px 0 !important; }
  .msg-bubble ul { padding-left: 20px; margin: 8px 0; }
  .msg-bubble h2 { font-size: 19px !important; margin: 14px 0 6px; }
  .msg-bubble h3 { font-size: 18px !important; margin: 12px 0 4px; }
  .msg-bubble h4 { font-size: 15px !important; }
  .msg-time      { font-size: 12px; }

  /* Input area */
  .chat-input-area { padding: 10px 12px 16px; }
  .input-row        { gap: 8px; }
  textarea#chat-input {
    font-size: 17px;
    min-height: 50px;
    padding: 12px 16px;
    border-radius: 25px;
    line-height: 1.5;
  }
  .attach-btn { width: 44px; height: 50px; border-radius: 14px; }
  .send-btn   { width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0; }
  .char-count { display: none; }  /* hidden until near limit — see JS */

  /* Quick actions */
  .quick-actions     { grid-template-columns: 1fr 1fr; gap: 10px; }
  .quick-btn         { padding: 16px 14px; border-radius: 16px; }
  .quick-btn-label   { font-size: 15px; line-height: 1.4; }
  .quick-btn-icon    { font-size: 22px; }
}

@media (max-width: 430px) {
  .quick-actions { grid-template-columns: 1fr; }
  .msg-wrap      { max-width: 93%; }
}

@media (min-width: 768px) {
  #screen-chat { max-width: 680px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ── Feedback bar upgrades ────────────────────────── */
.msg-feedback { flex-wrap: wrap; align-items: center; }
.feedback-btn.voted-up   { border-color: #22c55e; color: #22c55e; background: rgba(34,197,94,0.08); }
.feedback-btn.voted-down { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.08); }
.feedback-btn.note-btn   { border-style: dashed; }
.feedback-saved { font-size: 11px; color: #22c55e; font-weight: 600; }

/* ── Correction area ─────────────────────────────── */
.correction-area { padding: 6px 4px 0; max-width: 90%; }
.correction-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  resize: none;
  min-height: 56px;
  outline: none;
  box-sizing: border-box;
}
.correction-input:focus { border-color: rgba(255,255,255,0.3); }
.correction-actions { display: flex; gap: 6px; margin-top: 6px; }
.corr-save {
  background: var(--tf-red); color: #fff;
  border: none; border-radius: 16px;
  padding: 5px 14px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.corr-cancel {
  background: none; border: 1px solid var(--border);
  border-radius: 16px; padding: 5px 14px;
  font-size: 12px; cursor: pointer; color: var(--text-dim);
}


/* ════════════════════════════════════════════════════
   LIGHT MODE
   ════════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg-page:       #F2F3F5;
  --bg-card:       #FFFFFF;
  --bg-input:      #F0F1F4;
  --bg-msg-agent:  #EAEDF1;
  --bg-msg-user:   #E5001E;
  --bg-header:     #FFFFFF;
  --bg-overlay:    rgba(0,0,0,0.55);

  --border:        rgba(0,0,0,0.09);
  --border-focus:  rgba(229,0,30,0.5);

  --text-primary:  #1A1C22;
  --text-secondary:#5A6070;
  --text-dim:      #8A919E;
  --text-agent:    #1A1C22;

  --green:         #15A34A;
  --yellow:        #D97706;
  --shadow-card:   0 8px 32px rgba(0,0,0,0.12);
}

[data-theme="light"] body {
  background: var(--bg-page);
  color: var(--text-primary);
}

[data-theme="light"] .chat-header {
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

[data-theme="light"] .msg-feedback .feedback-btn {
  color: var(--text-secondary);
  border-color: rgba(0,0,0,0.12);
}

[data-theme="light"] .msg-feedback .feedback-btn:hover {
  background: rgba(0,0,0,0.05);
}

/* ════════════════════════════════════════════════════
   HEADER CONTROLS
   ════════════════════════════════════════════════════ */
.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.ctrl-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}
[data-theme="light"] .ctrl-btn:hover {
  background: rgba(0,0,0,0.06);
}
.ctrl-btn svg { display: block; }

/* ════════════════════════════════════════════════════
   FEEDBACK GUIDE SIDEBAR
   ════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: 300px;
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,0.3);
}
.sidebar.open {
  transform: translateX(0);
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  display: none;
  opacity: 0;
  transition: opacity 0.25s;
}
.sidebar-backdrop.open {
  display: block;
  opacity: 1;
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}
.sidebar-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
.sidebar-close:hover { color: var(--text-primary); }

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.sidebar-body h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--tf-red);
  margin-bottom: -8px;
}
.sidebar-body ul {
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.sidebar-intro {
  color: var(--text-primary);
  font-size: 13px;
}
.sidebar-feedback-guide {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sfg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.sfg-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.sidebar-tip {
  font-size: 12px;
  font-style: italic;
  color: var(--text-dim);
}
.sidebar-admin-link {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sidebar-admin-link a {
  display: block;
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--tf-red);
  color: var(--tf-red);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.sidebar-admin-link a:hover {
  background: var(--tf-red-glow);
  text-decoration: none;
}
