/* ============================================
   ZAL - ז"ל - Stylesheet (matching galed.co.il exactly)
   ============================================ */

/* --- Fonts --- */
@font-face {
    font-family: 'OpenSansHebrew';
    src: url('../fonts/OpenSansHebrew-Regular.ttf') format('truetype');
    font-weight: 400;
}
@font-face {
    font-family: 'OpenSansHebrew';
    src: url('../fonts/OpenSansHebrew-Bold.ttf') format('truetype');
    font-weight: 700;
}
@font-face {
    font-family: 'VarelaRound';
    src: url('../fonts/VarelaRound-Regular.ttf') format('truetype');
    font-weight: 400;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

/* --- Root vars --- */
:root {
    --header-height: 96px;
    --footer-height: 66px;
    --bg:          #1D232D;
    --bg-secondary:#243040;
    --bg-page:     #1a1a1a;
    --fg:          #343E4D;
    --border-color:#343E4D;
    --hover-bg:    rgba(255,255,255,0.07);
    --gold:        #F4CD78;
    --red:         #F47878;
    --teal:        #AAC9C3;
    --white:       #FFFFFF;
    --grey-a:      #C2C2C2;
    --grey-b:      #949494;
    --grey-c:      #696969;
    --text:        #FFFFFF;
    --input-bg:    #343E4D;
    --card-bg:     #343E4D;
    --card-bg2:    #2A3140;
    --success:     #78F4B8;
    --nav-border:  #343E4D;
    --profile-border: #1D232D;
}

/* Prevent flash before JS runs */
html.dark-init body, html:not(.alt-init) body { background-color: #1D232D; }
html.alt-init body { background-color: #F8FAFB; }

/* ============================================================
   ALT MODE — "יער ופנינה" (Forest & Pearl)
   Clean white base · Forest green accent · Slate text
   All text colors WCAG AA compliant (≥4.5:1 contrast)
   ============================================================ */
body.alt-mode {
    --bg:            #F8FAFB;   /* clean near-white */
    --bg-secondary:  #EFF3F7;
    --bg-page:       #E4ECF4;
    --fg:            #D1DCE8;
    --border-color:  #CBD5E1;
    --hover-bg:      rgba(27,94,55,0.05);
    --gold:          #B45309;   /* dark amber — readable on white (4.9:1) */
    --red:           #DC2626;
    --teal:          #0369A1;   /* deep sky blue */
    --white:         #0F172A;   /* in alt-mode: "contrast text" = dark on light backgrounds */
    --grey-a:        #0F172A;   /* near-black slate */
    --grey-b:        #334155;   /* dark slate (8.9:1 on white) */
    --grey-c:        #5A6477;   /* medium slate (5.9:1 on white) */
    --text:          #0F172A;
    --input-bg:      #FFFFFF;
    --card-bg:       #FFFFFF;
    --card-bg2:      #F1F5F9;
    --success:       #166534;
    --nav-border:    #E2EBF4;
    --profile-border:#F8FAFB;
}

/* Alt mode — primary action: deep forest green */
body.alt-mode .btn-solid,
body.alt-mode .btn-primary {
    background: #1B5E37;
    border-color: #1B5E37;
    color: #FFFFFF;
}
body.alt-mode .btn-solid:hover,
body.alt-mode .btn-primary:hover {
    background: #144A2B;
    border-color: #144A2B;
}

/* Alt mode — secondary buttons */
body.alt-mode .btn-light {
    border-color: #1B5E37;
    color: #1B5E37;
    background: transparent;
}
body.alt-mode .btn-light:hover {
    background: #1B5E37;
    color: #FFFFFF;
    border-color: #1B5E37;
}
body.alt-mode .btn-label {
    color: #334155;
}
body.alt-mode .btn-label:hover {
    color: #0F172A;
}

/* Alt mode — forms & cards */
body.alt-mode .form-card {
    background: #FFFFFF;
    border-color: #CBD5E1;
    box-shadow: 0 4px 24px rgba(15,23,42,0.08);
}
body.alt-mode .form-card h2 {
    color: #0F172A;
}
body.alt-mode .form-input,
body.alt-mode .form-textarea {
    background: #FFFFFF;
    border-color: #CBD5E1;
    color: #0F172A;
}
body.alt-mode .form-input:focus,
body.alt-mode .form-textarea:focus {
    border-color: #1B5E37;
    box-shadow: 0 0 0 3px rgba(27,94,55,0.12);
    background: #FFFFFF;
}
body.alt-mode .form-input::placeholder,
body.alt-mode .form-textarea::placeholder {
    color: #94A3B8;
}
body.alt-mode .form-label,
body.alt-mode .form-group label {
    color: #334155;
    font-weight: 600;
}
body.alt-mode .form-link {
    color: #1B5E37;
}
body.alt-mode .form-link:hover {
    text-decoration: underline;
}

/* Alt mode — topnav */
body.alt-mode .topnav {
    background: #FFFFFF;
    border-bottom: 1px solid #E2EBF4;
    box-shadow: 0 1px 8px rgba(15,23,42,0.06);
}
body.alt-mode .lang-btn {
    color: #334155;
}
body.alt-mode .lang-btn.active {
    color: #1B5E37;
    font-weight: 700;
}
body.alt-mode .theme-toggle {
    color: #334155;
}
body.alt-mode .dropdown-menu {
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    box-shadow: 0 4px 20px rgba(15,23,42,0.10);
}
body.alt-mode .dropdown-item {
    color: #334155;
}
body.alt-mode .dropdown-item:hover {
    background: #F1F5F9;
    color: #1B5E37;
}

/* Alt mode — modals */
body.alt-mode .modal-box {
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    box-shadow: 0 12px 48px rgba(15,23,42,0.12);
}
body.alt-mode .modal-title {
    color: #1B5E37;
}
body.alt-mode .modal-close {
    color: #5A6477;
}
body.alt-mode .modal-close:hover {
    color: #0F172A;
}

/* Alt mode — candle button */
body.alt-mode .btn-candle {
    border-color: #B45309;
    color: #92400E;
}
body.alt-mode .btn-candle:hover,
body.alt-mode .btn-candle.active {
    background: #B45309;
    border-color: #B45309;
    color: #FFFFFF;
}

/* Alt mode — story cards */
body.alt-mode .story-card {
    background: #FFFFFF;
    border: 1px solid #E2EBF4;
    box-shadow: 0 2px 8px rgba(15,23,42,0.05);
}
body.alt-mode .story-card:hover {
    border-color: #1B5E37;
    box-shadow: 0 6px 20px rgba(27,94,55,0.10);
}
body.alt-mode .story-topic-chip {
    background: rgba(27,94,55,0.08);
    color: #1B5E37;
    border: 1px solid rgba(27,94,55,0.2);
}
body.alt-mode .story-author-name {
    color: #0F172A;
}
body.alt-mode .story-author-relation {
    color: #5A6477;
}

/* Alt mode — alerts */
body.alt-mode .alert-error   { color: #DC2626; }
body.alt-mode .alert-success { color: #166534; }
body.alt-mode .alert-info    { color: #0369A1; }
body.alt-mode .alert-box.alert-info {
    background: rgba(3,105,161,0.06);
    border-color: rgba(3,105,161,0.25);
    color: #0369A1;
}
body.alt-mode .alert-box.alert-error {
    background: rgba(220,38,38,0.06);
    border-color: rgba(220,38,38,0.22);
    color: #DC2626;
}
body.alt-mode .alert-box.alert-success {
    background: rgba(22,101,52,0.06);
    border-color: rgba(22,101,52,0.22);
    color: #166534;
}
body.alt-mode .form-error {
    color: #DC2626;
}

/* Alt mode — memo page */
body.alt-mode .memo-info-name {
    color: #1B5E37;
    text-shadow: none;
}
body.alt-mode .memo-hero-gradient {
    background: linear-gradient(to bottom, rgba(248,250,251,0) 30%, #F8FAFB 100%);
}

/* Memo grid cards: overlay is always dark → text always white regardless of theme */
body.alt-mode .memo-info .name {
    color: #FFFFFF;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
body.alt-mode .memo-info .years {
    color: #F4CD78;
}

/* Alt mode — mobile menu */
body.alt-mode .mobile-menu {
    background: #FFFFFF;
    border-left: 1px solid #E2EBF4;
    box-shadow: -4px 0 24px rgba(15,23,42,0.10);
}
body.alt-mode .mobile-item-text {
    color: #334155;
}
body.alt-mode .mobile-item-text.gold {
    color: #1B5E37;
    font-weight: 600;
}
body.alt-mode .mobile-item-text.teal {
    color: #0369A1;
}
body.alt-mode .mobile-item {
    border-bottom-color: #EFF3F7;
}

/* Alt mode — separator */
body.alt-mode .sep {
    background: #E2EBF4;
}

/* Alt mode — nav buttons (waze / gmaps) */
body.alt-mode .nav-btn {
    background: #F1F5F9;
    border-color: #CBD5E1;
    color: #334155;
}
body.alt-mode .nav-btn:hover {
    background: #1B5E37;
    color: #FFFFFF;
    border-color: #1B5E37;
}

/* Alt mode — settings / accordion */
body.alt-mode .settings-option {
    border-color: #CBD5E1;
}
body.alt-mode .settings-option.selected,
body.alt-mode .settings-option:hover {
    border-color: #1B5E37;
    background: rgba(27,94,55,0.04);
}
body.alt-mode .accordion-header {
    background: #F1F5F9;
    border-color: #CBD5E1;
    color: #334155;
}
body.alt-mode .accordion-body {
    background: #FFFFFF;
    border-color: #E2EBF4;
}

/* Alt mode — share/copy link box */
body.alt-mode .copy-link-box {
    background: #F1F5F9;
    border-color: #CBD5E1;
    color: #334155;
}
body.alt-mode .copy-link-btn {
    color: #1B5E37;
}

/* Alt mode — share platform buttons */
body.alt-mode .share-platform-btn {
    background: #F1F5F9;
    border-color: #CBD5E1;
    color: #334155;
}
body.alt-mode .share-platform-btn:hover {
    background: #1B5E37;
    color: #FFFFFF;
    border-color: #1B5E37;
}

/* Alt mode — Leaflet map */
body.alt-mode .leaflet-container {
    background: #EFF3F7;
}
body.alt-mode .leaflet-popup-content-wrapper,
body.alt-mode .leaflet-popup-tip {
    background: #FFFFFF;
    color: #0F172A;
    box-shadow: 0 4px 16px rgba(15,23,42,0.12);
}

/* --- Base --- */
html { font-family: OpenSansHebrew, VarelaRound, Arial, sans-serif; font-size: 16px; }
body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    direction: rtl;
    font-family: OpenSansHebrew, VarelaRound, Arial, sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }

/* =====================================================
   TOPNAV
   ===================================================== */
.topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    direction: ltr;
    padding: 0 64px;
    border-bottom: 1px solid var(--nav-border);
    transition: background 0.3s, border-color 0.3s;
}
.topnav-inner {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

/* Logo */
.nav-logo {
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.nav-logo img { height: 40px; width: auto; }

/* Nav actions (left side in ltr layout = visually right side) */
.nav-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 32px;
}

.nav-toggles {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

/* Dark mode toggle */
.theme-toggle {
    width: 36px;
    height: 64px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 61px;
    background: #354255;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: white;
}

/* Language toggle */
.lang-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    color: var(--grey-a);
}
.lang-btn {
    background: none;
    border: none;
    color: var(--grey-a);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}
.lang-btn.active { color: var(--gold); }
.lang-sep { color: var(--grey-c); }

/* Nav buttons group */
.nav-buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

/* --- Button Variants --- */
/* Plain text button */
.btn {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 48px;
    padding: 0 16px;
    font-size: 16px;
    border-radius: 8px;
    border: none;
    background: none;
    color: var(--white);
    font-weight: 400;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
}

/* Outlined gold */
.btn-light {
    border: 1.5px solid var(--gold);
    color: var(--gold);
    background: none;
}
.btn-light:hover { background: var(--gold); color: var(--bg); }

/* Filled gold */
.btn-solid {
    border: 1.5px solid var(--gold);
    background: var(--gold);
    color: var(--bg);
    font-weight: 600;
}
.btn-solid:hover { background: #e8bc60; border-color: #e8bc60; }

/* Plain label */
.btn-label {
    color: var(--grey-a);
    background: none;
    border: none;
}
.btn-label:hover { color: var(--white); }

/* Red / coral */
.btn-danger {
    border: 1.5px solid var(--red);
    background: var(--red);
    color: var(--bg);
}
.btn-danger:hover { background: #e06060; }

/* Full-width */
.btn-full { width: 100%; justify-content: center; }

/* Form link row */
.form-link-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    direction: rtl;
    margin-top: 12px;
    font-size: 14px;
}

/* OR divider */
.or-divider {
    text-align: center;
    color: var(--grey-c);
    font-size: 13px;
    margin: 20px 0;
    position: relative;
}
.or-divider::before, .or-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--card-bg);
}
.or-divider::before { left: 0; }
.or-divider::after  { right: 0; }

/* Social login buttons */
.social-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1.5px solid var(--border-color);
    background: var(--card-bg);
    color: var(--white);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s;
    margin-bottom: 10px;
    direction: rtl;
}
.social-btn:hover { background: #454f60; }
.social-btn.google { }

/* Primary = alias for solid */
.btn-primary {
    border: 1.5px solid var(--gold);
    background: var(--gold);
    color: var(--bg);
    font-weight: 600;
    width: 100%;
    justify-content: center;
}
.btn-primary:hover { background: #e8bc60; border-color: #e8bc60; }

/* Account dropdown wrapper */
.account-wrap { position: relative; }
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    background: var(--fg);
    border-radius: 10px;
    min-width: 160px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    overflow: hidden;
    z-index: 9999;
}
.dropdown-item {
    display: block;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
    direction: rtl;
    text-align: right;
    white-space: nowrap;
}
.dropdown-item:hover { background: rgba(255,255,255,0.08); }

/* Mobile burger (hidden desktop) */
.burger-btn {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    padding: 8px;
}

/* =====================================================
   MOBILE MENU
   ===================================================== */
.mobile-menu {
    display: none;
    position: fixed;
    top: 0; right: 0;
    width: 100%;
    height: 100vh;
    background: var(--bg);
    z-index: 10000;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
.mobile-menu.open {
    transform: translateX(0);
    display: flex;
}
.mobile-menu-top {
    padding: 24px 20px;
    display: flex;
    justify-content: flex-start;
}
.mobile-close-btn {
    background: none;
    border: none;
    color: var(--white);
    padding: 4px;
}
.mobile-menu-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mobile-item { border-bottom: 1px solid var(--nav-border); }
.mobile-item-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    cursor: pointer;
}
.mobile-item-text { font-size: 18px; color: var(--white); }
.mobile-item-text.gold { color: var(--gold); }
.mobile-item-text.teal { color: var(--teal); }
.mobile-menu-footer {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--border-color);
}
.mobile-copy { font-size: 13px; color: var(--grey-c); }

/* =====================================================
   PAGE WRAPPER
   ===================================================== */
.page-wrapper {
    padding-top: var(--header-height);
    padding-bottom: var(--footer-height);
    min-height: 100vh;
}

/* =====================================================
   HOME PAGE
   ===================================================== */
.page-content {
    box-sizing: border-box;
    width: 100%;
    min-height: 100vh;
    background: var(--bg);
    padding: 56px;
    position: relative;
}

/* Leaf background */
.leaf-bg {
    position: fixed;
    top: 0; right: 0;
    width: auto; height: auto;
    z-index: 1;
    pointer-events: none;
}

.home-wrapper {
    display: flex;
    flex-direction: row;
    gap: 36px;
    align-items: flex-start;
    justify-content: space-between;
    margin-top: 44px;
    position: relative;
    z-index: 2;
}

/* Left column: grid */
.home-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Search */
.search-box-wrap {
    width: 435px;
    height: 48px;
    background: #2c2c2c;
    border-radius: 8px;
    border: 1px solid var(--grey-c);
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
}
.search-icon { color: var(--grey-b); flex-shrink: 0; }
.search-box-wrap input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 16px;
    color: var(--grey-a);
    text-align: right;
    font-family: inherit;
    direction: rtl;
}
.search-box-wrap input::placeholder { color: var(--grey-b); }

.search-stats {
    width: 100%;
    text-align: right;
    font-size: 15px;
    color: var(--grey-a);
    margin-top: 12px;
    margin-bottom: 16px;
}

/* Memorial grid */
.memo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(284px, 1fr));
    gap: 20px;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 32px;
}

.empty-state {
    grid-column: 1/-1;
    text-align: center;
    color: var(--grey-b);
    font-size: 16px;
    padding: 40px 0;
}

/* Memorial thumbnail card */
.memo-thumbnail {
    position: relative;
    width: 100%;
    height: 284px;
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    background: #000;
}
.memo-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0; left: 0;
    transition: transform 0.3s ease;
}
.memo-thumbnail:hover img { transform: scale(1.04); }
.memo-thumbnail-blank {
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}
.memo-thumbnail-blank svg { width: 64px; height: 64px; opacity: 0.4; }

/* Card gradient overlay */
.memo-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.85) 30%, rgba(0,0,0,0.05) 55%, transparent 55%);
    display: flex;
    align-items: flex-end;
}
.memo-info {
    width: 100%;
    padding: 0 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}
.memo-info .name {
    font-size: 18px;
    color: var(--white);
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.memo-info .years {
    font-size: 14px;
    color: var(--gold);
    margin-top: 4px;
}

/* Right column: hero text */
.home-right {
    width: 445px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    text-align: right;
    padding-top: 8px;
}
.home-intro-title {
    font-size: 48px;
    color: var(--gold);
    line-height: 1.2;
    font-weight: 700;
    direction: rtl;
}
.home-intro-desc {
    font-size: 18px;
    color: var(--white);
    line-height: 1.8;
    direction: rtl;
}

/* =====================================================
   MEMORIAL PAGE
   ===================================================== */

/* Full-width hero banner */
.memo-header {
    position: relative;
    width: 100%;
    height: 420px;
    overflow: hidden;
    background: var(--bg);
}
.memo-header-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.memo-header-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.92) 31%, rgba(1,1,1,0.02) 55%, transparent 55%);
}
.memo-header-watermark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(100px, 22vw, 260px);
    font-weight: 900;
    color: rgba(244,205,120,0.13);
    pointer-events: none;
    user-select: none;
    letter-spacing: -4px;
    z-index: 1;
}

/* Main body below banner */
.memo-body {
    background: var(--bg);
    padding: 0;
    position: relative;
}
.memo-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 32px 80px;
}

/* Admin bar */
.memo-admin-bar {
    background: rgba(244,205,120,0.1);
    border: 1px solid rgba(244,205,120,0.3);
    border-radius: 10px;
    padding: 12px 20px;
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    margin-top: 20px;
    margin-right: 210px;
    flex-direction: row-reverse;
}

/* Subscription warning banner */
.subscription-banner {
    background: #c0392b;
    border: none;
    border-radius: 8px;
    padding: 13px 24px;
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    margin-bottom: 16px;
    line-height: 1.5;
}
.subscription-banner strong { color: #FFFFFF; font-weight: 700; }
.subscription-banner:hover { background: #a93226; }

/* Profile row: photo + name */
.memo-profile-row {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 24px;
    margin-top: -60px;
    position: relative;
    z-index: 10;
    margin-bottom: 24px;
    direction: rtl;
}
.memo-profile-photo {
    width: 180px;
    height: 180px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--card-bg);
    border: 4px solid var(--profile-border);
    flex-shrink: 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.memo-profile-photo-blank {
    width: 180px;
    height: 180px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 4px solid var(--profile-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.memo-name-block {
    text-align: right;
    padding-bottom: 8px;
    direction: rtl;
}
.memo-name {
    font-size: 36px;
    color: var(--white);
    font-weight: 700;
    line-height: 1.2;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.memo-official-title {
    font-size: 14px;
    color: var(--teal);
    margin-bottom: 4px;
    letter-spacing: 0.03em;
}
.memo-lifespan {
    font-size: 18px;
    color: var(--gold);
    margin-top: 4px;
}
.memo-short-desc {
    font-size: 14px;
    color: var(--grey-a);
    margin-top: 8px;
    font-style: italic;
    opacity: 0.85;
    direction: rtl;
}

/* Two-column layout */
.memo-main-layout {
    display: flex;
    flex-direction: row;
    gap: 40px;
    align-items: flex-start;
    direction: rtl;
}

/* Sidebar (right in RTL) */
.memo-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: calc(var(--header-height) + 20px);
}
.memo-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Candle button */
.btn-candle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    border-radius: 8px;
    border: 1.5px solid var(--gold);
    background: none;
    color: var(--gold);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
    width: 100%;
    white-space: nowrap;
}
.btn-candle:hover, .btn-candle.active { background: var(--gold); color: var(--bg); }

/* Navigation button */
.btn-navigate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1.5px solid var(--gold);
    color: var(--gold);
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    background: none;
    transition: background 0.2s, color 0.2s;
    flex: 1;
    text-decoration: none;
    font-family: inherit;
}
.btn-navigate:hover { background: var(--gold); color: var(--bg); }

.sep { height: 1px; background: var(--card-bg); margin: 8px 0; }
.section-title {
    font-size: 15px;
    color: var(--grey-a);
    font-weight: 600;
    text-align: right;
    margin-bottom: 8px;
}

/* Accordion */
.accordion { display: flex; flex-direction: column; gap: 6px; }
.accordion-item {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
}
.accordion-header {
    padding: 10px 14px;
    font-size: 14px;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    text-align: right;
    direction: rtl;
}

/* Main content (left in RTL) */
.memo-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Description */
.memo-description {
    font-size: 16px;
    color: var(--grey-a);
    line-height: 1.8;
    text-align: right;
    direction: rtl;
    overflow: hidden;
    transition: max-height 0.4s ease;
    max-height: 9999px; /* default: fully visible */
}
.memo-description.collapsed {
    max-height: calc(1.8em * 5); /* exactly 5 lines */
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

/* Filter tabs */
.filter-tabs {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
    direction: rtl;
}
.filter-tab {
    padding: 8px 18px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: none;
    color: var(--grey-a);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.2s;
}
.filter-tab.active, .filter-tab:hover {
    background: var(--gold);
    color: var(--bg);
    border-color: var(--gold);
}

/* Stories section */
.stories-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Story card */
.story-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    text-align: right;
    direction: rtl;
}
.story-card-header {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.story-author-photo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg);
    flex-shrink: 0;
    overflow: hidden;
}
.story-author-info { flex: 0 0 auto; text-align: right; }
.story-author-name { font-size: 15px; color: var(--white); font-weight: 600; }
.story-author-relation { font-size: 13px; color: var(--grey-b); margin-top: 2px; }
.story-date { font-size: 12px; color: var(--grey-c); white-space: nowrap; margin-left: auto; }
.story-text {
    font-size: 15px;
    color: var(--white);
    line-height: 1.75;
    margin-bottom: 12px;
}
.story-topic-chip {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(244,205,120,0.15);
    color: var(--gold);
    border-radius: 20px;
    font-size: 12px;
    margin-bottom: 12px;
}
.story-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.story-media-grid img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
}
.story-actions {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.07);
}
.story-action-btn {
    background: none;
    border: none;
    color: var(--grey-b);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: inherit;
    transition: color 0.2s, background 0.2s;
}
.story-action-btn:hover { color: var(--white); background: var(--hover-bg); }
.story-action-btn.liked { color: var(--red); }

/* State badges */
.badge-pending {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(244,205,120,0.2);
    color: var(--gold);
    border-radius: 8px;
    font-size: 11px;
}
.badge-rejected {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(244,120,120,0.2);
    color: var(--red);
    border-radius: 8px;
    font-size: 11px;
}

/* Comments */
.comments-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
/* Inline story comments */
.story-comments-wrap {
    border-top: 1px solid var(--border-color);
    margin-top: 12px;
    padding-top: 12px;
}
.story-comments-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.comment-item {
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 10px 14px;
    direction: rtl;
    text-align: right;
}
.comment-author { font-size: 13px; color: var(--gold); margin-bottom: 4px; }
.comment-text { font-size: 14px; color: var(--grey-a); line-height: 1.6; }
.add-comment-row {
    display: flex;
    gap: 8px;
    align-items: center;
    direction: rtl;
}
/* Comment input — always visible gold border */
.story-comments-wrap .form-input,
.add-comment-row .form-input {
    border: 1.5px solid rgba(244,205,120,0.4);
    background: rgba(244,205,120,0.04);
}
.story-comments-wrap .form-input:focus,
.add-comment-row .form-input:focus {
    border-color: var(--gold);
    background: rgba(244,205,120,0.08);
    box-shadow: 0 0 0 3px rgba(244,205,120,0.15);
    outline: none;
}

/* Settings option */
.settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    border: 1.5px solid transparent;
    margin-bottom: 8px;
    cursor: pointer;
    direction: rtl;
    text-align: right;
    font-size: 15px;
    color: var(--white);
    transition: all 0.2s;
}
.settings-option:hover { background: rgba(255,255,255,0.08); }
.settings-option.selected { border-color: var(--gold); border-width:2px; background: rgba(244,205,120,0.15); color: var(--gold); font-weight:600; }
.settings-option.selected .settings-radio { outline: 2px solid var(--gold); outline-offset: 2px; border-radius:50%; }
.settings-radio { accent-color: var(--gold); width:18px; height:18px; cursor:pointer; flex-shrink:0; }

/* Share */
.share-platforms { display: flex; gap: 10px; flex-wrap: wrap; }
.share-platform-btn {
    flex: 1;
    min-width: 100px;
    padding: 12px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--white);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}
.share-platform-btn:hover { background: #454f60; }
.copy-link-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--grey-a);
    gap: 12px;
    direction: rtl;
}
.copy-link-btn {
    color: var(--gold);
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    flex-shrink: 0;
}
.copy-link-btn:hover { text-decoration: underline; }

/* =====================================================
   FORMS (login, register, new-memo etc.)
   ===================================================== */
.form-page {
    max-width: 480px;
    margin: 40px auto;
    padding: 0 20px;
}
.form-card {
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
}
.form-title {
    font-size: 28px;
    color: var(--gold);
    text-align: right;
    margin-bottom: 8px;
}
.form-subtitle {
    font-size: 15px;
    color: var(--grey-b);
    text-align: right;
    margin-bottom: 28px;
}
.form-group {
    margin-bottom: 18px;
    text-align: right;
}
.form-label,
.form-group label {
    display: block;
    font-size: 14px;
    color: var(--grey-a);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    height: 48px;
    background: var(--card-bg);
    border: 1.5px solid transparent;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 16px;
    color: var(--white);
    font-family: inherit;
    direction: rtl;
    text-align: right;
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--gold); }
.form-input::placeholder { color: var(--grey-c); }
.form-textarea {
    width: 100%;
    background: var(--card-bg);
    border: 1.5px solid transparent;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--white);
    font-family: inherit;
    direction: rtl;
    text-align: right;
    outline: none;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s;
}
.form-textarea:focus { border-color: var(--gold); }
.form-error {
    font-size: 13px;
    color: var(--red);
    margin-top: 6px;
    text-align: right;
}
.form-link {
    color: var(--gold);
    cursor: pointer;
    font-size: 14px;
}
.form-link:hover { text-decoration: underline; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--grey-a);
    cursor: pointer;
    direction: rtl;
}
.checkbox-label input[type="checkbox"] { accent-color: var(--gold); width: 16px; height: 16px; }

/* Date row with checkboxes */
.date-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-direction: row-reverse;
}
.date-row input[type="date"] {
    flex: 1;
    height: 48px;
    background: var(--card-bg);
    border: 1.5px solid transparent;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 15px;
    color: var(--white);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    direction: rtl;
}
.date-row input[type="date"]:focus { border-color: var(--gold); }
.date-row label { font-size: 13px; color: var(--grey-a); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.date-row input[type="checkbox"] { accent-color: var(--gold); width: 16px; height: 16px; }

/* Step indicator */
.step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 28px;
    direction: rtl;
    flex-direction: row-reverse;
}
.step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--grey-b);
    background: var(--bg);
    transition: all 0.2s;
}
.step-dot.active { border-color: var(--gold); color: var(--gold); }
.step-dot.done { border-color: var(--gold); background: var(--gold); color: var(--bg); }
.step-line {
    flex: 1;
    height: 2px;
    background: var(--card-bg);
    max-width: 60px;
}
.step-panel { display: none; }
.step-panel.active { display: block; }

/* Photo upload areas */
.photo-upload-area {
    width: 100%;
    height: 180px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    background: rgba(255,255,255,0.03);
    transition: border-color 0.2s;
    position: relative;
}
.photo-upload-area:hover { border-color: var(--gold); }
.photo-upload-area img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0; left: 0;
}
.profile-photo-upload {
    width: 100px;
    height: 100px;
    border: 2px dashed var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255,255,255,0.03);
    transition: border-color 0.2s;
    position: relative;
}
.profile-photo-upload:hover { border-color: var(--gold); }
.profile-photo-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
}
.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--grey-b);
    font-size: 13px;
    text-align: center;
    pointer-events: none;
}
.upload-placeholder.hidden { display: none; }

/* Community filter dropdown */
.community-option:hover { background: rgba(244,205,120,0.1); color: var(--gold) !important; }

/* Community chips */
.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    direction: rtl;
    margin-top: 10px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(244,205,120,0.15);
    border: 1px solid var(--gold);
    color: var(--gold);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.chip.selected { background: var(--gold); color: var(--bg); }
.chip-remove { font-size: 16px; line-height: 1; }

/* New memo page */
.new-memo-page { max-width: 720px; margin: 0 auto; }
.form-step-nav {
    display: flex;
    gap: 10px;
    direction: rtl;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* =====================================================
   PLANS PAGE
   ===================================================== */
.plans-page { max-width: 900px; margin: 0 auto; }
.plans-header {
    text-align: center;
    margin-bottom: 40px;
    direction: rtl;
}
.plans-header h2 { font-size: 28px; color: var(--gold); margin-bottom: 16px; }
.plans-header p { font-size: 15px; color: var(--grey-a); line-height: 1.7; }
.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}
.plan-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    position: relative;
    border: 1.5px solid transparent;
    direction: rtl;
    transition: border-color 0.2s;
}
.plan-card.popular { border-color: var(--gold); }
.plan-card:hover { border-color: var(--gold); }
.popular-badge {
    position: absolute;
    top: -13px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gold);
    color: var(--bg);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 20px;
    white-space: nowrap;
}
.plan-name { font-size: 20px; color: var(--white); font-weight: 700; margin-bottom: 12px; }
.plan-price { font-size: 32px; color: var(--gold); font-weight: 700; margin-bottom: 20px; }
.plan-price span { font-size: 15px; color: var(--grey-a); font-weight: 400; }
.plan-features { list-style: none; margin-bottom: 24px; display: flex; flex-direction: column; gap: 10px; }
.plan-features li { font-size: 14px; color: var(--grey-a); text-align: right; padding-right: 20px; position: relative; }
.plan-features li::before { content: '✓'; position: absolute; right: 0; color: var(--gold); }

/* =====================================================
   ALERTS
   ===================================================== */
.alert-box {
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 14px;
    direction: rtl;
    text-align: right;
    margin-bottom: 16px;
}
/* =====================================================
   CUSTOM SELECT (replaces native datalist/select)
   ===================================================== */
.zal-select { position: relative; width: 100%; }
.zal-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 48px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
    font-family: inherit;
    direction: rtl;
    transition: border-color 0.2s;
    user-select: none;
}
.zal-select-btn:hover, .zal-select.open .zal-select-btn {
    border-color: var(--gold);
}
.zal-select-placeholder { color: var(--grey-c); }
.zal-select-arrow {
    font-size: 11px;
    color: var(--grey-b);
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-right: 8px;
}
.zal-select.open .zal-select-arrow { transform: rotate(180deg); }
.zal-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0; left: 0;
    background: var(--card-bg);
    border: 1px solid var(--gold);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    z-index: 9999;
    overflow: hidden;
    display: none;
    direction: rtl;
}
.zal-select.open .zal-select-dropdown { display: block; }
.zal-select-search {
    width: 100%;
    padding: 10px 14px;
    background: var(--input-bg);
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    direction: rtl;
    outline: none;
    box-sizing: border-box;
}
.zal-select-options { max-height: 220px; overflow-y: auto; }
.zal-select-option {
    padding: 11px 16px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    direction: rtl;
    transition: background 0.15s;
}
.zal-select-option:hover, .zal-select-option.focused {
    background: rgba(244,205,120,0.12);
    color: var(--gold);
}
.zal-select-option.selected {
    background: rgba(244,205,120,0.08);
    color: var(--gold);
    font-weight: 600;
}
.zal-select-empty {
    padding: 14px 16px;
    color: var(--grey-c);
    font-size: 13px;
    text-align: center;
}

/* Settings toggle row */
.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    direction: rtl;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    gap: 12px;
    user-select: none;
}
.settings-toggle-row input[type="checkbox"] {
    width: 18px; height: 18px; cursor: pointer; flex-shrink: 0;
    accent-color: var(--gold);
}

.alert-error { background: rgba(244,120,120,0.15); color: #c0392b; border: 1px solid rgba(244,120,120,0.4); }
.alert-success { background: rgba(39,174,96,0.12); color: #1a7a42; border: 1px solid rgba(39,174,96,0.4); }
.alert-info { background: rgba(41,128,185,0.12); color: #1a5a85; border: 1px solid rgba(41,128,185,0.3); }
body.dark-mode .alert-error { color: var(--red); }
body.dark-mode .alert-success { color: var(--success); }
body.dark-mode .alert-info { color: var(--teal); }
.hidden { display: none !important; }

/* =====================================================
   SUBSCRIPTION WALL
   ===================================================== */
.sub-wall {
    padding: 40px 0 60px;
    direction: rtl;
}
.sub-wall-inner { max-width: 900px; margin: 0 auto; text-align: center; }
.sub-wall-title {
    font-size: clamp(22px, 4vw, 32px);
    color: var(--gold);
    font-weight: 700;
    margin-bottom: 12px;
}
.sub-wall-sub {
    font-size: 15px;
    color: var(--grey-b);
    margin-bottom: 36px;
}
.sub-plans-grid {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 36px;
}
.sub-plan {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px 24px 24px;
    width: 260px;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sub-plan-featured {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold);
    transform: scale(1.03);
}
.sub-plan-badge {
    background: var(--gold);
    color: var(--bg);
    font-size: 12px;
    font-weight: 700;
    border-radius: 20px;
    padding: 4px 14px;
    display: inline-block;
    margin-bottom: 4px;
}
.sub-plan-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
}
.sub-plan-price {
    font-size: 32px;
    font-weight: 800;
    color: var(--gold);
}
.sub-plan-price span {
    font-size: 14px;
    font-weight: 400;
    color: var(--grey-b);
}
.sub-plan-features {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: right;
    flex: 1;
}
.sub-plan-features li {
    font-size: 13px;
    color: var(--grey-a);
    padding: 5px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sub-plan-features li::before { content: '✓'; color: var(--gold); font-weight: 700; flex-shrink: 0; }
.sub-plan-btn {
    background: var(--gold);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
    margin-top: 8px;
}
.sub-plan-btn:hover { opacity: 0.85; }
.sub-wall-footer {
    font-size: 14px;
    color: var(--grey-b);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.7;
}
@media (max-width: 680px) {
    .sub-plans-grid { flex-direction: column; align-items: center; }
    .sub-plan-featured { transform: none; }
    .sub-plan { width: 100%; max-width: 340px; }
}

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 9998;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
    background: var(--bg);
    border-radius: 20px;
    padding: 36px;
    max-width: 520px;
    width: calc(100% - 40px);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    direction: rtl;
    text-align: right;
}
/* Taller modal for forms with many fields on small screens */
.modal-box-scroll {
    max-height: 92vh;
    padding: 24px 28px;
}
@media (max-height: 700px) {
    .modal-box-scroll {
        max-height: 96vh;
        border-radius: 12px;
        padding: 16px 18px;
    }
}
@media (max-width: 480px) {
    .modal-box, .modal-box-scroll {
        padding: 18px 16px;
        border-radius: 14px;
        width: calc(100% - 16px);
    }
}
.modal-close {
    position: absolute;
    top: 16px;
    left: 16px;
    background: none;
    border: none;
    color: var(--grey-b);
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.modal-close:hover { color: var(--white); background: rgba(255,255,255,0.1); }
.modal-title {
    font-size: 22px;
    color: var(--gold);
    margin-bottom: 20px;
    padding-left: 40px;
}
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-direction: row-reverse;
}

/* =====================================================
   FOOTER
   ===================================================== */
.site-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--footer-height);
    background: var(--bg);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    align-items: center;
}
.footer-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 64px;
}
.footer-copyright {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--grey-a);
}
.footer-links {
    display: flex;
    align-items: center;
    gap: 24px;
    direction: rtl;
}
.footer-links a {
    font-size: 14px;
    color: var(--teal);
    cursor: pointer;
    text-decoration: none;
}
.footer-links a:hover { text-decoration: underline; }

/* =====================================================
   SPINNER
   ===================================================== */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(244,205,120,0.3);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================
   MOBILE RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    :root { --header-height: 64px; }

    .topnav { padding: 0 16px; }
    .nav-actions { display: none; }
    .burger-btn { display: flex; }

    .page-content { padding: 16px; }

    .home-wrapper {
        flex-direction: column-reverse;
        gap: 16px;
        margin-top: 8px;
    }
    .home-right { width: 100%; margin-top: 0; }
    .home-intro-title { font-size: 28px; }
    .search-box-wrap { width: 100%; }
    .memo-grid { grid-template-columns: repeat(2, 1fr); padding: 16px; gap: 12px; }
    .memo-thumbnail { height: 160px; }

    .memo-inner { padding: 0 16px 60px; }
    .memo-header { height: 240px; }
    .memo-profile-photo,
    .memo-profile-photo-blank { width: 120px; height: 120px; }
    .memo-name { font-size: 22px; }
    .memo-main-layout { flex-direction: column-reverse; }
    .memo-sidebar { width: 100%; position: static; }

    .footer-inner { padding: 0 16px; }
    .footer-links { gap: 12px; }
    .footer-links a { font-size: 12px; }

    .plans-grid { grid-template-columns: 1fr; }

    .form-row { grid-template-columns: 1fr; }
    .form-card { padding: 24px; }
}

/* =====================================================
   ADMIN PANEL
   ===================================================== */
.admin-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    direction: rtl;
}
.stat-card.pending { border-color: rgba(244,205,120,0.4); }
.stat-val { font-size: 28px; color: var(--gold); font-weight: 700; margin-bottom: 6px; }
.stat-lbl { font-size: 13px; color: var(--grey-b); }

.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--nav-border);
    direction: rtl;
}
.admin-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--grey-b);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
}
.admin-tab:hover { color: var(--white); }
.admin-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.admin-panel { display: none; }
.admin-panel.active { display: block; }

.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    direction: rtl;
}
.admin-search {
    flex: 1;
    max-width: 360px;
    height: 40px;
    background: var(--card-bg);
    border: 1.5px solid transparent;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 15px;
    color: var(--white);
    font-family: inherit;
    direction: rtl;
    outline: none;
    transition: border-color 0.2s;
}
.admin-search:focus { border-color: var(--gold); }
.admin-search::placeholder { color: var(--grey-c); }

.table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    direction: rtl;
    text-align: right;
}
.admin-table th {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--grey-b);
    background: var(--bg);
    white-space: nowrap;
    border-bottom: 1px solid var(--nav-border);
}
.admin-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--grey-a);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,0.03); }
.admin-table tr.row-deleted td { opacity: 0.5; text-decoration: line-through; }

.table-loading {
    text-align: center;
    color: var(--grey-b);
    padding: 32px;
    font-size: 14px;
}

.table-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    flex-direction: row;
}
.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--grey-a);
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn-icon:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.btn-icon.red { color: var(--red); }
.btn-icon.green { color: var(--success); }
.btn-icon.gold { color: var(--gold); }

.admin-select {
    background: var(--card-bg);
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
    color: var(--grey-a);
    font-family: inherit;
    cursor: pointer;
    outline: none;
}
.admin-select:focus { border-color: var(--gold); }

.admin-slug-preview {
    font-size: 12px;
    color: var(--grey-c);
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    padding: 6px 12px;
    margin-top: 8px;
    direction: ltr;
    text-align: left;
}
.admin-slug-preview span:last-child { color: var(--gold); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.green { background: rgba(120,244,184,0.15); color: var(--success); }
.badge.red { background: rgba(244,120,120,0.15); color: var(--red); }
.badge.orange { background: rgba(244,180,80,0.15); color: #f4b450; }
.badge.gold { background: rgba(244,205,120,0.15); color: var(--gold); }

.admin-section-title {
    font-size: 17px;
    color: var(--white);
    margin-bottom: 12px;
    direction: rtl;
    padding-right: 4px;
}

/* Templates */
.templates-list { display: flex; flex-direction: column; gap: 10px; }
.template-item {
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px 20px;
    cursor: pointer;
    direction: rtl;
    transition: border-color 0.2s;
}
.template-item:hover { border-color: var(--gold); }
.template-key { font-size: 13px; color: var(--grey-b); margin-bottom: 4px; font-family: monospace; }
.template-subject { font-size: 15px; color: var(--white); margin-bottom: 4px; }
.template-updated { font-size: 12px; color: var(--grey-c); }

.template-editor .form-actions { margin-top: 20px; display: flex; gap: 10px; direction: rtl; }

.admin-forbidden {
    text-align: center;
    padding: 80px 20px;
    direction: rtl;
    color: var(--grey-a);
}
.admin-forbidden h2 { font-size: 28px; color: var(--red); margin-bottom: 12px; }

@media (max-width: 900px) {
    .admin-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
    .admin-stats { grid-template-columns: repeat(2, 1fr); }
    .admin-wrap { padding: 0 12px 80px; }
}

/* =====================================================
   ACCOUNT PAGE
   ===================================================== */
.account-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}
.account-header {
    display: flex;
    align-items: center;
    gap: 20px;
    direction: rtl;
    margin-bottom: 32px;
    padding: 24px;
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
}
.account-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--card-bg);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-name { font-size: 22px; color: var(--white); font-weight: 600; margin-bottom: 4px; }
.account-email { font-size: 14px; color: var(--grey-b); }

.account-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--nav-border);
    direction: rtl;
}
.account-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--grey-b);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
}
.account-tab:hover { color: var(--white); }
.account-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.account-panel { display: none; }
.account-panel.active { display: block; }

.account-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    direction: rtl;
    margin-bottom: 20px;
}
.account-panel-header h2 { font-size: 20px; color: var(--white); }

.account-form-card {
    max-width: 560px;
    margin: 0 auto;
}

.photo-upload-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    direction: rtl;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--grey-b);
    direction: rtl;
}
.empty-state p { font-size: 16px; margin-bottom: 16px; }

.file-label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.form-actions {
    display: flex;
    gap: 10px;
    direction: rtl;
    margin-top: 8px;
}


/* =============================================
   LEAFLET MAP — Dark theme overrides
   ============================================= */
.leaflet-container {
    background: #1a2230;
    font-family: inherit;
    direction: ltr;
}
.leaflet-control-attribution {
    font-size: 10px !important;
    background: rgba(29,35,45,0.8) !important;
    color: var(--grey-c) !important;
}
.leaflet-control-attribution a { color: var(--teal) !important; }
.leaflet-popup-content-wrapper {
    background: var(--card-bg);
    color: var(--text);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.leaflet-popup-tip { background: var(--card-bg); }
.leaflet-control-zoom a {
    background: var(--card-bg) !important;
    color: var(--text) !important;
    border-color: var(--border-color) !important;
}
.leaflet-control-zoom a:hover {
    background: var(--hover-bg) !important;
}
