: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: 1320px; margin: 0 auto; padding: 20px 18px 32px; min-height: 100vh; display:flex; flex-direction:column; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap: 12px; margin-bottom: 14px; position: sticky; top: 0; z-index: 10; padding-bottom: 10px; background: linear-gradient(to bottom, rgba(15,23,42,0.98), rgba(15,23,42,0.92)); backdrop-filter: blur(18px); border-radius: 0 0 20px 20px; border-bottom: 1px solid rgba(30,64,175,0.35); }
.brand { font-weight: 800; letter-spacing: 0.2px; font-size: 15px; padding: 6px 10px; border-radius: 999px; background: rgba(15,23,42,0.92); border: 1px solid rgba(148,163,184,0.8); color: #e5e7eb; }
.topbar-actions { display:flex; gap: 10px; align-items:center; }
.grid { display:grid; grid-template-columns: minmax(0, 1.6fr) 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.96), 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(22px); }
.title { font-size: 16px; font-weight: 800; color: #e5e7eb; }
.sub { margin-top: 6px; opacity: 0.8; 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; }

.row { display:flex; gap: 10px; margin-top: 12px; align-items:center; }
.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.95); background: rgba(15,23,42,0.9); color: #e5e7eb; padding: 0 10px; box-sizing: border-box; }
.select { height: 40px; border-radius: 999px; border: 1px solid rgba(51,65,85,0.95); background: rgba(15,23,42,0.9); color: #e5e7eb; padding: 0 12px; box-sizing: border-box; }
.textarea { width: 100%; min-height: 70vh; margin-top: 12px; border-radius: 14px; border: 1px solid rgba(51,65,85,0.95); 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: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(148,163,184,0.85); background: #e5e7eb; color: #020617; cursor: pointer; font-weight: 700; transition: transform 0.1s ease-out, box-shadow 0.12s ease-out, background 0.12s ease-out; }
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); box-shadow: 0 0 0 rgba(0,0,0,0); }
.btn-ghost { background: transparent; color: #e5e7eb; border-color: rgba(51,65,85,0.95); }
.btn-danger { background: #ff3b30; color: #fff; border-color: rgba(255,255,255,0.2); }
.btn-danger-ghost { background: transparent; color: #ff8a83; border-color: rgba(255,138,131,0.35); color: #ff8a83; }
.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); }

.list { margin-top: 12px; display:flex; flex-direction: column; gap: 10px; }
.item { display:flex; align-items:flex-start; justify-content:space-between; gap: 12px; padding: 10px; border: 1px solid rgba(51,65,85,0.85); border-radius: 10px; text-decoration:none; color: inherit; background: rgba(15,23,42,0.9); cursor:pointer; }
.item:hover { background: rgba(30,64,175,0.28); border-color: rgba(59,130,246,0.7); }
.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; }

.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); }
}
