/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: #1a1a1a; background: #f5f5f5; }
body { min-height: 100vh; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }

/* ── Layout ── */
#app { min-height: 100vh; }

/* Login screen */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 2rem; max-width: 420px; width: 100%; }
.login-box h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.login-box .sep { display: flex; align-items: center; gap: .75rem; margin: 1.5rem 0; color: #888; font-size: .85rem; }
.login-box .sep::before, .login-box .sep::after { content: ''; flex: 1; border-top: 1px solid #ddd; }
.login-box label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; color: #555; }
.login-box input { width: 100%; padding: .5rem .75rem; border: 1px solid #ccc; border-radius: 4px; margin-bottom: .75rem; }
.login-box input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }

/* Main layout */
.shell { display: grid; grid-template-rows: auto 1fr; grid-template-columns: 260px 1fr; min-height: 100vh; }
.header { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: .5rem 1rem; background: #1e293b; color: #f1f5f9; }
.header h1 { font-size: 1.1rem; font-weight: 600; }
.header .user-info { display: flex; align-items: center; gap: .75rem; font-size: .85rem; }

.sidebar { background: #fff; border-right: 1px solid #e2e8f0; padding: .75rem 0; overflow-y: auto; }
.content { padding: 1.5rem; overflow-y: auto; background: #f8fafc; }

/* Sidebar tree */
.tree-item { display: flex; align-items: center; padding: .35rem .75rem .35rem calc(.75rem + var(--depth, 0) * 1.25rem); cursor: pointer; font-size: .9rem; border-left: 3px solid transparent; }
.tree-item:hover { background: #f1f5f9; }
.tree-item.active { background: #eff6ff; border-left-color: #2563eb; font-weight: 600; }
.tree-item .icon { margin-right: .5rem; font-size: .8rem; }

/* Breadcrumbs */
.breadcrumbs { display: flex; align-items: center; gap: .25rem; font-size: .85rem; color: #64748b; margin-bottom: 1rem; flex-wrap: wrap; }
.breadcrumbs span { cursor: pointer; }
.breadcrumbs span:hover { color: #2563eb; }
.breadcrumbs .sep { cursor: default; }
.breadcrumbs .sep:hover { color: #64748b; }

/* Toolbar */
.toolbar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* Cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .75rem; }
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 1rem; cursor: pointer; transition: border-color .15s; }
.card:hover { border-color: #93c5fd; }
.card .card-title { font-weight: 600; margin-bottom: .25rem; word-break: break-word; }
.card .card-meta { font-size: .8rem; color: #94a3b8; }
.card.folder-card { border-left: 3px solid #f59e0b; }
.card.prompt-card { border-left: 3px solid #2563eb; }
.card .badge { display: inline-block; font-size: .7rem; background: #e2e8f0; color: #475569; padding: .1rem .4rem; border-radius: 3px; margin-left: .5rem; }

/* Prompt detail */
.prompt-detail { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 1.5rem; }
.prompt-detail h2 { margin-bottom: 1rem; }
.prompt-detail .prompt-content { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 4px; padding: 1rem; white-space: pre-wrap; word-break: break-word; font-family: "SFMono-Regular", Consolas, monospace; font-size: .9rem; line-height: 1.6; margin-bottom: 1rem; max-height: 60vh; overflow-y: auto; }
.prompt-detail .bash-section { margin-top: 1rem; }
.prompt-detail .bash-section h3 { font-size: .9rem; color: #64748b; margin-bottom: .5rem; }
.prompt-detail .bash-content { background: #1e293b; color: #e2e8f0; border-radius: 4px; padding: 1rem; font-family: monospace; font-size: .85rem; white-space: pre-wrap; word-break: break-word; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; color: #475569; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: .5rem .75rem; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; }
.form-group textarea { min-height: 200px; font-family: monospace; resize: vertical; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .9rem; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; cursor: pointer; font-size: .85rem; font-weight: 500; color: #1e293b; transition: background .15s; }
.btn:hover { background: #f1f5f9; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-copy { background: #f1f5f9; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 8px; padding: 1.5rem; max-width: 560px; width: 95%; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.15); }
.modal h2 { margin-bottom: 1rem; font-size: 1.2rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

/* Share section */
.shares-section { margin-top: 2rem; border-top: 1px solid #e2e8f0; padding-top: 1rem; }
.shares-section h3 { font-size: 1rem; margin-bottom: .75rem; }
.share-item { display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; margin-bottom: .5rem; font-size: .85rem; }
.share-item .share-code { font-family: monospace; font-weight: 600; }

/* Admin */
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; overflow: hidden; }
.admin-table th, .admin-table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: .85rem; }
.admin-table th { background: #f8fafc; font-weight: 600; color: #475569; }

/* Toast */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: #1e293b; color: #f1f5f9; padding: .6rem 1.2rem; border-radius: 6px; font-size: .85rem; z-index: 200; animation: fadeInUp .3s; }
.toast.error { background: #dc2626; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Utility */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.text-muted { color: #94a3b8; font-size: .85rem; }
.hidden { display: none !important; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* Responsive */
@media (max-width: 768px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .sidebar.open { display: block; position: fixed; inset: 0; top: 48px; z-index: 50; width: 280px; box-shadow: 2px 0 12px rgba(0,0,0,.15); }
    .header .menu-toggle { display: inline-flex; }
}
@media (min-width: 769px) {
    .header .menu-toggle { display: none; }
}
