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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fff;
    color: #1a1a1a;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 20px 16px 12px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111;
}

.header .tagline {
    font-size: 0.875rem;
    color: #666;
    margin-top: 2px;
}

.header .x-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: #555;
    text-decoration: none;
}

.header .x-link:hover {
    color: #000;
    text-decoration: underline;
}

.energy-bar {
    position: relative;
    width: 120px;
    height: 16px;
    background: #eee;
    border-radius: 8px;
    margin: 8px auto 0;
    overflow: hidden;
}

.energy-fill {
    height: 100%;
    background: #34c759;
    border-radius: 8px;
    transition: width 0.5s ease, background 0.5s ease;
    width: 100%;
}

.energy-label {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.65rem;
    line-height: 16px;
    color: #333;
    font-weight: 600;
}

/* Chat area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.message {
    display: flex;
    margin-bottom: 12px;
}

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

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

.bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.message.user .bubble {
    background: #007aff;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
    background: #f0f0f0;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.bubble a {
    color: inherit;
    text-decoration: underline;
}

/* Thinking indicator */
.thinking {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #f0f0f0;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    max-width: 80%;
}

.thinking span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.thinking span:nth-child(2) { animation-delay: 0.2s; }
.thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input area */
.input-area {
    border-top: 1px solid #eee;
    padding: 12px 16px;
    flex-shrink: 0;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.input-row {
    display: flex;
    gap: 8px;
}

#msg-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
}

#msg-input:focus {
    border-color: #007aff;
}

#send-btn {
    padding: 10px 20px;
    background: #007aff;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
}

#send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#send-btn:hover:not(:disabled) {
    background: #005ecb;
}

/* Powered by */
.powered-by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px 12px;
    flex-shrink: 0;
}

.powered-by span {
    font-size: 0.7rem;
    color: #ccc;
    letter-spacing: 0.02em;
}

.powered-logo {
    height: 16px;
    opacity: 0.25;
}

/* Mobile */
@media (max-width: 480px) {
    .header { padding: 14px 12px 10px; }
    .header h1 { font-size: 1.25rem; }
    .chat-container { padding: 12px; }
    .bubble { max-width: 88%; font-size: 0.9rem; }
    .input-area { padding: 10px 12px; }
}
