:root {
    /* Backgrounds */
    --bg-base: #fffbf9;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-soft: #fdf5f1;
    --bg-softer: #f9eee8;
    --bg-gradient: #fdf5f1;
    --bg-shadow: rgba(28, 24, 23, 0.04);
    --bg-dropdown: #ffffff;
    --bg-mark: #fbeee9;

    /* Borders */
    --border-color: #f0e6e2;
    --border-hover: #e0d0c9;
    --border: #f0e6e2;
    --border-accent: #d9c5bd;

    /* Text */
    --text-main: #1c1817;
    --text-soft: #4d423e;
    --text-muted: #6b6360;
    --text-delete: #d93829;

    /* Buttons */
    --btn-bg: #ffffff;
    --btn-text: #1c1817;
    --btn-border: #f0e6e2;
    --btn-hover: #fdf5f1;
    --btn-delete: #fbeee9;

    /* Header and menus */
    --bg-header: #fffbf9;
    --bg-submenu: #f9eee8;
    --bg-hover: #f7e0d8;

    /* Primary and accent */
    --primary: #d93829;
    --primary-hover: #b82a1d;
    --primary-active: #961d12;
    --accent: #d93829;
    --accent-soft: #fbeee9;
    --accent-soft-hover: #f7e0d8;

    /* Shadows and layout */
    --shadow-card: 0 10px 30px rgba(28, 24, 23, 0.04);
    --max: 1140px;
    --radius: 16px;
    --radius-sm: 10px;
}

[data-theme="dark"] {
    /* Backgrounds */
    --bg-base: #141110;
    --bg-surface: #1c1716;
    --bg-card: #1c1716;
    --bg-soft: #241d1b;
    --bg-softer: #2e2421;
    --bg-gradient: #241d1b;
    --bg-shadow: rgba(0, 0, 0, 0.3);
    --bg-dropdown: #1c1716;
    --bg-mark: #2e1815;

    /* Borders */
    --border-color: #2d2523;
    --border-hover: #423633;
    --border: #2d2523;
    --border-accent: #6b514a;

    /* Text */
    --text-main: #f5f0ed;
    --text-soft: #d0c3bd;
    --text-muted: #ab9f9a;
    --text-delete: #ff9a9a;

    /* Buttons */
    --btn-bg: #241d1b;
    --btn-text: #f5f0ed;
    --btn-border: #423633;
    --btn-hover: #302522;
    --btn-delete: #2e1815;

    /* Header and menus */
    --bg-header: #171211;
    --bg-submenu: #3b2c28;
    --bg-hover: #3d201c;

    /* Primary and accent */
    --primary: #e64535;
    --primary-hover: #f05a4b;
    --primary-active: #fa6f60;
    --accent: #e64535;
    --accent-soft: #2e1815;
    --accent-soft-hover: #3d201c;

    /* Shadows and layout */
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.3);
    --max: 1140px;
    --radius: 16px;
    --radius-sm: 10px;
}



input{
        width: 100%;

    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 14px;
}

input:focus {
  outline: none;
}

input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
  /* Replace 'white' with whatever background color you want */
  -webkit-box-shadow: 0 0 0 1000px var(--bg-surface) inset !important;
  /* Controls the color of the text during autofill */
  -webkit-text-fill-color: var(--text-main) !important;
}

/* ==========================================================
   Global Themed File Input Styling (IMC Theme)
   ================================================---------- */
input[type="file"] {
    background: var(--bg-surface, #241e1d);
    border: 1px solid var(--border-color, #2d2625);
    border-radius: 8px;
    color: var(--text-muted, #9ca3af);
    font-family: inherit;
    font-size: 13.5px;
    padding: 6px 10px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

input[type="file"]:hover {
    border-color: var(--primary, #d93829);
}

input[type="file"]:focus {
    border-color: var(--primary, #d93829);
    box-shadow: 0 0 0 3px var(--accent-soft, rgba(217, 56, 41, 0.15));
}

/* Style the file picker button across all modern browsers */
input[type="file"]::file-selector-button {
    background: var(--primary, #d93829);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    font-weight: 600;
    font-size: 12.5px;
    cursor: pointer;
    margin-right: 12px;
    transition: background 0.15s, transform 0.15s;
}

input[type="file"]::file-selector-button:hover {
    background: #b82d20;
}

/* Webkit fallback for Safari/Chrome */
input[type="file"]::-webkit-file-upload-button {
    background: var(--primary, #d93829);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    font-weight: 600;
    font-size: 12.5px;
    cursor: pointer;
    margin-right: 12px;
    transition: background 0.15s;
}

input[type="file"]::-webkit-file-upload-button:hover {
    background: #b82d20;
}

*{box-sizing:border-box;} html,body{height:100%;}
@media (prefers-reduced-motion: reduce){ *{transition:none !important;} }
body{margin:0;background:var(--bg-base);color:var(--text-main);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;}
a{color:inherit;text-decoration:none;} button{font-family:inherit;} img{max-width:100%;display:block;}

/* Topbar & Breakpoint Fix (1024px) */
.topbar{position:sticky;top:0;z-index:20;background:var(--bg-surface);border-bottom:1px solid var(--border-color);}
.topbar-inner{max-width:var(--max);margin:0 auto;padding:12px 20px;display:flex;align-items:center;gap:24px;}
.brand{display:flex;align-items:center;gap:9px;white-space:nowrap;}
.brand-logo{width:45px;height:25px;object-fit:contain;margin-right:4px;flex-shrink:0;filter:opacity(0.7) invert(1);}

[data-theme="dark"] .brand-logo {
    filter: opacity(0.9);
}
.brand-short{font-weight:800;font-size:17px;}
.tabs{display:flex;gap:2px;flex:1;overflow-x:auto;min-width:0;}
.tab{padding:8px 14px;border-radius:var(--radius-sm);font-size:14px;font-weight:600;color:var(--text-muted);white-space:nowrap;cursor:pointer;border:none;background:none;}
.tab:hover{background:var(--accent-soft);color:var(--text-main);}
.tab.active{background:var(--accent-soft);color:var(--primary);}
@media (max-width:1024px){ .tabs{display:none;} }

.topbar-right{display:flex;align-items:center;gap:10px;margin-left:auto;flex-shrink:0;position:relative;}
.icon-btn{width:36px;height:36px;border-radius:50%;border:1px solid var(--border-color);background:var(--bg-surface);color:var(--text-main);cursor:pointer;display:flex;align-items:center;justify-content:center;}
.icon-btn:hover{border-color:var(--border-hover);background:var(--accent-soft);}

/* Adaptive "More" Menu (Bottom Sheet on Mobile, Reddit Dropdown on Desktop) */
.sheet-overlay{position:fixed;inset:0;background:rgba(0,0,0,.4);opacity:0;pointer-events:none;transition:opacity .2s;z-index:40;}
.sheet-overlay.open{opacity:1;pointer-events:auto;}

/* --- ADAPTIVE "MORE" MENU (Bottom Sheet on Mobile, Reddit Dropdown on Desktop) --- */
.sheet-overlay{position:fixed;inset:0;background:rgba(0,0,0,.4);opacity:0;pointer-events:none;transition:opacity .2s ease;z-index:40;}
.sheet-overlay.open{opacity:1;pointer-events:auto;}

.sheet{
    position:fixed;left:0;right:0;bottom:56px;
    
    background:var(--bg-card);
    border-radius:var(--radius) var(--radius) 0 0;
    box-shadow:var(--shadow-card);
    transform:translateY(100%);
    transition:transform .25s ease, opacity .25s ease;
    z-index:50;
    padding-bottom:env(safe-area-inset-bottom,0px);
}
.sheet.open{transform:translateY(0);}

/* Desktop Reddit-Style Dropdown Behavior (No Glitch on Resize) */
@media (min-width:1025px){
  .sheet {
      position: absolute;
      top: calc(100% + 8px);
      right: 0;
      left: auto;
      bottom: auto;
      width: 260px;
      border-radius: var(--radius);
      transform: translateY(10px);
      opacity: 0;
      pointer-events: none;
      box-shadow: var(--shadow-card);
      border: 1px solid var(--border-color);
      transition: transform .15s ease, opacity .15s ease;
  }
  .sheet.open {
      transform: translateY(0);
      opacity: 1;
      pointer-events: auto;
  }
  .sheet-handle { display: none; }
}

.sheet-handle{width:36px;height:4px;background:var(--border-color);border-radius:999px;margin:10px auto;}
.sheet-item{display:flex;align-items:center;justify-content:space-between;width:100%;padding:14px 20px;border:none;background:none;border-bottom:1px solid var(--border-color);font-size:14.5px;font-weight:600;color:var(--text-main);cursor:pointer;text-align:left;}
.sheet-item:last-child{border-bottom:none;}
.sheet-item:hover{background:var(--accent-soft);}
.sheet-item-left{display:flex;align-items:center;gap:12px;}
.sheet-icon{flex-shrink:0;color:var(--text-muted);}

/* --- SMART ADAPTIVE MOBILE DOCK NAV --- */
.dock{display:none;}
@media (max-width:1024px){
  .dock{
    display: flex; 
    gap: 4px; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    position: fixed; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    z-index: 30;
    background: var(--bg-surface); 
    border-top: 1px solid var(--border-color);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom,0px));
    width: 100%;
    scrollbar-width: none; /* Hide scrollbar for clean UI */
  }
  .dock::-webkit-scrollbar { display: none; }
  body{ padding-bottom: 64px; }
}

.dock-item{
    flex: 1; /* Automatically expands to fill all available horizontal space evenly */
    min-width: 68px; /* The smart threshold: once space drops below this per item, it smoothly becomes a slider */
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    gap: 2px; 
    padding: 6px 4px; 
    border-radius: var(--radius-sm); 
    border: none; 
    background: none; 
    color: var(--text-muted); 
    font-size: 9.5px; 
    font-weight: 600;
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
}
.dock-item.active{color: var(--primary); background: var(--accent-soft);}

.switch{width:40px;height:24px;border-radius:999px;background:var(--border-color);position:relative;flex-shrink:0;transition:background .2s;}
.switch-knob{width:18px;height:18px;border-radius:50%;background:#fff;position:absolute;top:3px;left:3px;transition:transform .2s;}
.switch.on{background:var(--primary);}
.switch.on .switch-knob{transform:translateX(16px);}

.avatar{width:34px;height:34px;border-radius:50%;background:var(--accent-soft);color:var(--primary);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:13px;flex-shrink:0;}
.btn{border:none;border-radius:999px;padding:9px 18px;font-size:14px;font-weight:700;cursor:pointer;}
.btn-primary{background:var(--primary);color:#fff;}
.btn-primary:hover{background:var(--primary-hover);}
.btn-primary:active{background:var(--primary-active);}
.btn-ghost{background:transparent;color:var(--text-main);border:1px solid var(--border-color);}
.btn-ghost:hover{background:var(--accent-soft);border-color:transparent;}

.page{max-width:var(--max);margin:0 auto;padding:24px 5px 60px;}
.two-col{display:grid;grid-template-columns:1fr 340px;gap:24px;}
@media (max-width:1024px){
  .two-col{grid-template-columns:1fr;}
  .sidebar-col{display:none;}
  .sidebar-col.mobile-show{display:block;}
}

.card{background:var(--bg-card);border:1px solid var(--border-color);border-radius:var(--radius);box-shadow:var(--shadow-card);}
.section{display:none;} .section.active{display:block;}

/* Locked Prompt Styles */
.locked{padding:36px 24px;text-align:center;max-width: 500px;
    margin: auto;}
.locked h3{margin:0 0 6px;font-size:17px;}
.locked p{margin:0 0 18px;color:var(--text-muted);font-size:14px;}
.locked .btn-row{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;}

/* Community / Post Styles */
.composer{padding:16px 18px;margin-bottom:20px;display:flex;gap:12px;align-items:center;}
.composer-input{flex:1;padding:11px 16px;border-radius:999px;border:1px solid var(--border-color);color:var(--text-muted);font-size:14px;}
.post{padding:18px 20px;margin-bottom:16px;}
.post-head{display:flex;align-items:center;gap:12px;margin-bottom:12px;}
.post-name{font-weight:700;font-size:14.5px;}
.post-sub{font-size:12.5px;color:var(--text-muted);}
.pinned{margin-left:auto;font-size:12px;font-weight:700;color:var(--primary);background:var(--accent-soft);padding:4px 10px;border-radius:999px;}
.post-body{font-size:15px;line-height:1.55;margin-bottom:14px;}
.post-actions{display:flex;gap:18px;font-size:13.5px;color:var(--text-muted);font-weight:600;}
.post-actions span:hover{color:var(--primary);}

/* Chatroom */
.chat-wrap{display:grid;grid-template-columns:150px 1fr;height:520px;overflow:hidden;}
@media (max-width:640px){ .chat-wrap{grid-template-columns:96px 1fr;height:460px;} }
.chat-channels{background:var(--accent-soft);padding:14px 8px;overflow-y:auto;border-right:1px solid var(--border-color);}
.chat-channel{padding:8px 10px;border-radius:var(--radius-sm);font-size:13px;font-weight:600;color:var(--text-muted);cursor:pointer;margin-bottom:2px;}
.chat-channel.active{background:var(--bg-card);color:var(--primary);}
.chat-main{display:flex;flex-direction:column;min-width:0;}
.chat-messages{flex:1;overflow-y:auto;padding:16px;}
.chat-msg{display:flex;gap:10px;margin-bottom:16px;}
.chat-msg .avatar{width:28px;height:28px;font-size:11px;}
.chat-msg-name{font-weight:700;font-size:13px;}
.chat-msg-time{font-size:11px;color:var(--text-muted);margin-left:6px;font-weight:500;}
.chat-msg-text{line-height:1.5;margin-top:2px;font-size:13.5px;}
.chat-input-row{border-top:1px solid var(--border-color);padding:10px 12px;display:flex;gap:8px;}
.chat-input{flex:1;padding:9px 14px;border-radius:999px;border:1px solid var(--border-color);font-size:13.5px;color:var(--text-muted);}

/* Courses */
.course-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:16px;}
@media (max-width:640px){ .course-grid{grid-template-columns:1fr;} }
.course-card{overflow:hidden;}
.course-thumb{height:96px;}
.thumb-1{background:linear-gradient(135deg,var(--primary),var(--primary-active));}
.thumb-2{background:linear-gradient(135deg,#e8b23d,#c9860a);}
.thumb-3{background:linear-gradient(135deg,#4f7cac,#2f5a86);}
.thumb-4{background:linear-gradient(135deg,#4caf82,#2e7d5b);}
.course-body{padding:14px 16px;}
.course-title{font-weight:700;font-size:14.5px;margin:0 0 4px;}
.course-meta{font-size:12px;color:var(--text-muted);margin-bottom:10px;}
.progress-bar{height:6px;border-radius:999px;background:var(--accent-soft);overflow:hidden;margin-bottom:12px;}
.progress-fill{height:100%;background:var(--primary);}
.course-card .btn{width:100%;padding:8px;font-size:13px;}

/* Members */
.member-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;}
@media (max-width:640px){ .member-grid{grid-template-columns:repeat(2,1fr);} }
.member-card{padding:18px 14px;text-align:center;}
.member-card .avatar{width:48px;height:48px;font-size:16px;margin:0 auto 10px;}
.member-card-name{font-weight:700;font-size:13.5px;}
.member-card-role{font-size:11.5px;color:var(--text-muted);margin-top:2px;}

/* Leaderboard */
.filter-row{display:flex;gap:8px;margin-bottom:16px;}
.chip{padding:7px 14px;border-radius:999px;border:1px solid var(--border-color);font-size:13px;font-weight:600;color:var(--text-muted);cursor:pointer;}
.chip.active{background:var(--accent-soft);color:var(--primary);border-color:transparent;}
.lb-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-bottom:1px solid var(--border-color);}
.lb-row:last-child{border-bottom:none;}
.lb-rank{width:26px;height:26px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:12px;background:var(--accent-soft);color:var(--text-muted);flex-shrink:0;}
.lb-rank.gold{background:#f5c451;color:#5a3d00;}
.lb-rank.silver{background:#cfd4da;color:#3a3f45;}
.lb-rank.bronze{background:#d99a5b;color:#4a2c0f;}
.lb-name{flex:1;font-weight:600;font-size:14px;}
.lb-pts{font-weight:700;color:var(--primary);font-size:13px;}

/* Articles */
.article-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:16px;}
@media (max-width:640px){ .article-grid{grid-template-columns:1fr;} }
.article-card{overflow:hidden;}
.article-thumb{height:110px;}
.article-body{padding:14px 16px;}
.article-title{font-weight:700;font-size:14.5px;margin:0 0 6px;}
.article-excerpt{font-size:12.5px;color:var(--text-muted);line-height:1.5;margin-bottom:10px;}
.article-meta{font-size:11.5px;color:var(--text-muted);}

/* Sidebar Styles (.stat-num, .stat-label, etc.) */
.side-card{padding:20px;   max-width: 340px; min-width:340px; margin:auto; margin-bottom:20px; }
.side-banner{height:90px;background:linear-gradient(135deg,var(--primary),var(--primary-active));margin:-20px -20px 14px -20px;border-radius:var(--radius) var(--radius) 0 0;
        background-image: url(../img/banner.webp?33);
    height: 127px;
    background-size: contain;
    
}
.community-name{font-size:19px;font-weight:800;margin:0 0 2px;}
.community-desc{font-size:13.5px;color:var(--text-muted);line-height:1.5;margin:0 0 14px;}
.stat-row{display:flex;gap:18px;margin-bottom:16px;}
.stat-num{font-weight:800;font-size:16px;}
.stat-label{font-size:12px;color:var(--text-muted);}
.side-card .btn{width:100%;padding:11px;}
.side-title{font-size:13px;font-weight:700;color:var(--text-muted);margin:0 0 14px;}

/* --- Mobile Sidebar Display Rules --- */
@media (max-width: 1024px) {
  .sidebar-col {
      display: none; /* Hidden by default on mobile */
  }
  .sidebar-col.mobile-show {
      display: block !important; /* Forces visibility when toggled on locked sections */
      margin-top: 20px;
  }
}