/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #e0e7ff;
  --bg:            #f1f5f9;
  --card:          #ffffff;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --danger:        #ef4444;
  --success-bg:    #dcfce7;
  --success-text:  #166534;
  --error-bg:      #fee2e2;
  --error-text:    #991b1b;
  --radius:        10px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
em { font-style: normal; color: var(--primary); }

code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: .875em;
  background: #f1f5f9;
  padding: .1em .35em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Layout ────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.main { flex: 1; padding-bottom: 4rem; }

/* ── Navbar ────────────────────────────────────────────────── */
.nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}
.nav-brand:hover { text-decoration: none; opacity: .85; }

.brand-icon { font-size: 1.3rem; color: var(--primary); }

.nav-links {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.nav-email {
  font-size: .85rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:active { opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(99,102,241,.25);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm  { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg  { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-full { width: 100%; }

.btn-copy {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: .15rem .35rem;
  border-radius: 4px;
  opacity: .55;
  transition: opacity .15s;
  line-height: 1;
  flex-shrink: 0;
}
.btn-copy:hover { opacity: 1; }

/* ── Flash messages ────────────────────────────────────────── */
.flash {
  padding: .75rem 0;
  font-size: .9rem;
  font-weight: 500;
}
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error   { background: var(--error-bg);   color: var(--error-text);   }

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 1.25rem;
}
.alert-error   { background: var(--error-bg);   color: var(--error-text);   }
.alert-success { background: var(--success-bg); color: var(--success-text); }

/* ── Forms ─────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 1.1rem; }

.field { display: flex; flex-direction: column; gap: .35rem; }

.field label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
}

.field-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: .8rem;
}

.field input[type="email"],
.field input[type="password"],
.field input[type="text"],
input[type="text"][id="site-name"] {
  padding: .6rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

.field input:focus,
input[type="text"][id="site-name"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ── Auth pages ────────────────────────────────────────────── */
.auth-wrap {
  display: flex;
  justify-content: center;
  padding: 3.5rem 1rem;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.auth-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: .35rem;
  letter-spacing: -.02em;
}

.auth-sub {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  font-size: .95rem;
}

.auth-alt {
  margin-top: 1.25rem;
  text-align: center;
  font-size: .875rem;
  color: var(--text-muted);
}

.btn-google {
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  font-weight: 500;
}
.btn-google:hover { background: #f8f9ff; border-color: #c5cae9; }
.btn-google svg   { flex-shrink: 0; }

.auth-divider {
  position: relative;
  text-align: center;
  margin: 1.25rem 0;
  font-size: .8rem;
  color: var(--text-muted);
}
.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.auth-divider span {
  position: relative;
  background: var(--card);
  padding: 0 .75rem;
}

/* ── Hero ──────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 55%, #3730a3 100%);
  color: white;
  padding: 5.5rem 0 4.5rem;
  text-align: center;
}

.hero-inner { max-width: 680px; margin: 0 auto; }

.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  padding: .3rem 1rem;
  border-radius: 100px;
  font-size: .8rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  letter-spacing: .02em;
}

.hero-title {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  letter-spacing: -.03em;
}
.hero-title em { color: #a5b4fc; }

.hero-sub {
  font-size: 1.1rem;
  color: rgba(255,255,255,.75);
  margin-bottom: 2.5rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.hero-actions .btn-ghost {
  border-color: rgba(255,255,255,.3);
  color: rgba(255,255,255,.9);
}
.hero-actions .btn-ghost:hover { background: rgba(255,255,255,.1); }

/* ── Steps section ─────────────────────────────────────────── */
.steps-section {
  padding: 4.5rem 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.section-title {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 2.5rem;
  letter-spacing: -.02em;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
}

.step { text-align: center; }

.step-num {
  width: 48px;
  height: 48px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 auto 1rem;
}

.step h3 { font-size: 1rem; font-weight: 600; margin-bottom: .4rem; }
.step p   { color: var(--text-muted); font-size: .9rem; }

/* ── Features section ──────────────────────────────────────── */
.features-section { padding: 4.5rem 0; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.feature-icon { font-size: 2rem; margin-bottom: .75rem; }
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: .4rem; }
.feature-card p  { color: var(--text-muted); font-size: .875rem; }

/* ── Dashboard ─────────────────────────────────────────────── */
.dashboard { padding-top: 2.5rem; }

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.dashboard-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.dashboard-sub { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }

/* ── Upload panel ──────────────────────────────────────────── */
.upload-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.panel-title { font-size: 1.1rem; font-weight: 600; margin-bottom: .3rem; }
.panel-sub   { color: var(--text-muted); font-size: .875rem; margin-bottom: 1.5rem; }

/* ── Drop zone ─────────────────────────────────────────────── */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-content,
.drop-selected {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
  pointer-events: none;
  gap: .25rem;
}

.drop-icon  { font-size: 2.5rem; margin-bottom: .25rem; }
.drop-title { font-weight: 600; font-size: 1rem; }
.drop-hint  { color: var(--text-muted); font-size: .85rem; }
.drop-filesize { color: var(--text-muted); font-size: .8rem; }

.upload-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ── Project grid ──────────────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.project-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .85rem;
  transition: box-shadow .2s;
}
.project-card:hover { box-shadow: var(--shadow-md); }

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}

.project-name { font-size: 1rem; font-weight: 600; }
.project-date { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }

.project-url-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .4rem .65rem;
  min-width: 0;
}

.project-url {
  font-size: .8rem;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  color: var(--primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.project-meta {
  display: flex;
  gap: 1rem;
  font-size: .8rem;
  color: var(--text-muted);
}

.project-actions { display: flex; gap: .5rem; margin-top: auto; }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-muted);
}

.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h2 { font-size: 1.3rem; font-weight: 600; color: var(--text); margin-bottom: .5rem; }
.empty-state p  { margin-bottom: 1.5rem; }

/* ── Footer ────────────────────────────────────────────────── */
.footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: .5rem;
}

.footer-legal {
  display: flex;
  gap: 1.2rem;
}
.footer-legal a {
  color: var(--text-muted);
  text-decoration: none;
}
.footer-legal a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ── Dashboard CTA group ───────────────────────────────────── */
.dash-cta { display: flex; gap: .6rem; flex-wrap: wrap; }

/* ── Editor page ───────────────────────────────────────────── */
.editor-wrap {
  max-width: 860px;
  padding-top: 2.5rem;
  padding-bottom: 4rem;
}

.editor-header  { margin-bottom: 2rem; }
.editor-title   { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .35rem; }
.editor-sub     { color: var(--text-muted); font-size: .95rem; }

.editor-name-field {
  max-width: 400px;
  margin-bottom: 2rem;
}

/* ── Page entries ──────────────────────────────────────────── */
.pages-list { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 1rem; }

.page-entry {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.page-entry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

/* URL-bar style name input */
.page-name-row {
  display: flex;
  align-items: center;
  gap: 0;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: .85rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
}

.page-name-static { white-space: nowrap; }

.page-name-input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  color: var(--primary);
  font-weight: 600;
  padding: 0 1px;
  min-width: 60px;
  width: 10ch;
  outline: none;
}
.page-name-input:focus { text-decoration: underline; text-underline-offset: 2px; }

.page-home-badge {
  margin-left: .6rem;
  font-size: .7rem;
  font-family: system-ui, sans-serif;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  padding: .1rem .45rem;
  border-radius: 100px;
  white-space: nowrap;
}

/* Code textarea */
.code-textarea {
  display: block;
  width: 100%;
  min-height: 320px;
  padding: 1rem 1.1rem;
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
  font-size: .875rem;
  line-height: 1.65;
  color: #e2e8f0;
  background: #0f172a;
  border: none;
  resize: vertical;
  tab-size: 2;
  outline: none;
}
.code-textarea::placeholder { color: #475569; }

.btn-add-page { margin-bottom: 1rem; }

/* ── Editor section labels ─────────────────────────────────── */
.editor-section-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.section-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Entry top row ─────────────────────────────────────────── */
.entry-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

/* ── File type badge ───────────────────────────────────────── */
.file-type-badge {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .05em;
  padding: .15rem .45rem;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
}
.file-type-css  { background: #dbeafe; color: #1d4ed8; }
.file-type-js   { background: #fef9c3; color: #854d0e; }
.file-type-json { background: #dcfce7; color: #166534; }
.file-type-svg  { background: #fce7f3; color: #9d174d; }
.file-type-xml  { background: #f3e8ff; color: #6b21a8; }

/* ── Entry URL bar ────────────────────────────────────────── */
.entry-url {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .75rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.entry-url-text {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: .75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
a.entry-url-text:hover { color: var(--primary); text-decoration: underline; }

/* ── File name input (with extension) ─────────────────────── */
.file-name-input {
  border: none;
  background: transparent;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: .85rem;
  color: var(--primary);
  font-weight: 600;
  padding: 0 1px;
  min-width: 80px;
  width: 16ch;
  outline: none;
}
.file-name-input:focus { text-decoration: underline; text-underline-offset: 2px; }

.editor-footer-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav-email { display: none; }
  .hero { padding: 3.5rem 0 3rem; }
  .hero-title { font-size: 2rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .dashboard-header { flex-direction: column; align-items: stretch; }
  .project-grid { grid-template-columns: 1fr; }
  .upload-actions { flex-direction: column; }
  .upload-actions .btn { width: 100%; justify-content: center; }
  .dash-cta { flex-direction: column; }
  .dash-cta .btn { width: 100%; justify-content: center; }
  .editor-footer-actions { flex-direction: column; }
  .editor-footer-actions .btn { width: 100%; justify-content: center; }
}
