/* ================================================================
   Federix — Premium UI  2026
   ================================================================ */

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; min-height: 100vh; transition: background .25s, color .25s; }
a, button { cursor: pointer; }
button { border: none; background: none; font: inherit; }
input, textarea, select { font: inherit; }
ul, ol { list-style: none; }
.hidden { display: none !important; }
.view { min-height: 100vh; }

/* ── CSS Variables ──────────────────────────────────────────────── */
body.dark {
  --bg:          #0c0c0e;
  --surface:     #141416;
  --surface2:    #1c1c20;
  --surface3:    #242428;
  --border:      rgba(255,255,255,0.07);
  --border2:     rgba(255,255,255,0.13);
  --txt:         #f0f0f2;
  --txt2:        #8888a0;
  --txt3:        #55556a;
  --accent:      #e8433a;
  --accent2:     #ff5a50;
  --accent-dark: #c0312a;
  --accent-glow: rgba(232,67,58,0.20);
  --accent-sub:  rgba(232,67,58,0.10);
  --text2:       #8888a0;
  --text3:       #55556a;
  --red:         #e8433a;
  --radius:      10px;
  --radius-sm:   7px;
  --scrollbar:   #2a2a32;
  --shadow:      0 12px 40px rgba(0,0,0,0.60);
  --shadow-sm:   0 3px 14px rgba(0,0,0,0.45);
}
body.light {
  --bg:          #f0f0f5;
  --surface:     #ffffff;
  --surface2:    #f5f5f9;
  --surface3:    #eaeaef;
  --border:      rgba(0,0,0,0.08);
  --border2:     rgba(0,0,0,0.14);
  --txt:         #111118;
  --txt2:        #555568;
  --txt3:        #9090a8;
  --accent:      #e8433a;
  --accent2:     #ff5a50;
  --accent-dark: #c0312a;
  --accent-glow: rgba(232,67,58,0.14);
  --accent-sub:  rgba(232,67,58,0.07);
  --text2:       #555568;
  --text3:       #9090a8;
  --red:         #e8433a;
  --radius:      10px;
  --radius-sm:   7px;
  --scrollbar:   #d0d0da;
  --shadow:      0 12px 40px rgba(0,0,0,0.12);
  --shadow-sm:   0 3px 14px rgba(0,0,0,0.08);
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }

body { background: var(--bg); color: var(--txt); }

/* ================================================================
   AUTH PAGE
   ================================================================ */
.auth-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.auth-bg::before, .auth-bg::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  animation: blob 14s ease-in-out infinite;
}
.auth-bg::before {
  width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(200,38,32,0.20) 0%, transparent 68%);
  top: -200px; left: -170px;
}
.auth-bg::after {
  width: 440px; height: 440px;
  background: radial-gradient(circle, rgba(165,25,20,0.13) 0%, transparent 68%);
  bottom: -110px; right: -80px;
  animation-delay: -7s;
}
@keyframes blob {
  0%,100% { transform: translate(0,0) scale(1); }
  33%      { transform: translate(30px,-26px) scale(1.05); }
  66%      { transform: translate(-18px,22px) scale(0.96); }
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  margin: 2rem;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 22px;
  padding: 2.6rem 2.4rem;
  box-shadow: var(--shadow), 0 0 0 1px rgba(232,67,58,0.05);
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin-bottom: 2rem;
}
.auth-logo svg { width: 44px; height: 44px; }
.auth-logo span { font-size: 1.8rem; font-weight: 700; letter-spacing: -.5px; color: var(--txt); }

/* ── Tabs ─────────────────────────────────────────────────────── */
.tab-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface2);
  border-radius: 11px;
  padding: 4px;
  margin-bottom: 1.75rem;
  gap: 4px;
}
.tab-btn { padding: .58rem; border-radius: 8px; font-weight: 600; font-size: .88rem; color: var(--txt2); transition: background .2s, color .2s, box-shadow .2s; }
.tab-btn.active { background: var(--accent); color: #fff; box-shadow: 0 3px 14px var(--accent-glow); }
.tab-btn:not(.active):hover { color: var(--txt); background: var(--surface3); }

/* ── Form ─────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .45rem; font-size: .78rem; font-weight: 700; color: var(--txt2); text-transform: uppercase; letter-spacing: .055em; }

input[type=text], input[type=email], input[type=password],
input[type=search], input[type=datetime-local], input[type=number],
select, .modal-input {
  display: block; width: 100%;
  padding: .72rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--txt);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus,
input[type=search]:focus, input[type=number]:focus,
input[type=datetime-local]:focus, select:focus, .modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-sub);
}
input::placeholder { color: var(--txt3); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  background-size: 12px;
  padding-right: 2.4rem;
  cursor: pointer;
}
select option { background: var(--surface2); color: var(--txt); }

.form-err { background: rgba(220,38,38,0.10); border: 1px solid rgba(220,38,38,0.25); color: #ff7070; border-radius: 9px; padding: .62rem .95rem; font-size: .84rem; margin-bottom: .85rem; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .72rem 1.4rem;
  background: var(--accent); color: #fff;
  border-radius: 10px; font-weight: 700; font-size: .9rem;
  transition: background .18s, box-shadow .18s, transform .12s;
  box-shadow: 0 4px 20px var(--accent-glow);
  text-decoration: none;
}
.btn-primary:hover { background: var(--accent2); box-shadow: 0 6px 26px rgba(232,67,58,.35); }
.btn-primary:active { transform: scale(.97); }
.btn-primary.full { width: 100%; margin-top: .5rem; }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .72rem 1.4rem;
  background: var(--surface2); border: 1px solid var(--border); color: var(--txt2);
  border-radius: 10px; font-weight: 600; font-size: .9rem;
  transition: background .18s, color .18s;
}
.btn-ghost:hover { background: var(--surface3); color: var(--txt); }

.btn-sm {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .38rem .85rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; font-size: .8rem; font-weight: 600; color: var(--txt2);
  transition: background .15s, color .15s; white-space: nowrap;
}
.btn-sm:hover { background: var(--surface3); color: var(--txt); }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px; color: var(--txt2); transition: background .15s, color .15s; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface2); color: var(--txt); }

/* ================================================================
   DRIVE LAYOUT
   ================================================================ */
#view-drive { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: 232px; min-width: 232px; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.2rem .85rem;
  overflow-y: auto;
}
.sidebar-logo { display: flex; align-items: center; gap: .6rem; padding: .25rem .4rem .9rem; margin-bottom: .5rem; border-bottom: 1px solid var(--border); }
.sidebar-logo svg { flex-shrink: 0; }
.sidebar-logo span { font-size: 1.15rem; font-weight: 700; letter-spacing: -.3px; color: var(--txt); }

.btn-upload {
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  width: 100%; padding: .62rem; margin: .75rem 0 .9rem;
  background: var(--accent); color: #fff;
  border-radius: 11px; font-weight: 700; font-size: .88rem;
  transition: background .18s, box-shadow .18s, transform .12s;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-upload svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-upload:hover { background: var(--accent2); box-shadow: 0 6px 24px rgba(232,67,58,.32); }
.btn-upload:active { transform: scale(.97); }

.sidebar-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .56rem .75rem; border-radius: 9px;
  font-size: .87rem; font-weight: 500; color: var(--txt2);
  transition: background .15s, color .15s; user-select: none; text-decoration: none;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--txt); }
.nav-item.active { background: var(--accent-sub); color: var(--accent2); font-weight: 600; }
.nav-item.active svg { stroke: var(--accent2); }

/* Storage */
.storage-bar-wrap { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.storage-label { display: flex; justify-content: space-between; font-size: .74rem; color: var(--txt3); margin-bottom: .4rem; }
.storage-bar { height: 5px; background: var(--surface3); border-radius: 99px; overflow: hidden; }
#storage-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .6s ease; }

/* ── Main ────────────────────────────────────────────────────── */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; gap: .75rem; padding: .8rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; z-index: 20; }

.search-wrap { flex: 1; max-width: 480px; position: relative; display: flex; align-items: center; }
.search-wrap > svg { position: absolute; left: .85rem; width: 16px; height: 16px; color: var(--txt3); pointer-events: none; z-index: 1; }
.search-wrap input { width: 100%; padding: .6rem 1rem .6rem 2.5rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; color: var(--txt); font-size: .87rem; }
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-sub); outline: none; }

.search-drop { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border2); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; z-index: 200; animation: drop-in .15s ease; }
.search-drop-item { display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem; font-size: .87rem; color: var(--txt); cursor: pointer; transition: background .13s; }
.search-drop-item:hover { background: var(--surface2); }

.topbar-right { display: flex; align-items: center; gap: .3rem; margin-left: auto; }

/* ── User menu ─────────────────────────────────────────────── */
.user-menu-wrap { position: relative; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; font-weight: 700; font-size: .88rem; display: flex; align-items: center; justify-content: center; transition: transform .15s, box-shadow .15s; }
.user-avatar:hover { transform: scale(1.07); box-shadow: 0 0 0 3px var(--accent-glow); }

.dropdown { position: absolute; top: calc(100% + 10px); right: 0; min-width: 220px; background: var(--surface); border: 1px solid var(--border2); border-radius: 13px; box-shadow: var(--shadow); overflow: hidden; z-index: 300; animation: drop-in .15s ease; }
@keyframes drop-in { from { opacity:0; transform:translateY(-6px) scale(.97); } to { opacity:1; transform:translateY(0) scale(1); } }

/* Avatar row inside dropdown */
.dropdown-avatar-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: 1rem 1rem .85rem;
}
.dropdown-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.dropdown-avatar-hint {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .18s;
  pointer-events: none;
  color: #fff;
}
.dropdown-avatar-wrap:hover .dropdown-avatar-hint { opacity: 1; }
.dropdown-avatar-info { min-width: 0; }
.dropdown-uname { font-size: .88rem; font-weight: 700; color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: .3rem; }
.dropdown-avatar-change {
  font-size: .74rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: opacity .15s;
  letter-spacing: .01em;
}
.dropdown-avatar-change:hover { opacity: .75; }

.dropdown-header { padding: .75rem 1rem .45rem; font-size: .73rem; font-weight: 700; color: var(--txt3); text-transform: uppercase; letter-spacing: .07em; }
.dropdown-item { display: block; padding: .58rem 1rem; font-size: .88rem; color: var(--txt); transition: background .13s; text-decoration: none; }
.dropdown-item:hover { background: var(--surface2); }
.dropdown-item.danger { color: #ff7070; }
.dropdown-item.danger:hover { background: rgba(220,38,38,0.1); }
.dropdown-divider { height: 1px; background: var(--border); margin: .3rem 0; }

/* ================================================================
   CONTENT AREA
   ================================================================ */
.content-area { flex: 1; overflow-y: auto; padding: 1.5rem 1.8rem 3rem; }

.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; font-size: .82rem; color: var(--txt3); margin-bottom: .9rem; min-height: 1.4rem; }
.breadcrumb-item { color: var(--accent); cursor: pointer; transition: opacity .15s; }
.breadcrumb-item:hover { opacity: .75; }
.breadcrumb-sep { color: var(--txt3); }
.breadcrumb-current { color: var(--txt); font-weight: 600; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.3rem; gap: 1rem; }
.section-title { font-size: 1.2rem; font-weight: 800; color: var(--txt); letter-spacing: -.35px; }
.section-actions { display: flex; gap: .5rem; }

/* ================================================================
   FILE GRID
   ================================================================ */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: .85rem; align-content: start; }

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .18s;
  position: relative;
  user-select: none;
}
.file-card:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.file-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }

.file-card-checkbox-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-start; justify-content: flex-end; padding: .5rem; cursor: pointer; z-index: 10; }
.file-card-checkbox { cursor: pointer; width: 20px; height: 20px; }

.file-card-thumb { width: 100%; aspect-ratio: 1; overflow: hidden; background: var(--surface2); display: flex; align-items: center; justify-content: center; }
.file-card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; display: block; }
.file-card:hover .file-card-thumb img { transform: scale(1.05); }

.file-card-info { padding: .62rem .72rem; border-top: 1px solid var(--border); }
.file-card-name { font-size: .82rem; font-weight: 600; color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: .12rem; }
.file-card-meta { font-size: .73rem; color: var(--txt3); }
.file-card-star { position: absolute; top: .5rem; right: .55rem; font-size: .85rem; line-height: 1; }

/* ── File type icons ───────────────────────────────────────── */
.ftype-icon {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; color: #fff; background: #666;
}
.ftype-icon svg { width: 52%; height: 52%; stroke: currentColor; fill: none; flex-shrink: 0; }
.file-icon { width: 52px; height: 52px; border-radius: 10px; }
.ftype-folder { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ftype-image  { background: linear-gradient(135deg, #10b981, #059669); }
.ftype-video  { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.ftype-audio  { background: linear-gradient(135deg, #ec4899, #be185d); }
.ftype-pdf    { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.ftype-doc    { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.ftype-zip    { background: linear-gradient(135deg, #f97316, #c2410c); }
.ftype-code   { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.ftype-other  { background: linear-gradient(135deg, #64748b, #475569); }

/* ── List view ─────────────────────────────────────────────── */
.file-list-header {
  display: grid;
  grid-template-columns: 1fr 130px 90px 36px;
  padding: .38rem .85rem;
  font-size: .74rem; font-weight: 700; color: var(--txt3);
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3px;
}
.file-item-list {
  display: grid;
  grid-template-columns: 1fr 130px 90px 36px;
  align-items: center;
  padding: .52rem .85rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background .13s;
  user-select: none;
  min-width: 0;
}
.file-item-list:has(.item-checkbox) {
  grid-template-columns: 32px 1fr 130px 90px 36px;
}
.file-list-header {
  grid-template-columns: 1fr 130px 90px 36px;
}
.file-list-header:has(.select-all-checkbox) {
  grid-template-columns: 32px 1fr 130px 90px 36px;
}
.file-item-list:hover { background: var(--surface2); }
.file-item-list.selected { background: var(--accent-sub); }
.file-item-list input[type="checkbox"] { cursor: pointer; }
.file-item-list .file-name { display: flex; align-items: center; gap: .65rem; font-size: .87rem; font-weight: 500; color: var(--txt); min-width: 0; overflow: hidden; }
.file-item-list .file-name > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-list-header input[type="checkbox"] { cursor: pointer; }
.col-date, .col-size { font-size: .78rem; color: var(--txt3); }
.col-actions { display: flex; justify-content: flex-end; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 5rem 2rem; opacity: .3; pointer-events: none; }
.empty-state svg { stroke: var(--txt3); }
.empty-state p { font-size: .95rem; color: var(--txt2); }

/* ================================================================
   CONTEXT MENU
   ================================================================ */
#context-menu, .ctx-menu {
  position: fixed; background: var(--surface); border: 1px solid var(--border2);
  border-radius: 13px; box-shadow: var(--shadow); min-width: 175px; z-index: 999;
  overflow: hidden; animation: drop-in .12s ease;
}
.ctx-item { display: flex; align-items: center; gap: .6rem; padding: .58rem 1rem; font-size: .87rem; color: var(--txt); cursor: pointer; transition: background .12s; }
.ctx-item:hover { background: var(--surface2); }
.ctx-item.danger { color: #ff7070; }
.ctx-item.danger:hover { background: rgba(220,38,38,0.10); }
.ctx-divider { height: 1px; background: var(--border); margin: .25rem 0; }

/* ================================================================
   MODALS
   ================================================================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 1rem; animation: overlay-in .18s ease; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal { background: var(--surface); border: 1px solid var(--border2); border-radius: 18px; padding: 1.8rem; width: 100%; max-width: 420px; box-shadow: var(--shadow); animation: modal-in .2s cubic-bezier(.34,1.26,.7,1); max-height: 90vh; overflow-y: auto; }
.modal-wide { max-width: 540px; }
@keyframes modal-in { from { opacity:0; transform:scale(.91) translateY(14px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal h3 { font-size: 1.1rem; font-weight: 800; color: var(--txt); margin-bottom: 1.4rem; letter-spacing: -.25px; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.5rem; }

/* ── Preview ───────────────────────────────────────────────── */
.preview-overlay { background: rgba(0,0,0,0.92) !important; backdrop-filter: blur(18px) !important; -webkit-backdrop-filter: blur(18px) !important; }
.preview-close { position: absolute; top: 1rem; right: 1rem; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.09); color: rgba(255,255,255,0.85); font-size: 1.1rem; display: flex; align-items: center; justify-content: center; transition: background .15s; z-index: 10; }
.preview-close:hover { background: rgba(255,255,255,0.18); }
#preview-container { max-width: 92vw; max-height: 92vh; display: flex; align-items: center; justify-content: center; }
#preview-container img { max-width: 90vw; max-height: 88vh; border-radius: 10px; object-fit: contain; }
#preview-container video { max-width: 90vw; max-height: 80vh; border-radius: 10px; }
#preview-container audio { min-width: 340px; }
#preview-container iframe { width: 80vw; height: 84vh; border: none; border-radius: 10px; background: #fff; }
#preview-container pre { max-width: 80vw; max-height: 84vh; overflow: auto; background: var(--surface); border-radius: 12px; padding: 1.5rem; color: var(--txt); font-size: .85rem; line-height: 1.65; white-space: pre-wrap; word-break: break-all; }
.preview-text-body { max-width: 80vw; max-height: 84vh; overflow: auto; background: var(--surface); border-radius: 12px; padding: 1.5rem; color: var(--txt); font-size: .87rem; line-height: 1.7; white-space: pre-wrap; }

/* ================================================================
   UPLOAD TOAST
   ================================================================ */
.upload-toast { position: fixed; bottom: 1.5rem; right: 1.5rem; width: 310px; background: var(--surface); border: 1px solid var(--border2); border-radius: 14px; box-shadow: var(--shadow); z-index: 900; overflow: hidden; animation: slide-up .22s ease; }
@keyframes slide-up { from { opacity:0; transform:translateY(18px); } to { opacity:1; transform:translateY(0); } }
.upload-toast-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .84rem; font-weight: 700; color: var(--txt); }
.upload-toast-header button { color: var(--txt3); font-size: .95rem; padding: 2px 6px; border-radius: 5px; transition: background .13s; }
.upload-toast-header button:hover { background: var(--surface2); color: var(--txt); }
#upload-progress-list { padding: .5rem .75rem .75rem; display: flex; flex-direction: column; gap: .55rem; max-height: 210px; overflow-y: auto; }
.upload-item { font-size: .82rem; }
.upload-item-name { display: flex; justify-content: space-between; align-items: center; color: var(--txt); margin-bottom: .28rem; overflow: hidden; }
.upload-item-name span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.upload-item-pct { color: var(--txt3); font-size: .74rem; flex-shrink: 0; margin-left: .5rem; }
.upload-bar { height: 4px; background: var(--surface3); border-radius: 99px; overflow: hidden; }
.upload-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .25s; }

/* ================================================================
   DRAG DROP
   ================================================================ */
.drop-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.78); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; z-index: 800; }
.drop-inner { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; color: #fff; border: 2px dashed rgba(232,67,58,0.7); border-radius: 24px; padding: 4.5rem 5.5rem; animation: pulse-border 1.6s ease infinite; }
.drop-inner svg { stroke: var(--accent); opacity: .85; }
.drop-inner p { font-size: 1.25rem; font-weight: 700; opacity: .9; }
@keyframes pulse-border { 0%,100% { box-shadow:none; } 50% { box-shadow:0 0 40px 4px var(--accent-glow); border-color:var(--accent2); } }

/* ================================================================
   SHARE LINK BOX
   ================================================================ */
.share-link-box { display: flex; align-items: center; gap: .6rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: .62rem .85rem; margin-top: 1rem; }
.share-link-box span { flex: 1; font-size: .82rem; color: var(--accent2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================================================
   SYNC / SHARES CARDS
   ================================================================ */
.sync-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.05rem 1.25rem; display: flex; align-items: center; gap: 1rem; margin-bottom: .65rem; }
.sync-info { flex: 1; min-width: 0; }
.sync-name { font-weight: 700; font-size: .92rem; color: var(--txt); margin-bottom: .18rem; }
.sync-path { font-size: .77rem; color: var(--txt3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-meta { font-size: .78rem; color: var(--txt3); margin-top: .3rem; line-height: 1.5; }

.badge { display: inline-block; padding: .2rem .65rem; border-radius: 99px; font-size: .72rem; font-weight: 700; vertical-align: middle; }
.badge-idle    { background: var(--surface3); color: var(--txt3); }
.badge-running { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-error   { background: rgba(220,38,38,0.15); color: #f87171; }
.badge-admin   { background: var(--accent-sub); color: var(--accent2); }
.badge-user    { background: var(--surface3); color: var(--txt3); }

/* ================================================================
   ADMIN
   ================================================================ */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: .85rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem 1.1rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--txt); letter-spacing: -.5px; }
.stat-label { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--txt3); margin-top: .3rem; }

.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data-table th { text-align: left; padding: .65rem 1rem; background: var(--surface2); font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--txt3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: .7rem 1rem; color: var(--txt); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface2); }

/* ================================================================
   PUBLIC SHARE PAGE
   ================================================================ */
.share-page { min-height: 100vh; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 2rem; }
.share-card { background: var(--surface); border: 1px solid var(--border2); border-radius: 22px; padding: 2.5rem 2.4rem; width: 100%; max-width: 540px; box-shadow: var(--shadow); }
.share-file-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 9px; transition: background .13s; }
.share-file-item:hover { background: var(--surface2); }
.share-file-item span:first-of-type { flex-shrink: 0; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 680px) {
  .sidebar { width: 64px; min-width: 64px; padding: 1rem .5rem; }
  .sidebar-logo span, .btn-upload span, .nav-item > span, .storage-bar-wrap { display: none; }
  .btn-upload { padding: .62rem; }
  .nav-item { justify-content: center; padding: .6rem; }
  .content-area { padding: 1rem 1rem 3rem; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .65rem; }
  .topbar { padding: .7rem 1rem; }
  .file-list-header, .file-item-list { grid-template-columns: 1fr 80px; }
  .file-item-list .col-size, .file-item-list .col-actions { display: none; }
}

/* ─── Avatar ──────────────────────────────────────────────────────────────── */
.user-avatar img { border-radius: 50%; display: block; }

/* ─── Federation ──────────────────────────────────────────────────────────── */
.fed-user-card { cursor: pointer; }
.fed-user-card:hover { border-color: var(--accent2, #555); }

.fed-avatar-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2, #252525);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}

.fed-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fed-avatar-init {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--txt2);
  background: var(--surface2, #252525);
  user-select: none;
}

/* Federation tabs */
.fed-tabs {
  display: flex;
  gap: .4rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .5rem;
}
.fed-tab {
  background: none;
  border: none;
  color: var(--txt2);
  font-size: .875rem;
  font-weight: 600;
  padding: .35rem .85rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.fed-tab:hover { background: var(--surface2); color: var(--txt); }
.fed-tab.active { background: var(--red); color: #fff; }

/* ================================================================
   MOBILE UI — bottom nav, FAB, more sheet
   ================================================================ */

/* Bottom nav bar (shown only in mobile media query) */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(58px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  align-items: center;
  justify-content: space-around;
}
.mnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: .45rem 0;
  color: var(--txt3);
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .02em;
  background: none;
  border: none;
  transition: color .15s;
  min-width: 0;
}
.mnav-btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.mnav-btn.active { color: var(--accent); }
.mnav-btn.active svg { stroke: var(--accent); }

/* Floating action button (upload) */
.mobile-fab {
  display: none;
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom));
  right: 1.25rem;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
  z-index: 201;
  align-items: center;
  justify-content: center;
  transition: transform .15s, box-shadow .15s;
}
.mobile-fab:active { transform: scale(.93); }
.mobile-fab svg { width: 22px; height: 22px; }

/* Slide-up animation shared by sheet + modals on mobile */
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* More overlay */
.mobile-more-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 400;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.mobile-more-sheet {
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: .5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border2);
  animation: sheet-up .25s cubic-bezier(.34,1.26,.7,1);
}
.mobile-more-handle {
  width: 40px; height: 4px;
  background: var(--border2);
  border-radius: 99px;
  margin: .5rem auto .85rem;
}
.mobile-more-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .82rem .5rem;
  font-size: .93rem;
  font-weight: 500;
  color: var(--txt);
  cursor: pointer;
  transition: color .13s;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.mobile-more-item:last-child { border-bottom: none; }
.mobile-more-item svg { width: 20px; height: 20px; color: var(--txt3); flex-shrink: 0; stroke: var(--txt3); }
.mobile-more-item.danger { color: #ff7070; }
.mobile-more-item.danger svg { stroke: #ff7070; }
.mobile-more-divider { height: 1px; background: var(--border); margin: .25rem -.5rem; }

/* ── Mobile Layout (iPhone 390px and similar) ─────────────────── */
@media (max-width: 480px) {
  /* Kill desktop sidebar entirely */
  .sidebar { display: none !important; }

  /* Show mobile chrome */
  .mobile-nav { display: flex; }
  .mobile-fab { display: flex; }

  /* Full-height flex column for drive view */
  #view-drive { flex-direction: column; height: 100dvh; overflow: hidden; }
  .main-area  { flex: 1; min-width: 0; height: 100%; overflow: hidden; display: flex; flex-direction: column; }

  /* Topbar: tighter, hide desktop-only icon buttons */
  .topbar { padding: .65rem .9rem; gap: .5rem; }
  .icon-btn[title="Grid view"],
  .icon-btn[title="List view"] { display: none; }
  .search-wrap { max-width: 100%; }

  /* Content area: bottom padding clears bottom nav */
  .content-area { padding: .9rem .9rem calc(72px + env(safe-area-inset-bottom)); }

  /* File grid: slightly smaller tiles */
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }

  /* List view: strip size + actions columns */
  .file-list-header,
  .file-item-list { grid-template-columns: 1fr 80px; }
  .file-item-list .col-size,
  .file-item-list .col-actions { display: none; }

  /* Section title slightly smaller */
  .section-title { font-size: 1rem; }

  /* Modals become bottom sheets on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 22px 22px 0 0 !important;
    max-height: 88dvh;
    padding-bottom: calc(1.8rem + env(safe-area-inset-bottom));
    animation: sheet-up .25s cubic-bezier(.34,1.26,.7,1) !important;
  }

  /* Upload toast floats above bottom nav */
  .upload-toast {
    left: .75rem; right: .75rem; width: auto;
    bottom: calc(1rem + 58px + env(safe-area-inset-bottom));
  }

  /* Sync cards: allow wrapping on narrow screens */
  .sync-card { flex-wrap: wrap; }

  /* Auth card: full-screen feel on small devices */
  .auth-card { margin: 1rem; padding: 2rem 1.5rem; }
}
