/* =========================================================
   FileWiz — Design tokens
   Palette: charcoal base + kraft/copper "folder" accent
   Type: Space Grotesk (display) / IBM Plex Sans (body) / IBM Plex Mono (data)
   ========================================================= */
:root{
  --bg:            #14171A;
  --panel:         #1D2226;
  --panel-2:       #262C31;
  --panel-3:       #2E3539;
  --border:        #33393E;
  --text:          #ECEFF1;
  --text-dim:      #9BA5AC;
  --text-faint:    #6B747A;
  --copper:        #C9722C;
  --copper-bright: #E08A42;
  --copper-dim:    #7A461C;
  --green:         #4CA37B;
  --red:           #D9534F;
  --blue:          #5B8DEF;
  --yellow:        #E0B341;
  --pink:          #C96FA8;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-1: 0 2px 10px rgba(0,0,0,.35);
  --shadow-2: 0 12px 40px rgba(0,0,0,.45);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
.hidden{ display:none !important; }
button{ font-family: inherit; }
ul{ list-style:none; margin:0; padding:0; }
svg{ width:20px; height:20px; fill: currentColor; }

::selection{ background: var(--copper-dim); color: #fff; }

/* scrollbars */
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-thumb{ background: var(--panel-3); border-radius: 8px; }
::-webkit-scrollbar-track{ background: transparent; }

/* =========================================================
   Signature mark: the "folder tab" brandmark, reused as the
   breadcrumb signature element throughout the app.
   ========================================================= */
.brandmark{ position:relative; width:34px; height:26px; display:inline-block; }
.brandmark-tab{
  position:absolute; top:0; left:0; width:60%; height:8px;
  background: var(--copper-dim);
  border-radius: 3px 3px 0 0;
}
.brandmark-body{
  position:absolute; top:6px; left:0; width:100%; height:20px;
  background: linear-gradient(155deg, var(--copper-bright), var(--copper));
  border-radius: 4px;
}
.brandmark-sm{ width:24px; height:19px; }
.brandmark-sm .brandmark-tab{ height:6px; }
.brandmark-sm .brandmark-body{ top:4px; height:15px; }

/* =========================================================
   Onboarding / permission screen
   ========================================================= */
.onboarding{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  padding: 32px 20px;
  background:
    radial-gradient(600px 400px at 15% 0%, rgba(201,114,44,.14), transparent 60%),
    var(--bg);
}
.onboarding-card{
  max-width: 460px; width:100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 30px 30px;
  box-shadow: var(--shadow-2);
}
.onboarding-card .brandmark{ width:52px; height:40px; margin-bottom:22px; }
.onboarding-card .brandmark-tab{ height:12px; }
.onboarding-card .brandmark-body{ top:9px; height:31px; border-radius:6px; }
.eyebrow{
  font-family: var(--font-mono); font-size:12px; letter-spacing:.12em; text-transform:uppercase;
  color: var(--copper-bright); margin:0 0 10px;
}
.onboarding-title{
  font-family: var(--font-display); font-weight:600; font-size:28px; line-height:1.22;
  margin: 0 0 14px;
}
.onboarding-text{ color: var(--text-dim); line-height:1.6; font-size:14.5px; margin:0 0 20px; }
.onboarding-points{ margin:0 0 26px; padding:0; list-style:none; }
.onboarding-points li{
  font-size:13.5px; color: var(--text-dim); padding:8px 0 8px 22px; position:relative;
  border-top:1px solid var(--border);
}
.onboarding-points li:first-child{ border-top:none; }
.onboarding-points li::before{
  content:''; position:absolute; left:0; top:14px; width:8px; height:8px; border-radius:2px;
  background: var(--copper);
}
.onboarding-points b{ color: var(--text); font-weight:600; }
.onboarding-hint{ margin-top:14px; font-size:13px; color: var(--text-faint); min-height: 18px; }

/* =========================================================
   Buttons
   ========================================================= */
.btn{
  font-family: var(--font-body); font-weight:600; font-size:14px;
  border-radius: 12px; border: 1px solid transparent; cursor:pointer;
  padding: 11px 18px; transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn:active{ transform: scale(.97); }
.btn-primary{ background: linear-gradient(155deg, var(--copper-bright), var(--copper)); color:#1A0F06; }
.btn-primary:hover{ filter: brightness(1.08); }
.btn-ghost{ background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover{ border-color: var(--text-faint); color: var(--text); }
.btn-danger{ background: var(--red); color:#fff; }
.btn-lg{ width:100%; padding:14px 18px; font-size:15px; }

/* =========================================================
   App shell
   ========================================================= */
.app{ display:flex; flex-direction:column; height:100vh; height:100dvh; }

.topbar{
  display:flex; align-items:center; gap:14px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink:0;
}
.brand{ display:flex; align-items:center; gap:8px; }
.brand-name{ font-family: var(--font-display); font-weight:700; font-size:18px; letter-spacing:-.01em; }

.storage-meter{ flex:1; max-width:220px; display:none; flex-direction:column; gap:4px; }
@media (min-width: 560px){ .storage-meter{ display:flex; } }
.storage-meter-track{ height:5px; border-radius:4px; background: var(--panel-3); overflow:hidden; }
.storage-meter-fill{ height:100%; width:0%; background: linear-gradient(90deg, var(--copper), var(--copper-bright)); transition: width .4s ease; }
.storage-meter-label{ font-family: var(--font-mono); font-size:10.5px; color: var(--text-faint); }

.topbar-actions{ display:flex; gap:4px; margin-left:auto; }
.icon-btn{
  width:38px; height:38px; border-radius:10px; border:none; background:transparent; color: var(--text-dim);
  display:flex; align-items:center; justify-content:center; cursor:pointer; transition: background .15s, color .15s;
}
.icon-btn:hover{ background: var(--panel-2); color: var(--text); }
.icon-btn-danger:hover{ background: rgba(217,83,79,.15); color: var(--red); }

.searchbar{
  display:flex; align-items:center; gap:10px; padding:10px 16px; border-bottom:1px solid var(--border);
  color: var(--text-faint);
}
.searchbar input{
  flex:1; background:transparent; border:none; outline:none; color: var(--text); font-size:15px; font-family: var(--font-body);
}

/* ---- Signature: folder-tab breadcrumb ---- */
.tabpath-wrap{ padding: 12px 12px 0; overflow-x:auto; flex-shrink:0; }
.tabpath-wrap::-webkit-scrollbar{ display:none; }
.tabpath{ display:flex; align-items:flex-end; min-width:max-content; }
.tabpath-item{
  font-family: var(--font-mono); font-size:12.5px; white-space:nowrap;
  background: var(--panel-2); color: var(--text-dim);
  border: 1px solid var(--border); border-bottom:none;
  padding: 8px 16px 9px; margin-right:-10px;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%);
  cursor:pointer; position:relative; transition: background .15s, color .15s;
}
.tabpath-item:first-child{ clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); padding-left:14px; }
.tabpath-item:hover{ background: var(--panel-3); color: var(--text); }
.tabpath-item.active{
  background: linear-gradient(155deg, var(--copper-bright), var(--copper));
  color:#1A0F06; font-weight:600; z-index:1;
}

.subtoolbar{
  display:flex; align-items:center; gap:8px; padding: 10px 16px; flex-shrink:0;
}
.chip{
  display:flex; align-items:center; gap:6px; font-size:12.5px; font-weight:500;
  padding:7px 12px; border-radius:20px; background: var(--panel-2); color: var(--text-dim);
  border:1px solid var(--border); cursor:pointer; white-space:nowrap;
}
.chip svg{ width:14px; height:14px; }
.chip-muted{ color: var(--text-faint); cursor:default; }
.chip-accent{ background: var(--copper-dim); color:#FDE3C8; border-color: var(--copper); }
.spacer{ flex:1; }

.selectionbar{
  display:flex; align-items:center; gap:2px; padding: 8px 10px;
  background: var(--panel-2); border-bottom:1px solid var(--border); flex-shrink:0;
}
.selection-count{ font-size:13.5px; font-weight:600; margin-left:4px; }

/* =========================================================
   File list
   ========================================================= */
.filelist-wrap{ flex:1; overflow-y:auto; padding: 4px 8px 100px; }
.filelist{ display:flex; flex-direction:column; }

.file-row{
  display:flex; align-items:center; gap:12px;
  padding: 10px 10px; border-radius: 12px; cursor:pointer; user-select:none;
  transition: background .12s ease;
}
.file-row:hover{ background: var(--panel); }
.file-row.selected{ background: rgba(201,114,44,.14); }

.file-icon{
  width:42px; height:42px; border-radius:10px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-mono); font-size:10px; font-weight:600; letter-spacing:.02em;
  color:#fff;
}
.file-icon.is-folder{ background:transparent; }
.file-icon.is-folder svg{ width:32px; height:32px; }

.file-main{ flex:1; min-width:0; }
.file-name{ font-size:14.5px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.file-meta{ font-family: var(--font-mono); font-size:11.5px; color: var(--text-faint); margin-top:2px; }

.file-check{
  width:22px; height:22px; border-radius:7px; border:1.5px solid var(--panel-3); flex-shrink:0;
  display:flex; align-items:center; justify-content:center; transition: all .12s;
}
.file-row.selected .file-check{ background: var(--copper); border-color: var(--copper); }
.file-check svg{ width:14px; height:14px; opacity:0; color:#1A0F06; }
.file-row.selected .file-check svg{ opacity:1; }

.file-kebab{ width:34px; height:34px; border-radius:9px; display:flex; align-items:center; justify-content:center; color:var(--text-faint); flex-shrink:0; }
.file-kebab:hover{ background: var(--panel-2); color:var(--text); }

.filelist.grid-view{
  display:grid; grid-template-columns: repeat(auto-fill, minmax(86px,1fr)); gap:6px 4px;
}
.file-row.grid-cell{
  flex-direction:column; text-align:center; gap:6px; padding:14px 6px 10px; position:relative;
}
.file-row.grid-cell .file-check{ position:absolute; top:4px; left:4px; width:18px; height:18px; }
.file-row.grid-cell .file-kebab{ position:absolute; top:0; right:0; width:26px; height:26px; }
.file-row.grid-cell .file-icon{ width:46px; height:46px; }
.file-row.grid-cell .file-icon.is-folder svg{ width:38px; height:38px; }
.file-row.grid-cell .file-main{ width:100%; }
.file-row.grid-cell .file-name{ font-size:12px; white-space:normal; overflow-wrap:break-word; text-align:center; }
.file-row.grid-cell .file-meta{ font-size:10px; text-align:center; }

.empty-state{ text-align:center; padding: 60px 24px; }
.empty-illustration{
  width:76px; height:60px; margin: 0 auto 18px; position:relative;
  background: var(--panel-2); border-radius: 10px; border:1px solid var(--border);
}
.empty-illustration::before{
  content:''; position:absolute; top:-8px; left:8px; width:34px; height:10px;
  background: var(--panel-2); border:1px solid var(--border); border-bottom:none; border-radius:4px 4px 0 0;
}
.empty-title{ font-family: var(--font-display); font-weight:600; font-size:16px; margin: 0 0 6px; }
.empty-text{ color: var(--text-faint); font-size:13.5px; max-width:280px; margin:0 auto; }

/* =========================================================
   FAB
   ========================================================= */
.fab-wrap{ position:fixed; right:20px; bottom:24px; display:flex; flex-direction:column; align-items:flex-end; gap:12px; z-index:40; }
.fab{
  width:58px; height:58px; border-radius:18px; border:none; cursor:pointer;
  background: linear-gradient(155deg, var(--copper-bright), var(--copper)); color:#1A0F06;
  display:flex; align-items:center; justify-content:center; box-shadow: var(--shadow-2);
  transition: transform .2s ease;
}
.fab svg{ width:26px; height:26px; }
.fab.open{ transform: rotate(45deg); }
.fab-menu{
  display:flex; flex-direction:column; gap:8px; align-items:flex-end;
  opacity:0; pointer-events:none; transform: translateY(8px); transition: all .18s ease;
}
.fab-menu.open{ opacity:1; pointer-events:auto; transform: translateY(0); }
.fab-item{
  display:flex; align-items:center; gap:10px; border:1px solid var(--border);
  background: var(--panel-2); color: var(--text); border-radius: 14px; padding: 10px 14px;
  cursor:pointer; box-shadow: var(--shadow-1); font-size:13.5px; font-weight:500; white-space:nowrap;
}
.fab-ico{ width:30px; height:30px; border-radius:8px; display:inline-block; background: var(--panel-3); position:relative; flex-shrink:0; }
.fab-ico-folder::before{ content:''; position:absolute; inset:8px; border-radius:3px; background: var(--copper); }
.fab-ico-file::before{ content:''; position:absolute; top:6px; left:9px; right:9px; bottom:6px; border-radius:2px; background: var(--blue); }
.fab-ico-upload::before{ content:''; position:absolute; left:50%; top:50%; width:12px; height:12px; transform: translate(-50%,-50%) rotate(45deg); border-top:2px solid var(--green); border-right:2px solid var(--green); }

/* =========================================================
   Modals
   ========================================================= */
.modal-backdrop{
  position:fixed; inset:0; background: rgba(8,10,11,.65); backdrop-filter: blur(3px);
  display:flex; align-items:flex-end; justify-content:center; z-index:100;
}
@media (min-width:640px){ .modal-backdrop{ align-items:center; } }
.modal{
  background: var(--panel); border:1px solid var(--border); width:100%;
  border-radius: 20px 20px 0 0; padding: 22px 20px 20px; box-shadow: var(--shadow-2);
  max-height: 88vh; overflow-y:auto;
}
@media (min-width:640px){ .modal{ border-radius: 20px; } }
.modal-sm{ max-width: 420px; }
.modal-full{ max-width: 760px; height: 88vh; display:flex; flex-direction:column; padding:0; }
.modal h2{ font-family: var(--font-display); font-size:18px; margin:0 0 16px; }
.modal-text{ color: var(--text-dim); font-size:13.5px; line-height:1.55; margin: 0 0 14px; }
.text-field{
  width:100%; background: var(--panel-2); border:1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size:15px; font-family: var(--font-mono); outline:none;
}
.text-field:focus{ border-color: var(--copper); }
.field-error{ color: var(--red); font-size:12.5px; margin-top:8px; }
.modal-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:20px; }

.editor-head{
  display:flex; align-items:center; gap:10px; padding:14px 16px; border-bottom:1px solid var(--border); flex-shrink:0;
}
.editor-filename{ font-family: var(--font-mono); font-size:13.5px; font-weight:500; }
.editor-status{ font-size:11.5px; color: var(--text-faint); }
.editor-textarea{
  flex:1; width:100%; resize:none; border:none; outline:none;
  background: var(--bg); color: var(--text); font-family: var(--font-mono); font-size:13.5px;
  line-height:1.6; padding: 16px; tab-size:2;
}
.modal-image{ background:#000; }
.image-stage{ flex:1; display:flex; align-items:center; justify-content:center; overflow:auto; }
.image-stage img{ max-width:100%; max-height:100%; object-fit:contain; }

.props-list{ margin:0; display:grid; grid-template-columns: 84px 1fr; gap:10px 12px; font-size:13.5px; }
.props-list dt{ color: var(--text-faint); }
.props-list dd{ margin:0; font-family: var(--font-mono); word-break:break-all; }

.archive-preview{ max-height:200px; overflow-y:auto; border:1px solid var(--border); border-radius:10px; margin-bottom:6px; }
.archive-preview li{ font-family: var(--font-mono); font-size:12px; padding:7px 12px; border-bottom:1px solid var(--border); color: var(--text-dim); }
.archive-preview li:last-child{ border-bottom:none; }

/* =========================================================
   Toasts / progress
   ========================================================= */
.toast-stack{ position:fixed; top:16px; left:50%; transform:translateX(-50%); z-index:200; display:flex; flex-direction:column; gap:8px; align-items:center; }
.toast{
  background: var(--panel-2); border:1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 12px; font-size:13.5px; box-shadow: var(--shadow-1);
  animation: toast-in .2s ease;
}
.toast.success{ border-color: var(--green); }
.toast.error{ border-color: var(--red); }
@keyframes toast-in{ from{ opacity:0; transform: translateY(-8px);} to{ opacity:1; transform:none; } }

.progress-overlay{ position:fixed; inset:0; background: rgba(8,10,11,.7); z-index:300; display:flex; align-items:center; justify-content:center; }
.progress-card{ background: var(--panel); border:1px solid var(--border); border-radius:16px; padding:26px 34px; display:flex; flex-direction:column; align-items:center; gap:14px; }
.spinner{ width:30px; height:30px; border-radius:50%; border:3px solid var(--panel-3); border-top-color: var(--copper); animation: spin .8s linear infinite; }
@keyframes spin{ to{ transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
