/* ==========================================================================
   Xero AI · components.css
   Reusable pieces: icon buttons, pop-up menus, viewers, dialogs, the sign-in
   modal, the profile page, the sources sheet and attachment chips.
   ========================================================================== */

/* ---- Icon buttons (block headers, message actions, viewers) ---- */
.icon-action {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.icon-action svg { width: 17px; height: 17px; }
.icon-action:hover { background: color-mix(in srgb, CanvasText 7%, transparent); color: var(--text); } /* a pale black background on hover (pale white in dark mode), no lift */
.icon-action.is-done { color: var(--accent); }
.icon-action.is-active[aria-pressed] svg { fill: currentColor; fill-opacity: .18; } /* the soft fill is for like / dislike only; the read-aloud bars stay plain while playing */

.block-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }

/* ---- Pop-up menu ---- */
.popup-menu {
  position: fixed;
  z-index: 2500;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--glass-edge);
  border-radius: 16px;
  background: var(--popup-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: 0 0 16px rgba(16, 24, 19, .14); /* same as the Effort menu */
  animation: pop .14s ease both;
}
.popup-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  font-size: var(--ui-size);
  font-weight: 500;
  text-align: left;
}
.popup-menu-item:hover, .popup-menu-item:focus-visible { background: var(--soft); outline: none; }
.popup-menu-item:disabled { opacity: .45; }
.popup-menu-sep { height: 1px; margin: 6px 10px; background: var(--glass-edge); }
.popup-menu-item svg { width: 18px; height: 18px; color: var(--muted); }
.popup-menu-item.is-danger, .popup-menu-item.is-danger svg { color: var(--danger); }

/* ---- Full-window viewers (drawing, image) ---- */
.viewer-backdrop, .confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  padding: 3vh 3vw;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: appear .18s ease;
}
.viewer {
  width: min(100%, 1100px);
  height: min(100%, 90dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  background: var(--viewer-bg);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .35);
}
.viewer.image-viewer { width: min(100%, 960px); }
/* One picture opened on a computer */
.lightbox-backdrop { position: fixed; inset: 0; z-index: 1400; display: grid; place-items: center; padding: 4vh 6vw; background: rgba(0, 0, 0, .62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: appear .18s ease; }
.lightbox { display: flex; flex-direction: column; align-items: center; max-width: 100%; }
.lightbox-frame { position: relative; display: flex; max-width: 100%; }
.lightbox-img { display: block; max-width: min(78vw, 1100px); max-height: 82vh; object-fit: contain; border-radius: 14px; background: #fff; }
.lightbox-side { position: absolute; top: 0; left: calc(100% + 14px); display: flex; flex-direction: column; gap: 8px; }
.lightbox-btn { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; }
.lightbox-btn:hover { background: rgba(255, 255, 255, .26); color: #fff; }
.lightbox-btn svg { width: 19px; height: 19px; }
.lightbox-name { max-width: 100%; margin: 12px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: .9375rem; font-weight: 600; }

/* ---- Code panel (laptops and desktops): opens on the right, the chat narrows, the chat list slides away ---- */
.code-panel {
  flex: 0 0 0;
  min-width: 0;
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--viewer-bg);
  transition: flex-basis .26s ease;
}
.code-panel.is-open { flex-basis: min(50vw, 860px); }
.code-panel > * { width: min(50vw, 860px); } /* the code keeps its width while the panel slides, so it never re-wraps */
.code-panel > .viewer-code { flex: 1; }
.code-panel-scrim { position: fixed; top: 0; bottom: 0; left: 0; right: min(50vw, 860px); z-index: 1000; cursor: default; }
/* Code on phones and tablets: the same bottom sheet as Sources and Thought for a moment */
.code-sheet { transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.code-sheet-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.code-sheet .viewer-code { flex: 1 1 auto; min-height: 0; padding: 4px 16px 16px; font-size: 0.78125rem; }
body.code-panel-open .sidebar { margin-left: calc(-1 * var(--sidebar-w)); visibility: hidden; transition: margin-left .26s ease, visibility 0s .26s; }
.viewer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--line);
}
.code-panel:has(> .file-view-wrap) > .viewer-head { padding: 3px 8px 3px 16px; } /* opened files: a slimmer top bar than code */
.code-panel:has(> .file-view-wrap) > .viewer-head .icon-action { width: 28px; height: 28px; }
.code-sheet:has(> .file-view-wrap) .sheet-head { padding-bottom: 4px; }
.code-sheet:has(> .file-view-wrap) .block-actions .icon-action { width: 28px; height: 28px; }
.viewer-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; font-weight: 650; }
.viewer-body { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.viewer-body.is-centered { display: flex; align-items: center; justify-content: center; }
.viewer-image { display: block; max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; }
.viewer-code[contenteditable]:focus { outline: none; }
.viewer-code { flex: 1; min-height: 0; margin: 0; padding: 18px 20px; overflow: auto; white-space: pre; tab-size: 2; font: .84375rem/1.7 var(--mono); }

/* ---- Confirm dialog ---- */
.confirm-backdrop { z-index: 1300; }
.confirm-dialog {
  width: min(100%, 340px);
  padding: 24px 22px 18px;
  border: 1px solid var(--glass-edge);
  border-radius: 20px;
  background: var(--popup-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .30);
  text-align: center;
}
.confirm-dialog h3 { margin: 0 0 8px; font-size: 1.125rem; font-weight: 650; }
.confirm-dialog .pp-input { margin-top: 12px; }
.confirm-dialog p { margin: 0; color: var(--muted); font-size: var(--ui-size); line-height: 1.55; }
.confirm-dialog .confirm-error { margin-top: 10px; color: var(--danger); }
.confirm-actions { display: flex; gap: 10px; margin-top: 20px; }
.confirm-btn {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--glass-edge);
  border-radius: 12px;
  background: var(--soft);
  font-size: var(--ui-size);
  font-weight: 600;
  transition: border-color .2s ease, transform .2s ease;
}
.confirm-btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.confirm-btn:disabled { opacity: .6; }
.confirm-danger { border-color: #c0453a; background: #c0453a; color: #fff; }
.confirm-danger:hover:not(:disabled) { border-color: #a93a30; background: #a93a30; }
/* "Rename chat": left-aligned, a close button, and a green Save */
.rename-dialog { width: min(100%, 420px); text-align: left; }
.rename-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rename-head h3 { margin: 0 0 4px; }
.rename-x { flex: none; width: 28px; height: 28px; margin: -4px -6px 0 0; padding: 0; border: 0; background: none; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.rename-x:hover { color: var(--text); }
.rename-dialog .pp-input:focus-visible { outline: none; border-color: var(--accent); } /* one thin green line instead of the wide ring */
.rename-dialog .confirm-actions { justify-content: flex-end; }
.rename-dialog .confirm-btn { flex: none; min-width: 84px; }
.confirm-primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.confirm-primary:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--accent-hover); }

/* ---- Sign-in modal ---- */
.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.auth-modal {
  position: relative;
  width: min(100%, 380px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 34px 24px 20px;
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  background: var(--popup-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .30), var(--glass-hi);
  text-align: center;
  animation: pop .2s ease both;
}
.auth-modal h2 { margin: 0 0 8px; font-size: 1.25rem; font-weight: 600; letter-spacing: -.2px; }
.auth-description { max-width: 300px; margin: 0 auto 18px; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
}
.auth-close:hover { background: var(--soft); }
.auth-provider-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 9px; /* same height, corners and tint as the "+ New chat" box in the left panel */
  border: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  font-size: var(--msg-size);
  line-height: 1.4;
  font-weight: 600;
  transition: border-color .2s ease, transform .2s ease;
}
.auth-provider-btn:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.google-g { width: 18px; height: 18px; flex: none; }
.auth-provider-btn + .auth-provider-btn { margin-top: 8px; }
/* "Continue with phone" swaps the email box for the phone box (and the button then offers email instead). */
#authViewMain .when-phone { display: none; }
#authViewMain.is-phone .when-email { display: none; }
#authViewMain.is-phone span.when-phone { display: inline; }
#authViewMain.is-phone svg.when-phone { display: block; }
#authViewMain.is-phone form.when-phone { display: block; }
.auth-select { position: relative; }
.auth-select select {
  width: 100%; padding: 11px 34px 11px 12px; border: 1px solid var(--glass-edge); border-radius: 12px; appearance: none; -webkit-appearance: none;
  background: transparent; color: var(--text); font: inherit; font-size: var(--msg-size); line-height: 1.4; text-align: left;
}
.auth-select select { cursor: pointer; }
.auth-select select:focus { outline: none; border-color: var(--accent); }
.auth-select select option { color: #111; }
.auth-select svg { position: absolute; right: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--muted); pointer-events: none; }
.auth-phone-row { position: relative; margin-top: 8px; }
.auth-phone-row .auth-input { padding-left: 52px; }
.auth-dial { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: var(--msg-size); pointer-events: none; }
.auth-icon { width: 18px; height: 18px; flex: none; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 14px 0; color: var(--muted); font-size: 0.75rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--glass-edge); }
.auth-input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--glass-edge); border-radius: 12px;
  background: transparent; color: var(--text); font: inherit; font-size: var(--msg-size); line-height: 1.4; text-align: left;
}
.auth-input:focus { outline: none; border-color: var(--accent); }
.auth-code { text-align: center; letter-spacing: .3em; }
.auth-continue {
  width: 100%; margin-top: 8px; padding: 11px 9px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--on-accent); font-size: var(--msg-size); line-height: 1.4; font-weight: 600;
  transition: background .2s ease, opacity .2s ease, transform .2s ease;
}
.auth-continue:hover { background: var(--accent-hover); transform: translateY(-1px); }
.auth-continue:disabled { opacity: .5; cursor: default; transform: none; }
.auth-link { margin-top: 8px; padding: 6px 10px; border: 0; background: transparent; color: var(--muted); font-size: 0.75rem; text-decoration: underline; }
.auth-error { margin: -6px auto 12px; max-width: 300px; color: var(--danger); font-size: 0.75rem; line-height: 1.45; }
.auth-terms { margin: 14px 0 0; color: var(--muted); font-size: 0.6875rem; line-height: 1.5; }
.auth-terms a, .pp-hint a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.auth-terms a:hover, .pp-hint a:hover { color: var(--accent); }

/* ---- Profile & settings page ---- */
/* (No "fixed" background here: the page already covers the screen, and a fixed background repaints on every frame of the
   reveal, which made the screen flicker on tablets. The page gets its own layer while it opens and closes.) */
.profile-page { position: fixed; inset: 0; z-index: 900; display: flex; background: var(--app-bg); }
/* Circular reveal from the avatar on open, back into it on close. */
.profile-page:not([hidden]) { animation: pp-reveal .65s cubic-bezier(.22, .8, .24, 1) backwards; will-change: clip-path; transform: translateZ(0); backface-visibility: hidden; }
.profile-page.is-closing { animation: pp-hide .18s cubic-bezier(.4, 0, .8, .4) forwards; }
@keyframes pp-reveal {
  from { clip-path: circle(0 at var(--cx, 40px) var(--cy, calc(100vh - 40px))); }
  to { clip-path: circle(150vmax at var(--cx, 40px) var(--cy, calc(100vh - 40px))); }
}
@keyframes pp-hide {
  from { clip-path: circle(150vmax at var(--cx, 40px) var(--cy, calc(100vh - 40px))); }
  to { clip-path: circle(0 at var(--cx, 40px) var(--cy, calc(100vh - 40px))); }
}
.pp-side {
  flex: 0 0 255px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 23px 16px;
  overflow-y: auto;
  background: var(--app-bg);
  border-right: 1px solid color-mix(in srgb, var(--text) 11%, transparent);
}
.pp-head { display: flex; align-items: center; gap: 8px; }
.pp-side h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.5px; }
.pp-back {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.pp-back:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.pp-back svg { width: 20px; height: 20px; transition: transform .25s cubic-bezier(.3, .85, .3, 1); }
.pp-back:hover svg { transform: translateX(-3px); }
.pp-back:active { transform: scale(.92); }

.pp-tabs { position: relative; display: flex; flex-direction: column; gap: 4px; }
.pp-tab {
  position: relative;
  z-index: 1;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font-size: var(--ui-size);
  transition: color .25s ease, background .2s ease;
}
.pp-tab:not(.active):hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.pp-tab.active { font-weight: 600; }
.pp-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  opacity: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  pointer-events: none;
  transition: transform .38s cubic-bezier(.3, .85, .3, 1), width .38s cubic-bezier(.3, .85, .3, 1), height .38s cubic-bezier(.3, .85, .3, 1), opacity .15s ease;
}
.pp-indicator.is-ready { opacity: 1; }
.pp-indicator.no-anim { transition: none; }

.pp-admin-link {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: var(--ui-size);
  text-decoration: none;
}
.pp-admin-link:hover { background: color-mix(in srgb, var(--text) 5%, transparent); color: var(--text); }

.pp-main { flex: 1; min-width: 0; overflow-y: auto; padding: 40px 56px 48px; }
.pp-mhead { display: none; align-items: center; gap: 8px; margin-bottom: 8px; }
.pp-mhead h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.5px; }
.pp-inner { max-width: 720px; margin: 0 auto; }
.pp-panel { display: flex; flex-direction: column; }
.pp-card {
  padding: 18px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 11%, transparent);
  font-size: var(--ui-size);
}
.pp-card:last-child { border-bottom: 0; }
/* A setting with choices: text on the left, the choices on the right. */
.pp-card:has(> .seg) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; }
.pp-card:has(> .seg) > .seg { grid-column: 2; grid-row: 1 / span 2; }
.pp-card strong { display: block; font-size: var(--ui-size); }
.pp-user { display: flex; align-items: center; gap: 16px; }
.pp-user strong { font-size: 1rem; }
.pp-user small { display: block; margin-top: 4px; color: var(--muted); font-size: 0.8125rem; overflow-wrap: anywhere; }
.pp-avatar { width: 58px; height: 58px; font-size: 1.25rem; flex-shrink: 0; }
.pp-label { display: block; margin: 0 0 8px; font-size: var(--ui-size); font-weight: 600; }
.pp-card .pp-label:not(:first-child) { margin-top: 16px; }
.pp-hint { display: block; margin-top: 6px; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.pp-row { display: flex; align-items: center; gap: 10px; }
.pp-between { justify-content: space-between; }
.pp-end { justify-content: flex-end; margin-top: 14px; }
.pp-input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
  border-radius: 8px;
  background: transparent;
  font-size: var(--msg-size);
}
.pp-input[readonly], .pp-input:disabled { opacity: .75; }
.pp-textarea { resize: vertical; line-height: 1.6; }
.pp-btn {
  flex-shrink: 0;
  padding: 9px 15px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--ui-size);
  font-weight: 600;
}
.pp-btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.pp-btn:disabled { opacity: .5; }
.pp-danger { border-color: var(--danger); background: transparent; color: var(--danger); }
.pp-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); }
.seg { display: inline-flex; flex-wrap: wrap; margin-top: 12px; border: 1px solid color-mix(in srgb, var(--text) 18%, transparent); border-radius: 8px; overflow: hidden; }
.pp-card:has(> .seg) > .seg { margin-top: 0; }
.seg-btn { padding: 8px 16px; border: 0; border-radius: 0; background: transparent; font-size: var(--ui-size); }
.seg-btn:not(.active):hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.seg-btn.active { background: color-mix(in srgb, var(--text) 8%, transparent); font-weight: 600; }

/* ---- Sources bottom sheet (phones) ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: transparent;
  transition: background .25s ease;
}
.sheet-backdrop.show { background: rgba(16, 24, 19, .42); }
.sheet {
  width: min(100%, 640px);
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border: 1px solid var(--glass-edge);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--popup-bg);
  box-shadow: 0 -12px 40px rgba(16, 24, 19, .22);
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet-backdrop.show .sheet { transform: none; }
/* Computers: the activity panel slides in from the right and fills the full height, like the left panel. */
.sheet-backdrop.is-side { align-items: stretch; justify-content: flex-end; pointer-events: none; }
.sheet-backdrop.is-side.show { background: transparent; }
.sheet-backdrop.is-side .sheet {
  width: min(420px, 42vw);
  max-height: none;
  padding: 8px 0 0;
  border: 0;
  border-left: 1px solid var(--sidebar-edge);
  border-radius: 0;
  background: var(--popup-bg);
  box-shadow: -3px 0 14px -10px rgba(16, 24, 19, .14);
  pointer-events: auto;
  transform: translateX(100%);
  transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}
.sheet-backdrop.is-side.show .sheet { transform: none; }
.sheet-backdrop.is-side .sheet-grip { display: none; }
.sheet-backdrop.is-side .sheet-head { padding: 14px 18px 12px; cursor: default; }
.sheet-backdrop.is-side .sheet-body { flex: 1 1 auto; min-height: 0; padding-bottom: 24px; }
.sheet-head { flex: none; padding: 8px 18px 10px; touch-action: none; cursor: grab; }
.sheet-grip { display: block; width: 38px; height: 4px; margin: 0 auto 12px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 45%, transparent); }
.sheet-title { color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 18px 14px; }
.sheet-row { display: flex; flex-direction: column; gap: 4px; padding: 14px 0; color: var(--text); text-decoration: none; border-top: 1px solid var(--line); }
.sheet-row:first-child { border-top: 0; }
.sheet-site { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.8125rem; }
.sheet-row strong { font-size: 1rem; font-weight: 600; line-height: 1.3; }
.sheet-snippet { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 0.875rem; line-height: 1.45; }

/* ---- Attachment chips ---- */
.file-preview { display: none; flex-wrap: nowrap; gap: 8px; padding: 2px 0 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.file-preview.has-files { display: flex; }
.file-preview .file-chip { flex: 0 0 auto; }
.file-preview.nudge .file-chip { animation: nudge .42s ease; }
@keyframes nudge { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.file-chip {
  --kind: var(--accent);
  position: relative;
  max-width: 100%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 7px 8px 7px 7px;
  border: 1px solid var(--glass-edge);
  border-radius: 16px;
  background: var(--glass-strong);
  box-shadow: var(--shadow), var(--glass-hi);
  font-size: 0.75rem;
  line-height: 1.35;
}
.file-chip[data-kind="image"] { --kind: #3F8F6B; }
.file-chip[data-kind="video"] { --kind: #5B7BC0; }
.file-chip[data-kind="audio"] { --kind: #B07A2C; }
.file-chip[data-kind="pdf"] { --kind: #B84F43; }
.file-chip[data-kind="sheet"] { --kind: #2F7D4E; }
.file-chip[data-kind="code"] { --kind: #6B5FB5; }
.file-chip[data-kind="json"] { --kind: #A8793A; }
.file-chip[data-kind="markdown"] { --kind: #4F7F9A; }
.file-chip[data-kind="doc"] { --kind: #3E6FA8; }
.file-chip[data-kind="text"], .file-chip[data-kind="file"] { --kind: var(--muted); }
/* Light sweep across the card on hover, left to right only (it snaps back without running in reverse). */
.file-chip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, color-mix(in srgb, #fff 45%, transparent) 50%, transparent 70%);
  transform: translateX(-120%);
  pointer-events: none;
}
.file-chip:hover::before { transform: translateX(120%); transition: transform .7s ease; }
/* Upload progress strip; --progress (0-1) is set by the script. */
.file-chip.is-uploading::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: calc(var(--progress, 0) * 100%);
  height: 3px;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width .25s ease;
}
.file-chip-icon {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--glass-edge);
  border-radius: 11px;
  background: color-mix(in srgb, var(--kind) 16%, var(--surface));
  color: var(--kind);
}
.file-chip-icon svg { width: 18px; height: 18px; }
.file-chip-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.file-chip-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78125rem; font-weight: 600; }
.file-chip-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; color: var(--muted); font-size: 0.6875rem; white-space: nowrap; }
.file-chip-status { display: inline-flex; align-items: center; gap: 5px; }
.file-chip-state { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--muted); }
.file-chip.is-ready .file-chip-state { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.file-chip.is-uploading .file-chip-status { color: var(--accent); }
.file-chip.is-uploading .file-chip-state { width: 10px; height: 10px; border: 2px solid var(--accent); border-right-color: transparent; background: transparent; animation: spin .8s linear infinite; }
.file-chip.is-failed .file-chip-status { color: var(--danger); }
.file-chip.is-failed .file-chip-state { background: var(--danger); }
.file-chip-retry { padding: 1px 8px; border: 1px solid var(--danger); border-radius: 7px; background: transparent; color: var(--danger); font-size: 0.6875rem; font-weight: 600; }
.file-chip-remove {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}
.file-chip-remove:hover { background: var(--soft); color: var(--text); }

/* ---- Phones ---- */
@media (max-width: 700px) {
  .viewer-backdrop { padding: 0; }
  .viewer { width: 100%; height: 100%; border: 0; border-radius: 0; }
  .viewer-code { padding: 14px; font-size: 0.78125rem; }
  .auth-modal { padding: 34px 18px 18px; border-radius: 18px; }
  .profile-page { flex-direction: column; }
  /* Like ChatGPT and Claude: a list of sections first, then the chosen section on its own screen. */
  .pp-side { flex: 1 1 auto; gap: 14px; padding: 14px 16px 24px; border-right: 0; }
  .pp-tabs { gap: 0; }
  .pp-indicator { display: none; }
  .pp-tab { display: flex; align-items: center; justify-content: space-between; padding: 17px 4px; border-radius: 0; border-bottom: 1px solid color-mix(in srgb, var(--text) 11%, transparent); font-size: 1rem; }
  .pp-tab::after { content: "›"; color: var(--muted); font-size: 1.5rem; line-height: 1; }
  .pp-tab.active { font-weight: 400; }
  .pp-main { display: none; padding: 14px 16px 32px; }
  .profile-page.detail .pp-side { display: none; }
  .profile-page.detail .pp-main { display: block; flex: 1 1 auto; }
  .pp-mhead { display: flex; }
  .pp-card:has(> .seg) { display: block; }
  .pp-card:has(> .seg) > .seg { margin-top: 12px; }
  .pp-between { flex-wrap: wrap; }
  .file-chip-name { max-width: 170px; }
}

/* ---- Cookie banner ---- */
.cookie-banner { position: fixed; z-index: 90; right: 20px; bottom: 20px; width: min(420px, calc(100vw - 24px)); opacity: 0; transform: translateY(12px); transition: opacity .2s ease, transform .2s ease; }
.cookie-banner.is-visible { opacity: 1; transform: none; }
.cookie-card { padding: 20px; border: 1px solid var(--glass-edge); border-radius: 20px; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--shadow), 0 18px 48px rgba(0, 0, 0, .16); color: var(--text); }
.cookie-card h2 { margin: 0 0 8px; font-size: 1.125rem; font-weight: 650; }
.cookie-card p { margin: 0 0 14px; color: var(--muted); font-size: var(--ui-size); line-height: 1.5; }
.cookie-card a { color: var(--text); text-decoration: underline; }
.ck-btn { min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--text); font: inherit; font-size: var(--ui-size); font-weight: 600; cursor: pointer; transition: background .15s ease; }
.ck-btn:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ck-btn.ck-primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.ck-btn.ck-primary:hover { background: var(--accent); filter: brightness(1.08); }
.ck-wide { width: 100%; margin-bottom: 8px; }
.ck-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ck-opt { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.ck-opt:first-of-type { border-top: 0; }
.ck-opt-title { display: block; font-size: var(--ui-size); font-weight: 600; }
.ck-opt small { display: block; margin-top: 3px; color: var(--muted); font-size: .8125rem; line-height: 1.45; }
.ck-opt + .ck-row, .ck-opt:last-of-type { margin-bottom: 12px; }
.ck-switch { position: relative; flex: none; width: 42px; height: 24px; margin-top: 2px; }
.ck-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ck-switch input:disabled { cursor: not-allowed; }
.ck-switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s ease; pointer-events: none; }
.ck-switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s ease; }
.ck-switch input:checked + i { background: var(--accent); }
.ck-switch input:checked + i::after { transform: translateX(18px); }
.ck-switch input:disabled + i { opacity: .6; }
.ck-switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 700px) { .cookie-banner { right: 12px; left: 12px; bottom: 12px; width: auto; } }
