/* ============================================================
   روتين الملكة 👑 — Mobile-first, royal pink/purple/gold palette
   ============================================================ */

:root {
    --bg: #fff5f8;
    --surface: #ffffff;
    --surface-2: #fbe6ee;
    --text: #2b1f28;
    --text-muted: #8a7381;
    --border: #f7dbe6;
    --accent: #e0357f;
    --accent-2: #ff8fab;
    --accent-soft: #fde6f0;
    --gold: #cf9a34;
    --gold-soft: #fbf0d9;
    --success: #4caf7d;
    --danger: #d1495b;
    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow: 0 4px 16px rgba(142, 79, 174, 0.12);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font-body: 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
    --font-display: 'Aref Ruqaa', 'Cairo', serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1420;
        --surface: #251a2a;
        --surface-2: #2d2032;
        --text: #f6eef3;
        --text-muted: #b49ead;
        --border: #3b2b41;
        --accent: #ff7aab;
        --accent-2: #ffb3c9;
        --accent-soft: #3d2530;
        --gold: #e6bb5c;
        --gold-soft: #3a2f1c;
        --success: #7fd9a8;
        --danger: #ef8a95;
        --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    }
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.page {
    max-width: 460px;
    margin: 0 auto;
    padding: calc(24px + var(--safe-top)) 18px calc(36px + var(--safe-bottom));
}

.page.has-bottom-nav {
    padding-bottom: calc(88px + var(--safe-bottom));
}

/* ---------- Bottom navbar ---------- */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 6px calc(8px + var(--safe-bottom));
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    padding: 4px 0;
    border-radius: var(--radius-sm);
}

.bottom-nav-icon {
    font-size: 20px;
    line-height: 1;
}

.bottom-nav-label {
    font-size: 10.5px;
    font-weight: 700;
}

.bottom-nav-item.active {
    color: var(--accent);
}

/* ---------- Header ---------- */

.app-header {
    margin-bottom: 20px;
    padding: 30px 22px 26px;
    border-radius: var(--radius-lg);
    background: linear-gradient(150deg, #8a4fae 0%, #c9629a 55%, #dd9a68 100%);
    box-shadow: 0 10px 26px rgba(142, 79, 174, 0.25);
    position: relative;
    overflow: hidden;
    text-align: center;
}

.app-header::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 15%, rgba(255,255,255,0.20) 0, transparent 38%),
        radial-gradient(circle at 88% 85%, rgba(255,255,255,0.14) 0, transparent 42%);
    pointer-events: none;
}

.app-header .crown {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.app-header h1 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: 0.01em;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.app-header .subtitle {
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    margin: 0;
    position: relative;
    letter-spacing: 0.02em;
}

/* ---------- About card ---------- */

.about-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 26px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    text-align: center;
    position: relative;
    border: 1px solid var(--border);
}

.about-card::before,
.about-card::after {
    content: "✦";
    position: absolute;
    color: var(--gold);
    font-size: 14px;
    opacity: 0.7;
}

.about-card::before { top: 16px; right: 18px; }
.about-card::after { bottom: 16px; left: 18px; }

.about-name {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
}

.about-tagline {
    font-size: 14px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.02em;
    margin-bottom: 16px;
}

.about-note {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    margin: 0;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}

.about-signature {
    display: block;
    margin-top: 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-muted);
}

/* ---------- Surprise link ---------- */

.surprise-row {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.surprise-link {
    flex: 1;
    display: block;
    text-align: center;
    padding: 13px 10px;
    border-radius: 999px;
    background: linear-gradient(120deg, #cf9a34, #e6bb5c);
    box-shadow: 0 6px 16px rgba(207, 154, 52, 0.35);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
}

/* ---------- Mood card ---------- */

.mood-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    border: 1px solid var(--border);
    text-align: center;
}

.mood-title {
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.mood-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.mood-option {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--surface-2);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
    padding: 0;
}

.mood-option:active {
    transform: scale(0.92);
}

.mood-option.selected {
    border-color: var(--gold);
    background: var(--gold-soft);
    transform: scale(1.08);
}

/* ---------- Notification card ---------- */

.notify-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
    border: 1px solid var(--border);
}

.notify-card p {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

.btn-primary {
    display: block;
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(120deg, #8a4fae, #d6588f);
    box-shadow: 0 6px 16px rgba(214, 88, 143, 0.32);
    color: #fff;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn-outline {
    display: block;
    width: 100%;
    padding: 13px 18px;
    border: 2px solid var(--accent);
    border-radius: 999px;
    background: transparent;
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-outline:active {
    transform: scale(0.98);
}

.btn-outline:disabled {
    opacity: 0.6;
    cursor: default;
}

.status-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 12px;
}

.status-line.ok { color: var(--success); }
.status-line.error { color: var(--danger); }

.ios-instructions {
    background: var(--accent-soft);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--text);
    margin-top: 14px;
}

.ios-instructions b {
    display: block;
    margin-bottom: 4px;
    color: var(--accent);
}

/* ---------- Voice messages ---------- */

.voice-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    border: 1px solid var(--border);
    text-align: center;
}

.voice-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 14px;
}

.voice-record-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(120deg, #e0357f, #8a4fae);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(224, 53, 127, 0.35);
}

.voice-record-btn:active {
    transform: scale(0.94);
}

.voice-timer {
    font-variant-numeric: tabular-nums;
    font-size: 22px;
    font-weight: 700;
    color: var(--danger);
    margin: 12px 0;
}

.voice-pulse {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--danger);
    animation: voice-pulse 1s ease-in-out infinite;
    margin-left: 8px;
}

@keyframes voice-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.voice-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.voice-actions button {
    flex: 1;
}

.voice-list {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: right;
}

.voice-list li {
    background: var(--surface-2);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.voice-list audio {
    width: 100%;
    margin-top: 6px;
}

.voice-list .voice-time {
    font-size: 12px;
    color: var(--text-muted);
}

/* ---------- Chat ---------- */

.chat-screen {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    background: var(--bg);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(14px + var(--safe-top)) 18px 14px;
    background: linear-gradient(150deg, #8a4fae 0%, #c9629a 55%, #dd9a68 100%);
    box-shadow: 0 4px 14px rgba(142, 79, 174, 0.22);
    flex-shrink: 0;
}

.chat-header-back {
    color: #fff;
    text-decoration: none;
    padding: 4px 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.chat-header-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.chat-header-texts {
    overflow: hidden;
}

.chat-header-name {
    color: #fff;
    font-weight: 700;
    font-size: 15.5px;
    white-space: nowrap;
}

.chat-header-status {
    color: rgba(255, 255, 255, 0.85);
    font-size: 11.5px;
}

.chat-header-typing {
    color: rgba(255, 255, 255, 0.85);
    font-size: 11.5px;
    font-style: italic;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px calc(24px + var(--safe-bottom) + 68px);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-empty {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.9;
}

.chat-row {
    display: flex;
    position: relative;
}

.chat-row.own {
    justify-content: right;
}

.chat-row.other {
    justify-content: left;
}

.chat-bubble {
    max-width: 78%;
    padding: 9px 13px 6px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.6;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.chat-bubble.own {
    background: linear-gradient(120deg, #8a4fae, #d6588f);
    color: #fff;
}

.chat-bubble.other {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.chat-bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    margin-top: 3px;
}

.chat-bubble-time {
    font-size: 10px;
    opacity: 0.75;
}

.chat-tick {
    display: inline-flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.6);
}

.chat-tick .tick-2 {
    opacity: 0;
}

.chat-tick.seen {
    color: var(--gold);
}

.chat-tick.seen .tick-2 {
    opacity: 1;
}

.chat-sender {
    display: block;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 2px;
    opacity: 0.85;
}

.chat-bubble.own .chat-sender { color: rgba(255, 255, 255, 0.85); }
.chat-bubble.other .chat-sender { color: var(--accent); }

.chat-bubble {
    position: relative;
    touch-action: pan-y;
    transition: transform 0.18s ease;
}

.chat-bubble.dragging {
    transition: none;
}

.chat-reply-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
}

.chat-row.own .chat-reply-icon { left: -34px; }
.chat-row.other .chat-reply-icon { right: -34px; }

/* ---------- Chat: reply quote ---------- */

.chat-reply-quote {
    display: block;
    padding: 6px 9px;
    margin-bottom: 5px;
    border-right: 3px solid var(--gold);
    background: rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    font-size: 12.5px;
    line-height: 1.4;
}

.chat-bubble.other .chat-reply-quote {
    border-right-color: var(--accent);
    background: var(--surface-2);
}

.chat-reply-sender {
    display: block;
    font-weight: 700;
    font-size: 11.5px;
    color: var(--gold);
}

.chat-bubble.other .chat-reply-sender { color: var(--accent); }

.chat-reply-text {
    display: block;
    opacity: 0.85;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-reply-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--surface-2);
    border-radius: 10px;
    border-right: 3px solid var(--accent);
}

.chat-reply-bar-text {
    flex: 1;
    min-width: 0;
}

.chat-reply-bar .chat-reply-sender { color: var(--accent); }

.chat-reply-bar-close {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

/* صورة عادية داخل الفقاعة */
.chat-photo-thumb {
    display: block;
    max-width: 100%;
    max-height: 260px;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 2px;
}

/* صورة "مرة وحدة" لسا ما انفتحت */
.chat-viewonce-btn {
    display: block;
    width: 100%;
    border: none;
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
    border-radius: 10px;
    padding: 16px 12px;
    text-align: center;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
}

.chat-viewonce-btn small {
    font-weight: 500;
    opacity: 0.8;
}

.chat-viewonce-opened {
    padding: 10px 6px;
    font-size: 13px;
    opacity: 0.7;
    font-style: italic;
}

/* ---------- Chat: lightbox ---------- */

.chat-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(10, 6, 12, 0.92);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.chat-lightbox.open {
    display: flex;
}

.chat-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

/* ---------- Chat: input bar ---------- */

.chat-input-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.chat-input-row,
.chat-voice-row,
.chat-photo-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input-row input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 11px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14.5px;
}

.chat-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--surface-2);
    color: var(--text);
    font-size: 17px;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-icon-btn.accent {
    background: linear-gradient(120deg, #e0357f, #8a4fae);
    color: #fff;
}

.chat-icon-btn.danger {
    background: var(--danger);
    color: #fff;
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(120deg, #e0357f, #8a4fae);
    color: #fff;
    font-size: 17px;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:disabled,
.chat-icon-btn:disabled {
    opacity: 0.5;
}

.chat-voice-timer {
    flex: 1;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--danger);
}

.chat-voice-row audio {
    flex: 1;
    min-width: 0;
    height: 38px;
}

.chat-photo-row img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.chat-viewonce-toggle {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-muted);
}

/* ---------- Footer ---------- */

.footer-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 24px;
    letter-spacing: 0.02em;
}
