/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--text-secondary);
}

.btn-primary {
  background: var(--text-primary);
  color: var(--text-inverse);
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
}

.btn-ghost:hover {
  color: var(--text-primary);
}

/* Input */
.input-field {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-input);
  outline: none;
  transition: border-color var(--transition-fast);
}

.input-field:focus {
  border-color: var(--border-strong);
}

.input-field::placeholder {
  color: var(--text-muted);
}

/* Login Screen */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 320px;
  gap: 32px;
  z-index: 1;
  margin: auto;
}

.login-screen > * {
  opacity: 0;
  transform: translateY(16px);
  animation: loginEntrance 500ms ease forwards;
}

.login-screen > :nth-child(1) { animation-delay: 80ms; }
.login-screen > :nth-child(2) { animation-delay: 200ms; }
.login-screen > :nth-child(3) { animation-delay: 320ms; }
.login-screen > :nth-child(4) { animation-delay: 420ms; }
.login-screen > :nth-child(5) { animation-delay: 500ms; }

@keyframes loginEntrance {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-theme-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  opacity: 0;
  animation: loginEntrance 400ms ease 600ms forwards;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-bottom: 4px;
  animation: logoPulse 3s ease-in-out 1s infinite;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 20px -4px var(--accent-muted); }
}

.login-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login-tagline {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.login-features {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.login-dot {
  opacity: 0.4;
}

.login-form {
  width: 100%;
}

.login-error {
  color: var(--error);
  font-size: var(--fs-sm);
  text-align: center;
  margin-bottom: 10px;
  display: none;
}

.login-error.visible {
  display: block;
}

.login-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.login-input-wrap:focus-within {
  border-color: var(--border-strong);
}

.login-input {
  flex: 1;
  padding: 7px 11px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.8125rem;
  outline: none;
  min-width: 0;
}

.login-input::placeholder {
  color: var(--text-muted);
}

.login-submit {
  width: 28px;
  height: 28px;
  margin: 3px;
  border-radius: 6px;
  border: none;
  background: var(--text-primary);
  color: var(--text-inverse);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.login-submit:active {
  transform: scale(0.95);
}

.login-submit:disabled {
  opacity: 0.3;
  cursor: default;
  transform: none;
}

/* Login Divider & AI-Lab */
.login-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-alt-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.login-lab-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 10px 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  flex: 1;
  width: 100%;
}

.login-lab-toggle:hover {
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.login-lab-toggle.active {
  color: var(--text-secondary);
  border-color: var(--border-strong);
  background: var(--bg-tertiary);
}

.login-lab-desc {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  margin: 0 0 12px;
  animation: fadeIn 150ms ease;
}

.login-lab-form {
  opacity: 1 !important;
  transform: none !important;
  animation: fadeIn 150ms ease forwards;
}

/* Magic Link: Code Step */
.login-code-info {
  text-align: center;
  margin-bottom: 16px;
  animation: fadeIn 150ms ease;
}

.login-code-info p {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin: 0 0 6px;
  line-height: 1.5;
}

.login-code-info strong {
  color: var(--text-primary);
  font-weight: 600;
}

.login-code-hint {
  font-size: var(--fs-xs) !important;
  color: var(--text-muted) !important;
}

.login-code-input {
  text-align: center;
  font-size: 1.3rem !important;
  font-weight: 600;
  letter-spacing: 6px;
  font-family: monospace;
}

.login-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--fs-xs);
  padding: 10px;
  cursor: pointer;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  margin-top: 8px;
}

.login-back-btn:hover {
  color: var(--text-secondary);
}

/* Project Link (AI-Lab) */
.project-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.project-link:hover {
  color: var(--text-primary);
}

.project-link svg {
  opacity: 0.5;
  flex-shrink: 0;
}

.sysmgmt-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--error);
  font-weight: 500;
}

/* Demo Badge */
.demo-badge {
  display: inline-block;
  padding: 1px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-muted);
  vertical-align: middle;
  margin-left: 4px;
}

/* Project List */
.project-list {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

.list-section {
  padding: 4px 16px;
}

.list-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 0;
  border: none;
  border-bottom: 1px solid var(--border-light);
  background: none;
  color: var(--text-primary);
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  gap: 10px;
  transition: opacity var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:active {
  opacity: 0.5;
}

.list-item-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.list-item-icon.sysmgmt-icon {
  background: rgba(217, 83, 79, 0.15);
  color: var(--error);
}

.list-item-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.list-item-name {
  font-size: var(--fs-base);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.list-item-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.list-item-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.5;
}

/* Chat Messages */
.chat-message {
  padding: 14px 16px;
  animation: fadeIn 150ms ease;
  overflow: hidden;
}

.chat-message + .chat-message {
  border-top: 1px solid var(--border-light);
}

.chat-message.user {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  margin: 4px 10px;
  border-radius: var(--radius-md);
}

.chat-message.assistant {
  background: transparent;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-sender {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message-time {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 400;
  margin-left: auto;
}

.message-content {
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--text-primary);
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
}

.message-content > *:first-child { margin-top: 0; }
.message-content > *:last-child { margin-bottom: 0; }

.message-content p { margin: 0 0 12px; }
.message-content p:last-child { margin-bottom: 0; }

/* ── Headings ── */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  color: var(--text-primary);
  font-weight: 600;
  margin: 20px 0 8px;
  line-height: 1.3;
}
.message-content h1 { font-size: 1.3em; }
.message-content h2 { font-size: 1.15em; }
.message-content h3 { font-size: 1.05em; }
.message-content h4 { font-size: 1em; color: var(--text-secondary); }
.message-content > h1:first-child,
.message-content > h2:first-child,
.message-content > h3:first-child { margin-top: 0; }

/* ── Emphasis ── */
.message-content strong { color: var(--text-primary); font-weight: 600; }

/* ── Inline code ── */
.message-content code {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.88em;
  word-break: break-all;
  border: 1px solid var(--border-light);
}

/* ── Code blocks ── */
.message-content pre {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 12px 0;
}
.message-content pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 0;
  padding: 2px 8px;
  font-size: 10px;
  font-family: var(--font);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: 0 var(--radius-md) 0 var(--radius-sm);
  border-bottom: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.6;
}
.message-content pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: var(--fs-sm);
  line-height: 1.55;
  word-break: normal;
}

/* ── Lists ── */
.message-content ul, .message-content ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}
.message-content li {
  margin-bottom: 4px;
  line-height: 1.6;
}
.message-content li > p { margin-bottom: 4px; }

/* ── Blockquote ── */
.message-content blockquote {
  border-left: 3px solid var(--border-strong);
  padding: 8px 14px;
  margin: 12px 0;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.message-content blockquote p:last-child { margin-bottom: 0; }

/* ── Horizontal rule ── */
.message-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Tables ── */
.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.92em;
  overflow-x: auto;
  display: block;
}
.message-content thead {
  display: table;
  width: 100%;
  table-layout: fixed;
}
.message-content tbody {
  display: table;
  width: 100%;
  table-layout: fixed;
}
.message-content th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 0.88em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}
.message-content td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: top;
}
.message-content tbody tr:hover td {
  background: var(--bg-secondary);
}
.message-content tbody tr:last-child td {
  border-bottom: none;
}

/* ── Links ── */
.message-content a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}
.message-content a:hover {
  text-decoration-color: var(--text-secondary);
}

.message-error {
  padding: 10px 14px;
  background: var(--error-muted);
  border-radius: var(--radius-md);
  color: var(--error);
  font-size: var(--fs-sm);
}

/* Thinking Block */
.thinking-block {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.thinking-block summary {
  cursor: pointer;
  padding: 5px 10px;
  background: var(--bg-tertiary);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background var(--transition-fast);
  list-style: none;
}

.thinking-block summary::-webkit-details-marker { display: none; }

.thinking-block summary::before {
  content: '\25B6';
  font-size: 0.5rem;
  transition: transform 150ms ease;
  display: inline-block;
}

.thinking-block[open] summary::before {
  transform: rotate(90deg);
}

.thinking-label {
  font-style: italic;
}

.thinking-text {
  padding: 8px 10px;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--text-muted);
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--border);
}

/* Streaming */
.chat-message.streaming {
  animation: fadeIn 200ms ease;
}

.chat-message.streaming .message-content {
  min-height: 20px;
}

.chat-message.streaming .message-content > *:last-child {
  display: inline;
}

.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--text-secondary);
  animation: cursorBlink 0.8s ease-in-out infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
  border-radius: 1px;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}


/* Status bubble (inline in message flow) */
.status-bubble {
  padding: 0;
}

.status-bubble .status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  overflow: hidden;
}
.status-bubble .status-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.thinking-dots {
  display: flex;
  gap: 3px;
}

.thinking-dots span {
  width: 4px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Agent todos (persistent element during agent run) */
.agent-todos-bubble {
  padding: 8px 16px;
  border: none;
  background: none;
}
.agent-todo-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.5;
  transition: color 0.2s, opacity 0.2s;
}
.agent-todo-icon {
  flex-shrink: 0;
  width: 12px;
  text-align: center;
  font-size: 10px;
}
.agent-todo-item.active {
  color: var(--text-secondary);
  font-weight: 500;
}
.agent-todo-item.done {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Composer */
.chat-composer {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.chat-composer:focus-within {
  border-color: var(--border-strong);
}

.composer-input {
  flex: 1;
  resize: none;
  padding: 10px 12px 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.45;
  max-height: 140px;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.composer-input::placeholder {
  color: var(--text-muted);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 6px 8px;
}

.composer-mode {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 4px 20px 4px 8px;
  cursor: pointer;
  outline: none;
  transition: color var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' fill='none'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%23999' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  -webkit-tap-highlight-color: transparent;
}

.composer-mode:focus {
  color: var(--text-secondary);
}

.composer-mode option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.composer-send {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--text-muted);
  color: var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.composer-send:not(:disabled) {
  background: var(--text-primary);
}

.composer-send:not(:disabled):active {
  transform: scale(0.9);
}

.composer-send:disabled {
  opacity: 0.25;
  cursor: default;
}

.composer-send svg {
  width: 14px;
  height: 14px;
}

.composer-send.cancel-mode {
  background: var(--error);
  opacity: 1;
}

.composer-send.cancel-mode:active {
  transform: scale(0.9);
}

/* Composer Attach + File Preview */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.composer-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.composer-attach {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.composer-attach:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.composer-attach svg {
  width: 16px;
  height: 16px;
}

.file-preview {
  display: none;
}

.file-preview.has-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 0;
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  max-width: 200px;
  animation: fadeIn 150ms ease;
}

.file-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.file-thumb-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.file-preview-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.file-preview-name {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview-size {
  font-size: 10px;
  color: var(--text-muted);
}

.file-preview-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.file-preview-remove:hover {
  color: var(--error);
}

/* Drop Overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(var(--bg-surface-rgb, 26,26,26), 0.85);
  border: 2px dashed var(--text-muted);
  border-radius: var(--radius-md);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay.visible {
  display: flex;
}

.drop-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.drop-overlay-content svg {
  opacity: 0.6;
}

/* File Chips in Messages */
.message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px 2px 5px;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.file-chip svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.file-chip-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Agent Selector */
.agent-selector-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-selector {
  position: relative;
  margin-right: 0;
}

.model-selector-btn {
  color: var(--text-muted);
  opacity: 0.8;
}

.agent-selector-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.agent-selector-btn:hover {
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.agent-selector-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  z-index: 100;
  display: none;
}

.agent-selector-dropdown.open {
  display: block;
}

.agent-option {
  padding: 10px 14px;
  cursor: pointer;
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--transition-fast);
}

.agent-option:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.agent-option:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }

.agent-option:hover {
  background: var(--bg-hover);
}

.agent-option.active {
  color: var(--text-primary);
  font-weight: 500;
}

.agent-option .check {
  opacity: 0;
  font-size: var(--fs-sm);
}

.agent-option.active .check {
  opacity: 1;
}

.agent-option.disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* Provider Badge in Model Selector */
.model-provider-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  color: #fff;
}
.model-provider-badge.anthropic {
  background: #d97706;
}
.model-provider-badge.openai {
  background: #10a37f;
}

/* Grouped Model Dropdown */
.model-dropdown-grouped {
  min-width: 180px;
}
.model-group-header {
  padding: 6px 14px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  pointer-events: none;
  user-select: none;
  border-top: 1px solid var(--border-light);
}
.model-group-header.disabled {
  opacity: 0.45;
}
.model-group-header:first-child {
  border-top: none;
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--transition-fast);
}

.theme-toggle:hover {
  color: var(--text-primary);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }

[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  animation: fadeIn 150ms ease;
}

.modal-card h2 {
  font-size: var(--fs-base);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.modal-card .input-group {
  margin-bottom: 14px;
}

.modal-card .input-group label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.modal-error {
  color: var(--error);
  font-size: var(--fs-sm);
  min-height: 1.2em;
}

.modal-success {
  color: var(--success);
  font-size: var(--fs-sm);
  min-height: 1.2em;
}

/* Settings */
.settings-section {
  margin-bottom: 14px;
}

.settings-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settings-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-sm);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.settings-select:focus {
  border-color: var(--border-strong);
}

.settings-select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.settings-cred-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.settings-cred-title svg {
  opacity: 0.5;
}

.settings-cred-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 14px;
  line-height: 1.4;
}

.settings-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}

.settings-input:focus {
  border-color: var(--border-strong);
}

.settings-input::placeholder {
  color: var(--text-muted);
}

.settings-cred-form {
  display: flex;
  flex-direction: column;
}

.settings-cred-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.settings-cred-row .settings-input {
  flex: 1;
  min-width: 0;
}

.settings-cred-status {
  margin: 2px 0 0;
  color: var(--success);
  font-size: var(--fs-xs);
}

.settings-cred-msg {
  font-size: var(--fs-sm);
  min-height: 1.2em;
  margin-bottom: 4px;
}

.settings-cred-msg-error {
  color: var(--error);
}

.settings-cred-msg-success {
  color: var(--success);
}

.modal-card-credentials {
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
}

/* Credential Test */
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-outline:hover:not(:disabled) {
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-outline:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cred-test-result {
  font-size: var(--fs-xs);
  line-height: 1.4;
  min-height: 0;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 150ms ease;
  overflow: hidden;
}

.cred-test-result:empty {
  display: none;
}

.cred-test-result.testing {
  color: var(--text-muted);
  padding: 3px 0;
}

.cred-test-result.ok {
  color: var(--success);
  padding: 3px 0;
}

.cred-test-result.warning {
  color: #f59e0b;
  padding: 3px 0;
}

.cred-test-result.invalid,
.cred-test-result.error {
  color: var(--error);
  padding: 3px 0;
}

.cred-test-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: cred-spin 600ms linear infinite;
  flex-shrink: 0;
}

@keyframes cred-spin {
  to { transform: rotate(360deg); }
}

.settings-details summary {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.settings-details summary::-webkit-details-marker { display: none; }

.settings-details summary::before {
  content: '\25B6';
  font-size: 0.5rem;
  transition: transform 150ms ease;
  display: inline-block;
}

.settings-details[open] summary::before {
  transform: rotate(90deg);
}

.settings-pw-form {
  padding-top: 12px;
}

.settings-pw-form .input-group {
  margin-bottom: 10px;
}

.settings-pw-form .input-group label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.settings-close {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.settings-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.settings-close:active {
  transform: scale(0.98);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
  gap: 8px;
}

.empty-state-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: var(--fs-sm);
  max-width: 260px;
}

/* User Management */
.modal-card-lg {
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}

.user-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-surface);
}

.user-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.user-card-header strong {
  font-size: var(--fs-sm);
}

.user-role-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.user-role-badge.admin {
  background: var(--accent-bg, rgba(99,102,241,0.12));
  color: var(--accent, #6366f1);
}

.user-role-badge.user {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.user-card-projects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.user-project-tag {
  font-size: 11px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.btn-xs {
  padding: 2px 4px;
}

.btn-sm {
  padding: 4px 12px;
  font-size: var(--fs-sm);
}

.user-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.project-check-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  cursor: pointer;
  padding: 2px 0;
}

.project-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.project-check.sysmgmt-check {
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--error-muted);
}

.sysmgmt-tag {
  font-size: var(--fs-xs);
  color: var(--error);
  background: transparent;
  padding: 0;
  margin-left: auto;
}

@media (max-width: 600px) {
  .chat-message {
    padding: 10px 14px;
  }

  .message-content pre {
    margin: 10px -14px;
    max-width: calc(100% + 28px);
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 12px 14px;
  }

  .message-content table {
    font-size: 0.85em;
  }
  .message-content th,
  .message-content td {
    padding: 6px 8px;
  }

  .modal-card-lg {
    max-width: 100%;
    max-height: 90vh;
  }
}

/* ─── Tablet: Login ─── */
@media (min-width: 768px) {
  .login-screen {
    max-width: 380px;
    gap: 40px;
  }

  .login-brand {
    gap: 12px;
  }

  .login-logo {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    margin-bottom: 4px;
  }

  .login-logo svg {
    width: 34px;
    height: 34px;
  }

  .login-title {
    font-size: 1.5rem;
  }

  .login-tagline {
    font-size: 0.875rem;
    line-height: 1.6;
  }

  .login-features {
    font-size: 0.8125rem;
    gap: 8px;
    margin-top: 4px;
  }

  .login-input-wrap {
    border-radius: 10px;
  }

  .login-input {
    padding: 9px 14px;
    font-size: 0.875rem;
  }

  .login-submit {
    width: 34px;
    height: 34px;
    margin: 4px;
    border-radius: 8px;
  }

  .login-submit svg {
    width: 16px;
    height: 16px;
  }

  .login-divider {
    font-size: 0.8125rem;
    gap: 12px;
  }

  .login-lab-toggle {
    padding: 10px 20px;
    font-size: 0.8125rem;
    border-radius: 8px;
  }

  .login-code-input {
    font-size: 1.3rem !important;
    letter-spacing: 8px;
  }

  .login-code-info p {
    font-size: 0.875rem;
  }

  .login-back-btn {
    font-size: 0.8125rem;
    padding: 10px;
    margin-top: 8px;
  }

  .login-error {
    font-size: 0.8125rem;
  }

  .login-theme-toggle {
    top: 20px;
    right: 20px;
  }
}

@media (min-width: 1024px) {
  .login-screen {
    max-width: 400px;
    gap: 44px;
  }

  .login-brand {
    gap: 14px;
  }

  .login-logo {
    width: 72px;
    height: 72px;
    margin-bottom: 6px;
  }

  .login-logo svg {
    width: 38px;
    height: 38px;
  }

  .login-title {
    font-size: 1.65rem;
  }

  .login-tagline {
    font-size: 0.9375rem;
  }

  .login-features {
    font-size: 0.875rem;
    gap: 10px;
    margin-top: 6px;
  }

  .login-input {
    padding: 10px 14px;
    font-size: 0.9375rem;
  }

  .login-submit {
    width: 36px;
    height: 36px;
    margin: 4px;
  }

  .login-submit svg {
    width: 18px;
    height: 18px;
  }

  .login-lab-toggle {
    padding: 10px 20px;
    font-size: 0.875rem;
  }

  .login-code-input {
    font-size: 1.4rem !important;
    letter-spacing: 10px;
  }

  .login-theme-toggle {
    top: 28px;
    right: 28px;
  }
}

/* ─── Tablet: Project List / Dashboard ─── */
@media (min-width: 768px) {
  .dashboard-header {
    padding: 24px 32px 16px;
  }

  .dashboard-header h1 {
    font-size: var(--fs-lg);
  }

  .list-section {
    padding: 8px 32px;
  }

  .list-item {
    padding: 16px 0;
    gap: 14px;
  }

  .list-item-icon {
    width: 42px;
    height: 42px;
  }

  .list-item-icon svg {
    width: 20px;
    height: 20px;
  }

  .session-list-header {
    padding: 20px 32px 16px;
    gap: 16px;
  }

  .dashboard-footer {
    padding: 16px 32px 6px;
    font-size: var(--fs-sm);
  }

  .modal-card {
    max-width: 420px;
    padding: 28px;
  }

  .empty-state {
    padding: 48px;
    gap: 12px;
  }

  .empty-state-icon {
    width: 56px;
    height: 56px;
  }

  .empty-state h3 {
    font-size: var(--fs-lg);
  }
}

@media (min-width: 1024px) {
  .dashboard-header {
    padding: 28px 48px 20px;
  }

  .list-section {
    padding: 8px 48px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
  }

  .session-list-header {
    padding: 24px 48px 20px;
  }
}

/* ─── Tablet: Chat / Session ─── */
@media (min-width: 768px) {
  .session-header {
    padding: 0 24px;
    gap: 14px;
  }

  .session-header .back-btn {
    padding: 8px 14px;
    font-size: var(--fs-base);
  }

  .session-header .project-name {
    font-size: var(--fs-base);
  }

  .chat-message {
    padding: 18px 32px;
  }

  .chat-message.user {
    margin: 6px 24px;
    padding: 14px 18px;
    font-size: var(--fs-base);
  }

  .message-content {
    font-size: var(--fs-base);
    line-height: 1.7;
  }

  .message-content pre {
    padding: 16px;
  }

  .chat-input-area {
    padding: 12px 24px;
  }

  .composer-input {
    padding: 14px 16px 0;
    font-size: var(--fs-base);
    max-height: 180px;
  }

  .composer-toolbar {
    padding: 8px 8px 8px 12px;
  }

  .composer-send {
    width: 36px;
    height: 36px;
  }

  .composer-send svg {
    width: 16px;
    height: 16px;
  }

  .composer-attach {
    width: 34px;
    height: 34px;
  }

  .composer-attach svg {
    width: 18px;
    height: 18px;
  }

  .status-bubble .status-indicator {
    padding: 12px 32px;
  }

  .agent-selector-btn {
    padding: 6px 12px;
    font-size: var(--fs-sm);
  }
}

@media (min-width: 1024px) {
  .session-header {
    padding: 0 32px;
  }

  .chat-message {
    padding: 20px 48px;
  }

  .chat-message.user {
    margin: 8px 40px;
  }

  .chat-input-area {
    padding: 14px 40px;
  }

  .status-bubble .status-indicator {
    padding: 14px 48px;
  }
}

@media (min-width: 1280px) {
  .chat-composer {
    max-width: 960px;
    margin: 0 auto;
  }
}

/* ═══════════ Admin Page ═══════════ */

.admin-view {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
}

.admin-page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  flex-shrink: 0;
  gap: 12px;
}

.admin-header h1 {
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
}

/* Tab Navigation */
.admin-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}
.admin-tabs::-webkit-scrollbar { display: none; }

.admin-tab {
  padding: 10px 16px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  font-family: var(--font);
}
.admin-tab:hover {
  color: var(--text-secondary);
}
.admin-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

/* Content Area */
.admin-scroll {
  flex: 1;
  padding: 0 16px calc(16px + var(--safe-bottom));
  overflow-y: auto;
}

.admin-content {
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.admin-section {
  display: none;
  padding-top: 20px;
}
.admin-section.active {
  display: block;
}

/* Block = visual group */
.admin-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.admin-block-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.admin-block-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.admin-block-title-row .admin-block-title {
  margin: 0;
}

/* Fields */
.admin-field {
  margin-bottom: 12px;
}
.admin-field:last-child {
  margin-bottom: 0;
}

.admin-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.admin-value {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin: 0;
}

.admin-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}
.admin-input:focus {
  border-color: var(--border-strong);
}
.admin-input::placeholder {
  color: var(--text-muted);
}

.admin-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
  cursor: pointer;
}
.admin-select:focus {
  border-color: var(--border-strong);
}
.admin-select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.admin-row-inline {
  display: flex;
  gap: 12px;
}

.admin-form {
  display: flex;
  flex-direction: column;
}

.admin-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.admin-msg {
  font-size: var(--fs-sm);
  min-height: 1.2em;
  margin-bottom: 4px;
}
.admin-msg-error { color: var(--error); }
.admin-msg-success { color: var(--success); }

.admin-muted {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.admin-muted-sm {
  color: var(--text-muted);
  font-size: 12px;
}

/* Admin Users */
.admin-users-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-user-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: background var(--transition-fast);
}
.admin-user-row:hover {
  background: var(--bg-hover);
}

.admin-user-info {
  flex: 1;
  min-width: 0;
}

.admin-user-name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.admin-user-name strong {
  font-size: var(--fs-sm);
}

.admin-user-email {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.admin-user-projects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.admin-user-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.admin-tag {
  font-size: 11px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.admin-tag.sysmgmt-tag-list {
  background: var(--error-muted);
  color: var(--error);
}

/* ─── Admin Responsive ─── */
@media (min-width: 768px) {
  .admin-header {
    padding: 14px 32px;
  }
  .admin-tabs {
    padding: 0 32px;
  }
  .admin-scroll {
    padding: 0 32px calc(20px + var(--safe-bottom));
  }
  .admin-content {
    max-width: 680px;
  }
}

@media (min-width: 1024px) {
  .admin-header {
    padding: 16px 48px;
  }
  .admin-tabs {
    padding: 0 48px;
  }
  .admin-scroll {
    padding: 0 48px calc(20px + var(--safe-bottom));
  }
  .admin-content {
    max-width: 720px;
  }
}

@media (max-width: 560px) {
  .admin-row-inline {
    flex-direction: column;
    gap: 0;
  }
  .admin-tabs {
    padding: 0 12px;
  }
  .admin-scroll {
    padding: 0 12px calc(12px + var(--safe-bottom));
  }
}

/* Session List */
.session-list-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.session-list-title {
  flex: 1;
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-status-badge {
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  flex-shrink: 0;
}

.session-status-badge.active {
  background: var(--success-muted);
  color: var(--success);
}

.session-status-badge.ended {
  background: var(--accent-muted);
  color: var(--text-muted);
}

.loading-text {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  padding: 24px 16px;
}

/* Pull to Refresh */
.ptr-indicator {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: height 200ms ease;
  flex-shrink: 0;
}

.ptr-spinner {
  color: var(--text-muted);
  transition: transform 100ms ease, opacity 100ms ease;
  opacity: 0;
}

.ptr-ready .ptr-spinner {
  color: var(--text-secondary);
}

.ptr-loading .ptr-spinner {
  animation: ptr-spin 600ms linear infinite;
}

@keyframes ptr-spin {
  to { transform: rotate(360deg); }
}

/* Dashboard Footer */
.dashboard-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px calc(4px + var(--safe-bottom));
  font-size: var(--fs-xs);
  color: var(--text-muted);
  opacity: 0.6;
  flex-shrink: 0;
  margin-top: auto;
}

.dashboard-footer-dot {
  opacity: 0.4;
}

/* Credential Hint Banner (non-blocking) */
.cred-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 8px 16px;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.cred-hint svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.cred-hint a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.cred-hint-close {
  flex-shrink: 0;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: var(--fs-md);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.cred-hint-close:hover {
  color: var(--text-primary);
}

/* ─── Login Log ─────────────────────────────────── */
.login-log-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.login-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.login-log-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.login-log-table td {
  padding: 7px 10px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-muted, rgba(255,255,255,0.04));
  white-space: nowrap;
}

.login-log-table tbody tr:hover td {
  background: var(--bg-tertiary);
}

.log-cell-time {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.log-cell-ip {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.log-method {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.log-method-pw {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
}

.log-method-magic {
  background: rgba(124,110,240,0.12);
  color: #a594ff;
}

.log-method-demo {
  background: rgba(34,197,94,0.12);
  color: #4ade80;
}

.login-log-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 0;
}

.login-log-pager {
  display: flex;
  gap: 6px;
}

/* ─── Demo Info Button & Modal ──────────────────── */
.info-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.info-btn:hover {
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.demo-info-card {
  max-width: 380px;
}

.demo-info-card h2 {
  margin-bottom: 14px;
}

.demo-info-card p {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 10px;
}

.demo-info-card strong {
  color: var(--text-primary);
  font-weight: 600;
}

.demo-info-card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.demo-info-card li {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  padding-left: 18px;
  position: relative;
}

.demo-info-card li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.demo-info-live {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0 0;
  line-height: 1.5;
}

.demo-info-live a {
  color: var(--text-primary);
  font-weight: 500;
}
