/* ============================================================
   REAPER INC. - LAYOUT CSS (clean rewrite)
   ============================================================ */

:root {
  --sidebar-width: 48px;
  --rail-width: 48px;
  --flyout-width: 240px;
  --right-panel-width: 260px;
  --topbar-height: 52px;
  --userbar-height: 52px;
}

body { overflow: hidden; height: 100vh; display: flex; flex-direction: column; }
#grain { position: fixed; inset: 0; z-index: 9998; pointer-events: none; opacity: 0.025; background-image: url('data:image/svg+xml,%3Csvg viewBox=%220 0 200 200%22 xmlns=%22http://www.w3.org/2000/svg%22%3E%3Cfilter id=%22n%22%3E%3CfeTurbulence type=%22fractalNoise%22 baseFrequency=%220.85%22 numOctaves=%224%22 stitchTiles=%22stitch%22/%3E%3C/filter%3E%3Crect width=%22100%25%22 height=%22100%25%22 filter=%22url(%23n)%22/%3E%3C/svg%3E'); }
#app-shell { display: flex; flex: 1; height: calc(100vh - var(--userbar-height) - 28px); overflow: hidden; position: relative; }

/* MARQUEE */
#marquee-bar { height: 28px; background: #080808; border-bottom: 1px solid rgba(139,0,0,.15); overflow: hidden; position: relative; z-index: 200; flex-shrink: 0; }
#marquee-track { display: inline-flex; align-items: center; white-space: nowrap; animation: marqueeScroll 120s linear infinite; height: 100%; padding-left: 100%; }
#marquee-track:hover { animation-play-state: paused; }
.marquee-item { display: inline-flex; align-items: center; gap: 6px; padding: 0 20px; }
.marquee-icon { font-size: 11px; }
.marquee-text { font-family: 'Rajdhani', sans-serif; font-size: 11px; letter-spacing: 1.5px; color: #8a7d5e; text-transform: uppercase; }
.marquee-sep { color: rgba(139,0,0,.3); font-size: 9px; padding: 0 6px; }
@keyframes marqueeScroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
@keyframes notifPanelIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }
#topbar-notif-btn.active { border-color:rgba(139,0,0,.5) !important; color:#cc0000 !important; }

/* SIDEBAR - ICON RAIL */
#sidebar { width: var(--rail-width); min-width: var(--rail-width); height: 100%; position: relative; z-index: 100; flex-shrink: 0; }
#nav-rail { width: var(--rail-width); height: 100%; background: #080808; border-right: 1px solid rgba(107,33,168,.2); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 3px; overflow: hidden; position: relative; z-index: 102; }

#hamburger-btn { width: 36px; height: 36px; background: none; border: 1px solid rgba(107,33,168,.25); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; cursor: pointer; margin-bottom: 8px; border-radius: 4px; transition: all .15s; flex-shrink: 0; }
#hamburger-btn:hover { background: rgba(107,33,168,.25); border-color: rgba(168,85,247,.5); }
#hamburger-btn.active { background: rgba(107,33,168,.35); border-color: #6b21a8; }
#hamburger-btn.active .hb-line:nth-child(1) { transform: translateY(8px) rotate(45deg); }
#hamburger-btn.active .hb-line:nth-child(2) { opacity: 0; transform: scaleX(0); }
#hamburger-btn.active .hb-line:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
.hb-line { width: 16px; height: 2px; background: #8c9099; border-radius: 2px; transition: all .2s ease; transform-origin: center; display: block; }

.rail-btn { width: 36px; height: 36px; background: none; border: none; color: #666; font-size: 15px; cursor: pointer; border-radius: 4px; transition: all .15s; display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
.rail-btn:hover { background: rgba(107,33,168,.2); color: #a855f7; }
.rail-btn.active { background: rgba(107,33,168,.2); color: #a855f7; }
.rail-btn.active::before { content: ''; position: absolute; left: 0; top: 20%; bottom: 20%; width: 2px; background: #6b21a8; border-radius: 0 2px 2px 0; }

/* FLYOUT */
#nav-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.65); z-index: 500; }
#nav-overlay.visible { display: block; }
#nav-flyout { position: fixed; top: 0; bottom: 0; left: var(--rail-width); width: var(--flyout-width); background: #0a0a0a; border-right: 1px solid rgba(107,33,168,.25); z-index: 501; display: none; flex-direction: column; }
#nav-flyout.open { display: flex; }
#flyout-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px; border-bottom: 1px solid rgba(107,33,168,.12); flex-shrink: 0; min-height: var(--topbar-height); }
.flyout-logo-name { font-family: 'Cinzel Decorative', serif; font-size: 11px; color: #d4c9a8; letter-spacing: 2px; }
.flyout-logo-sub { font-family: 'Orbitron', monospace; font-size: 7px; color: #6b21a8; letter-spacing: 3px; margin-top: 2px; }
#flyout-close-btn { background: none; border: none; color: #444; font-size: 14px; cursor: pointer; padding: 4px 6px; border-radius: 3px; transition: all .15s; line-height: 1; }
#flyout-close-btn:hover { color: #a855f7; background: rgba(107,33,168,.1); }
#flyout-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 8px; scrollbar-width: thin; scrollbar-color: #1a1a1a transparent; }
#flyout-nav::-webkit-scrollbar { width: 3px; }
#flyout-nav::-webkit-scrollbar-thumb { background: #1a1a1a; border-radius: 2px; }
#flyout-footer { padding: 8px; border-top: 1px solid #111; flex-shrink: 0; }
.flyout-section-label { font-family: 'Orbitron', monospace; font-size: 7px; letter-spacing: 3px; color: #2a2a2a; text-transform: uppercase; padding: 10px 8px 4px; }
.flyout-item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; padding: 8px 10px; border-radius: 4px; cursor: pointer; text-align: left; transition: background .12s, color .12s; border-left: 2px solid transparent; }
.flyout-item:hover { background: rgba(107,33,168,.1); }
.flyout-item.active { background: rgba(107,33,168,.15); border-left-color: #6b21a8; }
.fi-icon { font-size: 13px; color: #666; width: 18px; text-align: center; flex-shrink: 0; transition: color .12s; }
.fi-label { font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 1px; color: #666; text-transform: uppercase; white-space: nowrap; transition: color .12s; }
.flyout-item:hover .fi-icon, .flyout-item:hover .fi-label { color: #8c9099; }
.flyout-item.active .fi-icon { color: #a855f7; }
.flyout-item.active .fi-label { color: #c4c8d0; }
.flyout-logout .fi-icon, .flyout-logout .fi-label { color: #2a2a2a; }
.flyout-logout:hover { background: rgba(220,38,38,.06) !important; }
.flyout-logout:hover .fi-icon, .flyout-logout:hover .fi-label { color: #dc2626 !important; }
#sidebar-overlay { display: none; }

/* CENTER COLUMN */
#center-column { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#topbar { height: var(--topbar-height); min-height: var(--topbar-height); background: rgba(0,0,0,.98); border-bottom: 1px solid rgba(140,144,153,.15); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 12px; flex-shrink: 0; position: relative; z-index: 50; backdrop-filter: blur(8px); }
#topbar-left { display: flex; align-items: center; gap: 12px; }
#topbar-right { display: flex; align-items: center; gap: 8px; }
#mobile-menu-btn { display: none; background: none; border: 1px solid rgba(139,0,0,.3); color: #8a7d5e; font-size: 16px; padding: 4px 9px; cursor: pointer; transition: all .2s; border-radius: 2px; }
#mobile-menu-btn:hover { border-color: #cc0000; color: #d4c9a8; }
#topbar-page-name { display: flex; align-items: center; gap: 8px; }
#topbar-icon { font-size: 16px; }
#topbar-title { font-family: 'Cinzel', serif; font-size: 13px; letter-spacing: 2px; color: #d4c9a8; text-transform: uppercase; }
#topbar-right-toggle { background: none; border: 1px solid #222; color: #555; font-size: 16px; padding: 4px 8px; cursor: pointer; transition: all .2s; border-radius: 2px; }
#topbar-right-toggle:hover { border-color: rgba(139,0,0,.3); color: #8a7d5e; }
#topbar-right-toggle.active { border-color: rgba(139,0,0,.4); color: #cc0000; }
#topbar-notif-btn { background: none; border: 1px solid #1a1a1a; color: #555; font-size: 14px; padding: 4px 9px; cursor: pointer; transition: all .2s; border-radius: 2px; position: relative; }
#topbar-notif-btn:hover { border-color: rgba(139,0,0,.3); color: #cc0000; }
.notif-badge { position: absolute; top: -4px; right: -4px; background: #8b0000; color: #fff; font-family: 'Orbitron', monospace; font-size: 8px; padding: 1px 4px; border-radius: 8px; min-width: 16px; text-align: center; line-height: 1.4; }
#main-content { flex: 1; overflow-y: auto; overflow-x: hidden; background: #020202; position: relative; transition: opacity .18s ease, transform .18s ease; scrollbar-width: thin; scrollbar-color: #8b0000 #000; }
#main-content::-webkit-scrollbar { width: 5px; }
#main-content::-webkit-scrollbar-track { background: #0a0a0a; }
#main-content::-webkit-scrollbar-thumb { background: #8b0000; border-radius: 3px; }

/* RIGHT PANEL */
#right-panel { width: var(--right-panel-width); min-width: var(--right-panel-width); height: 100%; background: #050505; border-left: 1px solid rgba(140,144,153,.12); overflow: hidden; flex-shrink: 0; display: flex; flex-direction: column; }
#right-panel-inner { width: 100%; flex: 1 1 0; min-height: 0; max-height: 100%; overflow-y: auto; overflow-x: hidden; padding: 12px 0 40px; scrollbar-width: none; }
#right-panel-inner::-webkit-scrollbar { display: none; }

/* MORTICIA */
#rp-morticia { flex-shrink: 0; flex-basis: auto; position: relative; border-top: 1px solid rgba(140,144,153,.2); cursor: pointer; overflow: hidden; }
#rp-morticia:hover #rp-morticia-av img { filter: brightness(0.95) contrast(1.15) saturate(0.9); }
#rp-morticia-av { width: 100%; height: 160px; position: relative; overflow: hidden; background: #020f0e; }
#rp-morticia-av img { width: 100%; height: 320px; object-fit: cover; object-position: center 30%; display: block; filter: brightness(0.75) contrast(1.1) saturate(0.85); transition: filter 0.3s ease; }
#rp-morticia-av::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg,transparent 0%,transparent 40%,rgba(2,10,10,0.6) 70%,rgba(8,8,8,0.98) 100%); pointer-events: none; }
#rp-morticia-av canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
#rp-morticia-label { position: absolute; bottom: 0; left: 0; right: 0; padding: 6px 12px 8px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
#rp-morticia-status { width: 6px; height: 6px; border-radius: 50%; background: #2abaaa; box-shadow: 0 0 6px #2abaaa; display: inline-block; margin-bottom: 2px; }
#rp-morticia-name { font-family: 'Cinzel Decorative', serif; font-size: 11px; color: #d4c9a8; letter-spacing: 1.5px; display: block; }
#rp-morticia-title { font-family: 'Orbitron', monospace; font-size: 7px; color: #2abaaa; letter-spacing: 2px; text-transform: uppercase; display: block; }
.rp-section { padding: 16px 14px; }
.rp-section-label { font-family: 'Orbitron', monospace; font-size: 9px; letter-spacing: 3px; color: #555; text-transform: uppercase; margin-bottom: 12px; }
.rp-divider { height: 1px; background: rgba(139,0,0,.12); margin: 4px 0; }
.rp-loading { font-family: 'Rajdhani', sans-serif; font-size: 11px; letter-spacing: 2px; color: #1a1a1a; text-transform: uppercase; padding: 8px 0; }
.rp-stat-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid #0d0d0d; }
.rp-stat-row:last-child { border-bottom: none; }
.rp-stat-label { font-family: 'Cinzel', serif; font-size: 10px; letter-spacing: 1px; color: #777; text-transform: uppercase; }
.rp-stat-val { font-family: 'Orbitron', monospace; font-size: 11px; color: #cc0000; font-weight: 700; }

/* USER BAR - elevated bottom bar */
#user-bar {
  height: var(--userbar-height);
  background: linear-gradient(180deg, #111114 0%, #0a0a0d 100%);
  border-top: 1px solid rgba(107,33,168,.3);
  box-shadow: 0 -4px 24px rgba(0,0,0,.6), 0 -1px 0 rgba(107,33,168,.12);
  display: flex;
  align-items: center;
  flex-shrink: 0; position: relative; z-index: 200;
}

/* Left card - fixed width */
#user-bar-left {
  width: 240px; min-width: 240px; flex-shrink: 0;
  display: flex; align-items: center; gap: 2px;
  padding: 0 8px; height: 100%;
  border-right: 1px solid rgba(107,33,168,.1);
}

/* Centre - empty, reserved */
#user-bar-centre { flex: 1; }

/* Profile card */
#profile-card {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 5px 8px; border-radius: 6px;
  transition: background .15s; flex: 1; min-width: 0; overflow: hidden;
}
#profile-card:hover { background: rgba(107,33,168,.15); }
#profile-card-avatar-wrap { position: relative; flex-shrink: 0; }
#user-bar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #1a0a2e, #2a1a3e);
  border: 1px solid rgba(107,33,168,.6);
  box-shadow: 0 0 10px rgba(107,33,168,.3);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 12px; color: #a855f7;
  overflow: hidden;
}
#user-bar-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
#profile-card:hover #user-bar-avatar { box-shadow: 0 0 16px rgba(168,85,247,.5); border-color: #a855f7; }
#profile-card-status {
  position: absolute; bottom: -1px; right: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #3ba55c;
  border: 2px solid #0a0a0d;
  box-shadow: 0 0 6px rgba(59,165,92,.5);
}
#profile-card-status.away    { background: #faa81a; box-shadow: 0 0 6px rgba(250,168,26,.5); }
#profile-card-status.offline { background: #555; box-shadow: none; }
#profile-card-status.dnd     { background: #ed4245; box-shadow: 0 0 6px rgba(237,66,69,.5); }
#user-bar-info { flex: 1; min-width: 0; overflow: hidden; }
#user-bar-name {
  font-family: 'Cinzel', serif; font-size: 12px; font-weight: 600;
  color: #f2f3f5; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; line-height: 1.2;
}
#user-bar-rank {
  font-family: 'Orbitron', monospace; font-size: 9px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3; letter-spacing: 1px;
}

/* Icon buttons */
#user-bar-actions { display: flex; gap: 2px; flex-shrink: 0; }
#user-bar-actions button {
  background: none; border: none; color: #444;
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s; padding: 0;
}
#user-bar-actions button:hover { background: rgba(107,33,168,.2); color: #a855f7; }
#user-bar-actions button#user-bar-logout-btn:hover { background: rgba(237,66,69,.12); color: #ed4245; }

/* Right player - fixed width, elevated */
#anthem-player {
  width: 380px; min-width: 380px; flex-shrink: 0;
  display: flex; flex-direction: column; justify-content: center;
  gap: 5px; padding: 6px 14px; height: 100%;
  border-left: 1px solid rgba(107,33,168,.1);
  background: linear-gradient(135deg, rgba(107,33,168,.05) 0%, transparent 60%);
  overflow: hidden;
}
#anthem-player.hidden-player { visibility: hidden; }
#anthem-controls-row { display: flex; align-items: center; gap: 10px; }
#anthem-play-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #6b21a8, #9333ea);
  border: none; color: #fff; font-size: 9px;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  box-shadow: 0 0 12px rgba(107,33,168,.5);
}
#anthem-play-btn:hover { transform: scale(1.08); box-shadow: 0 0 20px rgba(168,85,247,.6); }
#anthem-info { flex: 1; min-width: 0; overflow: hidden; }
#anthem-title {
  font-family: 'Cinzel', serif; font-size: 11px; color: #e0dbd0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block; line-height: 1.3;
}
#anthem-sub {
  font-family: 'Orbitron', monospace; font-size: 7px;
  color: #6b21a8; letter-spacing: 2px; display: block; margin-top: 1px;
}
#anthem-repeat-btn, #anthem-mute-btn {
  background: none; border: none; color: #444; font-size: 12px;
  cursor: pointer; transition: color .15s; padding: 3px;
  flex-shrink: 0; line-height: 1; border-radius: 4px;
}
#anthem-repeat-btn:hover, #anthem-mute-btn:hover { color: #a855f7; }
#anthem-progress-row { display: flex; align-items: center; gap: 8px; }
#anthem-time {
  font-family: 'Orbitron', monospace; font-size: 8px;
  color: #444; flex-shrink: 0; white-space: nowrap;
}
#anthem-progress-wrap {
  flex: 1; height: 3px; background: rgba(255,255,255,.07);
  border-radius: 4px; cursor: pointer; transition: height .15s;
}
#anthem-progress-wrap:hover { height: 5px; }
#anthem-progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #6b21a8, #a855f7);
  border-radius: 4px; transition: width .1s linear; pointer-events: none;
}
#anthem-vol { width: 55px; height: 3px; accent-color: #a855f7; cursor: pointer; flex-shrink: 0; }
#anthem-close-btn {
  background: none; border: none; color: #2a2a2a; font-size: 10px;
  cursor: pointer; padding: 2px 4px; border-radius: 4px; flex-shrink: 0; transition: color .15s;
}
#anthem-close-btn:hover { color: #dc2626; }

/* MOBILE */
#sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 99; background: rgba(0,0,0,.7); pointer-events: none; }
#sidebar-overlay.visible { display: block; pointer-events: all; }

@media (max-width: 900px) {
  #marquee-bar { display: none; }
  #app-shell { height: calc(100vh - var(--userbar-height)); }
  #sidebar { position: fixed; top: 0; left: 0; height: calc(100vh - var(--userbar-height)); z-index: 9000; transform: translateX(-100%); transition: transform .25s ease; width: var(--sidebar-width) !important; min-width: var(--sidebar-width) !important; }
  #sidebar.mobile-open { transform: translateX(0); }
  #sidebar-overlay.visible { display: block; z-index: 8999; }
  #mobile-menu-btn { display: flex !important; align-items: center; }
  #right-panel { display: none !important; }
  #anthem-player { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .page-content, .page-content-full, .page-content-narrow { padding: 16px; }
  .card { padding: 16px !important; }
  .notification { left: 12px !important; right: 12px !important; bottom: 16px !important; width: auto !important; max-width: none !important; }
  #koia-launcher { bottom: 16px !important; right: 16px !important; }
}

/* PAGE CONTENT */
.page-content { padding: 32px; max-width: 1100px; margin: 0 auto; }
.page-content-full { padding: 32px; }
.page-content-narrow { padding: 32px; max-width: 760px; margin: 0 auto; }

/* CHANNEL FEED */
.channel-feed { display: flex; flex-direction: column; }
.channel-message { display: flex; gap: 14px; padding: 10px 20px; border-bottom: 1px solid #0d0d0d; transition: background .15s; }
.channel-message:hover { background: rgba(107,33,168,.03); }
.channel-message.pinned { border-left: 2px solid #a855f7; background: rgba(107,33,168,.04); }
.channel-msg-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; margin-top: 2px; }
.channel-msg-body { flex: 1; min-width: 0; }
.channel-msg-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.channel-msg-author { font-family: 'Cinzel', serif; font-size: 13px; color: #ffffff; }
.channel-msg-date { font-family: 'Orbitron', monospace; font-size: 9px; color: #555; letter-spacing: 1px; }
.channel-msg-title { font-family: 'Cinzel', serif; font-size: 15px; color: #c4c8d0; margin-bottom: 6px; line-height: 1.4; }
.channel-msg-text { font-family: 'Rajdhani', sans-serif; font-size: 15px; color: #666; line-height: 1.7; }
.channel-msg-pin-badge { font-family: 'Orbitron', monospace; font-size: 8px; color: #c9a84c; letter-spacing: 1px; border: 1px solid rgba(201,168,76,.3); padding: 2px 6px; }
