/* ============================================
   kento-brain — Cyberpunk Hologram Command Center
   ============================================ */

:root {
  --bg: #050510;
  --bg-gradient: radial-gradient(ellipse at 50% 0%, rgba(0, 240, 255, 0.03) 0%, #050510 70%);
  --surface: rgba(10, 18, 30, 0.85);
  --surface-solid: #0a121e;
  --surface-2: rgba(15, 25, 40, 0.9);
  --glass: rgba(0, 240, 255, 0.03);
  --border: rgba(0, 240, 255, 0.1);
  --border-bright: rgba(0, 240, 255, 0.25);
  --cyan: #00f0ff;
  --cyan-dim: rgba(0, 240, 255, 0.12);
  --cyan-glow: rgba(0, 240, 255, 0.2);
  --cyan-deep: #00a8b3;
  --teal: #00e5a0;
  --teal-dim: rgba(0, 229, 160, 0.12);
  --magenta: #ff006e;
  --magenta-dim: rgba(255, 0, 110, 0.12);
  --error: #ff3355;
  --error-dim: rgba(255, 51, 85, 0.12);
  --text: #d0e8f0;
  --text-bright: #e8f8ff;
  --text-dim: #6a8899;
  --text-muted: #3d5566;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: var(--bg);
  background-image: var(--bg-gradient);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Screens ---- */

.screen {
  display: none;
  height: 100%;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ---- Auth ---- */

#auth-screen {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(0, 240, 255, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 80%, rgba(0, 229, 160, 0.03) 0%, transparent 50%);
}
.auth-container {
  margin: auto;
  padding: 2rem;
  text-align: center;
  width: 100%;
  max-width: 340px;
}
.auth-logo {
  font-size: 3.5rem;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.4));
}
.auth-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--cyan);
  text-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
  margin-bottom: 0.25rem;
}
.auth-subtitle {
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  margin-bottom: 2rem;
}
.auth-input {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(0, 240, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--cyan);
  font-size: 1rem;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  outline: none;
  transition: all var(--transition);
  margin-bottom: 1.25rem;
}
.auth-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.15), inset 0 0 20px rgba(0, 240, 255, 0.03);
}
.auth-input::placeholder {
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.auth-btn {
  width: 100%;
  padding: 0.8rem;
  background: transparent;
  color: var(--cyan);
  border: 1px solid var(--cyan);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.auth-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.auth-btn:hover::before {
  opacity: 1;
}
.auth-btn:hover {
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.2), inset 0 0 25px rgba(0, 240, 255, 0.05);
}
.auth-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.auth-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

/* ---- Header ---- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
}
.header-title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}
.tab-nav {
  display: flex;
  gap: 2px;
  background: rgba(0, 240, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.tab-btn {
  padding: 0.4rem 1rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

/* ---- Tab Content ---- */

.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}
.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ---- Dashboard ---- */

.dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
}
.section {
  margin-bottom: 1.75rem;
}
.section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

/* Status Cards */

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.status-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-bright), transparent);
}
.status-card.up {
  border-color: rgba(0, 229, 160, 0.2);
  box-shadow: 0 0 15px rgba(0, 229, 160, 0.05);
}
.status-card.down {
  border-color: rgba(255, 51, 85, 0.2);
  box-shadow: 0 0 15px rgba(255, 51, 85, 0.05);
}
.status-card .name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 0.4rem;
}
.status-card .badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 100px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.status-card.up .badge {
  background: var(--teal-dim);
  color: var(--teal);
  box-shadow: 0 0 8px rgba(0, 229, 160, 0.15);
}
.status-card.down .badge {
  background: var(--error-dim);
  color: var(--error);
  box-shadow: 0 0 8px rgba(255, 51, 85, 0.15);
}
.status-card .commit {
  margin-top: 0.5rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-card.skeleton {
  height: 90px;
  background: linear-gradient(90deg, var(--surface-solid) 25%, rgba(0, 240, 255, 0.04) 50%, var(--surface-solid) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Action Buttons */

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
.action-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}
.action-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.action-btn:hover {
  border-color: var(--border-bright);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.08);
}
.action-btn:hover::after {
  opacity: 1;
}
.action-btn:active {
  transform: scale(0.97);
}
.action-btn.loading {
  opacity: 0.5;
  pointer-events: none;
}
.action-btn .action-icon {
  font-size: 1.1rem;
  position: relative;
  z-index: 1;
}
.action-btn span:last-child {
  position: relative;
  z-index: 1;
}

/* ---- Chat ---- */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
}
.welcome-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* Message Bubbles */

.msg {
  margin-bottom: 1rem;
  animation: fadeIn 0.3s ease;
}
.msg-user {
  display: flex;
  justify-content: flex-end;
}
.msg-user .msg-bubble {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(0, 240, 255, 0.08));
  border: 1px solid rgba(0, 240, 255, 0.2);
  color: var(--text-bright);
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  padding: 0.6rem 1rem;
  max-width: 85%;
  font-size: 0.9rem;
  word-break: break-word;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.05);
}
.msg-assistant {
  display: flex;
  justify-content: flex-start;
}
.msg-assistant .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
  padding: 0.8rem 1rem;
  max-width: 92%;
  font-size: 0.9rem;
  word-break: break-word;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Tool Execution Indicator */

.msg-tool {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  color: var(--text-dim);
  background: rgba(0, 240, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-width: fit-content;
}
.msg-tool .tool-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.msg-tool.done .tool-spinner {
  display: none;
}
.msg-tool.done::before {
  content: ">";
  color: var(--teal);
  font-weight: 700;
  font-family: var(--font-mono);
}
.msg-tool.done {
  color: var(--teal);
  border-color: rgba(0, 229, 160, 0.15);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Neon pulse for streaming */
@keyframes neonPulse {
  0%, 100% { box-shadow: 0 0 5px rgba(0, 240, 255, 0.1); }
  50% { box-shadow: 0 0 15px rgba(0, 240, 255, 0.2); }
}

/* Markdown in assistant messages */

.msg-assistant .msg-bubble h1,
.msg-assistant .msg-bubble h2,
.msg-assistant .msg-bubble h3 {
  margin: 0.75rem 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--cyan);
}
.msg-assistant .msg-bubble h1:first-child,
.msg-assistant .msg-bubble h2:first-child,
.msg-assistant .msg-bubble h3:first-child {
  margin-top: 0;
}
.msg-assistant .msg-bubble p {
  margin: 0.4rem 0;
}
.msg-assistant .msg-bubble ul,
.msg-assistant .msg-bubble ol {
  margin: 0.4rem 0;
  padding-left: 1.3rem;
}
.msg-assistant .msg-bubble li {
  margin: 0.15rem 0;
}
.msg-assistant .msg-bubble code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: rgba(0, 240, 255, 0.06);
  color: var(--cyan);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.08);
}
.msg-assistant .msg-bubble pre {
  background: rgba(5, 5, 16, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin: 0.5rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.msg-assistant .msg-bubble pre::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.2), transparent);
}
.msg-assistant .msg-bubble pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text);
  border: none;
}
.msg-assistant .msg-bubble table {
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.82rem;
  width: 100%;
}
.msg-assistant .msg-bubble th,
.msg-assistant .msg-bubble td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  text-align: left;
}
.msg-assistant .msg-bubble th {
  background: rgba(0, 240, 255, 0.04);
  color: var(--cyan);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.msg-assistant .msg-bubble strong {
  color: var(--text-bright);
}
.msg-assistant .msg-bubble a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 240, 255, 0.3);
}

/* Chat Input */

.chat-input-area {
  padding: 0.75rem 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
}
.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: rgba(0, 240, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  transition: all var(--transition);
}
.chat-input-wrap:focus-within {
  border-color: rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.08), inset 0 0 25px rgba(0, 240, 255, 0.02);
}
.chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-bright);
  font-size: 0.95rem;
  font-family: var(--font);
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 120px;
  padding: 0.25rem 0.5rem;
}
.chat-input::placeholder {
  color: var(--text-muted);
}
.chat-send-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--cyan);
  border: 1px solid var(--cyan);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.chat-send-btn:hover {
  background: var(--cyan-dim);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}
.chat-send-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---- Thinking Indicator ---- */

.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  max-width: fit-content;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease, neonPulse 2s ease-in-out infinite;
}
.thinking-dots {
  display: flex;
  gap: 4px;
}
.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  animation: dotBounce 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}
.thinking-label {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

@keyframes dotBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
    box-shadow: 0 0 10px var(--cyan);
  }
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface-solid);
  color: var(--text-bright);
  padding: 0.6rem 1.2rem;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
  pointer-events: none;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success {
  border-color: var(--teal);
  box-shadow: 0 0 20px rgba(0, 229, 160, 0.15);
}
.toast.error {
  border-color: var(--error);
  box-shadow: 0 0 20px rgba(255, 51, 85, 0.15);
}

/* ---- Scrollbar ---- */

::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-bright);
}

/* ---- Responsive ---- */

@media (min-width: 768px) {
  .status-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .action-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .chat-messages {
    padding: 1.5rem 2rem;
  }
  .msg-user .msg-bubble,
  .msg-assistant .msg-bubble {
    max-width: 70%;
  }
}
