/* glass surface */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color .4s var(--ease-mag);
}
.glass:hover { border-color: rgba(255, 255, 255, .16); }

/* layout */
.workspace { display: grid; gap: 16px; grid-template-columns: 340px minmax(0, 1fr) minmax(0, 1.15fr); align-items: stretch; }
.rail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rail .glass { padding: 16px 18px; }
.rail .label { margin-bottom: 10px; }

/* desktop: an app-shell. The page itself stays put; each panel scrolls on its own. */
@media (min-width: 1281px) {
  .workspace { height: calc(100vh - 215px); min-height: 640px; }
  .rail { overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--gray-dark) transparent; }
  .convo, .viewer { height: 100%; min-height: 0; max-height: none; }
}
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.center { justify-content: center; }
@media (max-width: 1280px) {
  .workspace { grid-template-columns: 340px minmax(0, 1fr); }
  .viewer { grid-column: 1 / -1; height: 78vh; }
}
@media (max-width: 860px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

/* inputs */
.field {
  width: 100%; padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.04); outline: none; transition: border-color .3s, background .3s;
}
.field::placeholder { color: #6b7280; }
.field:focus { border-color: var(--line-2); background: rgba(255,255,255,.07); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: 999px; cursor: pointer; border: 1px solid transparent;
  font-size: .7rem; font-weight: 500; letter-spacing: .2em; text-transform: uppercase;
  transition: background .25s, color .25s, border-color .25s, opacity .25s;
}
.btn-solid { background: #fff; color: #000; }
.btn-solid:hover:not(:disabled) { background: #e5e7eb; }
.btn-ghost { background: var(--glass-2); border-color: var(--line); color: #fff; }
.btn-ghost:hover:not(:disabled) { border-color: var(--line-2); background: rgba(255,255,255,.12); }
.btn-sm { padding: 8px 16px; font-size: .62rem; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:focus-visible, .tab:focus-visible, .icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.btn.is-hot { background: #fff; color: #000; }

/* dropzone */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 16px 14px;
  margin-bottom: 10px; cursor: pointer; border: 1px dashed var(--line-2); border-radius: 16px;
  background: rgba(255,255,255,.02); color: var(--gray);
  transition: border-color .3s, background .3s, color .3s;
}
.drop svg { margin-bottom: 6px; }
.drop strong { color: #fff; font-weight: 500; font-size: .92rem; overflow-wrap: anywhere; }
.drop span { font-size: .75rem; }
.drop:hover, .drop.over { border-color: #fff; background: rgba(255,255,255,.06); color: #fff; }
.drop.has-file { border-style: solid; border-color: rgba(126,226,176,.45); }
.drop.is-bad { border-color: rgba(255,123,123,.6); }
.progress { height: 3px; border-radius: 2px; background: var(--line); margin: -4px 0 14px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: #fff; transition: width .2s linear; }
.progress.indeterminate i { width: 40%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* upload status line */
.doc-status { margin: 0; font-size: .82rem; color: var(--gray); }
.doc-status[data-kind="ok"] { color: var(--ok); }
.doc-status[data-kind="bad"] { color: var(--bad); }
.doc-status[data-kind="busy"] { color: var(--warn); }

/* locked while a file is processing or a call is live */
.drop.is-locked { cursor: not-allowed; opacity: .55; pointer-events: none; }
.field:disabled { opacity: .5; cursor: not-allowed; }

/* assistant picker */
.assistants { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.who small { display: none; }
.assistant {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02);
  transition: border-color .25s, background .25s, opacity .25s;
}
.assistant:hover:not(:disabled) { border-color: var(--line-2); background: rgba(255,255,255,.05); }
.assistant.is-selected { border-color: #fff; background: rgba(255,255,255,.1); }
.assistant:disabled { opacity: .5; cursor: not-allowed; }
.assistant:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.avatar {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--display); font-weight: 600; font-size: 1rem; color: #000;
  background: radial-gradient(circle at 32% 28%, #fff, #9ca3af);
}
.assistant:not(.is-selected) .avatar { background: rgba(255,255,255,.1); color: #fff; }
.who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.who b { font-weight: 500; font-size: .9rem; }
.who small { color: var(--gray); font-size: .68rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* call orb */
/* orb on the left, status + buttons on the right, so Start call is always in view */
.call {
  display: grid; grid-template-columns: 92px minmax(0, 1fr); grid-template-areas: "title title" "orb label" "orb buttons";
  column-gap: 16px; align-items: center;
}
.call .label { grid-area: title; }
.call .orb { grid-area: orb; }
.call .orb-label { grid-area: label; align-self: end; }
.call .row { grid-area: buttons; align-self: start; flex-wrap: nowrap; gap: 8px; justify-content: flex-start; }
.call .row .btn { flex: 1; padding: 11px 6px; letter-spacing: .14em; white-space: nowrap; }
.orb { position: relative; width: 92px; height: 92px; margin: 0; }
.orb span { position: absolute; border-radius: 50%; }
.orb .halo { inset: -18px; background: radial-gradient(circle, rgba(255,255,255,.18), transparent 65%); opacity: .5; transition: opacity .4s; }
.orb .ring { inset: 0; border: 1px solid var(--line-2); }
.orb .ring::after {
  content: ""; position: absolute; inset: -1px; border-radius: 50%; border: 1px solid transparent;
  border-top-color: #fff; opacity: 0;
}
.orb .core {
  inset: 18px; background: radial-gradient(circle at 32% 28%, #fff, #9ca3af 45%, #1f2937);
  box-shadow: 0 0 40px rgba(255,255,255,.18); transition: transform .35s var(--ease), filter .35s, box-shadow .35s;
}
.orb[data-state="idle"] .core { filter: grayscale(1) brightness(.55); box-shadow: none; }
.orb[data-state="idle"] .halo { opacity: .15; }
.orb[data-state="connecting"] .ring::after { opacity: 1; animation: spin 1.1s linear infinite; }
.orb[data-state="listening"] .core { animation: breathe 3.4s ease-in-out infinite; }
.orb[data-state="user"] .core { transform: scale(1.14); box-shadow: 0 0 60px rgba(126,226,176,.55); filter: hue-rotate(110deg) saturate(.7); }
.orb[data-state="user"] .halo { opacity: 1; }
.orb[data-state="agent"] .core { animation: speak .9s ease-in-out infinite; box-shadow: 0 0 70px rgba(255,255,255,.55); }
.orb[data-state="agent"] .halo { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.06); } }
@keyframes speak { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.orb-label { margin: 0 0 10px; min-height: 1.4em; font-size: .85rem; line-height: 1.35; color: var(--gray); }

/* conversation */
.convo { display: flex; flex-direction: column; min-height: 520px; max-height: 760px; min-width: 0; }
.chat { min-height: 0; }
.convo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.chat { flex: 1; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding: 8px 4px 4px 0; scrollbar-width: thin; scrollbar-color: var(--gray-dark) transparent; }
.chat.small { max-height: 320px; margin-top: 16px; }
.empty { margin: auto; text-align: center; color: var(--gray); font-size: .92rem; padding: 40px 12px; }
.empty span { display: block; margin-top: 6px; font-size: .78rem; color: #6b7280; }

.msg { max-width: 86%; padding: 12px 16px; border-radius: 18px; font-size: .94rem; overflow-wrap: anywhere; animation: pop .5s var(--ease); }
.msg small { display: block; margin-bottom: 3px; font-size: .58rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gray); }
.msg.user { align-self: flex-end; background: #fff; color: #000; border-bottom-right-radius: 6px; font-weight: 400; }
.msg.user small { color: #6b7280; }
.msg.agent { align-self: flex-start; background: var(--glass-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.system { align-self: center; max-width: 100%; padding: 2px; background: none; color: #6b7280; font-size: .72rem; letter-spacing: .1em; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }

/* clickable page citations */
.cite {
  display: inline; padding: 1px 9px; margin: 0 1px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.08); color: #fff; font-size: .86em; font-weight: 500;
  transition: background .25s, color .25s;
}
.cite:hover { background: #fff; color: #000; }
.msg.user .cite { color: #000; border-color: rgba(0,0,0,.3); background: rgba(0,0,0,.06); }
.msg.user .cite:hover { background: #000; color: #fff; }

/* archive */
.archive { display: grid; grid-template-columns: minmax(280px, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .archive { grid-template-columns: minmax(0, 1fr); } }
.sessions { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sessions li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02);
  transition: border-color .3s, background .3s;
}
.sessions li:hover { border-color: var(--line-2); background: rgba(255,255,255,.05); }
.sessions li.is-active { border-color: #fff; }
.sessions li.plain { cursor: default; color: var(--gray); }
.sessions li.plain:hover { border-color: var(--line); background: rgba(255,255,255,.02); }
.sessions .meta { min-width: 0; }
.sessions .meta b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sessions .meta span { color: var(--gray); font-size: .76rem; }
.sessions .badge { font-size: .6rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ok); white-space: nowrap; }
#detail-audio { width: 100%; margin-top: 12px; height: 44px; color-scheme: dark; }
#detail-meta { margin: 6px 0 0; }
#detail .row { margin: 0; }
a.btn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
