html, body {
    height: 100%;
    margin: 0;
}

body {
    background: #121212;
    color: #E0E0E0;
    font-family: Arial, sans-serif;
    padding-bottom: env(safe-area-inset-bottom);
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* HEADER */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #1A1A1A;
    border-bottom: 2px solid #FF3B3B;
}

.left {
    display: flex;
    align-items: center;
}

.logo {
    height: 48px;
}

/* CENTERED TITLE + AUTHOR */
.title-block {
    flex: 1;
    text-align: center;
}

.app-title {
    margin: 0;
    font-size: 28px;
    font-weight: bold;
    line-height: 1.1;
}

.subtitle {
    font-size: 22px;
    font-weight: normal;
    display: block;
    margin-top: 2px;
}

.app-author {
    margin-top: 4px;
    font-size: 21px;
    color: #FF3B3B;
}

.header-controls {
    display: flex;
    gap: 8px;
}

/* MAIN CHAT AREA */
#main {
    flex: 1;
    overflow: hidden;
}

#chat-window {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    box-sizing: border-box;
}

/* MESSAGES */
.msg {
    margin: 8px 0;
    padding: 10px;
    border-radius: 8px;
    max-width: 80%;
    line-height: 1.5;
}

.msg.user {
    background: #1E1E1E;
    color: #81C784;
    margin-left: auto;
}

.msg.bot {
    background: #1E1E1E;
    color: #E0E0E0;
    border-left: 3px solid #FF3B3B;
}

/* INPUT BAR */
.input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 10px;
    padding-left: 10px;
    background: #1A1A1A;
    border-top: 2px solid #FF3B3B;
    box-sizing: border-box;
}

.input-bar textarea {
    flex: 1;
    resize: none;
    max-height: 160px;
    padding: 8px 10px;
    background: #0F0F0F;
    border: 1px solid #333;
    color: #E0E0E0;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.4;
    box-sizing: border-box;
}

/* BUTTONS */
.icon-btn {
    background: #333;
    border: none;
    color: #E0E0E0;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    margin-left: 4px;
}

.icon-btn:active {
    transform: scale(0.96);
}

/* MIC RECORDING STATE */
#mic-btn.listening {
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255,59,59,0.7); }
    70% { box-shadow: 0 0 0 16px rgba(255,59,59,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,59,59,0); }
}

/* MEMORY SHEET */
#overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 40;
}

#overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

#memory-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 70vh;
    background: #181818;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.6);
    transform: translateY(100%);
    transition: transform 0.25s ease-out;
    z-index: 45;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
}

#memory-sheet.open {
    transform: translateY(0);
}

.sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: #444;
    margin: 8px auto;
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid #333;
}

#memory-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 16px 16px;
}

.memory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #222;
    padding: 6px 8px;
    margin-bottom: 6px;
    border-radius: 6px;
    font-size: 13px;
}

.memory-text {
    flex: 1;
    margin-right: 6px;
    word-wrap: break-word;
}

.small-btn {
    background: #444;
    border: none;
    color: #E0E0E0;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}

.sheet-close {
    margin: 8px 16px 12px 16px;
    padding: 8px;
    border-radius: 8px;
    border: none;
    background: #333;
    color: #E0E0E0;
    cursor: pointer;
}
