/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1e1e3a;
  --bg-input: #1e1e3a;
  --bg-hover: #252545;
  --primary: #6c63ff;
  --primary-dim: rgba(108, 99, 255, 0.15);
  --primary-glow: rgba(108, 99, 255, 0.3);
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b0;
  --text-muted: #6a6a7a;
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;
  --bubble-user: #3a3a5e;
  --bubble-assistant: #252540;
  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans KR', sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Scrollbar hide */
.scroll-area {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-area::-webkit-scrollbar {
  display: none;
}

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
}

.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.view.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.view.slide-left {
  transform: translateX(-20px);
}

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--nav-height);
  padding-bottom: var(--safe-bottom);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  position: relative;
  transition: color var(--transition);
  -webkit-user-select: none;
  user-select: none;
}

.nav-tab .nav-icon {
  font-size: 22px;
  line-height: 1;
}

.nav-tab.active {
  color: var(--primary);
}

.nav-tab.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ===== HEADER BAR ===== */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-bar h1 {
  font-size: 18px;
  font-weight: 600;
}

.header-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  transition: background var(--transition);
}

.header-btn:active {
  background: var(--bg-hover);
}

/* ===== CHAT VIEW ===== */
.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar {
  display: none;
}

/* Welcome screen */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  gap: 16px;
}

.chat-welcome .welcome-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), #4a3fcf);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 8px;
  box-shadow: 0 4px 24px var(--primary-glow);
}

.chat-welcome h2 {
  font-size: 22px;
  font-weight: 600;
}

.chat-welcome p {
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 300px;
}

/* Suggestion chips */
.suggestion-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 4px 4px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 400px;
}

.suggestion-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-user-select: none;
  user-select: none;
}

.chip:active {
  background: var(--primary-dim);
  border-color: var(--primary);
}

/* Chat input area at bottom */
.chat-input-area {
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--safe-bottom));
  background: var(--bg-input);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-chips-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 8px;
}

.input-chips-row::-webkit-scrollbar {
  display: none;
}

.input-chips-row .chip {
  font-size: 12px;
  padding: 6px 12px;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-row textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-light);
  border-radius: 22px;
  padding: 10px 16px;
  min-height: 44px;
  max-height: 120px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  line-height: 1.4;
  outline: none;
  transition: border-color var(--transition);
}

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

.input-row textarea:focus {
  border-color: var(--primary);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}

.send-btn.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

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

.send-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Message bubbles */
.message {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: fadeInMsg 0.3s ease;
}

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

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

.message.assistant {
  align-self: flex-start;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #4a3fcf);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.user .msg-avatar {
  background: var(--bubble-user);
}

.msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
}

.message.user .msg-bubble {
  background: var(--bubble-user);
  border-bottom-right-radius: 6px;
}

.message.assistant .msg-bubble {
  background: var(--bubble-assistant);
  border-bottom-left-radius: 6px;
}

.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }

.msg-bubble strong { font-weight: 600; }

.msg-bubble code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.msg-bubble pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
}

.msg-bubble pre code {
  background: none;
  padding: 0;
}

.msg-bubble ul, .msg-bubble ol {
  padding-left: 20px;
  margin: 6px 0;
}

.msg-bubble li {
  margin-bottom: 4px;
}

.msg-time {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 4px;
}

.message.user .msg-time {
  text-align: right;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  animation: fadeInMsg 0.3s ease;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bubble-assistant);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 6px;
}

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

.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ===== APPROVAL CARD (inline in chat) ===== */
.approval-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--warning);
  padding: 14px;
  margin: 4px 0;
  max-width: 100%;
  animation: fadeInMsg 0.3s ease;
  touch-action: pan-y;
}

.approval-card.write { border-left-color: var(--warning); }
.approval-card.delete { border-left-color: var(--error); }
.approval-card.transfer { border-left-color: #fb923c; }
.approval-card.read { border-left-color: var(--info); }

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

.approval-card-title {
  font-size: 14px;
  font-weight: 600;
}

.classification-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.classification-badge.write { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.classification-badge.delete { background: rgba(248, 113, 113, 0.15); color: var(--error); }
.classification-badge.transfer { background: rgba(251, 146, 60, 0.15); color: #fb923c; }
.classification-badge.read { background: rgba(96, 165, 250, 0.15); color: var(--info); }

.approval-card-detail {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.risk-flags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.risk-flag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(248, 113, 113, 0.1);
  color: var(--error);
}

.approval-actions {
  display: flex;
  gap: 10px;
}

.approval-actions button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  min-height: 44px;
  transition: all var(--transition);
}

.btn-approve {
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.btn-approve:active {
  background: rgba(74, 222, 128, 0.3);
}

.btn-reject {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
}

.btn-reject:active {
  background: rgba(248, 113, 113, 0.3);
}

/* Swipe hint */
.approval-card .swipe-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ===== TASK CARD ===== */
.task-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid var(--border);
}

.task-card:active {
  background: var(--bg-hover);
}

.task-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-card-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.status-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-badge.running { background: rgba(96, 165, 250, 0.12); color: var(--info); }
.status-badge.running .dot { background: var(--info); animation: pulse-dot 1.5s infinite; }
.status-badge.pending { background: rgba(251, 191, 36, 0.12); color: var(--warning); }
.status-badge.pending .dot { background: var(--warning); }
.status-badge.success { background: rgba(74, 222, 128, 0.12); color: var(--success); }
.status-badge.success .dot { background: var(--success); }
.status-badge.failed { background: rgba(248, 113, 113, 0.12); color: var(--error); }
.status-badge.failed .dot { background: var(--error); }
.status-badge.approval { background: rgba(251, 191, 36, 0.12); color: var(--warning); }
.status-badge.approval .dot { background: var(--warning); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.task-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ===== DASHBOARD VIEW ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--border);
}

.stat-card .stat-icon {
  font-size: 24px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== WORKFLOW CARD ===== */
.workflow-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.workflow-card:active {
  background: var(--bg-hover);
}

.workflow-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

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

.workflow-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workflow-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
  align-items: center;
}

.workflow-run-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.workflow-run-btn:active {
  transform: scale(0.9);
}

/* ===== SETTINGS VIEW ===== */
.settings-section {
  padding: 16px;
}

.settings-section h3 {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.settings-group {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  min-height: 48px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

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

.settings-item:active {
  background: var(--bg-hover);
}

.settings-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-item-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.settings-item-label {
  font-size: 15px;
}

.settings-item-value {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.server-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.server-dot.online { background: var(--success); }
.server-dot.offline { background: var(--error); }

.logout-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: rgba(248, 113, 113, 0.1);
  color: var(--error);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  min-height: 48px;
  transition: background var(--transition);
}

.logout-btn:active {
  background: rgba(248, 113, 113, 0.2);
}

/* ===== LIST STYLES ===== */
.list-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 12px 16px 4px;
  flex-shrink: 0;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font);
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 36px;
}

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

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 13px;
}

/* ===== LOGIN VIEW ===== */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.login-card .login-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), #4a3fcf);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.login-card h2 {
  font-size: 20px;
  font-weight: 600;
}

.login-card .input-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  min-height: 44px;
  transition: border-color var(--transition);
}

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

.login-card input:focus {
  border-color: var(--primary);
}

.login-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  min-height: 48px;
  transition: all var(--transition);
}

.login-btn:active {
  transform: scale(0.98);
}

.login-btn:disabled {
  opacity: 0.5;
}

.login-error {
  font-size: 13px;
  color: var(--error);
  text-align: center;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideInToast 0.3s ease;
  pointer-events: auto;
  font-size: 14px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

.toast.fade-out {
  animation: slideOutToast 0.3s ease forwards;
}

@keyframes slideInToast {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideOutToast {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-16px); }
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
}

/* ===== MODAL / BOTTOM SHEET ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bottom-sheet {
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  background: var(--bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
  padding-bottom: var(--safe-bottom);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.bottom-sheet.slide-down {
  animation: slideDown 0.3s ease forwards;
}

@keyframes slideDown {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 2px;
  margin: 10px auto 8px;
  flex-shrink: 0;
}

.sheet-header {
  padding: 8px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.sheet-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.sheet-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}

/* ===== PULL TO REFRESH ===== */
.pull-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 0;
  overflow: hidden;
  transition: height 0.2s ease;
  color: var(--text-muted);
  font-size: 13px;
}

.pull-indicator.active {
  height: 48px;
}

.pull-indicator .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ===== RIPPLE EFFECT ===== */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  width: 100px;
  height: 100px;
  margin-top: -50px;
  margin-left: -50px;
  top: var(--ripple-y, 50%);
  left: var(--ripple-x, 50%);
  transform: scale(0);
  opacity: 1;
  pointer-events: none;
}

.ripple:active::after {
  animation: rippleEffect 0.5s ease-out;
}

@keyframes rippleEffect {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ===== AUDIT LOG ===== */
.audit-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.audit-item .audit-action {
  font-weight: 600;
  margin-bottom: 2px;
}

.audit-item .audit-meta {
  color: var(--text-muted);
  font-size: 12px;
}

/* ===== SECRET / CONNECTOR ITEMS ===== */
.secret-item, .connector-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.secret-item:last-child, .connector-item:last-child {
  border-bottom: none;
}

.connector-health {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.connector-health.healthy { background: var(--success); }
.connector-health.unhealthy { background: var(--error); }
.connector-health.unknown { background: var(--text-muted); }

/* ===== FORM ELEMENTS IN MODALS ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  min-height: 44px;
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.form-submit-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  min-height: 48px;
  transition: all var(--transition);
}

.form-submit-btn:active {
  transform: scale(0.98);
}

/* ===== DIFF PREVIEW ===== */
.diff-preview {
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  overflow-x: auto;
  margin: 8px 0;
  line-height: 1.6;
}

.diff-preview .diff-add { color: var(--success); }
.diff-preview .diff-remove { color: var(--error); }

/* ===== DESKTOP LAYOUT (>=768px) ===== */
@media (min-width: 768px) {
  .app-layout {
    flex-direction: row;
  }

  .bottom-nav {
    flex-direction: column;
    width: 72px;
    height: 100%;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 16px 0;
    padding-top: calc(16px + var(--safe-top));
    padding-bottom: 16px;
    justify-content: flex-start;
    gap: 4px;
  }

  .nav-tab {
    width: 100%;
    padding: 12px 0;
  }

  .nav-tab.active::after {
    top: 50%;
    left: 0;
    right: auto;
    transform: translateY(-50%);
    width: 3px;
    height: 28px;
    border-radius: 0 3px 3px 0;
  }

  .main-content {
    flex: 1;
  }

  .modal-overlay {
    align-items: center;
  }

  .bottom-sheet {
    max-width: 520px;
    max-height: 70vh;
    border-radius: var(--radius-xl);
    margin-bottom: 0;
  }

  .chat-messages {
    padding: 24px 48px;
  }

  .message {
    max-width: 72%;
  }

  .dashboard-grid {
    padding: 24px;
    gap: 16px;
  }

  .list-view {
    padding: 24px;
  }

  .toast-container {
    left: auto;
    right: 24px;
    width: 360px;
  }
}

@media (min-width: 1024px) {
  .bottom-nav {
    width: 260px;
    align-items: flex-start;
  }

  .nav-tab {
    flex-direction: row;
    gap: 12px;
    padding: 12px 20px;
    justify-content: flex-start;
    font-size: 14px;
  }

  .nav-tab .nav-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
  }

  .nav-tab .nav-label {
    display: block;
  }
}

/* ===== ChatGPT-like Layout Overrides ===== */
:root {
  --gpt-bg: #f7f7f8;
  --gpt-panel: #f1f1f3;
  --gpt-card: #ffffff;
  --gpt-border: rgba(0, 0, 0, 0.1);
  --gpt-text: #202123;
  --gpt-muted: #6e6e80;
  --gpt-accent: #111111;
}

html, body {
  background: var(--gpt-bg);
  color: var(--gpt-text);
}

#app, .app-shell {
  height: 100%;
}

.app-shell {
  display: flex;
  background: var(--gpt-bg);
}

.gpt-sidebar {
  width: 260px;
  background: var(--gpt-panel);
  border-right: 1px solid var(--gpt-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
}
.gpt-sidebar.collapsed {
  width: 76px;
}
.gpt-sidebar-overlay {
  display: none;
}

.gpt-sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gpt-new-chat-btn {
  width: 100%;
  border: 1px solid var(--gpt-border);
  background: #fff;
  color: var(--gpt-text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.gpt-new-chat-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.gpt-nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gpt-nav-item {
  border: none;
  background: transparent;
  color: var(--gpt-muted);
  border-radius: 10px;
  text-align: left;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gpt-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--gpt-text);
}

.gpt-nav-item.active {
  background: #e7e7eb;
  color: var(--gpt-text);
}
.gpt-sidebar.collapsed .nav-text,
.gpt-sidebar.collapsed .gpt-user-chip,
.gpt-sidebar.collapsed .gpt-new-chat-btn {
  display: none;
}
.gpt-sidebar.collapsed .gpt-nav-item {
  justify-content: center;
}

.gpt-user-chip {
  border: 1px solid var(--gpt-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--gpt-muted);
  font-size: 13px;
  width: 100%;
  text-align: left;
  background: #fff;
  cursor: pointer;
}

.gpt-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gpt-main-header {
  height: 48px;
  border-bottom: 1px solid var(--gpt-border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  color: var(--gpt-text);
  justify-content: space-between;
}
.gpt-header-menu,
.gpt-icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  color: #5f6368;
}
.gpt-header-title {
  font-size: 34px;
  font-weight: 500;
}
.gpt-header-actions {
  display: flex;
  gap: 12px;
}

.main-content,
.view {
  position: static;
  transform: none;
}

.view {
  display: none;
  opacity: 1;
  pointer-events: auto;
  flex: 1;
  overflow: hidden;
}

.view.active {
  display: flex;
}

.chat-view {
  background: var(--gpt-bg);
}

.chat-messages {
  padding: 24px max(24px, calc((100vw - 900px) / 2));
  gap: 18px;
}
.chat-welcome h2 {
  font-size: 56px;
  font-weight: 500;
  color: #202123;
}
.chat-welcome p,
.chat-welcome .welcome-icon,
.suggestion-chips {
  display: none;
}

.message {
  max-width: 100%;
}

.message .msg-avatar {
  width: 28px;
  height: 28px;
  background: var(--gpt-card);
}

.message.user .msg-avatar {
  background: #3a3a3a;
}

.msg-bubble {
  background: transparent !important;
  border-radius: 0 !important;
  padding: 0 !important;
  font-size: 15px;
  color: #202123;
}

.msg-content {
  max-width: 820px;
}

.chat-input-area {
  background: var(--gpt-bg);
  border-top: none;
  padding: 12px 18px 28px;
}

.input-row {
  max-width: 860px;
  margin: 0 auto;
  border: 1px solid #d9d9e3;
  background: #ffffff;
  border-radius: 28px;
  padding: 10px;
}

.input-row textarea {
  background: transparent;
  border: none;
  min-height: 38px;
  color: #202123;
}
.attach-btn {
  border: none;
  background: transparent;
  font-size: 24px;
  color: #6b6b78;
  cursor: pointer;
  width: 34px;
}
.pending-files {
  max-width: 860px;
  margin: 0 auto 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pending-file-chip,
.file-tag {
  font-size: 12px;
  border: 1px solid #d9d9e3;
  background: #fff;
  border-radius: 14px;
  padding: 4px 10px;
  color: #444654;
}
.pending-file-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #6e6e80;
}

.send-btn {
  background: #111111;
  opacity: 1;
  transform: scale(1);
}

.send-btn.visible {
  opacity: 1;
}

.header-bar {
  display: none;
}

.settings-section h3 {
  color: var(--gpt-muted);
}

.settings-group,
.task-card,
.workflow-card,
.stat-card {
  background: #ffffff;
  border-color: var(--gpt-border);
}

.bottom-nav,
.nav-tab {
  display: none !important;
}

@media (max-width: 900px) {
  .gpt-sidebar {
    position: fixed;
    left: -270px;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 30;
    transition: left 0.2s ease;
  }
  .gpt-sidebar.open {
    left: 0;
  }
  .gpt-sidebar-overlay.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.28);
    z-index: 20;
  }
  .gpt-sidebar.collapsed {
    width: 260px;
    padding: 8px;
  }

  .gpt-new-chat-btn {
    text-align: center;
    font-size: 12px;
    padding: 8px;
  }

  .gpt-nav-item {
    font-size: 14px;
    text-align: left;
    padding: 10px;
  }

  .gpt-user-chip {
    text-align: center;
    font-size: 11px;
    padding: 8px 6px;
  }

  .chat-messages {
    padding: 16px;
  }
  .gpt-header-title {
    font-size: 18px;
    font-weight: 600;
  }
}
