/* ============================================================
   Intelligence Platform — platform-style.css
   Refactored from ColdCAIs v12 coldcase-style.css
   All cc- prefixes → ip-
   Scoped under .ip-wrap with all: initial reset
   ============================================================ */

/* ==========================================================
   1. VARIABLES & RESET
   ========================================================== */

:root {
  --ip-primary: #6366f1;
  --ip-primary-hover: #4f46e5;
  --ip-primary-light: #eef2ff;
  --ip-success: #22c55e;
  --ip-success-light: #f0fdf4;
  --ip-error: #ef4444;
  --ip-error-light: #fef2f2;
  --ip-warning: #f59e0b;
  --ip-warning-light: #fffbeb;
  --ip-info: #3b82f6;
  --ip-info-light: #eff6ff;

  --ip-bg: #f8fafc;
  --ip-surface: #ffffff;
  --ip-surface-raised: #ffffff;
  --ip-surface-sunken: #f1f5f9;

  --ip-text: #1e293b;
  --ip-text-secondary: #475569;
  --ip-text-muted: #94a3b8;

  --ip-border: #e2e8f0;
  --ip-border-light: #f1f5f9;

  --ip-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --ip-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --ip-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --ip-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  --ip-radius-sm: 10px;
  --ip-radius: 14px;
  --ip-radius-lg: 20px;
  --ip-radius-xl: 28px;
  --ip-radius-full: 9999px;

  --ip-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  --ip-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
}

/* Full scope reset */
.ip-wrap {
  all: initial;
  display: block;
  font-family: var(--ip-font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ip-text);
  background: var(--ip-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  box-sizing: border-box;
}

.ip-wrap *,
.ip-wrap *::before,
.ip-wrap *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.ip-wrap img {
  max-width: 100%;
  height: auto;
  display: block;
}

.ip-wrap a {
  color: var(--ip-primary);
  text-decoration: none;
  transition: color var(--ip-transition);
}

.ip-wrap a:hover {
  color: var(--ip-primary-hover);
  text-decoration: underline;
}

.ip-wrap button {
  font-family: var(--ip-font);
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
  color: inherit;
}

.ip-wrap input,
.ip-wrap textarea,
.ip-wrap select {
  font-family: var(--ip-font);
  font-size: inherit;
  color: inherit;
}


/* ==========================================================
   2. LAYOUT
   ========================================================== */

.ip-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 48px;
  min-height: 100vh;
}


/* ==========================================================
   3. LOCK SCREEN
   ========================================================== */

.ip-lock-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--ip-bg);
}

.ip-lock-card {
  background: var(--ip-surface);
  border-radius: var(--ip-radius-lg);
  box-shadow: var(--ip-shadow-lg);
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: ipFadeIn 0.4s ease;
}

.ip-lock-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--ip-text);
  margin-bottom: 8px;
}

.ip-lock-card p {
  font-size: 14px;
  color: var(--ip-text-secondary);
  margin-bottom: 28px;
  line-height: 1.5;
}

.ip-lock-card .ip-lock-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: var(--ip-primary-light);
  border-radius: var(--ip-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.ip-lock-card .ip-text-input {
  margin-bottom: 16px;
}

.ip-lock-card .ip-btn-primary {
  width: 100%;
}

.ip-lock-error {
  color: var(--ip-error);
  font-size: 13px;
  margin-top: 12px;
  font-weight: 500;
}


/* ==========================================================
   4. HEADER
   ========================================================== */

.ip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.ip-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ip-text);
  flex-shrink: 0;
}

.ip-brand:hover {
  text-decoration: none;
}

.ip-brand-icon {
  width: 44px;
  height: 44px;
  background: var(--ip-primary);
  border-radius: var(--ip-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--ip-shadow-sm);
}

.ip-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ip-brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--ip-text);
  line-height: 1.2;
}

.ip-brand-sub {
  font-size: 12px;
  color: var(--ip-text-muted);
  font-weight: 500;
  line-height: 1.2;
}

.ip-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ip-case-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ip-surface);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius-sm);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ip-text);
  cursor: pointer;
  transition: all var(--ip-transition);
  box-shadow: var(--ip-shadow-sm);
}

.ip-case-picker:hover {
  border-color: var(--ip-primary);
  box-shadow: var(--ip-shadow);
}

.ip-case-picker select {
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--ip-text);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 4px;
}

.ip-model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ip-primary-light);
  color: var(--ip-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--ip-radius-full);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.ip-model-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--ip-primary);
  border-radius: var(--ip-radius-full);
  flex-shrink: 0;
}


/* ==========================================================
   5. TABS / NAV
   ========================================================== */

.ip-tabs-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--ip-surface);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius);
  padding: 5px;
  margin-bottom: 24px;
  box-shadow: var(--ip-shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.ip-tabs-bar::-webkit-scrollbar {
  display: none;
}

.ip-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ip-text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--ip-radius-sm);
  cursor: pointer;
  transition: all var(--ip-transition);
  white-space: nowrap;
  position: relative;
  user-select: none;
}

.ip-tab:hover {
  color: var(--ip-text);
  background: var(--ip-surface-sunken);
}

.ip-tab.active {
  color: var(--ip-primary);
  background: var(--ip-primary-light);
  font-weight: 600;
}

.ip-tab .ip-tab-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.ip-tab .ip-tab-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--ip-border);
  color: var(--ip-text-secondary);
  border-radius: var(--ip-radius-full);
  padding: 1px 7px;
  line-height: 1.5;
  min-width: 20px;
  text-align: center;
}

.ip-tab.active .ip-tab-count {
  background: var(--ip-primary);
  color: #fff;
}


/* ==========================================================
   6. MAIN CARD
   ========================================================== */

.ip-main-card {
  background: var(--ip-surface);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius-lg);
  box-shadow: var(--ip-shadow);
  overflow: hidden;
  animation: ipFadeIn 0.35s ease;
}

.ip-tab-body {
  padding: 28px;
}

.ip-tab-body.hidden {
  display: none;
}


/* ==========================================================
   7. SECTIONS & GRID
   ========================================================== */

.ip-section {
  margin-bottom: 28px;
}

.ip-section:last-child {
  margin-bottom: 0;
}

.ip-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ip-text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ip-section-title .ip-section-icon {
  font-size: 18px;
  color: var(--ip-primary);
}

.ip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.ip-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.ip-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.ip-info-card {
  background: var(--ip-surface);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius);
  padding: 20px;
  transition: all var(--ip-transition);
}

.ip-info-card:hover {
  box-shadow: var(--ip-shadow-md);
  transform: translateY(-2px);
  border-color: var(--ip-primary);
}

.ip-info-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ip-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.ip-info-card-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--ip-text);
  line-height: 1.4;
  word-break: break-word;
}

.ip-info-card-meta {
  font-size: 13px;
  color: var(--ip-text-secondary);
  margin-top: 4px;
}

.ip-info-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--ip-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
  background: var(--ip-primary-light);
  color: var(--ip-primary);
}


/* ==========================================================
   8. BADGES
   ========================================================== */

.ip-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--ip-radius-full);
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.ip-badge.primary {
  background: var(--ip-primary-light);
  color: var(--ip-primary);
}

.ip-badge.success {
  background: var(--ip-success-light);
  color: var(--ip-success);
}

.ip-badge.error {
  background: var(--ip-error-light);
  color: var(--ip-error);
}

.ip-badge.warning {
  background: var(--ip-warning-light);
  color: var(--ip-warning);
}

.ip-badge.info {
  background: var(--ip-info-light);
  color: var(--ip-info);
}

.ip-badge.neutral {
  background: var(--ip-surface-sunken);
  color: var(--ip-text-secondary);
}

.ip-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--ip-radius-full);
  background: currentColor;
  flex-shrink: 0;
}


/* ==========================================================
   9. EMPTY STATES
   ========================================================== */

.ip-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.ip-empty-icon {
  width: 72px;
  height: 72px;
  background: var(--ip-surface-sunken);
  border-radius: var(--ip-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--ip-text-muted);
  margin-bottom: 20px;
}

.ip-empty-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ip-text);
  margin-bottom: 6px;
}

.ip-empty-desc {
  font-size: 14px;
  color: var(--ip-text-secondary);
  max-width: 340px;
  line-height: 1.5;
}

.ip-empty .ip-btn-primary {
  margin-top: 20px;
}


/* ==========================================================
   10. INVESTIGATOR / CHAT
   ========================================================== */

.ip-investigator {
  display: flex;
  height: 680px;
  border-radius: var(--ip-radius-lg);
  overflow: hidden;
  border: 1px solid var(--ip-border);
  background: var(--ip-surface);
}

/* Sidebar */
.ip-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--ip-surface-sunken);
  border-right: 1px solid var(--ip-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ip-sidebar-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--ip-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ip-sidebar-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ip-text);
}

/* Chat Area */
.ip-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.ip-chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ip-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--ip-surface);
}

.ip-chat-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ip-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ip-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.ip-messages::-webkit-scrollbar {
  width: 6px;
}

.ip-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ip-messages::-webkit-scrollbar-thumb {
  background: var(--ip-border);
  border-radius: var(--ip-radius-full);
}

.ip-messages::-webkit-scrollbar-thumb:hover {
  background: var(--ip-text-muted);
}

/* Message */
.ip-msg {
  display: flex;
  gap: 12px;
  animation: ipMsgIn 0.3s ease;
  max-width: 85%;
}

.ip-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ip-msg.assistant {
  align-self: flex-start;
}

.ip-msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--ip-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

.ip-msg.user .ip-msg-avatar {
  background: var(--ip-primary);
  color: #fff;
}

.ip-msg.assistant .ip-msg-avatar {
  background: var(--ip-surface-sunken);
  color: var(--ip-text-secondary);
  border: 1px solid var(--ip-border);
}

.ip-msg-content {
  padding: 12px 16px;
  border-radius: var(--ip-radius);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  position: relative;
}

.ip-msg.user .ip-msg-content {
  background: var(--ip-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ip-msg.assistant .ip-msg-content {
  background: var(--ip-surface-sunken);
  color: var(--ip-text);
  border: 1px solid var(--ip-border);
  border-bottom-left-radius: 4px;
}

.ip-msg-time {
  font-size: 11px;
  color: var(--ip-text-muted);
  margin-top: 4px;
  display: block;
}

.ip-msg.user .ip-msg-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.7);
}

/* Input Bar */
.ip-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--ip-border);
  background: var(--ip-surface);
}

.ip-input {
  flex: 1;
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ip-text);
  background: var(--ip-surface);
  resize: none;
  min-height: 46px;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color var(--ip-transition), box-shadow var(--ip-transition);
  outline: none;
  font-family: var(--ip-font);
}

.ip-input:focus {
  border-color: var(--ip-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

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

.ip-send-btn {
  width: 46px;
  height: 46px;
  background: var(--ip-primary);
  color: #fff;
  border: none;
  border-radius: var(--ip-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all var(--ip-transition);
  flex-shrink: 0;
}

.ip-send-btn:hover {
  background: var(--ip-primary-hover);
  transform: scale(1.04);
}

.ip-send-btn:active {
  transform: scale(0.96);
}

.ip-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}


/* ==========================================================
   11. QUICK ACTIONS
   ========================================================== */

.ip-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--ip-border-light);
  background: var(--ip-surface);
}

.ip-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ip-text-secondary);
  background: var(--ip-surface-sunken);
  border: 1px solid var(--ip-border-light);
  border-radius: var(--ip-radius-full);
  cursor: pointer;
  transition: all var(--ip-transition);
  white-space: nowrap;
}

.ip-quick-btn:hover {
  color: var(--ip-primary);
  border-color: var(--ip-primary);
  background: var(--ip-primary-light);
}

.ip-quick-btn .ip-quick-icon {
  font-size: 14px;
  line-height: 1;
}


/* ==========================================================
   12. THREAD LIST
   ========================================================== */

.ip-thread-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.ip-thread-list::-webkit-scrollbar {
  width: 4px;
}

.ip-thread-list::-webkit-scrollbar-track {
  background: transparent;
}

.ip-thread-list::-webkit-scrollbar-thumb {
  background: var(--ip-border);
  border-radius: var(--ip-radius-full);
}

.ip-thread {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--ip-radius-sm);
  cursor: pointer;
  transition: all var(--ip-transition);
  margin-bottom: 2px;
}

.ip-thread:hover {
  background: var(--ip-surface);
}

.ip-thread.active {
  background: var(--ip-primary-light);
  color: var(--ip-primary);
}

.ip-thread-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--ip-radius-sm);
  background: var(--ip-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  color: var(--ip-text-muted);
  border: 1px solid var(--ip-border-light);
}

.ip-thread.active .ip-thread-icon {
  background: var(--ip-primary);
  color: #fff;
  border-color: var(--ip-primary);
}

.ip-thread-info {
  flex: 1;
  min-width: 0;
}

.ip-thread-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ip-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ip-thread.active .ip-thread-name {
  color: var(--ip-primary);
}

.ip-thread-preview {
  font-size: 12px;
  color: var(--ip-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ip-thread-time {
  font-size: 11px;
  color: var(--ip-text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.ip-new-thread {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ip-primary);
  background: var(--ip-surface);
  border: 1px dashed var(--ip-primary);
  border-radius: var(--ip-radius-sm);
  cursor: pointer;
  transition: all var(--ip-transition);
  opacity: 0.8;
}

.ip-new-thread:hover {
  opacity: 1;
  background: var(--ip-primary-light);
}


/* ==========================================================
   13. TOOL TAGS
   ========================================================== */

.ip-tool-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--ip-radius-full);
  background: var(--ip-info-light);
  color: var(--ip-info);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.ip-tool-tag.searching {
  background: var(--ip-warning-light);
  color: var(--ip-warning);
}

.ip-tool-tag.complete {
  background: var(--ip-success-light);
  color: var(--ip-success);
}

.ip-tool-tag.error {
  background: var(--ip-error-light);
  color: var(--ip-error);
}


/* ==========================================================
   14. MARKDOWN CONTENT (inside assistant messages)
   ========================================================== */

.ip-msg.assistant .ip-msg-content h1,
.ip-msg.assistant .ip-msg-content h2,
.ip-msg.assistant .ip-msg-content h3,
.ip-msg.assistant .ip-msg-content h4 {
  font-weight: 700;
  color: var(--ip-text);
  margin-top: 16px;
  margin-bottom: 8px;
  line-height: 1.3;
}

.ip-msg.assistant .ip-msg-content h1 {
  font-size: 18px;
}

.ip-msg.assistant .ip-msg-content h2 {
  font-size: 16px;
}

.ip-msg.assistant .ip-msg-content h3 {
  font-size: 15px;
}

.ip-msg.assistant .ip-msg-content h4 {
  font-size: 14px;
}

.ip-msg.assistant .ip-msg-content p {
  margin-bottom: 10px;
}

.ip-msg.assistant .ip-msg-content p:last-child {
  margin-bottom: 0;
}

.ip-msg.assistant .ip-msg-content ul,
.ip-msg.assistant .ip-msg-content ol {
  margin-bottom: 10px;
  padding-left: 22px;
}

.ip-msg.assistant .ip-msg-content li {
  margin-bottom: 4px;
  line-height: 1.6;
}

.ip-msg.assistant .ip-msg-content li::marker {
  color: var(--ip-text-muted);
}

.ip-msg.assistant .ip-msg-content strong {
  font-weight: 700;
  color: var(--ip-text);
}

.ip-msg.assistant .ip-msg-content em {
  font-style: italic;
}

.ip-msg.assistant .ip-msg-content code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  font-size: 12.5px;
  background: var(--ip-surface);
  border: 1px solid var(--ip-border);
  border-radius: 6px;
  padding: 2px 6px;
}

.ip-msg.assistant .ip-msg-content pre {
  background: var(--ip-text);
  color: #e2e8f0;
  border-radius: var(--ip-radius-sm);
  padding: 16px;
  margin: 10px 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
}

.ip-msg.assistant .ip-msg-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  border-radius: 0;
}

.ip-msg.assistant .ip-msg-content blockquote {
  border-left: 3px solid var(--ip-primary);
  padding: 8px 14px;
  margin: 10px 0;
  background: var(--ip-primary-light);
  border-radius: 0 var(--ip-radius-sm) var(--ip-radius-sm) 0;
  color: var(--ip-text-secondary);
  font-size: 13.5px;
}

.ip-msg.assistant .ip-msg-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}

.ip-msg.assistant .ip-msg-content th,
.ip-msg.assistant .ip-msg-content td {
  border: 1px solid var(--ip-border);
  padding: 8px 12px;
  text-align: left;
}

.ip-msg.assistant .ip-msg-content th {
  background: var(--ip-surface);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ip-text-secondary);
}

.ip-msg.assistant .ip-msg-content hr {
  border: none;
  border-top: 1px solid var(--ip-border);
  margin: 14px 0;
}

.ip-msg.assistant .ip-msg-content a {
  color: var(--ip-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ip-msg.assistant .ip-msg-content a:hover {
  color: var(--ip-primary-hover);
}

.ip-msg.assistant .ip-msg-content img {
  border-radius: var(--ip-radius-sm);
  margin: 8px 0;
}


/* ==========================================================
   15. RESEARCH TAB
   ========================================================== */

.ip-research-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.ip-research-form-col {
  width: 380px;
  min-width: 380px;
  position: sticky;
  top: 24px;
}

.ip-research-list-col {
  flex: 1;
  min-width: 0;
}


/* ==========================================================
   16. FORM ELEMENTS
   ========================================================== */

.ip-form-card {
  background: var(--ip-surface);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius);
  padding: 24px;
  box-shadow: var(--ip-shadow-sm);
}

.ip-form-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ip-text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ip-field {
  margin-bottom: 18px;
}

.ip-field:last-child {
  margin-bottom: 0;
}

.ip-field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ip-text);
  margin-bottom: 6px;
}

.ip-field-label .ip-required {
  color: var(--ip-error);
  margin-left: 2px;
}

.ip-field-hint {
  font-size: 12px;
  color: var(--ip-text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.ip-text-input {
  display: block;
  width: 100%;
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ip-text);
  background: var(--ip-surface);
  transition: border-color var(--ip-transition), box-shadow var(--ip-transition);
  outline: none;
  font-family: var(--ip-font);
}

.ip-text-input:focus {
  border-color: var(--ip-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

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

.ip-text-input.error {
  border-color: var(--ip-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.ip-textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ip-text);
  background: var(--ip-surface);
  transition: border-color var(--ip-transition), box-shadow var(--ip-transition);
  outline: none;
  font-family: var(--ip-font);
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

.ip-textarea:focus {
  border-color: var(--ip-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.ip-textarea::placeholder {
  color: var(--ip-text-muted);
}

.ip-select {
  display: block;
  width: 100%;
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ip-text);
  background: var(--ip-surface);
  transition: border-color var(--ip-transition), box-shadow var(--ip-transition);
  outline: none;
  font-family: var(--ip-font);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.ip-select:focus {
  border-color: var(--ip-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.ip-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.ip-checkbox-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--ip-primary);
  cursor: pointer;
}

.ip-checkbox-wrap label {
  font-size: 14px;
  color: var(--ip-text);
  cursor: pointer;
  user-select: none;
}


/* ==========================================================
   17. UPLOAD
   ========================================================== */

.ip-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ip-primary);
  background: var(--ip-primary-light);
  border: 2px dashed var(--ip-primary);
  border-radius: var(--ip-radius);
  cursor: pointer;
  transition: all var(--ip-transition);
  width: 100%;
  text-align: center;
}

.ip-upload-btn:hover {
  background: var(--ip-surface);
  border-style: solid;
}

.ip-upload-btn .ip-upload-icon {
  font-size: 18px;
}

.ip-upload-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.ip-upload-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--ip-radius-sm);
  overflow: hidden;
  border: 1px solid var(--ip-border);
}

.ip-upload-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ip-upload-preview-item .ip-upload-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: var(--ip-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--ip-transition);
}

.ip-upload-preview-item .ip-upload-remove:hover {
  background: var(--ip-error);
}

.ip-upload-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--ip-surface-sunken);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius-sm);
  margin-top: 8px;
}

.ip-upload-file-icon {
  font-size: 20px;
  color: var(--ip-primary);
  flex-shrink: 0;
}

.ip-upload-file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--ip-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ip-upload-file-size {
  font-size: 12px;
  color: var(--ip-text-muted);
  flex-shrink: 0;
}


/* ==========================================================
   18. BUTTONS
   ========================================================== */

.ip-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--ip-primary);
  border: none;
  border-radius: var(--ip-radius-sm);
  cursor: pointer;
  transition: all var(--ip-transition);
  box-shadow: var(--ip-shadow-sm);
  white-space: nowrap;
  font-family: var(--ip-font);
}

.ip-btn-primary:hover {
  background: var(--ip-primary-hover);
  box-shadow: var(--ip-shadow);
  transform: translateY(-1px);
}

.ip-btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--ip-shadow-sm);
}

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

.ip-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--ip-error);
  border: none;
  border-radius: var(--ip-radius-sm);
  cursor: pointer;
  transition: all var(--ip-transition);
  box-shadow: var(--ip-shadow-sm);
  white-space: nowrap;
  font-family: var(--ip-font);
}

.ip-btn-danger:hover {
  background: #dc2626;
  box-shadow: var(--ip-shadow);
  transform: translateY(-1px);
}

.ip-btn-danger:active {
  transform: translateY(0);
}

.ip-btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ip-btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ip-text-secondary);
  background: transparent;
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius-sm);
  cursor: pointer;
  transition: all var(--ip-transition);
  white-space: nowrap;
  font-family: var(--ip-font);
}

.ip-btn-ghost:hover {
  color: var(--ip-text);
  border-color: var(--ip-text-muted);
  background: var(--ip-surface-sunken);
}

.ip-btn-ghost:active {
  background: var(--ip-border-light);
}

.ip-btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ip-btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.ip-btn-lg {
  padding: 14px 32px;
  font-size: 15px;
}

.ip-btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ip-radius-sm);
  font-size: 16px;
  color: var(--ip-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--ip-transition);
}

.ip-btn-icon:hover {
  color: var(--ip-text);
  background: var(--ip-surface-sunken);
  border-color: var(--ip-border);
}


/* ==========================================================
   19. RESEARCH LIST
   ========================================================== */

.ip-research-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ip-research-item {
  background: var(--ip-surface);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: all var(--ip-transition);
  position: relative;
}

.ip-research-item:hover {
  box-shadow: var(--ip-shadow);
  border-color: var(--ip-primary);
}

.ip-research-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.ip-research-item-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ip-text);
  line-height: 1.3;
}

.ip-research-item-date {
  font-size: 12px;
  color: var(--ip-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.ip-research-item-excerpt {
  font-size: 14px;
  color: var(--ip-text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ip-research-item-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.ip-research-item-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--ip-radius-full);
  background: var(--ip-surface-sunken);
  color: var(--ip-text-secondary);
}

/* Expanded research */
.ip-research-expanded {
  background: var(--ip-surface);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius);
  padding: 28px;
  animation: ipSlideIn 0.3s ease;
}

.ip-research-expanded-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.ip-research-expanded-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--ip-text);
  line-height: 1.3;
}

.ip-research-expanded-body {
  font-size: 14px;
  color: var(--ip-text);
  line-height: 1.7;
}

.ip-research-expanded-body p {
  margin-bottom: 12px;
}

.ip-research-expanded-body p:last-child {
  margin-bottom: 0;
}

.ip-research-expanded-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--ip-border);
  font-size: 13px;
  color: var(--ip-text-muted);
  flex-wrap: wrap;
}


/* ==========================================================
   20. TOAST NOTIFICATIONS
   ========================================================== */

.ip-toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.ip-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--ip-surface);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius);
  box-shadow: var(--ip-shadow-lg);
  font-size: 14px;
  color: var(--ip-text);
  min-width: 300px;
  max-width: 440px;
  animation: ipSlideIn 0.35s ease;
  border-left: 4px solid var(--ip-border);
}

.ip-toast.success {
  border-left-color: var(--ip-success);
}

.ip-toast.error {
  border-left-color: var(--ip-error);
}

.ip-toast.warning {
  border-left-color: var(--ip-warning);
}

.ip-toast.info {
  border-left-color: var(--ip-info);
}

.ip-toast-icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}

.ip-toast.success .ip-toast-icon {
  color: var(--ip-success);
}

.ip-toast.error .ip-toast-icon {
  color: var(--ip-error);
}

.ip-toast.warning .ip-toast-icon {
  color: var(--ip-warning);
}

.ip-toast.info .ip-toast-icon {
  color: var(--ip-info);
}

.ip-toast-body {
  flex: 1;
  min-width: 0;
}

.ip-toast-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.ip-toast-message {
  font-size: 13px;
  color: var(--ip-text-secondary);
  line-height: 1.4;
}

.ip-toast-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ip-radius-sm);
  font-size: 16px;
  color: var(--ip-text-muted);
  cursor: pointer;
  transition: all var(--ip-transition);
  flex-shrink: 0;
}

.ip-toast-close:hover {
  background: var(--ip-surface-sunken);
  color: var(--ip-text);
}


/* ==========================================================
   21. SPINNER
   ========================================================== */

.ip-spinner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
}

.ip-spinner-dot {
  width: 8px;
  height: 8px;
  background: var(--ip-primary);
  border-radius: var(--ip-radius-full);
  animation: ipBounce 1.4s infinite ease-in-out both;
}

.ip-spinner-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.ip-spinner-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.ip-spinner-dot:nth-child(3) {
  animation-delay: 0s;
}

.ip-spinner-text {
  font-size: 13px;
  color: var(--ip-text-muted);
  margin-left: 6px;
  font-weight: 500;
}

/* Circle spinner variant */
.ip-spinner-circle {
  width: 24px;
  height: 24px;
  border: 3px solid var(--ip-border);
  border-top-color: var(--ip-primary);
  border-radius: var(--ip-radius-full);
  animation: ipSpin 0.7s linear infinite;
}

.ip-spinner-circle.sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.ip-spinner-circle.lg {
  width: 36px;
  height: 36px;
  border-width: 4px;
}


/* ==========================================================
   22. PDF VIEWER
   ========================================================== */

.ip-pdf-wrap {
  background: var(--ip-surface-sunken);
  border: 1px solid var(--ip-border);
  border-radius: var(--ip-radius);
  overflow: hidden;
  position: relative;
}

.ip-pdf-wrap iframe {
  width: 100%;
  height: 600px;
  border: none;
  display: block;
}

.ip-pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--ip-surface);
  border-bottom: 1px solid var(--ip-border);
}

.ip-pdf-toolbar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ip-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ip-pdf-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}


/* ==========================================================
   23. ANIMATIONS
   ========================================================== */

@keyframes ipFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ipMsgIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ipSlideIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes ipSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes ipBounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes ipPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes ipShakeX {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-4px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(4px);
  }
}

.ip-animate-fade-in {
  animation: ipFadeIn 0.35s ease;
}

.ip-animate-slide-in {
  animation: ipSlideIn 0.35s ease;
}

.ip-animate-pulse {
  animation: ipPulse 2s ease-in-out infinite;
}

.ip-animate-shake {
  animation: ipShakeX 0.6s ease;
}


/* ==========================================================
   24. ACCESSIBILITY
   ========================================================== */

/* Focus-visible outlines */
.ip-wrap *:focus-visible {
  outline: 2px solid var(--ip-primary);
  outline-offset: 2px;
}

.ip-wrap button:focus-visible,
.ip-wrap a:focus-visible,
.ip-wrap input:focus-visible,
.ip-wrap textarea:focus-visible,
.ip-wrap select:focus-visible {
  outline: 2px solid var(--ip-primary);
  outline-offset: 2px;
}

/* Hide outline for mouse clicks */
.ip-wrap *:focus:not(:focus-visible) {
  outline: none;
}

/* Skip link */
.ip-skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--ip-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--ip-radius-sm);
  font-size: 14px;
  font-weight: 600;
  z-index: 10001;
  transition: top 0.2s ease;
}

.ip-skip-link:focus {
  top: 16px;
}

/* Screen reader only */
.ip-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ip-wrap *,
  .ip-wrap *::before,
  .ip-wrap *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast */
@media (forced-colors: active) {
  .ip-wrap {
    forced-color-adjust: none;
  }

  .ip-btn-primary,
  .ip-btn-danger,
  .ip-send-btn {
    border: 2px solid ButtonText;
  }

  .ip-text-input,
  .ip-textarea,
  .ip-select,
  .ip-input {
    border: 2px solid ButtonText;
  }
}


/* ==========================================================
   25. RESPONSIVE — 1024px
   ========================================================== */

@media (max-width: 1024px) {
  .ip-wrap {
    padding: 20px 24px 40px;
  }

  .ip-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .ip-research-layout {
    flex-direction: column;
  }

  .ip-research-form-col {
    width: 100%;
    min-width: 0;
    position: static;
  }

  .ip-research-list-col {
    width: 100%;
  }

  .ip-investigator {
    height: 620px;
  }

  .ip-sidebar {
    width: 240px;
    min-width: 240px;
  }
}


/* ==========================================================
   25. RESPONSIVE — 768px
   ========================================================== */

@media (max-width: 768px) {
  .ip-wrap {
    padding: 16px 16px 32px;
  }

  .ip-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .ip-header-right {
    width: 100%;
    justify-content: flex-start;
  }

  .ip-tabs-bar {
    gap: 2px;
    padding: 4px;
    border-radius: var(--ip-radius-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ip-tab {
    padding: 8px 14px;
    font-size: 13px;
    min-width: 0;
  }

  .ip-tab-body {
    padding: 20px 16px;
  }

  .ip-grid {
    grid-template-columns: 1fr;
  }

  .ip-grid-2 {
    grid-template-columns: 1fr;
  }

  .ip-grid-3 {
    grid-template-columns: 1fr;
  }

  /* Investigator stacks vertically */
  .ip-investigator {
    flex-direction: column;
    height: auto;
    min-height: 600px;
  }

  .ip-sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--ip-border);
    max-height: 240px;
  }

  .ip-chat {
    min-height: 400px;
  }

  .ip-messages {
    padding: 16px;
  }

  .ip-msg {
    max-width: 92%;
  }

  .ip-input-bar {
    padding: 12px 16px;
  }

  .ip-input {
    font-size: 16px; /* Prevent iOS zoom */
    min-height: 44px;
  }

  .ip-send-btn {
    width: 44px;
    height: 44px;
  }

  .ip-quick-actions {
    padding: 10px 16px;
  }

  .ip-lock-card {
    padding: 36px 24px;
    margin: 0 16px;
  }

  .ip-form-card {
    padding: 20px 16px;
  }

  .ip-research-expanded {
    padding: 20px 16px;
  }

  .ip-research-expanded-title {
    font-size: 18px;
  }

  /* Toast mobile */
  .ip-toast-wrap {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .ip-toast {
    min-width: 0;
    max-width: 100%;
  }

  /* Touch targets */
  .ip-btn-primary,
  .ip-btn-danger,
  .ip-btn-ghost {
    min-height: 44px;
  }

  .ip-thread {
    padding: 12px;
    min-height: 44px;
  }

  .ip-quick-btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  .ip-case-picker {
    min-height: 44px;
  }

  .ip-pdf-wrap iframe {
    height: 400px;
  }
}


/* ==========================================================
   25. RESPONSIVE — 380px (small phones)
   ========================================================== */

@media (max-width: 380px) {
  .ip-wrap {
    padding: 12px 12px 24px;
  }

  .ip-brand-name {
    font-size: 16px;
  }

  .ip-brand-icon {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .ip-tab {
    padding: 7px 10px;
    font-size: 12px;
    gap: 4px;
  }

  .ip-tab .ip-tab-icon {
    font-size: 14px;
  }

  .ip-tab-body {
    padding: 16px 12px;
  }

  .ip-msg-content {
    padding: 10px 12px;
    font-size: 13.5px;
  }

  .ip-msg-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .ip-messages {
    padding: 12px;
    gap: 12px;
  }

  .ip-input-bar {
    padding: 10px 12px;
  }

  .ip-section-title {
    font-size: 15px;
  }

  .ip-info-card {
    padding: 16px;
  }

  .ip-lock-card {
    padding: 28px 18px;
  }

  .ip-lock-card h2 {
    font-size: 19px;
  }

  .ip-form-card {
    padding: 16px 12px;
  }

  .ip-research-item {
    padding: 14px 16px;
  }

  .ip-research-expanded {
    padding: 16px 12px;
  }

  .ip-research-expanded-title {
    font-size: 16px;
  }

  .ip-pdf-wrap iframe {
    height: 320px;
  }

  /* Safe area padding for notched devices */
  .ip-wrap {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .ip-toast-wrap {
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
  }

  .ip-input-bar {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}


/* ==========================================================
   UTILITY CLASSES
   ========================================================== */

.ip-text-center {
  text-align: center;
}

.ip-text-right {
  text-align: right;
}

.ip-text-muted {
  color: var(--ip-text-muted);
}

.ip-text-secondary {
  color: var(--ip-text-secondary);
}

.ip-text-primary {
  color: var(--ip-primary);
}

.ip-text-success {
  color: var(--ip-success);
}

.ip-text-error {
  color: var(--ip-error);
}

.ip-text-warning {
  color: var(--ip-warning);
}

.ip-text-sm {
  font-size: 13px;
}

.ip-text-xs {
  font-size: 12px;
}

.ip-text-lg {
  font-size: 17px;
}

.ip-font-bold {
  font-weight: 700;
}

.ip-font-medium {
  font-weight: 500;
}

.ip-mt-0 { margin-top: 0; }
.ip-mt-1 { margin-top: 4px; }
.ip-mt-2 { margin-top: 8px; }
.ip-mt-3 { margin-top: 12px; }
.ip-mt-4 { margin-top: 16px; }
.ip-mt-6 { margin-top: 24px; }
.ip-mt-8 { margin-top: 32px; }

.ip-mb-0 { margin-bottom: 0; }
.ip-mb-1 { margin-bottom: 4px; }
.ip-mb-2 { margin-bottom: 8px; }
.ip-mb-3 { margin-bottom: 12px; }
.ip-mb-4 { margin-bottom: 16px; }
.ip-mb-6 { margin-bottom: 24px; }
.ip-mb-8 { margin-bottom: 32px; }

.ip-gap-1 { gap: 4px; }
.ip-gap-2 { gap: 8px; }
.ip-gap-3 { gap: 12px; }
.ip-gap-4 { gap: 16px; }

.ip-flex {
  display: flex;
}

.ip-flex-col {
  display: flex;
  flex-direction: column;
}

.ip-flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ip-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ip-flex-wrap {
  flex-wrap: wrap;
}

.ip-flex-1 {
  flex: 1;
  min-width: 0;
}

.ip-hidden {
  display: none !important;
}

.ip-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ip-w-full {
  width: 100%;
}

.ip-relative {
  position: relative;
}

.ip-overflow-hidden {
  overflow: hidden;
}

.ip-divider {
  border: none;
  border-top: 1px solid var(--ip-border);
  margin: 20px 0;
}

.ip-divider-light {
  border: none;
  border-top: 1px solid var(--ip-border-light);
  margin: 16px 0;
}
