/* batch 1 UX fixes (toasts, history rows, wide monitor tables). Load order matters: later files override earlier ones. */
/* ==========================================================================
   UX fixes after internal testing of batch 1 (2026-11-13): toasts, destructive confirm, history rows and banner,
   wide monitoring tables, wrapping tab bar.
   ========================================================================== */
.toast { display:flex; align-items:center; gap:12px; max-width:min(560px, calc(100vw - 32px)); }
.toast-error { background:#8f2a22; color:#fff; box-shadow:0 6px 24px rgba(0, 0, 0, .28); }
body.dark .toast-error { background:#5a1f1a; color:#ffe3df; border:1px solid #a8483f; }
.toast .toast-close { flex:none; min-height:28px; width:28px; padding:0; line-height:1; font-size:18px; color:inherit; background:transparent; border:1px solid currentColor; border-radius:50%; opacity:.85; }
.toast .toast-close:hover { background:rgba(255, 255, 255, .18); border-color:currentColor; opacity:1; }
.editor button.primary.danger-action, button.primary.danger-action { background:#b3261e; border-color:#b3261e; color:#fff; opacity:1; }
button.primary.danger-action:hover { background:#8f2a22; border-color:#8f2a22; }
body.dark button.primary.danger-action { background:#c4372d; border-color:#c4372d; }
body.dark button.primary.danger-action:hover { background:#d8493e; border-color:#d8493e; }

/* History rows: title line + "time · n 則" line (the part that tells metadata_only rows apart). */
.layout .sidebar nav .chat-history .history-open { display:flex; flex-direction:column; align-items:flex-start; gap:1px; white-space:normal; }
.layout .sidebar nav .chat-history .history-open > span { max-width:100%; text-align:left; }
.layout .sidebar nav .chat-history .history-pop .pop-item.danger { color:#b3261e; }
body.dark .layout .sidebar nav .chat-history .history-pop .pop-item.danger { color:#ffb4ab; }
.chat-history .history-title, .chat-history .history-meta { display:block; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-history .history-meta { font-size:11.5px; font-variant-numeric:tabular-nums; color:var(--fg-muted); }
.history-banner { margin:0 0 16px; padding:12px 16px; border:1px solid var(--home-warn-line, var(--fg-line)); border-left:3px solid var(--home-block-dot, var(--fg-accent)); border-radius:10px; background:var(--home-warn-bg, var(--fg-soft)); color:var(--home-warn-text, var(--fg-text)); font-size:14px; line-height:1.55; }
@media (max-width: 700px) {
  /* The ⋯ menu opens inline under its row instead of floating over the rows and the note below. */
  .chat-history .history-row { flex-wrap:wrap; }
  .chat-history .history-pop { position:static; flex:1 0 100%; min-width:0; margin:0 6px 6px 10px; box-shadow:none; }
}

/* Monitoring tables: only long-text columns (model, name) wrap, everything else stays on one line, and the table scrolls sideways with a visible
 * scrollbar plus edge shadows (pure CSS: shadows appear only on the side that has more content). */
.mon-table { overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:thin; scrollbar-color:var(--fg-muted) transparent; border:0; border-radius:0;
  background:
    linear-gradient(to right, var(--fg-surface) 30%, transparent) 0 0 / 40px 100% no-repeat local,
    linear-gradient(to left, var(--fg-surface) 30%, transparent) 100% 0 / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .22), transparent) 0 0 / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .22), transparent) 100% 0 / 14px 100% no-repeat scroll; }
body.dark .mon-table { background:
    linear-gradient(to right, var(--fg-surface) 30%, transparent) 0 0 / 40px 100% no-repeat local,
    linear-gradient(to left, var(--fg-surface) 30%, transparent) 100% 0 / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .6), transparent) 0 0 / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .6), transparent) 100% 0 / 14px 100% no-repeat scroll; }
.mon-table::-webkit-scrollbar { height:10px; }
.mon-table::-webkit-scrollbar-thumb { background:var(--fg-muted); border-radius:5px; border:2px solid var(--fg-surface); }
.mon-table::-webkit-scrollbar-track { background:transparent; }
.mon-table table { width:100%; }
.mon-table th { background:transparent; position:static; white-space:nowrap; }
.mon-table td { white-space:nowrap; vertical-align:top; }
.mon-table td.wrap { white-space:normal; overflow-wrap:anywhere; min-width:9em; }
@media (max-width: 700px) {
  /* Narrow screens: keep each cell on one line and let the table scroll sideways (edge shadow + scrollbar show it). */
  .mon-table td, .mon-table td.wrap { white-space:nowrap; overflow-wrap:normal; min-width:0; }
  .mon-table table { width:max-content; min-width:100%; }
  .mon-table th, .mon-table td { padding-left:8px; padding-right:8px; font-size:13px; }
  /* Tabs wrap onto a second row so none is hidden. */
  .mon-tabs { flex-wrap:wrap; overflow-x:visible; gap:0 2px; }
  .mon-tab { padding:9px 10px; }
}

/* Round 2 (2026-11-13): monitoring tables keep every numeric column in view. Name columns are capped and end in an ellipsis (full text in
 * the title attribute), numeric columns never shrink, and cell padding is tighter so the half-width panels fit all columns at 1280px. */
.mon-table th, .mon-table td { padding-left:10px; padding-right:10px; }
.mon-table .mon-name { display:block; max-width:11em; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.mon-table td.wrap { white-space:nowrap; min-width:0; overflow-wrap:normal; }
.mon-table th.num, .mon-table td.num { padding-left:8px; padding-right:8px; }
@media (max-width: 700px) {
  .mon-table .mon-name { max-width:6.5em; }
  .mon-table th, .mon-table td { padding-left:5px; padding-right:5px; font-size:12.5px; }
  .mon-table th { font-size:12px; }
  .mon-table th.num, .mon-table td.num { padding-left:4px; padding-right:4px; }
}

/* Round 2: toasts size to their text (position:fixed + left:50% would otherwise leave only half the screen), and the phone history menu stays inside the drawer. */
.toast { width:max-content; min-width:min(260px, 92vw); max-width:min(92vw, 420px); box-sizing:border-box; }
@media (max-width: 700px) {
  .chat-history .history-pop { flex:0 0 calc(100% - 16px); width:calc(100% - 16px); max-width:calc(100% - 16px); box-sizing:border-box; }
}

/* Reply-style editor (admin 模型與分級, docs/reply-style.md): secondary actions look like buttons, a live character counter,
 * a full-text preview before a restore, and a version table that scrolls sideways on phones instead of breaking every cell
 * into one character per line. */
.reply-style-actions { margin:12px 0 4px; }
.panel button.reply-style-button, button.reply-style-button { min-height:34px; padding:6px 14px; border:1px solid var(--fg-line); border-radius:8px; background:var(--fg-surface); color:var(--fg-text); font-weight:600; white-space:nowrap; }
.panel button.reply-style-button:hover, button.reply-style-button:hover { border-color:var(--fg-accent); color:var(--fg-accent); }
.reply-style-count { margin:-4px 0 0; font-size:12.5px; font-variant-numeric:tabular-nums; color:var(--fg-muted); }
.reply-style-count.over { color:#b3261e; font-weight:600; }
body.dark .reply-style-count.over { color:#ffb4ab; }
.reply-style-history { overflow-x:auto; -webkit-overflow-scrolling:touch; }
.reply-style-history:focus-visible { outline:2px solid var(--fg-accent); outline-offset:2px; }
.reply-style-history table { min-width:34rem; }
.reply-style-history th, .reply-style-history td { white-space:nowrap; }
.modal .reply-style-preview { max-height:50vh; margin:0 0 12px; padding:12px 14px; overflow:auto; border:1px solid var(--fg-line); border-radius:8px; background:var(--fg-soft); white-space:pre-wrap; overflow-wrap:anywhere; font:14px/1.7 inherit; }
