* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: #f5f5f5;
    color: #2d2d2d;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* Chat Interface Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
}

.chat-header {
    background: #ffffff;
    border-bottom: 2px solid #d0d0d0;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h1 {
    color: #2d2d2d;
    font-size: 20px;
    font-weight: 600;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #f5f5f5;
}

.message {
    display: flex;
    max-width: 80%;
    animation: fadeIn 0.3s ease-in;
}

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

.message.user {
    align-self: flex-end;
    justify-content: flex-end;
}

.message.assistant {
    align-self: flex-start;
    justify-content: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 0;
    word-wrap: break-word;
    line-height: 1.5;
    display: inline-block;
    max-width: 100%;
    border: 1px solid #d0d0d0;
}

.message.user .message-content {
    background: #e0e0e0;
    color: #2d2d2d;
    border: 1px solid #b0b0b0;
}

.message.assistant .message-content {
    background: #ffffff;
    color: #2d2d2d;
    border: 1px solid #d0d0d0;
}

.message.assistant .message-content:has(.diagram-container) {
    padding-bottom: 12px;
}

.diagram-container {
    margin-top: 12px;
    margin-bottom: 8px;
    text-align: center;
    line-height: 0;
    position: relative;
    width: 100%;
    display: block;
    overflow: visible;
    background-image: 
        linear-gradient(45deg, #e8e8e8 25%, transparent 25%),
        linear-gradient(-45deg, #e8e8e8 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e8e8e8 75%),
        linear-gradient(-45deg, transparent 75%, #e8e8e8 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    padding: 16px;
}

.diagram-container img {
    max-width: 100%;
    height: auto;
    border-radius: 0;
    cursor: zoom-in;
    display: block;
    margin: 0 auto;
    border: 1px solid #d0d0d0;
    background: #ffffff;
}

.diagram-container .svg-wrapper {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    line-height: 0;
    display: block;
    margin: 0 auto;
    padding: 0;
    position: relative;
    overflow: visible;
    background: #ffffff;
    border: 1px solid #d0d0d0;
}

.diagram-container .svg-wrapper svg {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
}

.diagram-container .svg-wrapper svg * {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.diagram-actions {
    margin-top: 8px;
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    line-height: normal;
    flex-wrap: wrap;
}

.library-info {
    font-size: 12px;
    color: #666666;
    padding: 4px 8px;
    background: #f0f0f0;
    border-radius: 0;
    border: 1px solid #d0d0d0;
}

.download-svg-btn {
    padding: 6px 12px;
    background: #2d2d2d;
    color: #ffffff;
    border: 1px solid #1a1a1a;
    border-radius: 0;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.download-svg-btn:hover {
    background: #1a1a1a;
}

.download-svg-btn:active {
    background: #0d0d0d;
}

.diagram-container img.inline-diagram {
    background: #ffffff;
}

.diagram-container img.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: contain;
    z-index: 1000;
    background: rgba(245, 245, 245, 0.98);
    cursor: zoom-out;
    padding: 20px;
    border-radius: 0;
    filter: none;
    margin: 0;
    border: 2px solid #2d2d2d;
}

.code-details {
    margin-top: 12px;
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 0;
    overflow: hidden;
}

.code-details summary {
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
    color: #666666;
    font-size: 13px;
    font-weight: 500;
    background: #f0f0f0;
}

.code-details summary:hover {
    background: #e0e0e0;
    color: #2d2d2d;
}

.code-details[open] summary {
    border-bottom: 1px solid #d0d0d0;
}

.code-wrapper {
    padding: 16px;
    position: relative;
}

.code-wrapper pre {
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    border: 1px solid #d0d0d0;
    border-radius: 0;
    padding: 12px;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    color: #2d2d2d;
    line-height: 1.5;
}

.copy-btn {
    margin-top: 8px;
    padding: 6px 12px;
    background: #2d2d2d;
    color: #ffffff;
    border: 1px solid #1a1a1a;
    border-radius: 0;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
}

.copy-btn:hover {
    background: #1a1a1a;
}

.copy-btn:active {
    background: #0d0d0d;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 0;
    background: #666666;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
    30% { transform: translateY(-10px); opacity: 1; }
}

.input-container {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 2px solid #d0d0d0;
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.input-container textarea {
    flex: 1;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 0;
    color: #2d2d2d;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 200px;
    min-height: 44px;
}

.input-container textarea:focus {
    outline: none;
    border-color: #2d2d2d;
    border-width: 2px;
}

.send-btn {
    padding: 12px 24px;
    background: #2d2d2d;
    color: #ffffff;
    border: 1px solid #1a1a1a;
    border-radius: 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    align-self: flex-end;
}

.send-btn:hover {
    background: #1a1a1a;
}

.send-btn:disabled {
    background: #e0e0e0;
    color: #999999;
    border-color: #d0d0d0;
    cursor: not-allowed;
    opacity: 0.6;
}

.error-message {
    background: #ffe0e0;
    border: 1px solid #ff6666;
    border-radius: 0;
    padding: 12px 16px;
    color: #cc0000;
    font-size: 13px;
    margin-top: 12px;
}
