@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Aref+Ruqaa:wght@400;700&family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
    --bg-color: #fdfcf9;
    --bg-gradient: radial-gradient(circle at 30% 20%, #ffffff, #f7f3ea 70%);
    --glass-bg: rgba(255, 255, 255, 0.88);
    --glass-border: rgba(212, 175, 55, 0.3);
    --glass-shadow: 0 8px 40px 0 rgba(0,0,0,0.05), 0 0 30px rgba(212, 175, 55, 0.1);
    --text-main: #000000;
    --text-muted: #000000;
    --primary: #c29d27;
    --primary-hover: #e0bb40;
    --primary-glow: rgba(194, 157, 39, 0.15);
    --secondary: #0d9467;
    --secondary-hover: #0a7551;
    --danger: #dc2626;
    --node-bg: #ffffff;
    --node-border: #c29d27;
    --line-color: #d4c28a;
    --highlight: #c29d27;
    --card-gradient: linear-gradient(145deg, #ffffff, #faf7f0);
    --card-glow: 0 0 20px rgba(194, 157, 39, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background: var(--bg-color);
    background-image: 
        radial-gradient(circle at 15% 30%, rgba(212, 175, 55, 0.06), transparent 35%),
        radial-gradient(circle at 85% 70%, rgba(212, 175, 55, 0.04), transparent 35%),
        radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.02), transparent 50%);
    color: var(--text-main);
    min-height: 100dvh;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    touch-action: manipulation;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(212, 175, 55, 0.01) 2px,
        rgba(212, 175, 55, 0.01) 4px
    );
    pointer-events: none;
    z-index: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Amiri', serif;
    font-weight: 700;
}

p, span, div, li, a, button, input, textarea {
    font-weight: 400;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: 'Amiri', serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.3px;
}

.primary-btn {
    background: linear-gradient(135deg, #d4af37, #aa8529);
    color: #fff;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    border: none;
}

.primary-btn:hover {
    background: linear-gradient(135deg, #e8c84a, #b8952e);
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.4);
}

.secondary-btn {
    background-color: var(--secondary);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.secondary-btn:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-2px);
}

.outline-btn {
    background-color: rgba(0, 0, 0, 0.5);
    color: var(--primary);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.outline-btn:hover {
    background-color: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.5);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.1);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.3s, transform 0.3s;
}

.icon-btn:hover {
    color: var(--highlight);
    transform: scale(1.1);
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 14px;
    padding: 2rem;
}

.modern-input {
    width: 100%;
    padding: 0.65rem 0.8rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: 'Tajawal', sans-serif;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    resize: vertical;
}

.modern-input:focus {
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.08);
}

.modern-input::placeholder {
    color: var(--text-muted);
}

.input-group {
    margin-bottom: 1.2rem;
    position: relative;
    text-align: right;
}

.input-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
}

.view-container {
    display: none;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    width: 100dvw;
}

.view-container.active {
    display: flex;
    flex-direction: column;
}

.glass-header {
    background: linear-gradient(to bottom, rgba(255,255,255,0.98), rgba(255,255,255,0.85));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding: 0.8rem 2rem;
    padding: 0.8rem max(2rem, env(safe-area-inset-right)) 0.8rem max(2rem, env(safe-area-inset-left));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    box-shadow: 0 4px 30px rgba(0,0,0,0.05), 0 1px 0 rgba(212, 175, 55, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.logo-wrapper {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1.5px solid rgba(212, 175, 55, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.1);
}

.logo-icon {
    font-size: 1.4rem;
    color: var(--primary);
    opacity: 0.8;
}

.header-left h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 2px;
    line-height: 1;
    color: var(--primary);
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 2rem;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 380px;
}

.search-box i {
    position: absolute;
    right: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(212, 175, 55, 0.6);
    font-size: 0.9rem;
    transition: color 0.3s;
}

.search-box:focus-within i {
    color: var(--primary);
}

.search-box input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 30px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: 'Tajawal', sans-serif;
    outline: none;
    transition: all 0.35s ease;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
}

.search-box input::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-box input:focus {
    border-color: rgba(212, 175, 55, 0.6);
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.15), inset 0 2px 8px rgba(0,0,0,0.05);
}

.search-results {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 20;
    display: none;
    box-shadow: 0 15px 40px rgba(0,0,0,0.1), 0 0 30px rgba(212, 175, 55, 0.1);
    padding: 0.5rem;
}

.search-results.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

.search-item {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 2px;
}

.search-item:last-child {
    margin-bottom: 0;
}

.search-item:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--primary);
    padding-right: 1.3rem;
}

.header-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.header-right .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.8);
    border-color: rgba(212, 175, 55, 0.3);
    color: var(--text-muted);
}

.header-right .btn:hover {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.4);
    color: var(--primary);
}

.header-right .btn i {
    font-size: 0.85rem;
}

/* ========== Large Screens (1200px+) ========== */
@media (min-width: 1200px) {
    .list-container { max-width: 800px; }
    .modal-panel { max-width: 520px; }
}

/* ========== Medium Screens / Tablets (769px - 1199px) ========== */
@media (min-width: 769px) and (max-width: 1199px) {
    .glass-header { padding: 0.7rem 1.2rem; }
    .search-box { max-width: 250px; }
}


/* ========== Small Screens / Mobile (768px and below) ========== */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: flex !important; }
    
    .glass-header { padding: 0.5rem 0.6rem; flex-wrap: nowrap; gap: 0.3rem; }
    .header-left h2 { font-size: 0.95rem; }
    .header-left .subtitle { display: none; }
    .header-left { gap: 0.5rem; }
    .header-center { padding: 0 0.5rem; }
    .header-right { gap: 0.2rem; }
    .header-right .btn { padding: 0.3rem 0.5rem; font-size: 0.7rem; border-radius: 5px; min-width: 0; }
    .header-right .btn i { font-size: 0.7rem; }
    
    .search-box { max-width: 120px; }
    .search-box input { padding: 0.35rem 0.6rem 0.35rem 1.6rem; font-size: 0.75rem; border-radius: 20px; }
    .search-box i { right: 0.6rem; font-size: 0.65rem; }
    .search-results { max-height: 200px; }
    .search-item { padding: 0.5rem 0.8rem; font-size: 0.95rem; }
    
    .logo-wrapper { width: 30px; height: 30px; flex-shrink: 0; }
    .logo-icon { font-size: 1rem; }
    
    .control-btn { width: 32px; height: 32px; font-size: 0.75rem; border-radius: 8px; }
    .fab { width: 44px; height: 44px; font-size: 1.2rem; bottom: 0.8rem; right: 0.8rem; }
    .tree-controls { bottom: 0.8rem; left: 0.8rem; gap: 0.3rem; }
    
    .modal-panel { margin: 0.5rem; padding: 1rem; max-width: 95vw; }
    .modal-actions .btn { padding: 0.5rem 0.8rem; font-size: 0.85rem; }
    .modal-header h3 { font-size: 1rem; }
    
    .list-wrapper { padding: 0.8rem; }
    .list-container { max-width: 100%; gap: 0.4rem; }
    .list-item { padding: 0.6rem 0.8rem; border-radius: 8px; }
    .list-item-actions { opacity: 1; }
    .list-item-actions button { width: 28px; height: 28px; font-size: 0.65rem; }
    .list-item-info { gap: 0.6rem; }
    .list-item-avatar { width: 36px; height: 36px; font-size: 0.9rem; }
    .list-item-details h4 { font-size: 1rem; }
    
    .toast-notification { font-size: 0.8rem; padding: 0.5rem 1rem; bottom: 1.5rem; }
    
    .fab-close-preview { top: 0.8rem; left: 0.8rem; padding: 0.4rem 0.8rem; font-size: 0.8rem; }
    
    .action-menu-inline { min-width: 160px !important; }
}

/* ========== Small Mobile (480px and below) ========== */
@media (max-width: 480px) {
    .glass-header { padding: 0.4rem 0.4rem; }
    .header-left h2 { font-size: 0.8rem; }
    .header-right .btn { padding: 0.2rem 0.4rem; font-size: 0.6rem; border-radius: 4px; }
    .header-right .btn i { font-size: 0.6rem; }
    .search-box { max-width: 80px; }
    .search-box input { padding: 0.25rem 0.4rem 0.25rem 1.4rem; font-size: 0.7rem; }
    .search-box i { right: 0.5rem; font-size: 0.55rem; }
    .logo-wrapper { width: 26px; height: 26px; }
    .logo-icon { font-size: 0.85rem; }
    .fab { width: 38px; height: 38px; font-size: 1rem; bottom: 0.6rem; right: 0.6rem; }
    .control-btn { width: 28px; height: 28px; font-size: 0.65rem; }
    .tree-controls { bottom: 0.6rem; left: 0.6rem; gap: 0.2rem; }
    .modal-panel { margin: 0.3rem; padding: 0.8rem; }
    .list-item-avatar { width: 30px; height: 30px; font-size: 0.8rem; }
    .list-item-details h4 { font-size: 0.9rem; }
    .list-item-details p { font-size: 0.7rem; }
}

/* ========== Landscape Mobile ========== */
@media (max-height: 500px) and (orientation: landscape) {
    .glass-header { padding: 0.3rem 0.5rem; }
    .header-left h2 { font-size: 0.8rem; }
    .logo-wrapper { width: 26px; height: 26px; }
    .logo-icon { font-size: 0.85rem; }
    .fab { width: 36px; height: 36px; font-size: 0.9rem; bottom: 0.4rem; right: 0.4rem; }
    .tree-controls { bottom: 0.4rem; left: 0.4rem; }
    .control-btn { width: 26px; height: 26px; font-size: 0.6rem; }
    .modal-panel { max-height: 85vh; overflow-y: auto; }
}

/* ========== Tablet Landscape ========== */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .glass-header { padding: 0.6rem 1rem; }
    .search-box { max-width: 200px; }
}


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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tree-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.tree-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse at 50% 0%, rgba(212, 175, 55, 0.03), transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(212, 175, 55, 0.02), transparent 50%);
    pointer-events: none;
}

.tree-wrapper:active {
    cursor: grabbing;
}

.d3-container {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

/* ===== SVG Tree Nodes (cross-platform, works on iOS) ===== */
.royal-svg-rect {
    cursor: pointer;
    transition: stroke 0.25s ease, stroke-width 0.25s ease;
}

.royal-svg-text {
    font-family: 'Aref Ruqaa', serif;
    pointer-events: none;
    transition: fill 0.25s ease;
}

.node:hover .royal-svg-rect {
    stroke: #e0bb40;
    stroke-width: 2;
}

.node:hover .royal-svg-text {
    fill: #e0bb40;
}

.node.has-children .royal-svg-rect {
    stroke: #b8942e;
    stroke-width: 2;
}

.node.highlighted .royal-svg-rect {
    stroke: #ffd700;
    stroke-width: 2.5;
    fill: #1a1406;
}

.node.highlighted .royal-svg-text {
    fill: #ffffff;
}

.node.dragging .royal-svg-rect {
    opacity: 0.7;
    stroke: #10b981;
    stroke-width: 2;
}

.link {
    fill: none;
    stroke: var(--line-color);
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.6;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.8));
    transition: all 0.4s ease;
}

.link.highlighted {
    stroke: var(--highlight);
    stroke-width: 4px;
    opacity: 1;
    filter: drop-shadow(0 0 12px var(--primary)) drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}

.tree-controls {
    position: fixed;
    bottom: 1.5rem;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    left: 1.5rem;
    left: calc(1.5rem + env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 100;
}

.control-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.3);
    backdrop-filter: blur(8px);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s;
}

.control-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.4);
    color: var(--primary);
    transform: scale(1.05);
}

.fab {
    position: fixed;
    bottom: 1.5rem;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    right: 1.5rem;
    right: calc(1.5rem + env(safe-area-inset-right));
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d4af37, #aa8529);
    color: #fff;
    font-size: 1.5rem;
    border: none;
    box-shadow: 0 4px 25px rgba(212, 175, 55, 0.3), 0 0 40px rgba(212, 175, 55, 0.08);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 35px rgba(212, 175, 55, 0.5), 0 0 60px rgba(212, 175, 55, 0.12);
}

.fab:active {
    transform: scale(0.95);
}

.list-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.list-wrapper::-webkit-scrollbar { width: 6px; }
.list-wrapper::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.2); border-radius: 3px; }

.list-container {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-bottom: 2rem;
}

.list-item {
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(252,250,245,0.95));
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-right: 3px solid rgba(212, 175, 55, 0.5);
    border-radius: 10px;
    padding: 1rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.list-item:hover {
    transform: translateX(-3px);
    border-color: rgba(212, 175, 55, 0.3);
    border-right-color: rgba(212, 175, 55, 0.6);
    box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 20px rgba(212, 175, 55, 0.05);
}

.list-item-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.list-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(212, 175, 55, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.list-item-details h4 {
    font-size: 1.2rem;
    font-family: 'Aref Ruqaa', serif;
    color: var(--text-main);
    margin-bottom: 2px;
    font-weight: 400;
}

.list-item-details p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
}

.list-item-actions {
    display: flex;
    gap: 0.4rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.list-item:hover .list-item-actions {
    opacity: 1;
}

.list-item-actions button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s;
    background: rgba(0,0,0,0.6);
    font-size: 0.85rem;
}

.btn-edit-list { color: var(--primary); border-color: rgba(212, 175, 55, 0.2); }
.btn-edit-list:hover { background: rgba(212, 175, 55, 0.15); color: var(--primary-hover); }

.btn-add-list { color: var(--secondary); border-color: rgba(16, 185, 129, 0.2); }
.btn-add-list:hover { background: rgba(16, 185, 129, 0.15); color: var(--secondary-hover); }

.btn-delete-list { color: var(--danger); border-color: rgba(239, 68, 68, 0.2); }
.btn-delete-list:hover { background: rgba(239, 68, 68, 0.15); color: #fff; }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-panel {
    width: 100%;
    max-width: 460px;
    animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 25px 60px rgba(0,0,0,0.1), 0 0 40px rgba(212, 175, 55, 0.15);
    padding: 1.5rem;
    background: var(--glass-bg);
    border-radius: 14px;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    padding-bottom: 0.8rem;
}

.modal-header h3 {
    color: var(--primary);
    font-size: 1.2rem;
    font-family: 'Amiri', serif;
}

.modal-header .icon-btn {
    opacity: 0.5;
    transition: opacity 0.3s;
}

.modal-header .icon-btn:hover {
    opacity: 1;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.modal-actions .btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
}

.input-group textarea.modern-input {
    min-height: 80px;
}

/* iOS input fixes */
input, textarea, select, button {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 8px;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
    -webkit-appearance: none;
}
textarea {
    -webkit-appearance: none;
    appearance: none;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.15);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.3);
}

.d3-tooltip {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: 'Tajawal', sans-serif;
    pointer-events: none;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1), 0 0 15px rgba(212, 175, 55, 0.1);
    z-index: 500;
    opacity: 0;
    transition: opacity 0.2s;
}

body.preview-mode .glass-header {
    display: none !important;
}

body.preview-mode .fab,
body.preview-mode .tree-controls {
    display: none !important;
}

body.preview-mode .tree-wrapper {
    background: radial-gradient(ellipse at 50% 30%, rgba(212, 175, 55, 0.04), transparent 50%);
}

body.preview-mode .fab-close-preview {
    display: flex !important;
}

.fab-close-preview {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 1000;
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: var(--text-muted);
    backdrop-filter: blur(10px);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.9rem;
    transition: all 0.3s;
}
.fab-close-preview:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.4);
    color: var(--primary);
}

.toast-notification {
    position: fixed;
    bottom: 2rem;
    bottom: calc(2rem + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(250,248,242,0.96));
    backdrop-filter: blur(12px);
    color: var(--text-main);
    border: 1px solid rgba(212, 175, 55, 0.3);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.1), 0 0 30px rgba(212, 175, 55, 0.1);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-notification i {
    color: var(--secondary);
    font-size: 1.1rem;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.link-gradient {
    stroke: url(#goldGradient);
}

/* Action menu mobile sizing override */
@media (max-width: 480px) {
    div[style*="z-index: 1000"][style*="position: absolute"] {
        min-width: 150px !important;
    }
    div[style*="z-index: 1000"][style*="position: absolute"] button {
        font-size: 0.75rem !important;
        padding: 0.3rem !important;
    }
}

/* Prevent text selection on tree drag */
.d3-container svg {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth font rendering for all devices */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Safe area for all fixed elements */
@media (display-mode: standalone) {
    .glass-header {
        padding-top: max(0.8rem, env(safe-area-inset-top)) !important;
    }
}
