:root {
  color-scheme: light;
  --paper: #f5f1e8;
  --paper-2: #fdfbf6;
  --paper-3: #efe9db;
  --card: #fffdf8;
  --ink: #1b1813;
  --ink-soft: #564e41;
  --ink-dim: #8c8372;
  --emerald: #1f5f4f;
  --emerald-d: #164034;
  --emerald-soft: #e7efe9;
  --gold: #a9822e;
  --gold-soft: #f1e7cf;
  --danger: #9f2d2d;
  --line: #e3dccb;
  --line-2: #d3cab4;
  --shadow: 0 1px 2px rgba(27, 24, 19, 0.04), 0 14px 40px rgba(27, 24, 19, 0.08);
  --shadow-strong: 0 4px 10px rgba(27, 24, 19, 0.07), 0 24px 60px rgba(31, 95, 79, 0.12);
  --body-glow-1: rgba(31, 95, 79, 0.06);
  --body-glow-2: rgba(169, 130, 46, 0.05);
  --header-bg: rgba(245, 241, 232, 0.82);
  --composer-bg: rgba(253, 251, 246, 0.86);
  --input-focus-bg: #fffefb;
  --record-ring: #1f5f4f;
  --record-shadow: rgba(31, 95, 79, 0.18);
  --action-shadow: rgba(31, 95, 79, 0.22);
  --danger-bg: #9f2d2d;
  --danger-text: #fffdf8;
  --danger-surface: rgba(159, 45, 45, 0.10);
  --danger-border: rgba(159, 45, 45, 0.34);
  --user-shadow: rgba(22, 64, 52, 0.16);
  --sidebar-bg: rgba(253, 251, 246, 0.84);
  --login-panel-bg: rgba(255, 253, 248, 0.92);
  --control-bg: #fffdf8;
  --control-text: #1b1813;
  --control-border: #c8bfa9;
  --control-hover-border: rgba(31, 95, 79, 0.52);
  --primary-bg: #1f5f4f;
  --primary-bg-hover: #164034;
  --primary-text: #fffdf8;
  --user-bg: #164034;
  --user-text: #fffdf8;
  --placeholder: #6d6456;
  --focus-ring: rgba(31, 95, 79, 0.16);
  --status-border: rgba(31, 95, 79, 0.22);
  --record-bg: #fffdf8;
  --record-text: #164034;
  --r-sm: 5px;
  --r-md: 9px;
  --r-lg: 14px;
  --r-pill: 999px;
}

:root[data-theme="dark"],
body[data-theme="dark"] {
  color-scheme: dark;
  --paper: #101714;
  --paper-2: #17211d;
  --paper-3: #202d27;
  --card: #131d19;
  --ink: #f4efe5;
  --ink-soft: #d0c7b8;
  --ink-dim: #9d9384;
  --emerald: #75b7a2;
  --emerald-d: #d7f0e7;
  --emerald-soft: rgba(117, 183, 162, 0.14);
  --gold: #d4ae58;
  --gold-soft: rgba(212, 174, 88, 0.16);
  --danger: #d46666;
  --line: #29372f;
  --line-2: #3b4b42;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 14px 40px rgba(0, 0, 0, 0.24);
  --shadow-strong: 0 4px 10px rgba(0, 0, 0, 0.28), 0 24px 60px rgba(0, 0, 0, 0.32);
  --body-glow-1: rgba(117, 183, 162, 0.10);
  --body-glow-2: rgba(212, 174, 88, 0.08);
  --header-bg: rgba(16, 23, 20, 0.84);
  --composer-bg: rgba(19, 29, 25, 0.88);
  --input-focus-bg: #17231e;
  --record-ring: #8bcdbb;
  --record-shadow: rgba(117, 183, 162, 0.24);
  --action-shadow: rgba(0, 0, 0, 0.28);
  --danger-bg: #e07272;
  --danger-text: #170908;
  --danger-surface: rgba(224, 114, 114, 0.15);
  --danger-border: rgba(224, 114, 114, 0.46);
  --user-shadow: rgba(0, 0, 0, 0.30);
  --sidebar-bg: rgba(18, 27, 23, 0.94);
  --login-panel-bg: rgba(19, 29, 25, 0.94);
  --control-bg: #17211d;
  --control-text: #f4efe5;
  --control-border: #53665b;
  --control-hover-border: rgba(117, 183, 162, 0.78);
  --primary-bg: #8bcdbb;
  --primary-bg-hover: #a4ddce;
  --primary-text: #07110e;
  --user-bg: #21493d;
  --user-text: #f4fff9;
  --placeholder: #b5ab9b;
  --focus-ring: rgba(117, 183, 162, 0.24);
  --status-border: rgba(117, 183, 162, 0.30);
  --record-bg: #111b17;
  --record-text: #d7f0e7;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse 70% 50% at 50% -8%, var(--body-glow-1), transparent 60%),
    radial-gradient(ellipse 50% 45% at 92% 12%, var(--body-glow-2), transparent 58%),
    var(--paper);
  color: var(--ink);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.72;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.app-shell {
  display: block;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  height: 100dvh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  backdrop-filter: blur(16px) saturate(145%);
}

.sidebar-main {
  display: grid;
  gap: 34px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  color: var(--ink);
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.brand span {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
}

.brand small {
  font-family: "JetBrains Mono", monospace;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.header-brand img {
  width: 34px;
  height: 34px;
}

.header-brand strong {
  font-size: 19px;
}

.header-brand small {
  font-size: 10px;
}

.product-kicker,
.eyeline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--gold);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.product-kicker::before,
.eyeline::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--gold);
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 {
  max-width: 9ch;
  font-size: 42px;
}

h2 {
  font-size: 40px;
}

.sidebar-title {
  display: grid;
  gap: 14px;
}

.sidebar-title p:last-child,
.chat-header p,
.muted,
.tenant-card small {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.sidebar-title p:last-child {
  max-width: 27ch;
  font-size: 15px;
}

.status-list {
  display: grid;
  gap: 10px;
}

.status-list span {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 14px;
}

.status-list b {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-soft);
}

.tenant-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow);
}

.tenant-card img {
  grid-row: 1 / 4;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--control-border);
}

.tenant-card span {
  color: var(--ink-dim);
  font-size: 12px;
}

.tenant-card strong {
  color: var(--ink);
  font-size: 15px;
}

.tenant-card small {
  font-size: 12.5px;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100dvh;
  min-height: 100dvh;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px clamp(14px, 2vw, 28px);
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(145%);
}

.header-main {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 28px);
  min-width: 0;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--control-border);
  border-radius: var(--r-md);
  background: var(--control-bg);
}

.mode-button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.mode-button:hover {
  color: var(--emerald);
  background: var(--emerald-soft);
}

.mode-button.active {
  color: var(--primary-text);
  background: var(--primary-bg);
  box-shadow: 0 4px 12px var(--action-shadow);
}

.mode-hint,
.model-badge,
.history-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

.model-badge {
  color: var(--emerald-d);
  background: var(--emerald-soft);
  border-color: var(--status-border);
}

.history-badge {
  color: var(--ink-soft);
}

.header-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, auto));
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.chat-header .eyeline {
  margin: 0;
  font-size: 18px;
  line-height: 1;
  white-space: nowrap;
}

.chat-workspace {
  min-height: 0;
  padding: 12px clamp(12px, 1.8vw, 28px);
  overflow: hidden;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0 auto;
  padding: 0 0 8px;
  overflow: auto;
  scroll-behavior: smooth;
}

.message {
  width: fit-content;
  max-width: min(1180px, 100%);
  padding: 10px 12px;
  border-radius: var(--r-md);
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message p {
  margin: 0;
}

.message.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--control-border);
  box-shadow: 0 1px 2px rgba(27, 24, 19, 0.04);
}

.message.user {
  align-self: flex-end;
  color: var(--user-text);
  background: var(--user-bg);
  box-shadow: 0 6px 18px var(--user-shadow);
}

.message.system {
  align-self: center;
  width: auto;
  color: var(--ink-soft);
  background: var(--control-bg);
  border: 1px dashed var(--control-border);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px clamp(12px, 1.8vw, 28px);
  border-top: 1px solid var(--line);
  background: var(--composer-bg);
  backdrop-filter: blur(14px);
  z-index: 20;
}

.composer textarea {
  width: 100%;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--control-border);
  border-radius: var(--r-md);
  background: var(--control-bg);
  color: var(--control-text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

textarea {
  min-height: 44px;
  max-height: 170px;
  padding: 11px 14px;
  resize: vertical;
  line-height: 1.45;
}

input {
  min-height: 48px;
  padding: 0 14px;
}

textarea::placeholder,
input::placeholder {
  color: var(--placeholder);
}

textarea:focus,
input:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: var(--input-focus-bg);
}

.composer button,
.login-form button,
.ghost-button,
.theme-button,
.voice-button,
.icon-button {
  min-height: 44px;
  border: 0;
  border-radius: var(--r-md);
  font-weight: 800;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.composer button[type="submit"],
.login-form button {
  padding: 0 22px;
  color: var(--primary-text);
  background: var(--primary-bg);
  box-shadow: 0 6px 20px var(--action-shadow);
}

.composer button[type="submit"]:hover,
.login-form button:hover {
  background: var(--primary-bg-hover);
  transform: translateY(-1px);
}

.ghost-button,
.theme-button,
.voice-button {
  padding: 0 14px;
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--control-text);
  white-space: nowrap;
}

.ghost-button:hover,
.theme-button:hover,
.voice-button:hover {
  color: var(--emerald);
  border-color: var(--control-hover-border);
  background: var(--emerald-soft);
}

.theme-button {
  min-width: 86px;
}

.voice-button {
  min-width: 112px;
}

.voice-button.active {
  color: var(--primary-text);
  border-color: var(--primary-bg);
  background: var(--primary-bg);
  box-shadow: 0 6px 18px var(--action-shadow);
}

.voice-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 58px;
  min-width: 58px;
  padding: 0;
  border: 2px solid var(--record-ring);
  background: var(--record-bg);
  color: var(--record-text);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1px var(--record-shadow), 0 0 0 1px var(--record-shadow), 0 6px 14px var(--record-shadow);
}

.icon-button:hover {
  border-color: var(--emerald);
  background: var(--emerald-soft);
  transform: translateY(-1px);
}

.icon-button.recording {
  color: var(--danger-text);
  background: var(--danger-bg);
  border-color: var(--danger-bg);
  box-shadow: 0 0 0 1px var(--danger-border), 0 6px 18px var(--danger-surface);
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-shell {
  width: min(940px, 100%);
}

.login-panel {
  display: grid;
  gap: 28px;
  width: min(540px, 100%);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--login-panel-bg);
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(14px);
}

.login-brand {
  margin-bottom: 2px;
}

.login-panel h1 {
  max-width: 11ch;
  margin-bottom: 14px;
  font-size: 54px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

.form-error,
.form-status {
  margin: 0;
  padding: 11px 13px;
  border-radius: var(--r-md);
  font-size: 14px;
}

.form-error {
  color: var(--danger);
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
}

.form-status {
  color: var(--emerald-d);
  background: var(--emerald-soft);
  border: 1px solid var(--status-border);
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-main {
    gap: 22px;
  }

  .sidebar-title {
    display: none;
  }

  .status-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tenant-card {
    display: none;
  }

  h2 {
    font-size: 34px;
  }
}

@media (max-width: 680px) {
  body {
    background: var(--paper);
  }

  .sidebar {
    gap: 18px;
  }

  .status-list {
    grid-template-columns: 1fr;
  }

  .chat-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 10px 12px;
  }

  .header-main {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
  }

  .chat-header .eyeline {
    font-size: 15px;
  }

  .header-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    gap: 6px;
  }

  .mode-switch {
    order: 3;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mode-hint,
  .model-badge,
  .history-badge {
    order: 4;
    width: 100%;
    justify-content: center;
    min-height: 30px;
    white-space: normal;
    text-align: center;
  }

  .mode-button {
    min-width: 0;
    padding: 0 6px;
    font-size: 11px;
  }

  .header-actions button {
    min-width: 0;
    min-height: 40px;
    padding: 0 6px;
    font-size: 11px;
  }

  .chat-workspace {
    padding: 10px;
  }

  .composer {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 10px;
  }

  .composer button[type="submit"] {
    grid-column: auto;
    padding: 0 10px;
  }

  .login-body {
    padding: 16px;
  }

  .login-panel {
    padding: 26px;
  }

  .login-panel h1 {
    max-width: 100%;
    font-size: 42px;
  }
}

/* v20 mobile portal cleanup */
@media (min-width: 681px) {
  .header-main {
    flex: 1 1 auto;
  }
  .header-actions {
    grid-template-columns: repeat(3, minmax(0, auto));
  }
}

@media (max-width: 860px) {
  body {
    background: var(--paper);
  }

  .chat-header {
    position: sticky;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  }

  .header-main {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px 10px;
  }

  .header-brand img {
    width: 30px;
    height: 30px;
  }

  .header-brand strong {
    font-size: 17px;
  }

  .header-brand small {
    font-size: 9px;
  }

  .chat-header .eyeline {
    justify-self: end;
    font-size: 12px;
  }

  .chat-header .eyeline::before {
    display: none;
  }

  .mode-switch {
    grid-column: 1 / -1;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mode-button {
    min-height: 34px;
    padding: 0 6px;
    font-size: 12px;
  }

  .mode-hint {
    display: none;
  }

  .header-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
  }

  .header-actions button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 12px;
  }

  .voice-button {
    min-width: 0;
  }

  .theme-button {
    min-width: 76px;
  }

  .chat-workspace {
    padding: 8px;
  }

  .messages {
    gap: 8px;
    padding-bottom: 4px;
  }

  .message {
    max-width: 92%;
    padding: 9px 10px;
    font-size: 14px;
    line-height: 1.4;
  }

  .message.system {
    max-width: 100%;
    font-size: 11px;
  }

  .composer {
    grid-template-columns: 48px minmax(0, 1fr) 82px;
    gap: 7px;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  }

  .icon-button {
    width: 48px;
    min-width: 48px;
    min-height: 42px;
  }

  textarea {
    min-height: 42px;
    max-height: 128px;
    padding: 10px 11px;
    font-size: 14px;
  }

  .composer button[type="submit"] {
    min-height: 42px;
    padding: 0 10px;
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .chat-header {
    gap: 7px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .brand {
    gap: 8px;
  }

  .chat-header .eyeline {
    font-size: 11px;
  }

  .mode-button span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    grid-template-columns: 1fr 74px 56px;
  }

  .header-actions button {
    padding: 0 7px;
  }

  .theme-button {
    min-width: 0;
  }

  .ghost-button {
    min-width: 0;
  }

  .composer {
    grid-template-columns: 46px minmax(0, 1fr) 74px;
    gap: 6px;
  }

  .message {
    max-width: 96%;
  }
}

/* v21 compact icon actions */
.header-actions {
  grid-template-columns: repeat(4, 44px);
}

.header-icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: var(--r-md);
  background: var(--control-bg);
  color: var(--control-text);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.header-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-icon-button:hover {
  color: var(--emerald);
  border-color: var(--control-hover-border);
  background: var(--emerald-soft);
  transform: translateY(-1px);
}

.header-icon-button.active,
.header-icon-button[aria-pressed="true"] {
  color: var(--primary-text);
  border-color: var(--primary-bg);
  background: var(--primary-bg);
  box-shadow: 0 6px 18px var(--action-shadow);
}

.theme-button .icon-sun {
  display: none;
}

.theme-button[data-theme="dark"] .icon-moon {
  display: none;
}

.theme-button[data-theme="dark"] .icon-sun {
  display: block;
}

@media (max-width: 860px) {
  .header-actions {
    grid-template-columns: repeat(4, 40px);
    justify-content: end;
    gap: 6px;
  }

  .header-icon-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .header-icon-button svg {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 420px) {
  .header-actions {
    grid-template-columns: repeat(4, 38px);
    justify-content: space-between;
  }

  .header-icon-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
  }
}

/* v23 upload incoming batches */
.header-actions {
  grid-template-columns: repeat(6, 44px);
}

.upload-modal[hidden] {
  display: none;
}

.upload-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 23, 20, 0.42);
  backdrop-filter: blur(8px);
}

.upload-dialog {
  display: grid;
  gap: 14px;
  width: min(460px, 100%);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-strong);
}

.upload-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.upload-dialog-head strong {
  font-size: 16px;
}

.upload-help,
.upload-summary {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}

.upload-pickers,
.upload-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.upload-pickers {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.upload-pickers .active {
  border-color: var(--primary-bg);
  color: var(--ink);
  background: var(--soft);
}

.upload-link-panel {
  display: grid;
  gap: 7px;
}

.upload-link-panel[hidden] {
  display: none;
}

.upload-link-panel label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.upload-link-panel input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0 12px;
  color: var(--ink);
  background: var(--bg);
  font: inherit;
}

.upload-link-panel small {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.35;
}

.upload-actions button:first-child {
  min-height: 44px;
  border: 0;
  border-radius: var(--r-md);
  color: var(--primary-text);
  background: var(--primary-bg);
  font-weight: 800;
  box-shadow: 0 6px 20px var(--action-shadow);
}

.upload-actions button:first-child:disabled {
  opacity: 0.55;
}

@media (max-width: 860px) {
  .header-actions {
    grid-template-columns: repeat(6, 40px);
  }
}

@media (max-width: 420px) {
  .header-actions {
    grid-template-columns: repeat(6, 38px);
  }
  .upload-dialog {
    padding: 14px;
  }
}

.upload-summary.warn{color:var(--danger);background:var(--danger-surface);border:1px solid var(--danger-border);border-radius:var(--r-md);padding:10px 11px}


.upload-link-guide {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 9px 10px;
  background: var(--soft);
}

.upload-link-guide summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.upload-link-guide div {
  display: grid;
  gap: 7px;
  padding-top: 8px;
}

.upload-link-guide p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}


.message.typing p::after {
  content: "";
  display: inline-block;
  width: 0.55ch;
  height: 1.05em;
  margin-left: 2px;
  border-right: 2px solid var(--ink-soft);
  vertical-align: -0.14em;
  animation: type-caret 0.9s steps(1) infinite;
}

@keyframes type-caret {
  0%, 45% {
    opacity: 1;
  }
  46%, 100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .message.typing p::after {
    animation: none;
  }
}


.process-panel[hidden] {
  display: none;
}

.process-panel {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 70;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  width: min(440px, calc(100vw - 28px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-strong);
}

.process-panel-head,
.process-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.process-panel-head div {
  display: grid;
  gap: 2px;
}

.process-panel-head strong {
  font-size: 16px;
}

.process-panel-head small,
.process-item small {
  color: var(--ink-soft);
  font-size: 12px;
}

.process-panel-actions {
  display: flex;
  justify-content: flex-start;
}

.process-list {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 0;
  overflow: auto;
}

.process-empty {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.process-item {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--control-border);
  border-radius: var(--r-md);
  background: var(--bg);
}

.process-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.process-item-head strong {
  min-width: 0;
  font-size: 14px;
  line-height: 1.25;
}

.process-item p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.process-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--ink-soft);
  background: var(--control-bg);
  font-size: 11px;
  font-weight: 800;
}

.process-badge.running,
.process-badge.queued {
  color: var(--primary-bg);
  background: var(--primary-soft);
}

.process-badge.completed {
  color: var(--success);
  background: var(--success-surface);
}

.process-badge.failed {
  color: var(--danger);
  background: var(--danger-surface);
}

.process-open-button {
  min-height: 34px;
  justify-self: start;
  padding: 0 12px;
}

.process-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.process-action-button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.78rem;
}

.message .process-quick-actions {
  margin-top: 10px;
}

.process-preview {
  display: grid;
  gap: 9px;
  min-height: 190px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.process-preview[hidden] {
  display: none;
}

.process-preview-head strong {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-preview pre {
  min-height: 0;
  max-height: 280px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--control-border);
  border-radius: var(--r-md);
  padding: 10px;
  color: var(--ink);
  background: var(--control-bg);
  font: 12px/1.45 "JetBrains Mono", monospace;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .process-panel {
    inset: 8px;
    width: auto;
  }
}
