:root { color-scheme: dark; }
body { margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial; background: radial-gradient(circle at top, #020617 0, #020617 55%, #020617 100%); color: #e5e7eb; min-height: 100vh; }
.app { max-width: 1280px; margin: 0 auto; padding: 18px 18px 28px; min-height: 100vh; display:flex; flex-direction:column; gap: 16px; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap: 16px; padding: 10px 14px; border-radius: 16px; background: rgba(15,23,42,0.96); border: 1px solid rgba(51,65,85,0.9); box-shadow: 0 18px 55px rgba(15,23,42,0.95); }
.brand { font-weight: 800; letter-spacing: 0.08em; font-size: 13px; padding: 6px 10px; border-radius: 999px; background: #020617; border: 1px solid rgba(148,163,184,0.9); color: #e5e7eb; text-transform: uppercase; }
.topbar-actions { display:flex; gap: 10px; align-items:center; flex-wrap: wrap; justify-content:flex-end; }
.grid { display:grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr); gap: 16px; align-items:flex-start; flex:1; }
@media (max-width: 980px) { .grid { grid-template-columns: 1fr; } }

.card { background: linear-gradient(135deg, rgba(15,23,42,0.98), rgba(15,23,42,0.9)); border: 1px solid rgba(51,65,85,0.95); border-radius: 18px; padding: 18px 18px 20px; box-shadow: 0 24px 70px rgba(15,23,42,0.9); backdrop-filter: blur(20px); }
.title { font-size: 16px; font-weight: 800; color: #e5e7eb; }
.sub { margin-top: 6px; opacity: 0.85; font-size: 12px; word-break: break-word; color: #9ca3af; }
.hint { margin-top: 10px; font-size: 12px; opacity: 0.9; white-space: pre-wrap; word-break: break-word; }
.hint.error { color: #ff8a83; opacity: 1; }

.loading { display:flex; align-items:center; gap: 10px; margin-top: 12px; }
.loading-inline { display:inline-flex; align-items:center; gap: 8px; vertical-align: middle; }
.spinner { width: 14px; height: 14px; border-radius: 999px; border: 2px solid rgba(51,65,85,0.95); border-top-color: rgba(59,130,246,0.9); animation: boe-spin 0.8s linear infinite; }
@keyframes boe-spin { to { transform: rotate(360deg); } }

.row { display:flex; gap: 10px; margin-top: 12px; align-items:center; justify-content:flex-start; flex-wrap:wrap; }
.field { display:flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.label { font-size: 12px; opacity: 0.8; color: #9ca3af; }
.input { width: 100%; height: 40px; border-radius: 10px; border: 1px solid rgba(51,65,85,0.9); background: rgba(15,23,42,0.9); color: #e5e7eb; padding: 0 10px; box-sizing: border-box; }
.select { height: 36px; border-radius: 999px; border: 1px solid rgba(51,65,85,0.9); background: rgba(15,23,42,0.9); color: #e5e7eb; padding: 0 12px; box-sizing: border-box; font-size: 13px; }
.textarea { width: 100%; min-height: 68vh; margin-top: 12px; border-radius: 14px; border: 1px solid rgba(51,65,85,0.9); background: rgba(15,23,42,0.9); color: #e5e7eb; padding: 12px 14px; box-sizing: border-box; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 13px; line-height: 1.6; }
.preview-shell { margin-top: 10px; border-radius: 14px; border: 1px solid rgba(51,65,85,0.9); background: rgba(15,23,42,0.75); padding: 10px 12px; max-height: 60vh; overflow:auto; box-sizing:border-box; }
.preview { font-size: 13px; line-height: 1.75; color: #e5e7eb; }
.preview h1, .preview h2, .preview h3, .preview h4, .preview h5, .preview h6 { margin: 14px 0 8px; line-height: 1.25; }
.preview p { margin: 10px 0; }
.preview a { color: #93c5fd; }
.preview blockquote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid rgba(59,130,246,0.7); background: rgba(30,64,175,0.18); border-radius: 10px; }
.preview ul { margin: 10px 0; padding-left: 18px; }
.preview li { margin: 6px 0; }
.preview img { max-width: 100%; border-radius: 10px; border: 1px solid rgba(51,65,85,0.75); }
.md-pre { margin: 10px 0; padding: 12px; border-radius: 12px; border: 1px solid rgba(51,65,85,0.8); background: rgba(2,6,23,0.75); overflow:auto; }
.md-code { padding: 2px 6px; border-radius: 8px; border: 1px solid rgba(51,65,85,0.8); background: rgba(2,6,23,0.65); }

.toast { position: fixed; top: 16px; right: 16px; max-width: 260px; padding: 10px 14px; border-radius: 999px; font-size: 13px; background: rgba(15,23,42,0.96); border: 1px solid rgba(148,163,184,0.9); color: #e5e7eb; box-shadow: 0 18px 45px rgba(15,23,42,0.85); opacity: 0; transform: translateY(-6px); transition: opacity 0.18s ease-out, transform 0.18s ease-out; z-index: 40; }
.toast-show { opacity: 1; transform: translateY(0); }
.toast-success { border-color: rgba(34,197,94,0.8); color: #bbf7d0; }
.toast-error { border-color: rgba(248,113,113,0.9); color: #fecaca; }

.btn { height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(148,163,184,0.7); background: #e5e7eb; color: #020617; cursor: pointer; font-weight: 600; font-size: 13px; display:inline-flex; align-items:center; gap: 6px; transition: transform 0.1s ease-out, box-shadow 0.12s ease-out, background 0.12s ease-out, border-color 0.12s ease-out; box-shadow: 0 10px 25px rgba(15,23,42,0.55); }
.btn:hover { filter: brightness(0.97); border-color: rgba(129,140,248,0.9); }
.btn:active { transform: translateY(1px); box-shadow: 0 0 0 rgba(0,0,0,0); }
.btn-ghost { background: rgba(15,23,42,0.9); color: #e5e7eb; border-color: rgba(51,65,85,0.95); box-shadow: 0 8px 20px rgba(15,23,42,0.65); }
.btn-ghost:hover { background: rgba(30,64,175,0.3); border-color: rgba(59,130,246,0.85); }
.btn-danger { background: #ef4444; color: #fef2f2; border-color: rgba(254,202,202,0.6); box-shadow: 0 10px 26px rgba(127,29,29,0.85); }
.btn-danger-ghost { background: transparent; color: #fecaca; border-color: rgba(248,113,113,0.55); }
.btn-full { width: 100%; justify-content: center; }

.snippet-group { display:flex; flex-wrap:wrap; gap: 8px; margin-top: 10px; }
.btn-chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(51,65,85,0.9); background: rgba(15,23,42,0.9); color: #e5e7eb; font-size: 12px; cursor: pointer; }
.btn-chip:hover { background: rgba(30,64,175,0.28); border-color: rgba(59,130,246,0.7); }

.site-list { margin-top: 10px; display:flex; flex-wrap:wrap; gap: 6px; }
.site-pill { padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(51,65,85,0.9); background: rgba(15,23,42,0.9); color: #e5e7eb; font-size: 11px; cursor: pointer; }
.site-pill:hover { border-color: rgba(59,130,246,0.8); background: rgba(30,64,175,0.32); }
.site-pill-active { border-color: rgba(59,130,246,0.9); background: rgba(30,64,175,0.4); color: #bfdbfe; }

.list { margin-top: 12px; display:flex; flex-direction: column; gap: 10px; }
.item { display:flex; align-items:flex-start; justify-content:space-between; gap: 14px; padding: 10px 12px; border: 1px solid rgba(51,65,85,0.85); border-radius: 12px; text-decoration:none; color: inherit; background: rgba(15,23,42,0.9); cursor:pointer; transition: background 0.12s ease-out, border-color 0.12s ease-out, transform 0.08s ease-out; }
.item:hover { background: rgba(30,64,175,0.32); border-color: rgba(59,130,246,0.8); transform: translateY(-1px); }
.item-title { font-weight: 800; }
.item-sub { opacity: 0.8; font-size: 12px; margin-top: 4px; color: #9ca3af; }
.item-meta { opacity: 0.7; font-size: 11px; text-align: right; max-width: 48%; color: #6b7280; }

.item-skeleton { cursor: default; }
.item-skeleton:hover { background: rgba(15,23,42,0.9); border-color: rgba(51,65,85,0.85); transform: none; }
.skeleton-line, .skeleton-sub { border-radius: 999px; background: linear-gradient(90deg, rgba(51,65,85,0.35), rgba(148,163,184,0.16), rgba(51,65,85,0.35)); background-size: 200% 100%; animation: boe-shimmer 1.15s ease-in-out infinite; }
.skeleton-line { height: 14px; width: 62%; }
.skeleton-sub { height: 10px; width: 28%; margin-top: 8px; }
@keyframes boe-shimmer { 0% { background-position: 0% 0; } 100% { background-position: -200% 0; } }

.divider { height: 1px; background: rgba(51,65,85,0.9); margin: 16px 0; }
.danger { color: #ff8a83; }

.auth-shell { display:flex; align-items:center; justify-content:center; min-height: calc(100vh - 96px); padding: 10px 0; }
.auth-card { max-width: 420px; width: 100%; padding: 24px 22px 22px; border-radius: 22px; background: linear-gradient(145deg, rgba(15,23,42,0.96), rgba(15,23,42,0.9)); border: 1px solid rgba(59,130,246,0.5); box-shadow: 0 30px 90px rgba(15,23,42,0.95); backdrop-filter: blur(30px); }
.auth-brand { font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.85; margin-bottom: 8px; color: #9ca3af; }
.auth-title { font-size: 20px; font-weight: 800; margin-top: 4px; }
.auth-sub { margin-top: 6px; font-size: 13px; opacity: 0.9; color: #9ca3af; }
.auth-fields { margin-top: 18px; }
.auth-actions { margin-top: 16px; }
.auth-hint { margin-top: 10px; }

@media (max-width: 768px) {
  .app { padding: 16px 12px 24px; }
  .auth-card { padding: 22px 18px 20px; border-radius: 20px; }
  .grid { gap: 12px; }
  .editor-split { grid-template-columns: 1fr; }
  .preview-pane { max-height: none; }
}

@media (max-width: 600px) {
  .topbar { margin-bottom: 10px; }
  .row { flex-wrap: wrap; }
  .auth-shell { min-height: calc(100vh - 80px); }
}
