@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --bg:        #08080e;
  --surface:   #10101a;
  --surface2:  #181824;
  --surface3:  #20202e;
  --border:    #252538;
  --border2:   #30304a;
  --text:      #eeeef5;
  --text-muted:#7070a0;
  --text-dim:  #40405a;
  --accent:    #7c5af5;
  --accent-h:  #6a48e4;
  --accent2:   #4f8ef7;
  --success:   #3ecf7e;
  --danger:    #f25757;
  --warning:   #f59e2a;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
  --font: 'Inter', system-ui, sans-serif;
  --gradient: linear-gradient(135deg, #7c5af5, #4f8ef7);
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: #7c5af540; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.page { min-height: 100vh; display: flex; flex-direction: column; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; width: 100%; }

/* Nav */
nav {
  background: rgba(8,8,14,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
  position: sticky; top: 0; z-index: 100;
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.nav-brand { font-weight: 800; font-size: 1.15rem; color: var(--text); letter-spacing: -0.03em; display: flex; align-items: center; gap: 0.5rem; }
.nav-brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gradient); display: inline-block; box-shadow: 0 0 8px #7c5af5; }
.nav-links { display: flex; align-items: center; gap: 0.75rem; }
.nav-user { color: var(--text-muted); font-size: 0.8rem; padding: 0.28rem 0.75rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1.1rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 600; cursor: pointer; border: none; transition: all 0.15s; text-decoration: none; font-family: var(--font); white-space: nowrap; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 2px 16px #7c5af530; }
.btn-primary:hover { box-shadow: 0 4px 24px #7c5af550; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--surface3); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border2); background: var(--surface2); }
.btn-sm { padding: 0.32rem 0.75rem; font-size: 0.78rem; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; border-radius: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* Landing */
.landing-nav { background: transparent; border-bottom: 1px solid transparent; }
.hero {
  padding: 7rem 0 5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; top: -150px; left: 50%;
  transform: translateX(-50%);
  width: 800px; height: 500px;
  background: radial-gradient(ellipse, #7c5af522 0%, transparent 70%);
  pointer-events: none;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.75rem; font-weight: 700; color: var(--accent);
  background: #7c5af514; border: 1px solid #7c5af330;
  border-radius: 20px; padding: 0.3rem 0.9rem;
  margin-bottom: 1.5rem; letter-spacing: 0.06em; text-transform: uppercase;
}
.hero h1 {
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 800; line-height: 1.08; letter-spacing: -0.045em;
  margin-bottom: 1.25rem;
}
.grad-text {
  background: var(--gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-sub { font-size: 1.05rem; color: var(--text-muted); max-width: 500px; margin: 0 auto 2.5rem; line-height: 1.75; }
.hero-ctas { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 4rem; }
.how-it-works {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; max-width: 780px; margin: 0 auto;
}
.hiw-step { background: var(--surface); padding: 1.75rem; text-align: left; }
.hiw-step:hover { background: var(--surface2); }
.hiw-num { font-size: 0.7rem; font-weight: 800; color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 0.65rem; }
.hiw-step h3 { font-size: 0.92rem; font-weight: 700; margin-bottom: 0.35rem; }
.hiw-step p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.65; }

.features { padding: 5rem 0; border-top: 1px solid var(--border); }
.section-label { font-size: 0.75rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.75rem; }
.section-title { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 0.5rem; }
.section-sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 2.5rem; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.6rem; transition: border-color 0.2s, transform 0.2s; }
.feature-card:hover { border-color: var(--border2); transform: translateY(-2px); }
.feature-icon { width: 38px; height: 38px; border-radius: 9px; background: #7c5af516; border: 1px solid #7c5af328; display: flex; align-items: center; justify-content: center; font-size: 1rem; margin-bottom: 0.9rem; }
.feature-card h3 { font-size: 0.92rem; font-weight: 700; margin-bottom: 0.35rem; }
.feature-card p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.65; }

.landing-footer { border-top: 1px solid var(--border); padding: 1.75rem 0; text-align: center; color: var(--text-dim); font-size: 0.78rem; }

/* Auth */
.auth-bg {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(ellipse at 50% 0%, #7c5af510 0%, transparent 55%);
}
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2.25rem; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.form-card-logo { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 0.25rem; }
.form-card-sub { color: var(--text-muted); font-size: 0.83rem; margin-bottom: 1.75rem; }
.form-group { margin-bottom: 1.1rem; }
label { display: block; margin-bottom: 0.38rem; color: var(--text-muted); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em; }
input, select, textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text); font-size: 0.875rem; padding: 0.62rem 0.85rem; outline: none; transition: border-color 0.15s, box-shadow 0.15s; font-family: var(--font); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #7c5af520; }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
.form-hint { font-size: 0.73rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-footer { margin-top: 1.25rem; text-align: center; color: var(--text-muted); font-size: 0.82rem; }
.error-msg { color: var(--danger); font-size: 0.82rem; margin-top: 0.75rem; min-height: 1.2em; text-align: center; }

/* App library */
.library-wrap { flex: 1; padding-bottom: 3rem; }
.library-header { display: flex; align-items: center; justify-content: space-between; padding: 1.75rem 0 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.library-title h1 { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.02em; }
.library-title p { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.app-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.4rem; cursor: pointer; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; gap: 0.8rem; text-decoration: none; color: inherit; }
.app-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 32px #7c5af515; text-decoration: none; }
.app-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.app-card-name { font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.app-card-path { font-size: 0.73rem; color: var(--accent); font-family: monospace; }
.app-card-footer { display: flex; align-items: center; justify-content: space-between; }
.app-card-meta { font-size: 0.73rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.4rem; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.status-active { background: var(--success); box-shadow: 0 0 5px var(--success); }
.status-provisioning { background: var(--warning); }
.status-error { background: var(--danger); }
.badge { display: inline-flex; align-items: center; padding: 0.18rem 0.5rem; border-radius: 5px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; flex-shrink: 0; }
.badge-vanilla { background: #f7df1e14; border: 1px solid #f7df1e28; color: #c9a800; }
.badge-react   { background: #61dafb14; border: 1px solid #61dafb28; color: #61dafb; }
.empty-state { grid-column: 1/-1; text-align: center; padding: 5rem 1rem; }
.empty-icon { width: 60px; height: 60px; background: var(--surface2); border: 1px solid var(--border); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; margin: 0 auto 1.25rem; }
.empty-state h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.4rem; }
.empty-state p { font-size: 0.83rem; color: var(--text-muted); margin-bottom: 1.5rem; }

/* Create */
.create-wrap { flex: 1; padding: 2.5rem 0; }
.create-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2.25rem; max-width: 560px; box-shadow: var(--shadow); }
.create-card h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.25rem; }
.create-card .sub { color: var(--text-muted); font-size: 0.83rem; margin-bottom: 1.75rem; }
.url-preview { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.55rem 0.85rem; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1.1rem; font-family: monospace; display: flex; align-items: center; gap: 0.35rem; }
.url-preview .path-part { color: var(--accent); font-weight: 600; }
.frontend-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.1rem; }
.frontend-opt { border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; cursor: pointer; transition: all 0.15s; }
.frontend-opt:hover { border-color: var(--border2); }
.frontend-opt.selected { border-color: var(--accent); background: #7c5af50e; }
.frontend-opt-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.2rem; }
.frontend-opt-desc { font-size: 0.74rem; color: var(--text-muted); line-height: 1.55; }

/* App view */
.app-view { flex: 1; display: grid; grid-template-columns: 1fr 272px; height: calc(100vh - 54px); overflow: hidden; }
.chat-panel { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--border); }
.chat-header { padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--surface); flex-shrink: 0; gap: 1rem; }
.chat-header-left h2 { font-size: 0.92rem; font-weight: 700; }
.chat-header-left .chat-sub { font-size: 0.72rem; color: var(--text-muted); font-family: monospace; margin-top: 0.08rem; }
.chat-header-right { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.open-app-link { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; font-weight: 600; color: var(--accent); background: #7c5af514; border: 1px solid #7c5af328; border-radius: 6px; padding: 0.28rem 0.65rem; text-decoration: none; transition: all 0.15s; }
.open-app-link:hover { background: #7c5af522; text-decoration: none; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.chat-hint { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-muted); gap: 0.6rem; }
.chat-hint-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.chat-hint h3 { font-size: 0.9rem; color: var(--text); font-weight: 600; }
.chat-hint p { font-size: 0.8rem; max-width: 240px; line-height: 1.6; }
.message { display: flex; flex-direction: column; gap: 0.22rem; max-width: 84%; }
.message.user { align-self: flex-end; align-items: flex-end; }
.message.agent { align-self: flex-start; align-items: flex-start; }
.message-bubble { padding: 0.68rem 0.95rem; border-radius: var(--radius); font-size: 0.868rem; line-height: 1.62; white-space: pre-wrap; word-break: break-word; }
.message.user .message-bubble { background: var(--gradient); color: #fff; border-radius: var(--radius) var(--radius) 4px var(--radius); }
.message.agent .message-bubble { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) var(--radius) 4px; }
.message-cost { font-size: 0.68rem; color: var(--text-dim); }
.message.streaming .message-bubble::after { content: '▋'; animation: blink 0.7s infinite; margin-left: 2px; color: var(--accent); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
.chat-input-area { padding: 0.85rem 1rem; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.chat-input-row { display: flex; gap: 0.55rem; align-items: flex-end; }
.chat-input-row textarea { flex: 1; resize: none; min-height: 40px; max-height: 150px; overflow-y: auto; background: var(--surface2); border-color: var(--border2); border-radius: var(--radius); padding: 0.58rem 0.8rem; font-size: 0.868rem; line-height: 1.5; }
.quota-row { margin-top: 0.55rem; display: flex; align-items: center; gap: 0.75rem; }
.quota-label { font-size: 0.68rem; color: var(--text-dim); white-space: nowrap; }
.quota-track { flex: 1; height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.quota-fill { height: 100%; background: var(--gradient); border-radius: 2px; transition: width 0.4s; }

/* Files */
.files-panel { display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }
.files-header { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.files-header h3 { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.files-list { flex: 1; overflow-y: auto; padding: 0.4rem; }
.files-empty { color: var(--text-dim); padding: 1.5rem 0.65rem; font-size: 0.78rem; text-align: center; }
.file-item { display: flex; align-items: center; padding: 0.38rem 0.5rem; border-radius: 7px; font-size: 0.78rem; transition: background 0.1s; gap: 0.4rem; }
.file-item:hover { background: var(--surface2); }
.file-item-icon { font-size: 1rem; flex-shrink: 0; line-height: 1; }
.file-item-name { color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { color: var(--text-dim); font-size: 0.68rem; flex-shrink: 0; }
.file-item-actions { display: none; align-items: center; gap: 0.1rem; flex-shrink: 0; }
.file-item:hover .file-item-actions { display: flex; }
.file-action-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 0.78rem; padding: 0.15rem 0.35rem; border-radius: 4px; line-height: 1; transition: color 0.1s, background 0.1s; }
.file-action-btn:hover { color: var(--text); background: var(--border); }
.file-action-del:hover { color: var(--danger) !important; background: #fef2f2 !important; }
.upload-area { padding: 0.65rem; border-top: 1px solid var(--border); flex-shrink: 0; }
.upload-btn { width: 100%; justify-content: center; }
.rename-modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.rename-modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; width: 320px; box-shadow: 0 8px 32px rgba(0,0,0,0.18); }
.rename-modal-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.75rem; }
.rename-input { width: 100%; background: var(--surface2, #fafaf8); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-size: 0.85rem; padding: 0.5rem 0.75rem; font-family: inherit; outline: none; }
.rename-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.rename-error { color: var(--danger); font-size: 0.72rem; margin-top: 0.35rem; min-height: 1em; }
.rename-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.85rem; }

/* Mobile files backdrop */
.files-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 199; }

/* Files toggle button — hidden on desktop */
.files-toggle-btn { display: none; }

/* Mobile: app view */
@media (max-width: 767px) {
  .app-view {
    grid-template-columns: 1fr;
    height: calc(100vh - 54px);
    height: calc(100dvh - 54px);
  }

  .chat-panel { border-right: none; }

  /* Files panel slides up from bottom */
  .files-panel {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 55vh;
    z-index: 200;
    border-top: 2px solid var(--border2);
    border-right: none;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.55);
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    /* override grid: always flex */
    display: flex;
    flex-direction: column;
  }
  .files-panel.mobile-open { transform: translateY(0); }

  /* Show toggle button */
  .files-toggle-btn { display: inline-flex; }

  /* Quota: hide label text, keep bar */
  .quota-label { display: none; }

  /* Nav: hide username pill to save space */
  .nav-user { display: none; }

  /* Chat input: full-width send button on very small screens */
  @media (max-width: 400px) {
    .chat-input-row { flex-direction: column; align-items: stretch; }
    .chat-input-row .btn { width: 100%; justify-content: center; }
  }
}
