@font-face {
    font-family: 'Uthmanic';
    src: url('/fonts/arabic.otf') format('opentype');
    font-display: swap;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    min-height: 100dvh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    background: #fff;
    color: #1a1a1a;
}
a { color: #1a1a1a; }
a:hover { opacity: 0.7; }

/* Layout */
.app {
    max-width: 1024px;
    margin: 0 auto;
    padding-top: 50px;
}
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: 50px;
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
    display: flex;
    align-items: center;
}
.app-header h1 { font-size: 18px; font-weight: 600; }
.nav-desktop { margin-left: auto; }
.nav-desktop a { margin-left: 16px; text-decoration: none; font-size: 13px; }
.nav-desktop a:hover { text-decoration: underline; }
.nav-toggle {
    display: none;
    margin-left: auto;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
}
.nav-mobile {
    display: none;
    position: absolute;
    top: 50px;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    min-width: 160px;
}
.nav-mobile a {
    display: block;
    padding: 12px 20px;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}
.nav-mobile a:last-child { border-bottom: none; }
.nav-mobile a:hover { background: #f8f8f8; }
.nav-mobile.open { display: block; }

@media (max-width: 640px) {
    .nav-desktop { display: none; }
    .nav-toggle { display: block; }
}

.app-content {
    padding: 16px;
}

.app-footer {
    position: sticky;
    bottom: 0;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e0e0e0;
    background: #fff;
}
.app-footer form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.app-footer textarea {
    flex: 1;
    height: 44px;
    max-height: 120px;
    padding: 12px;
    resize: none;
    font-size: 15px;
    line-height: 1.4;
    font-family: inherit;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    box-sizing: border-box;
    overflow: hidden;
}
.app-footer textarea:focus { outline: none; border-color: #999; }
.app-footer button {
    height: 44px;
    padding: 0 16px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}
.app-footer button:hover { background: #333; }
.app-footer button:disabled { opacity: 0.5; cursor: not-allowed; }
.app-footer #mic-btn { padding: 0 12px; font-size: 18px; }

/* Messages */
.message { margin-bottom: 16px; padding: 16px; }
.message.user { background: #f8f8f8; border-radius: 12px; }
.message.assistant { background: #fff; }
.message-role { font-size: 11px; color: #999; margin-bottom: 8px; }
.message-content { word-wrap: break-word; }
.message-content:not(.markdown) { white-space: pre-wrap; }

/* Common */
.muted { color: #888; }
.time { color: #999; font-size: 12px; }
h2 { font-weight: 600; font-size: 18px; margin-bottom: 16px; }
h3 { font-weight: 600; font-size: 16px; }
ul { list-style: none; }
li { padding: 14px 0; border-bottom: 1px solid #eee; }
li:last-child { border-bottom: none; }
input, button {
    font-family: inherit;
    font-size: inherit;
}
input {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
}
input:focus { outline: none; border-color: #999; }
.search-form { display: flex; gap: 10px; margin-bottom: 20px; }
.search-form input { flex: 1; }
.search-form button {
    padding: 10px 16px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #222;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
