body {
    font-family: 'Inter', sans-serif;
    font-size: 17px;
    line-height: 1.7;
}

.prose p {
    line-height: 1.8;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.editable-field {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    min-height: 32px;
    display: inline-block;
    width: 100%;
    background-color: #f8fafc;
}
.editable-field:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.editable-input {
    width: 100%;
    padding: 5px 9px;
    border-radius: 6px;
    border: 1px solid #6366f1;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    font-family: inherit;
    font-size: inherit;
    background: white;
    color: #1e293b;
}

.drawer-left-open { transform: translateX(0); }
.drawer-left-closed { transform: translateX(-100%); }
.drawer-right-open { transform: translateX(0); }
.drawer-right-closed { transform: translateX(100%); }

.tree-node-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    border-radius: 0.55rem;
    padding: 0.4rem 0.5rem;
    color: #334155;
    cursor: pointer;
    user-select: none;
}

.tree-node-row:hover {
    background: #f1f5f9;
}

.tree-node-row.active {
    background: #e0e7ff;
    color: #3730a3;
    font-weight: 600;
}

.tree-children {
    border-left: 1px dashed #e2e8f0;
    margin-left: 0.95rem;
    padding-left: 0.55rem;
}

.context-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border-radius: 0.5rem;
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
    color: #334155;
}

.context-item:hover {
    background: #f1f5f9;
}

.context-danger {
    color: #b91c1c;
}

.context-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 0.35rem 0;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
}

.icon-card {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    background: #fff;
    color: #334155;
    transition: all 0.15s ease;
    cursor: pointer;
}

.icon-card:hover {
    border-color: #6366f1;
    background: #eef2ff;
    color: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

/* Mobile touch improvements */
button, a, [role="button"] {
    touch-action: manipulation;
}
button > i, button > span > i, .btn-icon {
    pointer-events: none;
}

.icon-card i {
    font-size: 1.5rem;
    color: inherit;
}

.icon-card span {
    font-size: 0.65rem;
    line-height: 1.2;
    text-align: center;
    word-break: break-word;
    color: #64748b;
}

.icon-card:hover span {
    color: #4338ca;
}

.prose ul {
    list-style: none;
    list-style-type: none;
    padding-left: 0;
}
.prose ul li {
    position: relative;
    padding-left: 1.75rem;
    margin-bottom: 0.75rem;
    line-height: 1.75;
    list-style-type: none;
}
.prose ul li::marker {
    display: none;
    content: "";
}
.yaml-field .delete-field-btn {
    opacity: 0;
    transition: opacity 0.15s ease;
}
.yaml-field:hover .delete-field-btn {
    opacity: 1;
}

.prose ul li::before {
    content: "\2756";
    position: absolute;
    left: 0;
    top: 0;
    color: #8b5cf6;
    font-size: 1.1em;
    line-height: 1.6;
}

.agent-card {
    transition: all 0.2s ease;
}
.agent-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}
.agent-card .editable-field {
    transition: all 0.15s ease;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    min-height: 32px;
}
.agent-card .editable-field:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Attach panel */
.attach-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.4rem 0.6rem;
    border-radius: 0.4rem;
    font-size: 0.85rem;
    color: #334155;
    cursor: pointer;
    transition: all 0.1s ease;
    border: none;
    background: none;
    text-align: left;
}
.attach-item:hover {
    background: #eef2ff;
    color: #4338ca;
}
.attach-item-attached {
    opacity: 0.55;
}
.attach-item-attached:hover {
    opacity: 0.8;
}
.attach-item i {
    color: #6366f1;
}
.attach-item .file-path {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-left: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* Tree view */
.attach-tree-folder-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    padding: 0.35rem 0.5rem;
    border-radius: 0.4rem;
    font-size: 0.85rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.1s ease;
    border: none;
    background: none;
    text-align: left;
}
.attach-tree-folder-btn:hover {
    background: #f1f5f9;
    color: #334155;
}
.attach-tree-children {
    margin-left: 0;
}

/* Attachment bubbles in chat */
.attach-bubble {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    border-radius: 0.6rem;
    font-size: 0.8rem;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #4338ca;
    cursor: default;
    margin: 0.15rem;
}
.attach-bubble .remove-attach {
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0 0.15rem;
}
.attach-bubble .remove-attach:hover {
    color: #dc2626;
}

/* Todo/Plan styles */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
}

/* Streaming message cursor */
[data-streaming="true"] .prose::after {
    content: '▊';
    display: inline-block;
    animation: blink 0.8s step-end infinite;
    color: #6366f1;
    margin-left: 0.1em;
    font-size: 0.9em;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Confirmation panel */
#confirm-panel {
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Streaming indicator pulse */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.animate-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

/* xterm.js terminal container */
#terminal-container {
    background: #0f172a;
}
#terminal-container .xterm {
    height: 100%;
    padding: 4px;
}
#terminal-container .xterm-viewport {
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}
#terminal-container .xterm-viewport::-webkit-scrollbar {
    width: 6px;
}
#terminal-container .xterm-viewport::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}
#terminal-container .xterm-viewport::-webkit-scrollbar-track {
    background: transparent;
}

/* Gallery cards */
.gallery-card {
    background: white;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    opacity: 0;
    animation: galleryFadeIn 0.3s ease forwards;
}
.gallery-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.1);
}
@keyframes galleryFadeIn {
    to { opacity: 1; transform: translateY(0); }
}

/* Gallery badges */
.badge {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}
.badge-gen {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.badge-pending {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; display: inline-block; }
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Render preview styles */
.render-iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.render-image-container {
    min-height: 200px;
    background: #f8fafc;
}

.render-image-container img {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* View mode toggle buttons */
button .ph-eye,
button .ph-code {
    font-size: 0.85rem;
}

/* highlight.js overrides for source view */
.source-code pre code.hljs {
    background: transparent;
    padding: 0;
    font-size: 0.8rem;
    line-height: 1.7;
}
.source-code .hljs {
    background: transparent;
}

/* Chat code blocks - dark themed like Gemini/GitHub */
.chat-code-block {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
}
.chat-code-block .code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
}
.chat-code-block .code-header .code-lang {
    font-size: 11px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.chat-code-block .code-header .code-path {
    font-size: 11px;
    color: #58a6ff;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}
.chat-code-block .code-header .save-code-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid #30363d;
    background: #21262d;
    color: #c9d1d9;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.chat-code-block .code-header .save-code-btn:hover {
    background: #30363d;
    color: #f0f6fc;
    border-color: #8b949e;
}
.chat-code-block .code-header .save-code-btn.saving {
    opacity: 0.7;
    pointer-events: none;
}
.chat-code-block .code-header .save-code-btn .spinner {
    display: none;
    animation: spin 0.8s linear infinite;
}
.chat-code-block .code-header .save-code-btn.saving .spinner {
    display: inline-block;
}
.chat-code-block .code-header .save-code-btn.saving .btn-text {
    display: none;
}
.chat-code-block .code-header .save-as-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid #30363d;
    background: #21262d;
    color: #8b949e;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.chat-code-block .code-header .save-as-btn:hover {
    background: #30363d;
    color: #f0f6fc;
    border-color: #8b949e;
}
.chat-code-block pre {
    margin: 0 !important;
    padding: 16px !important;
    background: transparent !important;
    border: none !important;
    overflow-x: auto;
}
.chat-code-block pre code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #e6edf3;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}
.chat-code-block pre code .hljs { background: transparent; }

/* Ensure chat bubble text wraps properly - no overflow */
#chat-history .prose,
#chat-history .chat-bubble-text,
#chat-history .message-content {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}
#chat-history .w-full.max-w-full {
    min-width: 0;
}

/* Short Stories — daftar cerita di sidebar kanan (drag & drop reorder) */
.ss-story-item.ss-dragging {
    opacity: 0.4;
}
.ss-story-item.ss-drag-over {
    box-shadow: inset 0 3px 0 -1px #6366f1;
    background: #eef2ff;
}