/* Conversation Summary Prompt — responsive, accessible tool UI */
:root {
  --cs-primary: #3156d9;
  --cs-primary-hover: #2445bb;
  --cs-ink: #14213d;
  --cs-muted: #65738b;
  --cs-line: #dce3ef;
  --cs-surface: #ffffff;
  --cs-bg: #f4f7fc;
  --cs-success: #13845b;
  --cs-danger: #c53b48;
}
* { box-sizing: border-box; }
body[data-page="conversation-summary"] { background: var(--cs-bg); }
.conversation-summary-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .92fr);
  align-items: stretch;
  gap: 1.15rem;
  min-height: min(820px, calc(100vh - 110px));
  padding: clamp(.75rem, 2.2vw, 1.5rem);
  max-width: 1500px;
  margin: 0 auto;
  color: var(--cs-ink);
}
.conversation-summary-app > header {
  grid-column: 1 / -1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .45rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid #dbe4fb;
  border-radius: 20px;
  background: linear-gradient(125deg, #fff 8%, #f0f4ff 100%);
  box-shadow: 0 8px 28px rgba(30, 54, 110, .06);
}
.conversation-summary-app > header::after {
  content: ""; position: absolute; width: 170px; height: 170px; right: -45px; top: -75px;
  border-radius: 50%; background: rgba(49, 86, 217, .08); pointer-events: none;
}
.conversation-summary-app header h1 {
  margin: 0; color: var(--cs-primary); font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 800; letter-spacing: -.035em; line-height: 1.2;
}
.conversation-summary-app header p, .conversation-summary-app .helper-text {
  margin: 0; color: var(--cs-muted); font-size: .9rem; line-height: 1.6;
}
.conversation-summary-app .card {
  min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: .9rem;
  padding: clamp(1rem, 2vw, 1.35rem); background: var(--cs-surface);
  border: 1px solid var(--cs-line); border-radius: 18px;
  box-shadow: 0 8px 26px rgba(23, 43, 77, .045);
}
.conversation-summary-app .card h2 {
  margin: 0; font-size: 1.05rem; font-weight: 750; letter-spacing: -.015em;
}
.conversation-summary-app label { font-size: .85rem; font-weight: 700; }
.conversation-summary-app .req { color: var(--cs-danger); }
.conversation-input, .prompt-preview {
  display: block; width: 100%; min-height: 290px; flex: 1; resize: vertical;
  border: 1px solid #d5deeb; border-radius: 12px; padding: .95rem;
  font: 400 .87rem/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--cs-ink); background: #fbfcff; outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.conversation-input:focus, .prompt-preview:focus {
  border-color: var(--cs-primary); background: #fff;
  box-shadow: 0 0 0 4px rgba(49, 86, 217, .12);
}
.prompt-preview { min-height: 480px; background: #101b32; color: #d8e6ff; border-color: #263753; }
.conversation-meta {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .6rem;
  color: var(--cs-muted); font-size: .78rem;
}
.clear-btn {
  display: inline-flex; align-items: center; gap: .4rem; border: 1px solid transparent;
  background: transparent; color: #b52d3c; cursor: pointer; padding: .45rem .65rem;
  border-radius: 8px; font: inherit; font-weight: 650; transition: background .18s, border-color .18s;
}
.clear-btn:hover:not(:disabled) { background: #fff0f1; border-color: #ffd5d9; }
.clear-btn:disabled { opacity: .4; cursor: not-allowed; }
.limit-picker { padding: .95rem; border: 1px solid #dce5fb; background: #f8faff; border-radius: 14px; }
.limit-heading { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .7rem; }
.limit-title { font-size: .88rem; font-weight: 800; color: var(--cs-ink); }
.limit-hint { font-size: .75rem; color: var(--cs-muted); }
.limit-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.limit-option {
  display: flex; align-items: center; justify-content: center; gap: .45rem; min-height: 58px;
  border: 1px solid #d6dfef; border-radius: 11px; background: white; color: var(--cs-ink);
  cursor: pointer; transition: border-color .18s, background .18s, transform .15s, box-shadow .18s;
}
.limit-option:hover { border-color: #9aafea; transform: translateY(-1px); }
.limit-option.is-selected { border: 2px solid var(--cs-primary); background: #edf2ff; box-shadow: 0 0 0 3px rgba(49, 86, 217, .08); }
.limit-number { font-size: 1.2rem; font-weight: 850; letter-spacing: -.04em; }
.limit-copy { font-size: .77rem; font-weight: 650; }
.limit-note { margin: .65rem 0 0; color: var(--cs-muted); font-size: .75rem; line-height: 1.45; }
.conversation-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.conversation-summary-app .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem; min-height: 45px;
  border: 1px solid transparent; border-radius: 10px; padding: .75rem 1.05rem;
  background: var(--cs-primary); color: #fff; font-weight: 750; font-size: .88rem;
  cursor: pointer; transition: background .18s, transform .15s, box-shadow .18s;
}
.conversation-summary-app .btn:hover:not(:disabled) { background: var(--cs-primary-hover); box-shadow: 0 5px 14px rgba(49, 86, 217, .2); }
.conversation-summary-app .btn:active:not(:disabled) { transform: scale(.985); }
.conversation-summary-app .btn:focus-visible, .limit-option:focus-visible, .clear-btn:focus-visible { outline: 3px solid #9bb4ff; outline-offset: 3px; }
.conversation-summary-app .btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.conversation-summary-app .btn-secondary { background: #eaf0fb; border-color: #dbe4f3; color: #243654; }
.conversation-summary-app .btn-secondary:hover:not(:disabled) { background: #dce6f8; box-shadow: none; }
.conversation-summary-app .btn-success-state { background: var(--cs-success) !important; box-shadow: 0 4px 14px rgba(19, 132, 91, .18); }
.copy-status { color: var(--cs-success); font-size: .82rem; font-weight: 650; }
.toast-container {
  position: fixed; z-index: 9999; right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom)); display: grid; gap: .6rem;
  width: min(390px, calc(100vw - 2rem)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; border-radius: 13px;
  background: #17243d; color: #fff; box-shadow: 0 12px 35px rgba(10, 22, 45, .25);
  font-size: .86rem; line-height: 1.45; animation: toast-enter .22s ease-out both;
}
.toast-success { background: #116b4b; }
.toast-error { background: #a82b3b; }
.toast-info { background: #253f87; }
.toast-icon {
  display: grid; place-items: center; flex: 0 0 1.5rem; width: 1.5rem; height: 1.5rem;
  border-radius: 50%; background: rgba(255,255,255,.17); font-weight: 900;
}
.toast-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 900px) {
  .conversation-summary-app { grid-template-columns: minmax(0, 1fr); min-height: auto; }
  .conversation-summary-app > header { grid-column: 1; }
  .conversation-summary-app .card { min-height: auto; }
  .conversation-input { min-height: 300px; flex: initial; }
  .prompt-preview { min-height: 420px; flex: initial; }
}
@media (max-width: 480px) {
  .conversation-summary-app { gap: .8rem; padding: .65rem; }
  .conversation-summary-app > header { border-radius: 15px; padding: 1.15rem; }
  .conversation-summary-app .card { padding: .9rem; border-radius: 14px; }
  .conversation-summary-app .helper-text { font-size: .82rem; }
  .conversation-input { min-height: 250px; }
  .prompt-preview { min-height: 350px; }
  .conversation-summary-app .btn { width: 100%; }
  .conversation-actions { align-items: stretch; }
  .copy-status { width: 100%; }
  .limit-option { flex-direction: column; gap: .1rem; padding: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Viewport-fit refinement: keep the working surface compact while preserving responsive controls. */
html, body { min-height: 100%; }
body[data-page="conversation-summary"] { overflow-x: hidden; }
.conversation-summary-app {
  height: calc(100vh - 126px);
  height: calc(100dvh - 126px);
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: .75rem;
  padding: .75rem clamp(.75rem, 1.5vw, 1.25rem);
}
.conversation-summary-app > header {
  gap: .25rem;
  padding: .8rem 1.15rem;
  border-radius: 14px;
}
.conversation-summary-app header h1 { font-size: clamp(1.25rem, 2vw, 1.65rem); }
.conversation-summary-app header p { font-size: .82rem; line-height: 1.4; }
.conversation-summary-app .card {
  gap: .55rem;
  padding: .85rem;
  border-radius: 14px;
  overflow: hidden;
}
.conversation-summary-app .card h2 { font-size: .98rem; }
.conversation-summary-app .helper-text { font-size: .78rem; line-height: 1.35; }
.conversation-input, .prompt-preview {
  min-height: 0;
  height: 100%;
  flex: 1 1 0;
  resize: none;
  padding: .7rem;
  font-size: .79rem;
  line-height: 1.45;
}
.prompt-preview { min-height: 0; }
.limit-picker { padding: .65rem; border-radius: 11px; }
.limit-heading { margin-bottom: .4rem; }
.limit-options { gap: .45rem; }
.limit-option { min-height: 42px; }
.limit-number { font-size: 1.05rem; }
.limit-note { margin-top: .35rem; font-size: .7rem; }
.conversation-summary-app .btn { min-height: 39px; padding: .55rem .8rem; font-size: .82rem; }
.conversation-actions { gap: .5rem; }
@media (max-width: 900px) {
  .conversation-summary-app {
    height: auto;
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
    align-content: stretch;
    gap: .55rem;
    padding: .55rem;
  }
  .conversation-summary-app > header { padding: .65rem .85rem; }
  .conversation-summary-app header h1 { font-size: 1.18rem; }
  .conversation-summary-app header p { font-size: .75rem; }
  .conversation-summary-app .card { gap: .4rem; padding: .65rem; }
  .conversation-summary-app .helper-text { font-size: .72rem; }
  .conversation-input { min-height: 90px; height: 100%; flex: 1 1 0; }
  .prompt-preview { min-height: 110px; height: 100%; flex: 1 1 0; }
  .conversation-meta { gap: .25rem; font-size: .7rem; }
  .limit-picker { padding: .5rem; }
  .limit-hint, .limit-note { display: none; }
  .limit-option { min-height: 36px; flex-direction: row; }
  .conversation-summary-app .btn { min-height: 36px; padding: .45rem .65rem; }
  .conversation-summary-app .btn-secondary { width: 100%; }
}
@media (max-width: 480px) {
  .conversation-summary-app { gap: .45rem; padding: .4rem; }
  .conversation-summary-app > header { border-radius: 11px; padding: .55rem .7rem; }
  .conversation-summary-app .card { border-radius: 11px; padding: .55rem; }
  .conversation-summary-app .helper-text { display: none; }
  .conversation-summary-app label { font-size: .76rem; }
  .conversation-input { min-height: 72px; }
  .prompt-preview { min-height: 86px; }
  .conversation-actions { gap: .35rem; }
  .conversation-summary-app .btn { width: auto; }
  #copyPrompt { flex: 1; }
  .copy-status { width: auto; font-size: .72rem; }
  .limit-number { font-size: .95rem; }
  .limit-copy { font-size: .7rem; }
}
@media (max-height: 700px) {
  .conversation-summary-app { gap: .45rem; padding-top: .45rem; padding-bottom: .45rem; }
  .conversation-summary-app > header { padding-top: .45rem; padding-bottom: .45rem; }
  .conversation-summary-app .card { gap: .35rem; padding: .55rem; }
  .limit-picker { padding: .4rem; }
  .conversation-summary-app .helper-text { display: none; }
}
