/* CSS Variables */
:root {
    --primary-dark: #1a365d;
    --primary: #2c5282;
    --primary-light: #4a90a4;
    --accent: #c9a227;
    --accent-light: #d4af37;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border: #e2e8f0;
    --shadow: rgba(26, 54, 93, 0.1);
    --gradient-primary: linear-gradient(135deg, #1a365d 0%, #2c5282 50%, #4a90a4 100%);
    --gradient-subtle: linear-gradient(180deg, #f8fafc 0%, #edf2f7 100%);
    --gradient-hero: linear-gradient(135deg, rgba(26, 54, 93, 0.95) 0%, rgba(44, 82, 130, 0.9) 50%, rgba(74, 144, 164, 0.85) 100%);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    line-height: 1.3;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 900px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    order: 2;
}

.logo {
    width: 45px;
    height: 38px;
}

.site-title {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

.nav {
    display: flex;
    gap: 2.5rem;
    order: 1;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 0.25rem;
    position: relative;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: width 0.3s ease;
    border-radius: 1px;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary);
}

.nav-link.active::after,
.nav-link:hover::after {
    width: 100%;
}

/* Language Toggle */
.language-toggle {
    display: flex;
    gap: 0.25rem;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.lang-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.lang-btn.active {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.lang-btn .flag-icon {
    font-size: 1rem;
    line-height: 1;
}

/* Main Content */
.main-content {
    margin-top: 70px;
    min-height: calc(100vh - 70px);
}

.section {
    display: none;
    padding: 3rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--gradient-hero);
    border-radius: 20px;
    margin-bottom: 3rem;
    color: white;
}

.hero h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* Royal Houses Grid */
.royal-houses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.royal-house-card {
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid var(--border);
}

.royal-house-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(26, 54, 93, 0.15);
}

.card-image {
    height: 180px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.card-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(26, 54, 93, 0.3) 0%, transparent 50%);
}

.card-content {
    padding: 1.25rem;
}

.card-content h3 {
    font-size: 1.4rem;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.card-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* House Detail Section */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
    margin-bottom: 2rem;
    transition: color 0.3s ease;
}

.back-btn:hover {
    color: var(--primary-dark);
}

/* Hide back button in native app (using native iOS button instead) */
body.native-app .back-btn {
    display: none !important;
}

/* Hide web-only elements in native app (e.g., modal close buttons) */
body.native-app .web-only {
    display: none !important;
}

.house-header {
    text-align: center;
    margin-bottom: 2rem;
}

.house-header h2 {
    font-size: 2.5rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.house-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Tabs */
.house-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(44, 82, 130, 0.05);
}

.tab-btn.active {
    color: var(--primary);
    background: rgba(44, 82, 130, 0.1);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

/* House Info */
#house-info {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
}

#house-info h3 {
    font-size: 1.5rem;
    color: var(--primary-dark);
    margin: 2rem 0 1rem;
}

#house-info h3:first-child {
    margin-top: 0;
}

#house-info p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

#house-info ul {
    list-style: none;
    padding-left: 0;
}

#house-info li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

#house-info li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

/* Charities Content */
#charities-content {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
}

#charities-content h3 {
    font-size: 1.5rem;
    color: var(--primary-dark);
    margin: 2rem 0 1rem;
}

#charities-content h3:first-child {
    margin-top: 0;
}

#charities-content h4 {
    font-size: 1.2rem;
    color: var(--primary-dark);
    margin: 1.5rem 0 0.75rem;
}

#charities-content p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

#charities-content ul {
    list-style: none;
    padding-left: 0;
}

#charities-content li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

#charities-content li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

#charities-content li strong {
    color: var(--text-primary);
}

/* Family Tree - Modern Focus Navigation */
.family-tree-container {
    background: var(--gradient-subtle);
    border-radius: 16px;
    padding: 1.5rem;
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

/* Breadcrumb Navigation */
.tree-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: 10px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px var(--shadow);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.breadcrumb-item:hover {
    background: var(--primary-light);
    background: rgba(74, 144, 164, 0.1);
    color: var(--primary);
}

.breadcrumb-item.current {
    color: var(--primary-dark);
    font-weight: 600;
    cursor: default;
}

.breadcrumb-item.current:hover {
    background: transparent;
}

.breadcrumb-separator {
    color: var(--border);
    font-size: 0.75rem;
}

.breadcrumb-home {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Focus View Layout */
.tree-focus-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 1rem;
}

/* Tree Rows */
.tree-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

/* Parents Row */
.tree-parents-row {
    margin-bottom: 0;
}

.tree-parent-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.85;
}

.tree-parent-card:hover {
    opacity: 1;
    transform: translateY(-3px);
}

.tree-parent-card .card-inner {
    width: 100px;
    background: var(--surface);
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 3px 12px var(--shadow);
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.tree-parent-card:hover .card-inner {
    border-color: var(--primary-light);
    box-shadow: 0 6px 20px var(--shadow);
}

.tree-parent-card.monarch .card-inner {
    border-color: var(--accent);
}

.tree-parent-card .card-image {
    width: 100%;
    height: 100px;
    background-size: cover;
    background-position: center top;
    background-color: #e2e8f0;
    border-radius: 10px 10px 0 0;
}

.tree-parent-card .card-info {
    padding: 0.5rem;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tree-parent-card .card-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-dark);
    line-height: 1.2;
}

.tree-parent-card .card-relation {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Connectors */
.tree-connector {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
    position: relative;
}

.tree-connector::before {
    content: '';
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary-light), var(--primary));
    opacity: 0.4;
}

.tree-connector-parents::before {
    background: linear-gradient(to bottom, var(--primary), var(--primary-light));
}

.tree-connector.hidden {
    display: none;
}

/* Focus Row - Main Person + Spouse */
.tree-focus-row {
    padding: 1rem 0;
}

.tree-focus-couple {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.tree-focus-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tree-focus-card.main-focus {
    cursor: default;
}

.tree-focus-card.spouse-card:hover {
    transform: scale(1.02);
}

.tree-focus-card .card-inner {
    width: 160px;
    background: var(--surface);
    border-radius: 16px;
    overflow: visible;
    box-shadow: 0 8px 30px var(--shadow);
    border: 3px solid var(--primary);
    transition: all 0.3s ease;
}

.tree-focus-card.spouse-card .card-inner {
    width: 120px;
    border: 2px dashed var(--primary-light);
    box-shadow: 0 4px 15px var(--shadow);
    overflow: visible;
}

.tree-focus-card.spouse-card:hover .card-inner {
    border-color: var(--primary);
    border-style: solid;
}

.tree-focus-card.monarch .card-inner {
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(201, 162, 39, 0.25);
}

.tree-focus-card .card-image {
    width: 100%;
    height: 180px;
    background-size: cover;
    background-position: center top;
    background-color: #e2e8f0;
    position: relative;
    border-radius: 13px 13px 0 0;
}

.tree-focus-card.spouse-card .card-image {
    height: 130px;
    border-radius: 10px 10px 0 0;
}

.tree-focus-card.monarch .card-image::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='%23c9a227' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 16L3 5l5.5 5L12 4l3.5 6L21 5l-2 11H5z'/%3E%3C/svg%3E");
    background-size: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.tree-focus-card .card-info {
    padding: 1rem;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tree-focus-card.spouse-card .card-info {
    padding: 0.75rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tree-focus-card .card-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.tree-focus-card.spouse-card .card-name {
    font-size: 0.9rem;
}

.tree-focus-card .card-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.tree-focus-card.spouse-card .card-title {
    font-size: 0.7rem;
    margin-bottom: 0.25rem;
}

.tree-focus-card .card-dates {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
}

.tree-focus-card.spouse-card .card-dates {
    font-size: 0.7rem;
}

/* Marriage connector */
.tree-marriage-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.tree-marriage-line {
    width: 30px;
    height: 2px;
    background: var(--accent);
}

.tree-marriage-icon {
    font-size: 0.8rem;
}

/* Skilte ektefeller */
.tree-marriage-connector.divorced .tree-marriage-line {
    background: transparent;
    border-top: 2px dashed #999;
    height: 0;
}

.divorced-label {
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--surface);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    border: 1px dashed #ccc;
}

.tree-focus-card.divorced {
    opacity: 0.85;
}

.tree-focus-card.divorced .card-inner {
    border: 2px dashed #ccc;
    border-radius: 12px;
    overflow: visible;
}

.tree-focus-card.divorced .card-image {
    border-radius: 10px 10px 0 0;
}

.tree-focus-card.divorced .card-view-btn {
    border-radius: 0 0 10px 10px;
}

.tree-focus-card.divorced::after {
    content: '';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px dashed #999;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Seksjoner for skilte/nåværende ektefeller (desktop) */
.divorced-spouse-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.current-spouse-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Desktop: Horisontal layout for skilte ektefeller */
.tree-focus-couple.has-divorced {
    gap: 0.75rem;
}

/* Mellomstore skjermer */
@media (max-width: 900px) and (min-width: 769px) {
    .tree-focus-card .card-inner {
        width: 140px;
    }

    .tree-focus-card.spouse-card .card-inner {
        width: 100px;
    }

    .tree-focus-couple {
        gap: 1rem;
    }

    .tree-focus-couple.has-divorced {
        gap: 0.5rem;
    }

    .divorced-spouse-section {
        gap: 0.5rem;
    }

    .current-spouse-section {
        gap: 0.75rem;
    }

    .tree-marriage-connector .tree-marriage-line {
        width: 20px;
    }
}

/* Children Row */
.tree-children-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    max-width: 100%;
}

.tree-child-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tree-child-card:hover {
    transform: translateY(-5px);
}

.tree-child-card .card-inner {
    width: 90px;
    background: var(--surface);
    border-radius: 10px;
    overflow: visible;
    box-shadow: 0 3px 12px var(--shadow);
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.tree-child-card:hover .card-inner {
    border-color: var(--primary);
    box-shadow: 0 8px 25px var(--shadow);
}

.tree-child-card.monarch .card-inner {
    border-color: var(--accent);
}

.tree-child-card .card-image {
    width: 100%;
    height: 90px;
    background-size: cover;
    background-position: center top;
    background-color: #e2e8f0;
    border-radius: 8px 8px 0 0;
}

.tree-child-card .card-info {
    padding: 0.5rem;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tree-child-card .card-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-dark);
    line-height: 1.2;
}

.tree-child-card .card-dates {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* More children indicator */
.tree-more-children {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90px;
    height: 130px;
    background: var(--surface);
    border-radius: 10px;
    border: 2px dashed var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tree-more-children:hover {
    border-color: var(--primary);
    background: rgba(74, 144, 164, 0.05);
}

.tree-more-children span {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* Generation Info */
.tree-generation-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--shadow);
}

.generation-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.generation-dots {
    display: flex;
    gap: 0.4rem;
}

.generation-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s ease;
}

.generation-dot.active {
    background: var(--primary);
    transform: scale(1.2);
}

.generation-dot.monarch {
    background: var(--accent);
}

/* Empty state */
.tree-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
    text-align: center;
}

.tree-empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* View details button */
.card-view-btn {
    display: block;
    width: 100%;
    padding: 0.5rem;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 0 0 13px 13px;
}

.tree-focus-card.spouse-card .card-view-btn {
    border-radius: 0 0 8px 8px;
}

.card-view-btn:hover {
    background: var(--primary-dark);
}

/* Animation for transitions */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tree-focus-view > * {
    animation: fadeIn 0.3s ease-out;
}

/* Responsive - Family Tree Mobile */
@media (max-width: 768px) {
    .tree-focus-card .card-inner {
        width: 110px;
    }

    .tree-focus-card .card-image {
        height: 120px;
    }

    .tree-focus-card.spouse-card .card-inner {
        width: 90px;
    }

    .tree-focus-card.spouse-card .card-image {
        height: 100px;
    }

    .tree-child-card .card-inner {
        width: 70px;
    }

    .tree-child-card .card-image {
        height: 70px;
    }

    .tree-parent-card .card-inner {
        width: 80px;
    }

    .tree-parent-card .card-image {
        height: 80px;
    }

    /* Mobilvisning for par med skilte ektefeller */
    .tree-focus-couple {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
        row-gap: 1rem;
    }

    /* Skilte ektefeller vises i egen rad på mobil */
    .tree-focus-couple.has-divorced {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .tree-focus-couple.has-divorced .divorced-spouse-section {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        background: rgba(150, 150, 150, 0.08);
        border-radius: 12px;
        border: 1px dashed #ccc;
        width: auto;
        justify-content: center;
    }

    .tree-focus-couple.has-divorced .current-spouse-section {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* Skilsmisse-konnektor på mobil */
    .tree-marriage-connector.divorced {
        flex-direction: row;
    }

    .tree-marriage-connector.divorced .tree-marriage-line {
        width: 15px;
    }

    .divorced-label {
        font-size: 0.55rem;
        padding: 0.1rem 0.25rem;
    }

    /* Ekteskapskonnektor på mobil */
    .tree-marriage-connector .tree-marriage-line {
        width: 15px;
    }

    /* Skilt ektefelle-kort på mobil */
    .tree-focus-card.divorced .card-inner {
        width: 80px;
    }

    .tree-focus-card.divorced .card-image {
        height: 90px;
    }
}

/* Veldig små skjermer (under 400px) */
@media (max-width: 400px) {
    .tree-focus-card .card-inner {
        width: 95px;
    }

    .tree-focus-card .card-image {
        height: 100px;
    }

    .tree-focus-card.spouse-card .card-inner {
        width: 75px;
    }

    .tree-focus-card.spouse-card .card-image {
        height: 85px;
    }

    .tree-focus-card.divorced .card-inner {
        width: 70px;
    }

    .tree-focus-card.divorced .card-image {
        height: 80px;
    }

    .tree-focus-couple.has-divorced .divorced-spouse-section {
        padding: 0.4rem 0.5rem;
    }

    .tree-focus-couple.has-divorced .current-spouse-section {
        gap: 0.4rem;
    }

    .tree-marriage-connector .tree-marriage-line,
    .tree-marriage-connector.divorced .tree-marriage-line {
        width: 12px;
    }

    .divorced-label {
        font-size: 0.5rem;
        padding: 0.08rem 0.2rem;
    }

    .tree-child-card .card-inner {
        width: 60px;
    }

    .tree-child-card .card-image {
        height: 60px;
    }

    .tree-parent-card .card-inner {
        width: 70px;
    }

    .tree-parent-card .card-image {
        height: 70px;
    }

    .tree-focus-card .card-name {
        font-size: 0.75rem;
    }

    .tree-focus-card .card-title {
        font-size: 0.6rem;
    }

    .tree-focus-card.spouse-card .card-name {
        font-size: 0.65rem;
    }

    .card-view-btn {
        padding: 0.35rem;
        font-size: 0.6rem;
    }
}

/* Members Grid */
.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.member-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
    border: 1px solid var(--border);
}

.member-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(26, 54, 93, 0.15);
}

.member-card.monarch {
    border-color: var(--accent);
}

.member-image {
    width: 100%;
    height: 220px;
    background-size: cover;
    background-position: center top;
    background-color: #e2e8f0;
}

.member-info {
    padding: 1rem;
}

.member-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.member-card.monarch .member-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.member-card.monarch .member-name::after {
    content: '';
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='%23c9a227' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 16L3 5l5.5 5L12 4l3.5 6L21 5l-2 11H5z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.member-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.member-dates {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.member-children {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(44, 82, 130, 0.1);
    border-radius: 10px;
    display: inline-block;
}

/* News Section */
#news-section h2 {
    text-align: center;
    font-size: 2.5rem;
    color: var(--primary-dark);
    margin-bottom: 2rem;
}

.news-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.filter-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

/* Pull to Refresh */
.pull-to-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    height: 0;
    overflow: hidden;
    transition: height 0.2s ease;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.pull-to-refresh.pulling {
    height: 50px;
}

.pull-to-refresh.refreshing {
    height: 50px;
}

.ptr-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.pull-to-refresh.pulling .ptr-spinner {
    opacity: 1;
    transform: rotate(0deg);
}

.pull-to-refresh.refreshing .ptr-spinner {
    opacity: 1;
    animation: ptr-spin 0.8s linear infinite;
}

@keyframes ptr-spin {
    to { transform: rotate(360deg); }
}

.ptr-text {
    transition: opacity 0.2s ease;
}

.pull-to-refresh.refreshing .ptr-text::after {
    content: '...';
    animation: ptr-dots 1s steps(4, end) infinite;
}

@keyframes ptr-dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.news-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
    border: 1px solid var(--border);
}

.news-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(26, 54, 93, 0.15);
}

.news-image {
    height: 180px;
    background-size: cover;
    background-position: center 30%;
    position: relative;
}

.news-tag {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--gradient-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.news-content {
    padding: 1.25rem;
}

.news-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.news-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.news-excerpt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Calendar Section */
#calendar-section h2 {
    text-align: center;
    font-size: 2.5rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.calendar-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.calendar-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid var(--border);
}

.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.calendar-nav h3 {
    font-size: 1.5rem;
    color: var(--primary-dark);
}

.calendar-nav-btn {
    background: none;
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: all 0.3s ease;
}

.calendar-nav-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.calendar-grid {
    margin-bottom: 2rem;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.calendar-header span {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.calendar-day:hover {
    background: rgba(44, 82, 130, 0.05);
}

.calendar-day.other-month {
    color: var(--text-muted);
    opacity: 0.5;
}

.calendar-day.today {
    background: var(--gradient-primary);
    color: white;
}

.calendar-day.selected {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
    background: rgba(44, 82, 130, 0.1);
}

.calendar-day.selected.today {
    outline-color: white;
}

.calendar-day.has-event {
    background: rgba(212, 175, 55, 0.15);
    font-weight: 600;
}

/* Flagg-visning på kalenderdager */
.calendar-day-flags {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    gap: 1px;
}

.calendar-day.today.has-event {
    background: var(--gradient-primary);
}

.events-list {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

.events-list h4 {
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
}

.events-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.events-header h4 {
    margin-bottom: 0;
    text-transform: capitalize;
}

.show-all-events-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.show-all-events-btn:hover {
    background: var(--primary);
    color: white;
}

.no-events-message {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1rem;
    font-style: italic;
}

.event-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    background: var(--gradient-subtle);
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--primary);
}

.event-date-box {
    text-align: center;
    min-width: 50px;
}

.event-date-day {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.event-date-month {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.event-date-time {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 500;
    margin-top: 0.25rem;
}

.event-details h5 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.event-details p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.event-house {
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

/* Fargekoding for kongehus */
.event-item.house-norway {
    border-left-color: #1a365d;
}
.event-item.house-norway .event-date-day {
    color: #1a365d;
}
.event-item.house-norway .event-house {
    background: rgba(26, 54, 93, 0.1);
    color: #1a365d;
}

.event-item.house-uk {
    border-left-color: #1d6f42;
}
.event-item.house-uk .event-date-day {
    color: #1d6f42;
}
.event-item.house-uk .event-house {
    background: rgba(29, 111, 66, 0.1);
    color: #1d6f42;
}

.event-item.house-sweden {
    border-left-color: #006aa7;
}
.event-item.house-sweden .event-date-day {
    color: #006aa7;
}
.event-item.house-sweden .event-house {
    background: rgba(0, 106, 167, 0.1);
    color: #006aa7;
}

.event-item.house-denmark {
    border-left-color: #c60c30;
}
.event-item.house-denmark .event-date-day {
    color: #c60c30;
}
.event-item.house-denmark .event-house {
    background: rgba(198, 12, 48, 0.1);
    color: #c60c30;
}

.event-item.house-netherlands {
    border-left-color: #ff6600;
}
.event-item.house-netherlands .event-date-day {
    color: #ff6600;
}
.event-item.house-netherlands .event-house {
    background: rgba(255, 102, 0, 0.1);
    color: #ff6600;
}

.event-item.house-spain {
    border-left-color: #c60b1e;
}
.event-item.house-spain .event-date-day {
    color: #c60b1e;
}
.event-item.house-spain .event-house {
    background: rgba(198, 11, 30, 0.1);
    color: #c60b1e;
}

.event-item.house-monaco {
    border-left-color: #ce1126;
}
.event-item.house-monaco .event-date-day {
    color: #ce1126;
}
.event-item.house-monaco .event-house {
    background: rgba(206, 17, 38, 0.1);
    color: #ce1126;
}

.event-item.house-belgium {
    border-left-color: #2d2926;
}
.event-item.house-belgium .event-date-day {
    color: #2d2926;
}
.event-item.house-belgium .event-house {
    background: rgba(45, 41, 38, 0.1);
    color: #2d2926;
}

/* Flagg i event-items */
.event-flag {
    font-size: 1rem;
    margin-right: 0.25rem;
}

/* Modal */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 54, 93, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 20px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    position: relative;
    animation: slideUp 0.3s ease;
    outline: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* Native app: adjust modal z-index */
body.native-app .modal {
    z-index: 9999;
}

/* Native app: extra padding for modal content (tab bar at bottom, back button at top) */
body.native-app .modal-content {
    padding-top: calc(env(safe-area-inset-top, 44px) + 60px);
}

body.native-app .news-modal-image,
body.native-app .person-image-large {
    border-radius: 0;
}

body.native-app .news-modal-details,
body.native-app .person-details {
    padding-bottom: calc(3rem + 100px);
}

.modal-body {
    display: flex;
    flex-direction: column;
}

.person-image-large {
    width: 100%;
    height: 320px;
    background-size: cover;
    background-position: center top;
    background-color: #f8f4e8;
    border-radius: 20px 20px 0 0;
}

.person-details {
    padding: 2rem;
}

.person-details h2 {
    font-size: 2rem;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
}

.person-title {
    font-size: 1rem;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.person-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--gradient-subtle);
    border-radius: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span:last-child {
    font-weight: 500;
    color: var(--text-primary);
}

.person-bio {
    color: var(--text-secondary);
    line-height: 1.8;
}

/* News Modal */
.news-modal-content {
    max-width: 800px;
}

.news-modal-body {
    display: flex;
    flex-direction: column;
}

.news-modal-image {
    width: 100%;
    height: 350px;
    background-size: cover;
    background-position: center 25%;
    background-color: #f8f4e8;
    border-radius: 20px 20px 0 0;
}

.news-modal-details {
    padding: 2rem;
}

.news-modal-tag {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

.news-modal-date {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.news-modal-details h2 {
    font-size: 1.75rem;
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    line-height: 1.3;
}

.news-modal-text {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1.05rem;
    max-height: 400px;
    overflow-y: auto;
}

.news-modal-text p {
    margin-bottom: 1rem;
}

.news-modal-text p:last-child {
    margin-bottom: 0;
}

.news-modal-text img {
    width: 100%;
    max-width: 500px;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
}

/* News card hover effect */
.news-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.news-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(26, 54, 93, 0.15);
}

/* App Download Banner */
.app-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #8b6914, #c9a84c, #8b6914);
    padding: 8px 20px;
    z-index: 1001;
}

body.has-app-banner .header {
    top: 40px;
}

body.has-app-banner .main-content {
    margin-top: 110px;
}

.app-banner-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.app-banner-apple {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.9);
}

.app-banner-text {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.app-banner-btn {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    padding: 5px 14px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: background 0.2s;
}

.app-banner-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.app-banner-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    margin-left: 4px;
    transition: color 0.2s;
}

.app-banner-close:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* Footer */
.footer {
    background: var(--primary-dark);
    color: white;
    padding: 2rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-logo span {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 600;
}

.logo-small {
    width: 35px;
    height: 30px;
}

.logo-small path,
.logo-small circle {
    fill: white;
}

.footer p {
    font-size: 0.85rem;
    opacity: 0.7;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.footer-links a {
    color: white;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

.footer-divider {
    opacity: 0.4;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .header-inner {
        flex-direction: column;
        gap: 0.75rem;
        max-width: 100%;
    }

    .logo-container {
        order: 1;
    }

    .nav {
        order: 2;
        gap: 1.5rem;
    }

    .header-actions {
        order: 3;
        position: absolute;
        top: 0.75rem;
        right: 1rem;
    }

    .lang-btn span:not(.flag-icon) {
        display: none;
    }

    .lang-btn {
        padding: 0.3rem 0.5rem;
    }

    .main-content {
        margin-top: 110px;
    }

    body.has-app-banner .main-content {
        margin-top: 162px;
    }

    .section {
        padding: 2rem 1rem;
    }

    .hero {
        padding: 2rem 1rem;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .royal-houses-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .house-tabs {
        flex-wrap: wrap;
    }

    .news-filters {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
    }

    .filter-btn {
        flex-shrink: 0;
    }

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

    .modal {
        padding: 0;
        align-items: flex-start;
    }

    .modal-content {
        max-height: 100dvh;
        height: auto;
        min-height: 100dvh;
        border-radius: 0;
        margin: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .person-image-large {
        height: 250px;
        border-radius: 0;
        flex-shrink: 0;
    }

    .person-details {
        padding: 1.5rem;
        padding-top: 1rem;
        padding-bottom: 3rem;
    }

    .person-info {
        grid-template-columns: 1fr;
    }

    .news-modal-content {
        height: auto;
        min-height: 100dvh;
    }

    .news-modal-image {
        height: 200px;
        border-radius: 0;
        flex-shrink: 0;
    }

    .news-modal-details {
        padding: 1.5rem;
        padding-bottom: 3rem;
    }

    .news-modal-details h2 {
        font-size: 1.35rem;
    }

    .news-modal-text {
        max-height: none;
    }

    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Residence Modal */
.residence-modal-content {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.residence-modal-body {
    padding: 0;
}

.residence-header {
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid var(--border);
}

.residence-header h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.residence-meta {
    display: flex;
    gap: 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.residence-gallery {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    padding: 1rem;
    background: var(--background);
}

.gallery-item {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 8px;
}

.gallery-item.main-image {
    grid-column: span 3;
    grid-row: span 2;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 0.75rem 0.75rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-caption {
    opacity: 1;
}

.residence-info {
    padding: 1.5rem 2rem 2rem;
}

.residence-facts {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.residence-fact {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.fact-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.residence-fact span:not(.fact-label) {
    font-weight: 500;
    color: var(--primary);
}

.residence-description {
    line-height: 1.8;
    color: var(--text);
}

.residence-description p {
    margin-bottom: 1rem;
}

.residence-description p:last-child {
    margin-bottom: 0;
}

/* Clickable residence link */
.residence-link {
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(26, 54, 93, 0.3);
    text-underline-offset: 2px;
    transition: all 0.2s ease;
}

.residence-link:hover {
    text-decoration-color: var(--primary);
    color: var(--primary-dark, #0f2942);
}

/* Responsive residence modal */
@media (max-width: 768px) {
    .residence-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .residence-header {
        padding: 1.5rem;
    }

    .residence-header h2 {
        font-size: 1.5rem;
    }

    .residence-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .residence-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.25rem;
        padding: 0.5rem;
    }

    .gallery-item.main-image {
        grid-column: span 2;
        grid-row: span 1;
    }

    .gallery-caption {
        opacity: 1;
        font-size: 0.7rem;
        padding: 1.5rem 0.5rem 0.5rem;
    }

    .residence-info {
        padding: 1rem 1.5rem 2rem;
    }

    .residence-facts {
        flex-direction: column;
        gap: 1rem;
    }
}

/* ===================== */
/* Image Lightbox        */
/* ===================== */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.lightbox.active {
    display: flex;
}

.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    z-index: 3001;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.lightbox-content img {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

.lightbox-caption {
    color: white;
    text-align: center;
    margin-top: 1rem;
    font-size: 1rem;
    max-width: 600px;
    transition: opacity 0.3s ease;
}

/* Make about images look clickable */
.about-image img,
.gallery-item img {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.about-image img:hover,
.gallery-item img:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* ===================== */
/* About Section Styles  */
/* ===================== */

.about-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.about-header {
    text-align: center;
    margin-bottom: 3rem;
}

.about-header h2 {
    font-size: 2.5rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.about-tagline {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-style: italic;
}

.about-content {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow);
    overflow: hidden;
}

.about-story {
    padding: 2.5rem;
}

.about-intro {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.crown-icon {
    flex-shrink: 0;
    width: 80px;
    height: 50px;
    color: var(--accent);
}

.crown-icon svg {
    width: 100%;
    height: 100%;
}

.lead-text {
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--text-primary);
    font-weight: 500;
}

.about-section-block {
    margin-bottom: 2rem;
}

.about-section-block:last-of-type {
    margin-bottom: 2.5rem;
}

.about-section-block h3 {
    font-size: 1.4rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.about-section-block p {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.about-section-block p:last-of-type {
    margin-bottom: 0;
}

.about-image {
    margin-top: 1.5rem;
    text-align: center;
}

.about-image img {
    max-width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow);
}

.about-image .image-caption {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.75rem;
    margin-bottom: 0;
}

/* About Gallery */
.about-gallery {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.about-gallery h3 {
    font-size: 1.4rem;
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.gallery-grid .gallery-item {
    text-align: center;
    position: relative;
    aspect-ratio: unset;
    overflow: visible;
}

.gallery-grid .gallery-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 3px 10px var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-grid .gallery-item img:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 20px var(--shadow);
}

.gallery-grid .gallery-item p.image-caption {
    font-size: 0.9rem !important;
    color: var(--text-secondary) !important;
    font-style: italic;
    margin-top: 0.75rem !important;
    margin-bottom: 0.5rem;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

.features-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--gradient-subtle);
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.feature-icon {
    font-size: 1.5rem;
}

.feature-item span:last-child {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.about-footer {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.about-footer p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.about-footer .signature {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.25rem;
    font-style: italic;
    color: var(--primary-dark);
    font-weight: 600;
}

/* About Section Responsive */
@media (max-width: 768px) {
    .about-container {
        padding: 1rem;
    }

    .about-header h2 {
        font-size: 2rem;
    }

    .about-story {
        padding: 1.5rem;
    }

    .about-intro {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .crown-icon {
        width: 70px;
        height: 44px;
    }

    .features-list {
        grid-template-columns: 1fr;
    }

    .about-section-block h3 {
        font-size: 1.25rem;
    }
}

/* Calendar flags mobile */
@media (max-width: 768px) {
    .calendar-day-flags {
        font-size: 0.65rem;
        bottom: 1px;
        gap: 0px;
    }
}

/* ===================== */
/* Bottom Tab Bar (App)  */
/* ===================== */

.bottom-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(49px + env(safe-area-inset-bottom, 34px));
    padding-bottom: env(safe-area-inset-bottom, 34px);
    z-index: 1000;

    /* Liquid Glass effect */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);

    display: none;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 8px;
}

.bottom-tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    color: #8E8E93;
    text-decoration: none;
    transition: color 0.2s ease;
    min-width: 60px;
}

.bottom-tab-item .tab-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

.bottom-tab-item .tab-label {
    font-size: 10px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s ease;
    height: 0;
    overflow: hidden;
}

.bottom-tab-item.active {
    color: #1a365d;
}

.bottom-tab-item.active .tab-label {
    opacity: 1;
    transform: translateY(0);
    height: auto;
}

.bottom-tab-item.active .tab-icon {
    stroke-width: 2;
}

/* Body adjustments when bottom tabs are visible */
body.has-bottom-tabs {
    padding-bottom: calc(83px + env(safe-area-inset-bottom, 0px));
}

body.has-bottom-tabs .footer {
    margin-bottom: calc(83px + env(safe-area-inset-bottom, 0px));
}

body.has-bottom-tabs .main-content {
    margin-top: 0;
    padding-top: calc(env(safe-area-inset-top, 20px) + 10px);
}

/* Hide top header in app mode */
.header.app-header-hidden {
    display: none;
}

/* App-only hero adjustments */
body.has-bottom-tabs .hero {
    margin-top: 0;
}

/* ===================== */
/* Native App Mode       */
/* ===================== */

body.native-app {
    /* Remove top margin since header is hidden */
    padding-bottom: calc(83px + env(safe-area-inset-bottom, 0px));
}

body.native-app .main-content {
    margin-top: 0;
    padding-top: calc(env(safe-area-inset-top, 20px) + 50px);
}

/* Language toggle in native app mode */
body.native-app .app-language-toggle {
    position: fixed;
    top: calc(env(safe-area-inset-top, 44px) + 60px);
    right: 1rem;
    z-index: 100;
    display: flex !important;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.native-app .footer {
    margin-bottom: calc(83px + env(safe-area-inset-bottom, 0px));
}

/* Hide elements in native app that are only needed on web */
body.native-app .footer,
body.native-app .language-toggle,
body.native-app .app-language-toggle {
    display: none !important;
}

/* Support section: hide by default in native app (not shown when scrolling) */
body.native-app #support-section {
    display: none !important;
}

/* Support section: show when explicitly navigated to via More menu */
body.native-app #support-section.active {
    display: block !important;
}

/* ===================== */
/* Support Section       */
/* ===================== */

/* Hide support section on web */
.app-only-section {
    display: none !important;
}

body.native-app .app-only-section {
    display: block !important;
}

body.native-app .app-only-section.active {
    display: block !important;
}

.support-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.support-header {
    text-align: center;
    margin-bottom: 2rem;
}

.support-header h2 {
    font-size: 2rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.support-tagline {
    color: var(--text-muted);
    font-size: 1rem;
}

.support-content {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px var(--shadow);
}

.support-block {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.support-block:last-of-type {
    border-bottom: none;
    margin-bottom: 1rem;
    padding-bottom: 0;
}

.support-block h3 {
    font-size: 1.25rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
}

.support-block p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.faq-item {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.faq-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.faq-question {
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.faq-answer {
    color: var(--text-secondary);
}

.features-list-support {
    list-style: none;
    padding: 0;
}

.features-list-support li {
    padding: 0.75rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

.features-list-support li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1.1rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.features-list-support li strong {
    color: var(--primary-dark);
}

.support-contact {
    background: var(--gradient-subtle);
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 1.5rem;
}

.support-contact h3 {
    font-size: 1.25rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
}

.support-contact p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.support-contact a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.support-contact a:hover {
    text-decoration: underline;
}

.response-time {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

.support-updated {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Position news-image relative */
.news-image {
    position: relative;
}

/* ===================== */
/* Push Notifications    */
/* ===================== */

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    order: 3;
}

.push-bell-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.push-bell-btn:hover {
    background: var(--background);
    color: var(--primary);
}

.push-bell-btn.subscribed {
    color: var(--primary);
}

.bell-active-dot {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid white;
}

.push-bell-btn.subscribed .bell-active-dot {
    display: block;
}

/* Push Notification Prompt Banner */
.push-prompt {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    width: calc(100% - 2rem);
    max-width: 480px;
    animation: pushPromptSlideUp 0.4s ease;
}

@keyframes pushPromptSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.push-prompt-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    text-align: center;
}

.push-prompt-icon {
    color: var(--primary);
    flex-shrink: 0;
}

.push-prompt-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin: 0;
}

.push-prompt-buttons {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.push-prompt-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.push-prompt-yes {
    background: var(--primary);
    color: white;
}

.push-prompt-yes:hover {
    background: var(--primary-dark);
}

.push-prompt-no {
    background: var(--background);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.push-prompt-no:hover {
    background: var(--border);
}

@media (max-width: 768px) {
    .push-bell-btn {
        width: 32px;
        height: 32px;
    }

    .push-bell-btn svg {
        width: 18px;
        height: 18px;
    }

    .push-prompt {
        bottom: 1rem;
        width: calc(100% - 1rem);
    }
}
